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