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
00112
00113
00114
00115
00116
00117 #ifndef __OPAL_H235AUTH_H
00118 #define __OPAL_H235AUTH_H
00119
00120 #ifdef P_USE_PRAGMA
00121 #pragma interface
00122 #endif
00123
00124 class H323TransactionPDU;
00125 class H225_CryptoH323Token;
00126 class H225_ArrayOf_AuthenticationMechanism;
00127 class H225_ArrayOf_PASN_ObjectId;
00128 class H235_ClearToken;
00129 class H235_AuthenticationMechanism;
00130 class PASN_ObjectId;
00131 class PASN_Sequence;
00132 class PASN_Array;
00133
00134 class H323SignalPDU;
00135 class H323Connection;
00136 class PSSLCertificate;
00137
00138 namespace PWLibStupidLinkerHacks {
00139 extern int h235AuthLoader;
00140 };
00141
00145 class H235Authenticator : public PObject
00146 {
00147 PCLASSINFO(H235Authenticator, PObject);
00148 public:
00149 H235Authenticator();
00150
00151 virtual void PrintOn(
00152 ostream & strm
00153 ) const;
00154
00155 virtual const char * GetName() const = 0;
00156
00157 virtual BOOL PrepareTokens(
00158 PASN_Array & clearTokens,
00159 PASN_Array & cryptoTokens
00160 );
00161
00162 virtual H235_ClearToken * CreateClearToken();
00163 virtual H225_CryptoH323Token * CreateCryptoToken();
00164
00165 virtual BOOL Finalise(
00166 PBYTEArray & rawPDU
00167 );
00168
00169 enum ValidationResult {
00170 e_OK = 0,
00171 e_Absent,
00172 e_Error,
00173 e_InvalidTime,
00174 e_BadPassword,
00175 e_ReplyAttack,
00176 e_Disabled
00177 };
00178
00179 virtual ValidationResult ValidateTokens(
00180 const PASN_Array & clearTokens,
00181 const PASN_Array & cryptoTokens,
00182 const PBYTEArray & rawPDU
00183 );
00184
00185 virtual ValidationResult ValidateClearToken(
00186 const H235_ClearToken & clearToken
00187 );
00188
00189 virtual ValidationResult ValidateCryptoToken(
00190 const H225_CryptoH323Token & cryptoToken,
00191 const PBYTEArray & rawPDU
00192 );
00193
00194 virtual BOOL IsCapability(
00195 const H235_AuthenticationMechanism & mechansim,
00196 const PASN_ObjectId & algorithmOID
00197 ) = 0;
00198
00199 virtual BOOL SetCapability(
00200 H225_ArrayOf_AuthenticationMechanism & mechansims,
00201 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00202 ) = 0;
00203
00204 virtual BOOL UseGkAndEpIdentifiers() const;
00205
00206 virtual BOOL IsSecuredPDU(
00207 unsigned rasPDU,
00208 BOOL received
00209 ) const;
00210
00211 virtual BOOL IsSecuredSignalPDU(
00212 unsigned signalPDU,
00213 BOOL received
00214 ) const;
00215
00216 virtual BOOL IsActive() const;
00217
00218 virtual void Enable(
00219 BOOL enab = TRUE
00220 ) { enabled = enab; }
00221 virtual void Disable() { enabled = FALSE; }
00222
00223 virtual const PString & GetRemoteId() const { return remoteId; }
00224 virtual void SetRemoteId(const PString & id) { remoteId = id; }
00225
00226 virtual const PString & GetLocalId() const { return localId; }
00227 virtual void SetLocalId(const PString & id) { localId = id; }
00228
00229 virtual const PString & GetPassword() const { return password; }
00230 virtual void SetPassword(const PString & pw) { password = pw; }
00231
00232 virtual int GetTimestampGracePeriod() const { return timestampGracePeriod; }
00233 virtual void SetTimestampGracePeriod(int grace) { timestampGracePeriod = grace; }
00234
00235 enum Application {
00236 GKAdmission,
00237 EPAuthentication,
00238 LRQOnly,
00239 AnyApplication,
00240 };
00241
00242 Application GetApplication() { return usage; }
00243
00244 virtual void SetConnection(H323Connection * con);
00245
00246 protected:
00247 BOOL AddCapability(
00248 unsigned mechanism,
00249 const PString & oid,
00250 H225_ArrayOf_AuthenticationMechanism & mechansims,
00251 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00252 );
00253
00254 BOOL enabled;
00255
00256 PString remoteId;
00257 PString localId;
00258 PString password;
00259
00260 unsigned sentRandomSequenceNumber;
00261 unsigned lastRandomSequenceNumber;
00262 unsigned lastTimestamp;
00263 int timestampGracePeriod;
00264
00265 Application usage;
00266 H323Connection * connection;
00267 PMutex mutex;
00268 };
00269
00270
00271 PDECLARE_LIST(H235Authenticators, H235Authenticator)
00272 #ifdef DOC_PLUS_PLUS
00273 {
00274 #endif
00275 public:
00276
00277 void PreparePDU(
00278 H323TransactionPDU & pdu,
00279 PASN_Array & clearTokens,
00280 unsigned clearOptionalField,
00281 PASN_Array & cryptoTokens,
00282 unsigned cryptoOptionalField
00283 ) const;
00284
00285 H235Authenticator::ValidationResult ValidatePDU(
00286 const H323TransactionPDU & pdu,
00287 const PASN_Array & clearTokens,
00288 unsigned clearOptionalField,
00289 const PASN_Array & cryptoTokens,
00290 unsigned cryptoOptionalField,
00291 const PBYTEArray & rawPDU
00292 ) const;
00293
00294
00295 void PrepareSignalPDU(
00296 unsigned code,
00297 PASN_Array & clearTokens,
00298 PASN_Array & cryptoTokens
00299 ) const;
00300
00301 H235Authenticator::ValidationResult ValidateSignalPDU(
00302 unsigned code,
00303 const PASN_Array & clearTokens,
00304 const PASN_Array & cryptoTokens,
00305 const PBYTEArray & rawPDU
00306 ) const;
00307
00308 };
00309
00310 class H235AuthenticatorInfo : public PObject
00311 {
00312 PCLASSINFO(H235AuthenticatorInfo, PObject);
00313 public:
00314 H235AuthenticatorInfo(PString username,PString password,BOOL ishashed);
00315 H235AuthenticatorInfo(PSSLCertificate * cert);
00316 PString UserName;
00317 PString Password;
00318 BOOL isHashed;
00319 PSSLCertificate * Certificate;
00320 };
00321
00322 PDECLARE_LIST(H235AuthenticatorList, H235AuthenticatorInfo)
00323 #ifdef DOC_PLUS_PLUS
00324 {
00325 #endif
00326 BOOL HasUserName(PString UserName) const;
00327 void LoadPassword(PString UserName, PString & pass) const;
00328 void Add(PString username, PString password, BOOL isHashed = FALSE);
00329 PString PasswordEncrypt(const PString &clear) const;
00330 PString PasswordDecrypt(const PString &encrypt) const;
00331 };
00332
00334 PDICTIONARY(H235AuthenticatorDict,PString,H235AuthenticatorInfo);
00335
00340 class H235AuthSimpleMD5 : public H235Authenticator
00341 {
00342 PCLASSINFO(H235AuthSimpleMD5, H235Authenticator);
00343 public:
00344 H235AuthSimpleMD5();
00345
00346 PObject * Clone() const;
00347
00348 virtual const char * GetName() const;
00349
00350 virtual H225_CryptoH323Token * CreateCryptoToken();
00351
00352 virtual ValidationResult ValidateCryptoToken(
00353 const H225_CryptoH323Token & cryptoToken,
00354 const PBYTEArray & rawPDU
00355 );
00356
00357 virtual BOOL IsCapability(
00358 const H235_AuthenticationMechanism & mechansim,
00359 const PASN_ObjectId & algorithmOID
00360 );
00361
00362 virtual BOOL SetCapability(
00363 H225_ArrayOf_AuthenticationMechanism & mechansim,
00364 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00365 );
00366
00367 virtual BOOL IsSecuredPDU(
00368 unsigned rasPDU,
00369 BOOL received
00370 ) const;
00371
00372 virtual BOOL IsSecuredSignalPDU(
00373 unsigned rasPDU,
00374 BOOL received
00375 ) const;
00376 };
00377
00378
00385 class H235AuthCAT : public H235Authenticator
00386 {
00387 PCLASSINFO(H235AuthCAT, H235Authenticator);
00388 public:
00389 H235AuthCAT();
00390
00391 PObject * Clone() const;
00392
00393 virtual const char * GetName() const;
00394
00395 virtual H235_ClearToken * CreateClearToken();
00396
00397 virtual ValidationResult ValidateClearToken(
00398 const H235_ClearToken & clearToken
00399 );
00400
00401 virtual BOOL IsCapability(
00402 const H235_AuthenticationMechanism & mechansim,
00403 const PASN_ObjectId & algorithmOID
00404 );
00405
00406 virtual BOOL SetCapability(
00407 H225_ArrayOf_AuthenticationMechanism & mechansim,
00408 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00409 );
00410
00411 virtual BOOL IsSecuredPDU(
00412 unsigned rasPDU,
00413 BOOL received
00414 ) const;
00415 };
00416
00417
00418 #if P_SSL
00419
00420 namespace PWLibStupidLinkerHacks {
00421 extern int h235AuthProcedure1Loader;
00422 };
00423
00427 class H2351_Authenticator : public H235Authenticator
00428 {
00429 PCLASSINFO(H2351_Authenticator, H235Authenticator);
00430 public:
00431 H2351_Authenticator();
00432
00433 PObject * Clone() const;
00434
00435 virtual const char * GetName() const;
00436
00437 virtual H225_CryptoH323Token * CreateCryptoToken();
00438
00439 virtual BOOL Finalise(
00440 PBYTEArray & rawPDU
00441 );
00442
00443 virtual ValidationResult ValidateCryptoToken(
00444 const H225_CryptoH323Token & cryptoToken,
00445 const PBYTEArray & rawPDU
00446 );
00447
00448 virtual BOOL IsCapability(
00449 const H235_AuthenticationMechanism & mechansim,
00450 const PASN_ObjectId & algorithmOID
00451 );
00452
00453 virtual BOOL SetCapability(
00454 H225_ArrayOf_AuthenticationMechanism & mechansim,
00455 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00456 );
00457
00458 virtual BOOL IsSecuredPDU(
00459 unsigned rasPDU,
00460 BOOL received
00461 ) const;
00462
00463 virtual BOOL IsSecuredSignalPDU(
00464 unsigned rasPDU,
00465 BOOL received
00466 ) const;
00467
00468 virtual BOOL UseGkAndEpIdentifiers() const;
00469 };
00470
00471 typedef H2351_Authenticator H235AuthProcedure1;
00472
00473 #endif
00474
00475
00476 #endif //__OPAL_H235AUTH_H
00477
00478