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

Generated on Mon Sep 25 16:19:44 2006 for OPAL by  doxygen 1.4.7