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  * $Revision: 19427 $
00027  * $Author: rjongbloed $
00028  * $Date: 2008-02-09 03:23:08 +0000 (Sat, 09 Feb 2008) $
00029  */
00030 
00031 #ifndef __OPAL_H235AUTH_H
00032 #define __OPAL_H235AUTH_H
00033 
00034 #ifdef P_USE_PRAGMA
00035 #pragma interface
00036 #endif
00037 
00038 
00039 class H323TransactionPDU;
00040 class H225_CryptoH323Token;
00041 class H225_ArrayOf_AuthenticationMechanism;
00042 class H225_ArrayOf_PASN_ObjectId;
00043 class H235_ClearToken;
00044 class H235_AuthenticationMechanism;
00045 class PASN_ObjectId;
00046 class PASN_Sequence;
00047 class PASN_Array;
00048 
00049 namespace PWLibStupidLinkerHacks {
00050 extern int h235AuthLoader;
00051 };
00052 
00056 class H235Authenticator : public PObject
00057 {
00058     PCLASSINFO(H235Authenticator, PObject);
00059   public:
00060     H235Authenticator();
00061 
00062     virtual void PrintOn(
00063       ostream & strm
00064     ) const;
00065 
00066     virtual const char * GetName() const = 0;
00067 
00068     virtual PBoolean PrepareTokens(
00069       PASN_Array & clearTokens,
00070       PASN_Array & cryptoTokens
00071     );
00072 
00073     virtual H235_ClearToken * CreateClearToken();
00074     virtual H225_CryptoH323Token * CreateCryptoToken();
00075 
00076     virtual PBoolean Finalise(
00077       PBYTEArray & rawPDU
00078     );
00079 
00080     enum ValidationResult {
00081       e_OK = 0,     
00082       e_Absent,     
00083       e_Error,      
00084       e_InvalidTime,
00085       e_BadPassword,
00086       e_ReplyAttack,
00087       e_Disabled    
00088     };
00089 
00090     virtual ValidationResult ValidateTokens(
00091       const PASN_Array & clearTokens,
00092       const PASN_Array & cryptoTokens,
00093       const PBYTEArray & rawPDU
00094     );
00095 
00096     virtual ValidationResult ValidateClearToken(
00097       const H235_ClearToken & clearToken
00098     );
00099 
00100     virtual ValidationResult ValidateCryptoToken(
00101       const H225_CryptoH323Token & cryptoToken,
00102       const PBYTEArray & rawPDU
00103     );
00104 
00105     virtual PBoolean IsCapability(
00106       const H235_AuthenticationMechanism & mechansim,
00107       const PASN_ObjectId & algorithmOID
00108     ) = 0;
00109 
00110     virtual PBoolean SetCapability(
00111       H225_ArrayOf_AuthenticationMechanism & mechansims,
00112       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00113     ) = 0;
00114 
00115     virtual PBoolean UseGkAndEpIdentifiers() const;
00116 
00117     virtual PBoolean IsSecuredPDU(
00118       unsigned rasPDU,
00119       PBoolean received
00120     ) const;
00121 
00122     virtual PBoolean IsActive() const;
00123 
00124     void Enable(
00125       PBoolean enab = PTrue
00126     ) { enabled = enab; }
00127     void Disable() { enabled = PFalse; }
00128 
00129     const PString & GetRemoteId() const { return remoteId; }
00130     void SetRemoteId(const PString & id) { remoteId = id; }
00131 
00132     const PString & GetLocalId() const { return localId; }
00133     void SetLocalId(const PString & id) { localId = id; }
00134 
00135     const PString & GetPassword() const { return password; }
00136     void SetPassword(const PString & pw) { password = pw; }
00137 
00138 
00139   protected:
00140     PBoolean AddCapability(
00141       unsigned mechanism,
00142       const PString & oid,
00143       H225_ArrayOf_AuthenticationMechanism & mechansims,
00144       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00145     );
00146 
00147     PBoolean     enabled;
00148 
00149     PString  remoteId;      // ID of remote entity
00150     PString  localId;       // ID of local entity
00151     PString  password;      // shared secret
00152 
00153     unsigned sentRandomSequenceNumber;
00154     unsigned lastRandomSequenceNumber;
00155     unsigned lastTimestamp;
00156     int      timestampGracePeriod;
00157 
00158     PMutex mutex;
00159 };
00160 
00161 
00162 PDECLARE_LIST(H235Authenticators, H235Authenticator)
00163   public:
00164     void PreparePDU(
00165       H323TransactionPDU & pdu,
00166       PASN_Array & clearTokens,
00167       unsigned clearOptionalField,
00168       PASN_Array & cryptoTokens,
00169       unsigned cryptoOptionalField
00170     );
00171 
00172     H235Authenticator::ValidationResult ValidatePDU(
00173       const H323TransactionPDU & pdu,
00174       const PASN_Array & clearTokens,
00175       unsigned clearOptionalField,
00176       const PASN_Array & cryptoTokens,
00177       unsigned cryptoOptionalField,
00178       const PBYTEArray & rawPDU
00179     );
00180 };
00181 
00182 
00183 
00184 
00189 class H235AuthSimpleMD5 : public H235Authenticator
00190 {
00191     PCLASSINFO(H235AuthSimpleMD5, H235Authenticator);
00192   public:
00193     H235AuthSimpleMD5();
00194 
00195     PObject * Clone() const;
00196 
00197     virtual const char * GetName() const;
00198 
00199     virtual H225_CryptoH323Token * CreateCryptoToken();
00200 
00201     virtual ValidationResult ValidateCryptoToken(
00202       const H225_CryptoH323Token & cryptoToken,
00203       const PBYTEArray & rawPDU
00204     );
00205 
00206     virtual PBoolean IsCapability(
00207       const H235_AuthenticationMechanism & mechansim,
00208       const PASN_ObjectId & algorithmOID
00209     );
00210 
00211     virtual PBoolean SetCapability(
00212       H225_ArrayOf_AuthenticationMechanism & mechansim,
00213       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00214     );
00215 
00216     virtual PBoolean IsSecuredPDU(
00217       unsigned rasPDU,
00218       PBoolean received
00219     ) const;
00220 };
00221 
00222 
00229 class H235AuthCAT : public H235Authenticator
00230 {
00231     PCLASSINFO(H235AuthCAT, H235Authenticator);
00232   public:
00233     H235AuthCAT();
00234 
00235     PObject * Clone() const;
00236 
00237     virtual const char * GetName() const;
00238 
00239     virtual H235_ClearToken * CreateClearToken();
00240 
00241     virtual ValidationResult ValidateClearToken(
00242       const H235_ClearToken & clearToken
00243     );
00244 
00245     virtual PBoolean IsCapability(
00246       const H235_AuthenticationMechanism & mechansim,
00247       const PASN_ObjectId & algorithmOID
00248     );
00249 
00250     virtual PBoolean SetCapability(
00251       H225_ArrayOf_AuthenticationMechanism & mechansim,
00252       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00253     );
00254 
00255     virtual PBoolean IsSecuredPDU(
00256       unsigned rasPDU,
00257       PBoolean received
00258     ) const;
00259 };
00260 
00261 
00262 #if P_SSL
00263 
00264 namespace PWLibStupidLinkerHacks {
00265   extern int h235AuthProcedure1Loader;
00266 };
00267 
00270 class H235AuthProcedure1 : public H235Authenticator
00271 {
00272     PCLASSINFO(H235AuthProcedure1, H235Authenticator);
00273   public:
00274     H235AuthProcedure1();
00275 
00276     PObject * Clone() const;
00277 
00278     virtual const char * GetName() const;
00279 
00280     virtual H225_CryptoH323Token * CreateCryptoToken();
00281 
00282     virtual PBoolean Finalise(
00283       PBYTEArray & rawPDU
00284     );
00285 
00286     virtual ValidationResult ValidateCryptoToken(
00287       const H225_CryptoH323Token & cryptoToken,
00288       const PBYTEArray & rawPDU
00289     );
00290 
00291     virtual PBoolean IsCapability(
00292       const H235_AuthenticationMechanism & mechansim,
00293       const PASN_ObjectId & algorithmOID
00294     );
00295 
00296     virtual PBoolean SetCapability(
00297       H225_ArrayOf_AuthenticationMechanism & mechansim,
00298       H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00299     );
00300 
00301     virtual PBoolean UseGkAndEpIdentifiers() const;
00302 };
00303 
00304 #endif
00305 
00306 
00307 #endif //__OPAL_H235AUTH_H
00308 
00309 

Generated on Mon Sep 15 11:48:51 2008 for OPAL by  doxygen 1.5.1