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 2.9  2006/02/13 03:46:17  csoutheren
00028  * Added initialisation stuff to make sure that everything works OK
00029  *
00030  * Revision 2.8  2004/02/19 10:46:43  rjongbloed
00031  * Merged OpenH323 version 1.13.1 changes.
00032  *
00033  * Revision 2.7  2002/11/10 11:33:16  robertj
00034  * Updated to OpenH323 v1.10.3
00035  *
00036  * Revision 2.6  2002/09/16 02:52:33  robertj
00037  * Added #define so can select if #pragma interface/implementation is used on
00038  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00039  *
00040  * Revision 2.5  2002/09/04 06:01:46  robertj
00041  * Updated to OpenH323 v1.9.6
00042  *
00043  * Revision 2.4  2002/07/01 04:56:29  robertj
00044  * Updated to OpenH323 v1.9.1
00045  *
00046  * Revision 2.3  2002/01/14 06:35:56  robertj
00047  * Updated to OpenH323 v1.7.9
00048  *
00049  * Revision 2.2  2001/10/05 00:22:13  robertj
00050  * Updated to PWLib 1.2.0 and OpenH323 1.7.0
00051  *
00052  * Revision 2.1  2001/08/13 05:10:39  robertj
00053  * Updates from OpenH323 v1.6.0 release.
00054  *
00055  * Revision 1.15  2003/04/30 00:28:50  robertj
00056  * Redesigned the alternate credentials in ARQ system as old implementation
00057  *   was fraught with concurrency issues, most importantly it can cause false
00058  *   detection of replay attacks taking out an endpoint completely.
00059  *
00060  * Revision 1.14  2003/04/01 04:47:48  robertj
00061  * Abstracted H.225 RAS transaction processing (RIP and secondary thread) in
00062  *   server environment for use by H.501 peer elements.
00063  *
00064  * Revision 1.13  2003/02/25 06:48:14  robertj
00065  * More work on PDU transaction abstraction.
00066  *
00067  * Revision 1.12  2003/02/11 04:43:22  robertj
00068  * Fixed use of asymmetrical authentication schemes such as MD5.
00069  *
00070  * Revision 1.11  2003/02/01 13:31:14  robertj
00071  * Changes to support CAT authentication in RAS.
00072  *
00073  * Revision 1.10  2003/01/08 04:40:31  robertj
00074  * Added more debug tracing for H.235 authenticators.
00075  *
00076  * Revision 1.9  2002/09/16 01:14:15  robertj
00077  * Added #define so can select if #pragma interface/implementation is used on
00078  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00079  *
00080  * Revision 1.8  2002/09/03 06:19:36  robertj
00081  * Normalised the multi-include header prevention ifdef/define symbol.
00082  *
00083  * Revision 1.7  2002/08/05 10:03:47  robertj
00084  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00085  *
00086  * Revision 1.6  2002/08/05 05:17:37  robertj
00087  * Fairly major modifications to support different authentication credentials
00088  *   in ARQ to the logged in ones on RRQ. For both client and server.
00089  * Various other H.235 authentication bugs and anomalies fixed on the way.
00090  *
00091  * Revision 1.5  2002/05/17 03:39:28  robertj
00092  * Fixed problems with H.235 authentication on RAS for server and client.
00093  *
00094  * Revision 1.4  2001/12/06 06:44:42  robertj
00095  * Removed "Win32 SSL xxx" build configurations in favour of system
00096  *   environment variables to select optional libraries.
00097  *
00098  * Revision 1.3  2001/09/14 00:13:37  robertj
00099  * Fixed problem with some athenticators needing extra conditions to be
00100  *   "active", so make IsActive() virtual and add localId to H235AuthSimpleMD5
00101  *
00102  * Revision 1.2  2001/09/13 01:15:18  robertj
00103  * Added flag to H235Authenticator to determine if gkid and epid is to be
00104  *   automatically set as the crypto token remote id and local id.
00105  *
00106  * Revision 1.1  2001/08/10 11:03:49  robertj
00107  * Major changes to H.235 support in RAS to support server.
00108  *
00109  */
00110 
00111 #ifndef __OPAL_H235AUTH_H
00112 #define __OPAL_H235AUTH_H
00113 
00114 #ifdef P_USE_PRAGMA
00115 #pragma interface
00116 #endif
00117 
00118 
00119 class H323TransactionPDU;
00120 class H225_CryptoH323Token;
00121 class H225_ArrayOf_AuthenticationMechanism;
00122 class H225_ArrayOf_PASN_ObjectId;
00123 class H235_ClearToken;
00124 class H235_AuthenticationMechanism;
00125 class PASN_ObjectId;
00126 class PASN_Sequence;
00127 class PASN_Array;
00128 
00129 namespace PWLibStupidLinkerHacks {
00130 extern int h235AuthLoader;
00131 };
00132 
00136 class H235Authenticator : public PObject
00137 {
00138     PCLASSINFO(H235Authenticator, PObject);
00139   public:
00140     H235Authenticator();
00141 
00142     virtual void PrintOn(
00143       ostream & strm
00144     ) const;
00145 
00146     virtual const char * GetName() const = 0;
00147 
00148     virtual BOOL PrepareTokens(
00149       PASN_Array & clearTokens,
00150       PASN_Array & cryptoTokens
00151     );
00152 
00153     virtual H235_ClearToken * CreateClearToken();
00154     virtual H225_CryptoH323Token * CreateCryptoToken();
00155 
00156     virtual BOOL Finalise(
00157       PBYTEArray & rawPDU
00158     );
00159 
00160     enum ValidationResult {
00161       e_OK = 0,     
00162       e_Absent,     
00163       e_Error,      
00164       e_InvalidTime,
00165       e_BadPassword,
00166       e_ReplyAttack,
00167       e_Disabled    
00168     };
00169 
00170     virtual ValidationResult ValidateTokens(
00171       const PASN_Array & clearTokens,
00172       const PASN_Array & cryptoTokens,
00173       const PBYTEArray & rawPDU
00174     );
00175 
00176     virtual ValidationResult ValidateClearToken(
00177       const H235_ClearToken & clearToken
00178     );
00179 
00180     virtual ValidationResult ValidateCryptoToken(
00181       const H225_CryptoH323Token & cryptoToken,
00182       const PBYTEArray & rawPDU
00183     );
00184 
00185     virtual BOOL IsCapability(
00186       const H235_AuthenticationMechanism & mechansim,
00187       const PASN_ObjectId & algorithmOID
00188     ) = 0;
00189 
00190     virtual BOOL SetCapability(
00191       H225_ArrayOf_AuthenticationMechanism & mechansims,
00192       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00193     ) = 0;
00194 
00195     virtual BOOL UseGkAndEpIdentifiers() const;
00196 
00197     virtual BOOL IsSecuredPDU(
00198       unsigned rasPDU,
00199       BOOL received
00200     ) const;
00201 
00202     virtual BOOL IsActive() const;
00203 
00204     void Enable(
00205       BOOL enab = TRUE
00206     ) { enabled = enab; }
00207     void Disable() { enabled = FALSE; }
00208 
00209     const PString & GetRemoteId() const { return remoteId; }
00210     void SetRemoteId(const PString & id) { remoteId = id; }
00211 
00212     const PString & GetLocalId() const { return localId; }
00213     void SetLocalId(const PString & id) { localId = id; }
00214 
00215     const PString & GetPassword() const { return password; }
00216     void SetPassword(const PString & pw) { password = pw; }
00217 
00218 
00219   protected:
00220     BOOL AddCapability(
00221       unsigned mechanism,
00222       const PString & oid,
00223       H225_ArrayOf_AuthenticationMechanism & mechansims,
00224       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00225     );
00226 
00227     BOOL     enabled;
00228 
00229     PString  remoteId;      // ID of remote entity
00230     PString  localId;       // ID of local entity
00231     PString  password;      // shared secret
00232 
00233     unsigned sentRandomSequenceNumber;
00234     unsigned lastRandomSequenceNumber;
00235     unsigned lastTimestamp;
00236     int      timestampGracePeriod;
00237 
00238     PMutex mutex;
00239 };
00240 
00241 
00242 PDECLARE_LIST(H235Authenticators, H235Authenticator)
00243   public:
00244     void PreparePDU(
00245       H323TransactionPDU & pdu,
00246       PASN_Array & clearTokens,
00247       unsigned clearOptionalField,
00248       PASN_Array & cryptoTokens,
00249       unsigned cryptoOptionalField
00250     ) const;
00251 
00252     H235Authenticator::ValidationResult ValidatePDU(
00253       const H323TransactionPDU & pdu,
00254       const PASN_Array & clearTokens,
00255       unsigned clearOptionalField,
00256       const PASN_Array & cryptoTokens,
00257       unsigned cryptoOptionalField,
00258       const PBYTEArray & rawPDU
00259     ) const;
00260 };
00261 
00262 
00263 
00264 
00269 class H235AuthSimpleMD5 : public H235Authenticator
00270 {
00271     PCLASSINFO(H235AuthSimpleMD5, H235Authenticator);
00272   public:
00273     H235AuthSimpleMD5();
00274 
00275     PObject * Clone() const;
00276 
00277     virtual const char * GetName() const;
00278 
00279     virtual H225_CryptoH323Token * CreateCryptoToken();
00280 
00281     virtual ValidationResult ValidateCryptoToken(
00282       const H225_CryptoH323Token & cryptoToken,
00283       const PBYTEArray & rawPDU
00284     );
00285 
00286     virtual BOOL IsCapability(
00287       const H235_AuthenticationMechanism & mechansim,
00288       const PASN_ObjectId & algorithmOID
00289     );
00290 
00291     virtual BOOL SetCapability(
00292       H225_ArrayOf_AuthenticationMechanism & mechansim,
00293       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00294     );
00295 
00296     virtual BOOL IsSecuredPDU(
00297       unsigned rasPDU,
00298       BOOL received
00299     ) const;
00300 };
00301 
00302 
00309 class H235AuthCAT : public H235Authenticator
00310 {
00311     PCLASSINFO(H235AuthCAT, H235Authenticator);
00312   public:
00313     H235AuthCAT();
00314 
00315     PObject * Clone() const;
00316 
00317     virtual const char * GetName() const;
00318 
00319     virtual H235_ClearToken * CreateClearToken();
00320 
00321     virtual ValidationResult ValidateClearToken(
00322       const H235_ClearToken & clearToken
00323     );
00324 
00325     virtual BOOL IsCapability(
00326       const H235_AuthenticationMechanism & mechansim,
00327       const PASN_ObjectId & algorithmOID
00328     );
00329 
00330     virtual BOOL SetCapability(
00331       H225_ArrayOf_AuthenticationMechanism & mechansim,
00332       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00333     );
00334 
00335     virtual BOOL IsSecuredPDU(
00336       unsigned rasPDU,
00337       BOOL received
00338     ) const;
00339 };
00340 
00341 
00342 #if P_SSL
00343 
00344 namespace PWLibStupidLinkerHacks {
00345   extern int h235AuthProcedure1Loader;
00346 };
00347 
00350 class H235AuthProcedure1 : public H235Authenticator
00351 {
00352     PCLASSINFO(H235AuthProcedure1, H235Authenticator);
00353   public:
00354     H235AuthProcedure1();
00355 
00356     PObject * Clone() const;
00357 
00358     virtual const char * GetName() const;
00359 
00360     virtual H225_CryptoH323Token * CreateCryptoToken();
00361 
00362     virtual BOOL Finalise(
00363       PBYTEArray & rawPDU
00364     );
00365 
00366     virtual ValidationResult ValidateCryptoToken(
00367       const H225_CryptoH323Token & cryptoToken,
00368       const PBYTEArray & rawPDU
00369     );
00370 
00371     virtual BOOL IsCapability(
00372       const H235_AuthenticationMechanism & mechansim,
00373       const PASN_ObjectId & algorithmOID
00374     );
00375 
00376     virtual BOOL SetCapability(
00377       H225_ArrayOf_AuthenticationMechanism & mechansim,
00378       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00379     );
00380 
00381     virtual BOOL UseGkAndEpIdentifiers() const;
00382 };
00383 
00384 #endif
00385 
00386 
00387 #endif //__OPAL_H235AUTH_H
00388 
00389 

Generated on Fri Mar 7 06:33:18 2008 for OPAL by  doxygen 1.5.1