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
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 #ifndef __OPAL_H235AUTH_H
00112 #define __OPAL_H235AUTH_H
00113
00114 #ifdef P_USE_PRAGMA
00115 #pragma interface
00116 #endif
00117
00118
00119 class H323TransactionPDU;
00120 class H225_CryptoH323Token;
00121 class H225_ArrayOf_AuthenticationMechanism;
00122 class H225_ArrayOf_PASN_ObjectId;
00123 class H235_ClearToken;
00124 class H235_AuthenticationMechanism;
00125 class PASN_ObjectId;
00126 class PASN_Sequence;
00127 class PASN_Array;
00128
00129 namespace PWLibStupidLinkerHacks {
00130 extern int h235AuthLoader;
00131 };
00132
00136 class H235Authenticator : public PObject
00137 {
00138 PCLASSINFO(H235Authenticator, PObject);
00139 public:
00140 H235Authenticator();
00141
00142 virtual void PrintOn(
00143 ostream & strm
00144 ) const;
00145
00146 virtual const char * GetName() const = 0;
00147
00148 virtual BOOL PrepareTokens(
00149 PASN_Array & clearTokens,
00150 PASN_Array & cryptoTokens
00151 );
00152
00153 virtual H235_ClearToken * CreateClearToken();
00154 virtual H225_CryptoH323Token * CreateCryptoToken();
00155
00156 virtual BOOL Finalise(
00157 PBYTEArray & rawPDU
00158 );
00159
00160 enum ValidationResult {
00161 e_OK = 0,
00162 e_Absent,
00163 e_Error,
00164 e_InvalidTime,
00165 e_BadPassword,
00166 e_ReplyAttack,
00167 e_Disabled
00168 };
00169
00170 virtual ValidationResult ValidateTokens(
00171 const PASN_Array & clearTokens,
00172 const PASN_Array & cryptoTokens,
00173 const PBYTEArray & rawPDU
00174 );
00175
00176 virtual ValidationResult ValidateClearToken(
00177 const H235_ClearToken & clearToken
00178 );
00179
00180 virtual ValidationResult ValidateCryptoToken(
00181 const H225_CryptoH323Token & cryptoToken,
00182 const PBYTEArray & rawPDU
00183 );
00184
00185 virtual BOOL IsCapability(
00186 const H235_AuthenticationMechanism & mechansim,
00187 const PASN_ObjectId & algorithmOID
00188 ) = 0;
00189
00190 virtual BOOL SetCapability(
00191 H225_ArrayOf_AuthenticationMechanism & mechansims,
00192 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00193 ) = 0;
00194
00195 virtual BOOL UseGkAndEpIdentifiers() const;
00196
00197 virtual BOOL IsSecuredPDU(
00198 unsigned rasPDU,
00199 BOOL received
00200 ) const;
00201
00202 virtual BOOL IsActive() const;
00203
00204 void Enable(
00205 BOOL enab = TRUE
00206 ) { enabled = enab; }
00207 void Disable() { enabled = FALSE; }
00208
00209 const PString & GetRemoteId() const { return remoteId; }
00210 void SetRemoteId(const PString & id) { remoteId = id; }
00211
00212 const PString & GetLocalId() const { return localId; }
00213 void SetLocalId(const PString & id) { localId = id; }
00214
00215 const PString & GetPassword() const { return password; }
00216 void SetPassword(const PString & pw) { password = pw; }
00217
00218
00219 protected:
00220 BOOL AddCapability(
00221 unsigned mechanism,
00222 const PString & oid,
00223 H225_ArrayOf_AuthenticationMechanism & mechansims,
00224 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00225 );
00226
00227 BOOL enabled;
00228
00229 PString remoteId;
00230 PString localId;
00231 PString password;
00232
00233 unsigned sentRandomSequenceNumber;
00234 unsigned lastRandomSequenceNumber;
00235 unsigned lastTimestamp;
00236 int timestampGracePeriod;
00237
00238 PMutex mutex;
00239 };
00240
00241
00242 PDECLARE_LIST(H235Authenticators, H235Authenticator)
00243 public:
00244 void PreparePDU(
00245 H323TransactionPDU & pdu,
00246 PASN_Array & clearTokens,
00247 unsigned clearOptionalField,
00248 PASN_Array & cryptoTokens,
00249 unsigned cryptoOptionalField
00250 ) const;
00251
00252 H235Authenticator::ValidationResult ValidatePDU(
00253 const H323TransactionPDU & pdu,
00254 const PASN_Array & clearTokens,
00255 unsigned clearOptionalField,
00256 const PASN_Array & cryptoTokens,
00257 unsigned cryptoOptionalField,
00258 const PBYTEArray & rawPDU
00259 ) const;
00260 };
00261
00262
00263
00264
00269 class H235AuthSimpleMD5 : public H235Authenticator
00270 {
00271 PCLASSINFO(H235AuthSimpleMD5, H235Authenticator);
00272 public:
00273 H235AuthSimpleMD5();
00274
00275 PObject * Clone() const;
00276
00277 virtual const char * GetName() const;
00278
00279 virtual H225_CryptoH323Token * CreateCryptoToken();
00280
00281 virtual ValidationResult ValidateCryptoToken(
00282 const H225_CryptoH323Token & cryptoToken,
00283 const PBYTEArray & rawPDU
00284 );
00285
00286 virtual BOOL IsCapability(
00287 const H235_AuthenticationMechanism & mechansim,
00288 const PASN_ObjectId & algorithmOID
00289 );
00290
00291 virtual BOOL SetCapability(
00292 H225_ArrayOf_AuthenticationMechanism & mechansim,
00293 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00294 );
00295
00296 virtual BOOL IsSecuredPDU(
00297 unsigned rasPDU,
00298 BOOL received
00299 ) const;
00300 };
00301
00302
00309 class H235AuthCAT : public H235Authenticator
00310 {
00311 PCLASSINFO(H235AuthCAT, H235Authenticator);
00312 public:
00313 H235AuthCAT();
00314
00315 PObject * Clone() const;
00316
00317 virtual const char * GetName() const;
00318
00319 virtual H235_ClearToken * CreateClearToken();
00320
00321 virtual ValidationResult ValidateClearToken(
00322 const H235_ClearToken & clearToken
00323 );
00324
00325 virtual BOOL IsCapability(
00326 const H235_AuthenticationMechanism & mechansim,
00327 const PASN_ObjectId & algorithmOID
00328 );
00329
00330 virtual BOOL SetCapability(
00331 H225_ArrayOf_AuthenticationMechanism & mechansim,
00332 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00333 );
00334
00335 virtual BOOL IsSecuredPDU(
00336 unsigned rasPDU,
00337 BOOL received
00338 ) const;
00339 };
00340
00341
00342 #if P_SSL
00343
00344 namespace PWLibStupidLinkerHacks {
00345 extern int h235AuthProcedure1Loader;
00346 };
00347
00350 class H235AuthProcedure1 : public H235Authenticator
00351 {
00352 PCLASSINFO(H235AuthProcedure1, H235Authenticator);
00353 public:
00354 H235AuthProcedure1();
00355
00356 PObject * Clone() const;
00357
00358 virtual const char * GetName() const;
00359
00360 virtual H225_CryptoH323Token * CreateCryptoToken();
00361
00362 virtual BOOL Finalise(
00363 PBYTEArray & rawPDU
00364 );
00365
00366 virtual ValidationResult ValidateCryptoToken(
00367 const H225_CryptoH323Token & cryptoToken,
00368 const PBYTEArray & rawPDU
00369 );
00370
00371 virtual BOOL IsCapability(
00372 const H235_AuthenticationMechanism & mechansim,
00373 const PASN_ObjectId & algorithmOID
00374 );
00375
00376 virtual BOOL SetCapability(
00377 H225_ArrayOf_AuthenticationMechanism & mechansim,
00378 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00379 );
00380
00381 virtual BOOL UseGkAndEpIdentifiers() const;
00382 };
00383
00384 #endif
00385
00386
00387 #endif //__OPAL_H235AUTH_H
00388
00389