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 #ifndef __OPAL_H235AUTH_H
00100 #define __OPAL_H235AUTH_H
00101
00102 #ifdef P_USE_PRAGMA
00103 #pragma interface
00104 #endif
00105
00106 class H323TransactionPDU;
00107 class H225_CryptoH323Token;
00108 class H225_ArrayOf_AuthenticationMechanism;
00109 class H225_ArrayOf_PASN_ObjectId;
00110 class H235_ClearToken;
00111 class H235_AuthenticationMechanism;
00112 class PASN_ObjectId;
00113 class PASN_Sequence;
00114 class PASN_Array;
00115
00116 namespace PWLibStupidLinkerHacks {
00117 extern int h235AuthLoader;
00118 };
00119
00123 class H235Authenticator : public PObject
00124 {
00125 PCLASSINFO(H235Authenticator, PObject);
00126 public:
00127 H235Authenticator();
00128
00129 virtual void PrintOn(
00130 ostream & strm
00131 ) const;
00132
00133 virtual const char * GetName() const = 0;
00134
00135 virtual BOOL PrepareTokens(
00136 PASN_Array & clearTokens,
00137 PASN_Array & cryptoTokens
00138 );
00139
00140 virtual H235_ClearToken * CreateClearToken();
00141 virtual H225_CryptoH323Token * CreateCryptoToken();
00142
00143 virtual BOOL Finalise(
00144 PBYTEArray & rawPDU
00145 );
00146
00147 enum ValidationResult {
00148 e_OK = 0,
00149 e_Absent,
00150 e_Error,
00151 e_InvalidTime,
00152 e_BadPassword,
00153 e_ReplyAttack,
00154 e_Disabled
00155 };
00156
00157 virtual ValidationResult ValidateTokens(
00158 const PASN_Array & clearTokens,
00159 const PASN_Array & cryptoTokens,
00160 const PBYTEArray & rawPDU
00161 );
00162
00163 virtual ValidationResult ValidateClearToken(
00164 const H235_ClearToken & clearToken
00165 );
00166
00167 virtual ValidationResult ValidateCryptoToken(
00168 const H225_CryptoH323Token & cryptoToken,
00169 const PBYTEArray & rawPDU
00170 );
00171
00172 virtual BOOL IsCapability(
00173 const H235_AuthenticationMechanism & mechansim,
00174 const PASN_ObjectId & algorithmOID
00175 ) = 0;
00176
00177 virtual BOOL SetCapability(
00178 H225_ArrayOf_AuthenticationMechanism & mechansims,
00179 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00180 ) = 0;
00181
00182 virtual BOOL UseGkAndEpIdentifiers() const;
00183
00184 virtual BOOL IsSecuredPDU(
00185 unsigned rasPDU,
00186 BOOL received
00187 ) const;
00188
00189 virtual BOOL IsActive() const;
00190
00191 virtual void Enable(
00192 BOOL enab = TRUE
00193 ) { enabled = enab; }
00194 virtual void Disable() { enabled = FALSE; }
00195
00196 virtual const PString & GetRemoteId() const { return remoteId; }
00197 virtual void SetRemoteId(const PString & id) { remoteId = id; }
00198
00199 virtual const PString & GetLocalId() const { return localId; }
00200 virtual void SetLocalId(const PString & id) { localId = id; }
00201
00202 virtual const PString & GetPassword() const { return password; }
00203 virtual void SetPassword(const PString & pw) { password = pw; }
00204
00205 virtual int GetTimestampGracePeriod() const { return timestampGracePeriod; }
00206 virtual void SetTimestampGracePeriod(int grace) { timestampGracePeriod = grace; }
00207
00208 protected:
00209 BOOL AddCapability(
00210 unsigned mechanism,
00211 const PString & oid,
00212 H225_ArrayOf_AuthenticationMechanism & mechansims,
00213 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00214 );
00215
00216 BOOL enabled;
00217
00218 PString remoteId;
00219 PString localId;
00220 PString password;
00221
00222 unsigned sentRandomSequenceNumber;
00223 unsigned lastRandomSequenceNumber;
00224 unsigned lastTimestamp;
00225 int timestampGracePeriod;
00226
00227 PMutex mutex;
00228 };
00229
00230
00231 PDECLARE_LIST(H235Authenticators, H235Authenticator)
00232 #ifdef DOC_PLUS_PLUS
00233 {
00234 #endif
00235 public:
00236 void PreparePDU(
00237 H323TransactionPDU & pdu,
00238 PASN_Array & clearTokens,
00239 unsigned clearOptionalField,
00240 PASN_Array & cryptoTokens,
00241 unsigned cryptoOptionalField
00242 ) const;
00243
00244 H235Authenticator::ValidationResult ValidatePDU(
00245 const H323TransactionPDU & pdu,
00246 const PASN_Array & clearTokens,
00247 unsigned clearOptionalField,
00248 const PASN_Array & cryptoTokens,
00249 unsigned cryptoOptionalField,
00250 const PBYTEArray & rawPDU
00251 ) const;
00252 };
00253
00254
00255
00256
00261 class H235AuthSimpleMD5 : public H235Authenticator
00262 {
00263 PCLASSINFO(H235AuthSimpleMD5, H235Authenticator);
00264 public:
00265 H235AuthSimpleMD5();
00266
00267 PObject * Clone() const;
00268
00269 virtual const char * GetName() const;
00270
00271 virtual H225_CryptoH323Token * CreateCryptoToken();
00272
00273 virtual ValidationResult ValidateCryptoToken(
00274 const H225_CryptoH323Token & cryptoToken,
00275 const PBYTEArray & rawPDU
00276 );
00277
00278 virtual BOOL IsCapability(
00279 const H235_AuthenticationMechanism & mechansim,
00280 const PASN_ObjectId & algorithmOID
00281 );
00282
00283 virtual BOOL SetCapability(
00284 H225_ArrayOf_AuthenticationMechanism & mechansim,
00285 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00286 );
00287
00288 virtual BOOL IsSecuredPDU(
00289 unsigned rasPDU,
00290 BOOL received
00291 ) const;
00292 };
00293
00294
00301 class H235AuthCAT : public H235Authenticator
00302 {
00303 PCLASSINFO(H235AuthCAT, H235Authenticator);
00304 public:
00305 H235AuthCAT();
00306
00307 PObject * Clone() const;
00308
00309 virtual const char * GetName() const;
00310
00311 virtual H235_ClearToken * CreateClearToken();
00312
00313 virtual ValidationResult ValidateClearToken(
00314 const H235_ClearToken & clearToken
00315 );
00316
00317 virtual BOOL IsCapability(
00318 const H235_AuthenticationMechanism & mechansim,
00319 const PASN_ObjectId & algorithmOID
00320 );
00321
00322 virtual BOOL SetCapability(
00323 H225_ArrayOf_AuthenticationMechanism & mechansim,
00324 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00325 );
00326
00327 virtual BOOL IsSecuredPDU(
00328 unsigned rasPDU,
00329 BOOL received
00330 ) const;
00331 };
00332
00333
00334 #if P_SSL
00335
00336 namespace PWLibStupidLinkerHacks {
00337 extern int h235AuthProcedure1Loader;
00338 };
00339
00342 class H235AuthProcedure1 : public H235Authenticator
00343 {
00344 PCLASSINFO(H235AuthProcedure1, H235Authenticator);
00345 public:
00346 H235AuthProcedure1();
00347
00348 PObject * Clone() const;
00349
00350 virtual const char * GetName() const;
00351
00352 virtual H225_CryptoH323Token * CreateCryptoToken();
00353
00354 virtual BOOL Finalise(
00355 PBYTEArray & rawPDU
00356 );
00357
00358 virtual ValidationResult ValidateCryptoToken(
00359 const H225_CryptoH323Token & cryptoToken,
00360 const PBYTEArray & rawPDU
00361 );
00362
00363 virtual BOOL IsCapability(
00364 const H235_AuthenticationMechanism & mechansim,
00365 const PASN_ObjectId & algorithmOID
00366 );
00367
00368 virtual BOOL SetCapability(
00369 H225_ArrayOf_AuthenticationMechanism & mechansim,
00370 H225_ArrayOf_PASN_ObjectId & algorithmOIDs
00371 );
00372
00373 virtual BOOL UseGkAndEpIdentifiers() const;
00374 };
00375
00376 #endif
00377
00378
00379 #endif //__OPAL_H235AUTH_H
00380
00381