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

Generated on Mon Feb 21 20:19:20 2011 for OPAL by  doxygen 1.4.7