OpenH323 1.18.0
|
00001 /* 00002 * h235auth.h 00003 * 00004 * H.235 authorisation PDU's 00005 * 00006 * Open H323 Library 00007 * 00008 * Copyright (c) 1998-2001 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Open H323 Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Contributor(s): Fürbass Franz <franz.fuerbass@infonova.at> 00025 * 00026 * $Log: h235auth.h,v $ 00027 * Revision 1.20 2005/11/30 13:05:01 csoutheren 00028 * Changed tags for Doxygen 00029 * 00030 * Revision 1.19 2005/02/13 23:54:48 csoutheren 00031 * Allow access to H.235 timestamp grace period 00032 * Thanks to Jan Willamowius 00033 * 00034 * Revision 1.18 2004/11/20 22:00:48 csoutheren 00035 * Added hacks for linker problem 00036 * 00037 * Revision 1.17 2004/11/12 06:04:42 csoutheren 00038 * Changed H235Authentiators to use PFactory 00039 * 00040 * Revision 1.16 2004/05/13 02:26:13 dereksmithies 00041 * Fixes so make docs does not generate warning messages about brackets. 00042 * 00043 * Revision 1.15 2003/04/30 00:28:50 robertj 00044 * Redesigned the alternate credentials in ARQ system as old implementation 00045 * was fraught with concurrency issues, most importantly it can cause false 00046 * detection of replay attacks taking out an endpoint completely. 00047 * 00048 * Revision 1.14 2003/04/01 04:47:48 robertj 00049 * Abstracted H.225 RAS transaction processing (RIP and secondary thread) in 00050 * server environment for use by H.501 peer elements. 00051 * 00052 * Revision 1.13 2003/02/25 06:48:14 robertj 00053 * More work on PDU transaction abstraction. 00054 * 00055 * Revision 1.12 2003/02/11 04:43:22 robertj 00056 * Fixed use of asymmetrical authentication schemes such as MD5. 00057 * 00058 * Revision 1.11 2003/02/01 13:31:14 robertj 00059 * Changes to support CAT authentication in RAS. 00060 * 00061 * Revision 1.10 2003/01/08 04:40:31 robertj 00062 * Added more debug tracing for H.235 authenticators. 00063 * 00064 * Revision 1.9 2002/09/16 01:14:15 robertj 00065 * Added #define so can select if #pragma interface/implementation is used on 00066 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00067 * 00068 * Revision 1.8 2002/09/03 06:19:36 robertj 00069 * Normalised the multi-include header prevention ifdef/define symbol. 00070 * 00071 * Revision 1.7 2002/08/05 10:03:47 robertj 00072 * Cosmetic changes to normalise the usage of pragma interface/implementation. 00073 * 00074 * Revision 1.6 2002/08/05 05:17:37 robertj 00075 * Fairly major modifications to support different authentication credentials 00076 * in ARQ to the logged in ones on RRQ. For both client and server. 00077 * Various other H.235 authentication bugs and anomalies fixed on the way. 00078 * 00079 * Revision 1.5 2002/05/17 03:39:28 robertj 00080 * Fixed problems with H.235 authentication on RAS for server and client. 00081 * 00082 * Revision 1.4 2001/12/06 06:44:42 robertj 00083 * Removed "Win32 SSL xxx" build configurations in favour of system 00084 * environment variables to select optional libraries. 00085 * 00086 * Revision 1.3 2001/09/14 00:13:37 robertj 00087 * Fixed problem with some athenticators needing extra conditions to be 00088 * "active", so make IsActive() virtual and add localId to H235AuthSimpleMD5 00089 * 00090 * Revision 1.2 2001/09/13 01:15:18 robertj 00091 * Added flag to H235Authenticator to determine if gkid and epid is to be 00092 * automatically set as the crypto token remote id and local id. 00093 * 00094 * Revision 1.1 2001/08/10 11:03:49 robertj 00095 * Major changes to H.235 support in RAS to support server. 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; // ID of remote entity 00219 PString localId; // ID of local entity 00220 PString password; // shared secret 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