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