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_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;
00150 PString localId;
00151 PString password;
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