Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

h235auth.h

Go to the documentation of this file.
00001 /*
00002  * h235auth.h
00003  *
00004  * H.235 authorisation PDU's
00005  *
00006  * Open H323 Library
00007  *
00008  * Copyright (c) 1998-2001 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Open H323 Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Contributor(s): Fürbass Franz <franz.fuerbass@infonova.at>
00025  *
00026  * $Log: h235auth.h,v $
00027  * Revision 1.18  2004/11/20 22:00:48  csoutheren
00028  * Added hacks for linker problem
00029  *
00030  * Revision 1.17  2004/11/12 06:04:42  csoutheren
00031  * Changed H235Authentiators to use PFactory
00032  *
00033  * Revision 1.16  2004/05/13 02:26:13  dereksmithies
00034  * Fixes so make docs does not generate warning messages about brackets.
00035  *
00036  * Revision 1.15  2003/04/30 00:28:50  robertj
00037  * Redesigned the alternate credentials in ARQ system as old implementation
00038  *   was fraught with concurrency issues, most importantly it can cause false
00039  *   detection of replay attacks taking out an endpoint completely.
00040  *
00041  * Revision 1.14  2003/04/01 04:47:48  robertj
00042  * Abstracted H.225 RAS transaction processing (RIP and secondary thread) in
00043  *   server environment for use by H.501 peer elements.
00044  *
00045  * Revision 1.13  2003/02/25 06:48:14  robertj
00046  * More work on PDU transaction abstraction.
00047  *
00048  * Revision 1.12  2003/02/11 04:43:22  robertj
00049  * Fixed use of asymmetrical authentication schemes such as MD5.
00050  *
00051  * Revision 1.11  2003/02/01 13:31:14  robertj
00052  * Changes to support CAT authentication in RAS.
00053  *
00054  * Revision 1.10  2003/01/08 04:40:31  robertj
00055  * Added more debug tracing for H.235 authenticators.
00056  *
00057  * Revision 1.9  2002/09/16 01:14:15  robertj
00058  * Added #define so can select if #pragma interface/implementation is used on
00059  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00060  *
00061  * Revision 1.8  2002/09/03 06:19:36  robertj
00062  * Normalised the multi-include header prevention ifdef/define symbol.
00063  *
00064  * Revision 1.7  2002/08/05 10:03:47  robertj
00065  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00066  *
00067  * Revision 1.6  2002/08/05 05:17:37  robertj
00068  * Fairly major modifications to support different authentication credentials
00069  *   in ARQ to the logged in ones on RRQ. For both client and server.
00070  * Various other H.235 authentication bugs and anomalies fixed on the way.
00071  *
00072  * Revision 1.5  2002/05/17 03:39:28  robertj
00073  * Fixed problems with H.235 authentication on RAS for server and client.
00074  *
00075  * Revision 1.4  2001/12/06 06:44:42  robertj
00076  * Removed "Win32 SSL xxx" build configurations in favour of system
00077  *   environment variables to select optional libraries.
00078  *
00079  * Revision 1.3  2001/09/14 00:13:37  robertj
00080  * Fixed problem with some athenticators needing extra conditions to be
00081  *   "active", so make IsActive() virtual and add localId to H235AuthSimpleMD5
00082  *
00083  * Revision 1.2  2001/09/13 01:15:18  robertj
00084  * Added flag to H235Authenticator to determine if gkid and epid is to be
00085  *   automatically set as the crypto token remote id and local id.
00086  *
00087  * Revision 1.1  2001/08/10 11:03:49  robertj
00088  * Major changes to H.235 support in RAS to support server.
00089  *
00090  */
00091 
00092 #ifndef __OPAL_H235AUTH_H
00093 #define __OPAL_H235AUTH_H
00094 
00095 #ifdef P_USE_PRAGMA
00096 #pragma interface
00097 #endif
00098 
00099 class H323TransactionPDU;
00100 class H225_CryptoH323Token;
00101 class H225_ArrayOf_AuthenticationMechanism;
00102 class H225_ArrayOf_PASN_ObjectId;
00103 class H235_ClearToken;
00104 class H235_AuthenticationMechanism;
00105 class PASN_ObjectId;
00106 class PASN_Sequence;
00107 class PASN_Array;
00108 
00109 namespace PWLibStupidLinkerHacks {
00110 extern int h235AuthLoader;
00111 };
00112 
00116 class H235Authenticator : public PObject
00117 {
00118     PCLASSINFO(H235Authenticator, PObject);
00119   public:
00120     H235Authenticator();
00121 
00122     virtual void PrintOn(
00123       ostream & strm
00124     ) const;
00125 
00126     virtual const char * GetName() const = 0;
00127 
00128     virtual BOOL PrepareTokens(
00129       PASN_Array & clearTokens,
00130       PASN_Array & cryptoTokens
00131     );
00132 
00133     virtual H235_ClearToken * CreateClearToken();
00134     virtual H225_CryptoH323Token * CreateCryptoToken();
00135 
00136     virtual BOOL Finalise(
00137       PBYTEArray & rawPDU
00138     );
00139 
00140     enum ValidationResult {
00141       e_OK = 0,     
00142       e_Absent,     
00143       e_Error,      
00144       e_InvalidTime,
00145       e_BadPassword,
00146       e_ReplyAttack,
00147       e_Disabled    
00148     };
00149 
00150     virtual ValidationResult ValidateTokens(
00151       const PASN_Array & clearTokens,
00152       const PASN_Array & cryptoTokens,
00153       const PBYTEArray & rawPDU
00154     );
00155 
00156     virtual ValidationResult ValidateClearToken(
00157       const H235_ClearToken & clearToken
00158     );
00159 
00160     virtual ValidationResult ValidateCryptoToken(
00161       const H225_CryptoH323Token & cryptoToken,
00162       const PBYTEArray & rawPDU
00163     );
00164 
00165     virtual BOOL IsCapability(
00166       const H235_AuthenticationMechanism & mechansim,
00167       const PASN_ObjectId & algorithmOID
00168     ) = 0;
00169 
00170     virtual BOOL SetCapability(
00171       H225_ArrayOf_AuthenticationMechanism & mechansims,
00172       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00173     ) = 0;
00174 
00175     virtual BOOL UseGkAndEpIdentifiers() const;
00176 
00177     virtual BOOL IsSecuredPDU(
00178       unsigned rasPDU,
00179       BOOL received
00180     ) const;
00181 
00182     virtual BOOL IsActive() const;
00183 
00184     virtual void Enable(
00185       BOOL enab = TRUE
00186     ) { enabled = enab; }
00187     virtual void Disable() { enabled = FALSE; }
00188 
00189     virtual const PString & GetRemoteId() const { return remoteId; }
00190     virtual void SetRemoteId(const PString & id) { remoteId = id; }
00191 
00192     virtual const PString & GetLocalId() const { return localId; }
00193     virtual void SetLocalId(const PString & id) { localId = id; }
00194 
00195     virtual const PString & GetPassword() const { return password; }
00196     virtual void SetPassword(const PString & pw) { password = pw; }
00197 
00198 
00199   protected:
00200     BOOL AddCapability(
00201       unsigned mechanism,
00202       const PString & oid,
00203       H225_ArrayOf_AuthenticationMechanism & mechansims,
00204       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00205     );
00206 
00207     BOOL     enabled;
00208 
00209     PString  remoteId;      // ID of remote entity
00210     PString  localId;       // ID of local entity
00211     PString  password;      // shared secret
00212 
00213     unsigned sentRandomSequenceNumber;
00214     unsigned lastRandomSequenceNumber;
00215     unsigned lastTimestamp;
00216     int      timestampGracePeriod;
00217 
00218     PMutex mutex;
00219 };
00220 
00221 
00222 PDECLARE_LIST(H235Authenticators, H235Authenticator)
00223 #ifdef DOC_PLUS_PLUS
00224 {
00225 #endif
00226   public:
00227     void PreparePDU(
00228       H323TransactionPDU & pdu,
00229       PASN_Array & clearTokens,
00230       unsigned clearOptionalField,
00231       PASN_Array & cryptoTokens,
00232       unsigned cryptoOptionalField
00233     ) const;
00234 
00235     H235Authenticator::ValidationResult ValidatePDU(
00236       const H323TransactionPDU & pdu,
00237       const PASN_Array & clearTokens,
00238       unsigned clearOptionalField,
00239       const PASN_Array & cryptoTokens,
00240       unsigned cryptoOptionalField,
00241       const PBYTEArray & rawPDU
00242     ) const;
00243 };
00244 
00245 
00246 
00247 
00252 class H235AuthSimpleMD5 : public H235Authenticator
00253 {
00254     PCLASSINFO(H235AuthSimpleMD5, H235Authenticator);
00255   public:
00256     H235AuthSimpleMD5();
00257 
00258     PObject * Clone() const;
00259 
00260     virtual const char * GetName() const;
00261 
00262     virtual H225_CryptoH323Token * CreateCryptoToken();
00263 
00264     virtual ValidationResult ValidateCryptoToken(
00265       const H225_CryptoH323Token & cryptoToken,
00266       const PBYTEArray & rawPDU
00267     );
00268 
00269     virtual BOOL IsCapability(
00270       const H235_AuthenticationMechanism & mechansim,
00271       const PASN_ObjectId & algorithmOID
00272     );
00273 
00274     virtual BOOL SetCapability(
00275       H225_ArrayOf_AuthenticationMechanism & mechansim,
00276       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00277     );
00278 
00279     virtual BOOL IsSecuredPDU(
00280       unsigned rasPDU,
00281       BOOL received
00282     ) const;
00283 };
00284 
00285 
00292 class H235AuthCAT : public H235Authenticator
00293 {
00294     PCLASSINFO(H235AuthCAT, H235Authenticator);
00295   public:
00296     H235AuthCAT();
00297 
00298     PObject * Clone() const;
00299 
00300     virtual const char * GetName() const;
00301 
00302     virtual H235_ClearToken * CreateClearToken();
00303 
00304     virtual ValidationResult ValidateClearToken(
00305       const H235_ClearToken & clearToken
00306     );
00307 
00308     virtual BOOL IsCapability(
00309       const H235_AuthenticationMechanism & mechansim,
00310       const PASN_ObjectId & algorithmOID
00311     );
00312 
00313     virtual BOOL SetCapability(
00314       H225_ArrayOf_AuthenticationMechanism & mechansim,
00315       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00316     );
00317 
00318     virtual BOOL IsSecuredPDU(
00319       unsigned rasPDU,
00320       BOOL received
00321     ) const;
00322 };
00323 
00324 
00325 #if P_SSL
00326 
00327 namespace PWLibStupidLinkerHacks {
00328 extern int h235AuthProcedure1Loader;
00329 };
00330 
00333 class H235AuthProcedure1 : public H235Authenticator
00334 {
00335     PCLASSINFO(H235AuthProcedure1, H235Authenticator);
00336   public:
00337     H235AuthProcedure1();
00338 
00339     PObject * Clone() const;
00340 
00341     virtual const char * GetName() const;
00342 
00343     virtual H225_CryptoH323Token * CreateCryptoToken();
00344 
00345     virtual BOOL Finalise(
00346       PBYTEArray & rawPDU
00347     );
00348 
00349     virtual ValidationResult ValidateCryptoToken(
00350       const H225_CryptoH323Token & cryptoToken,
00351       const PBYTEArray & rawPDU
00352     );
00353 
00354     virtual BOOL IsCapability(
00355       const H235_AuthenticationMechanism & mechansim,
00356       const PASN_ObjectId & algorithmOID
00357     );
00358 
00359     virtual BOOL SetCapability(
00360       H225_ArrayOf_AuthenticationMechanism & mechansim,
00361       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00362     );
00363 
00364     virtual BOOL UseGkAndEpIdentifiers() const;
00365 };
00366 
00367 #endif
00368 
00369 
00370 #endif //__OPAL_H235AUTH_H
00371 
00372 

Generated on Tue Mar 15 11:16:50 2005 for OpenH323 by  doxygen 1.4.0