/usr/include/openh323/h235auth.h is in libh323plus-dev 1.24.0~dfsg2-1.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | /*
* h235auth.h
*
* H.235 authorisation PDU's
*
* H323Plus Library
*
* Copyright (c) 1998-2001 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Open H323 Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): Fürbass Franz <franz.fuerbass@infonova.at>
*
* $Id: h235auth.h,v 1.10 2011/10/01 03:11:11 shorne Exp $
*
*/
#ifndef __OPAL_H235AUTH_H
#define __OPAL_H235AUTH_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
class H323TransactionPDU;
class H225_CryptoH323Token;
class H225_ArrayOf_AuthenticationMechanism;
class H225_ArrayOf_PASN_ObjectId;
class H235_ClearToken;
class H235_AuthenticationMechanism;
class PASN_ObjectId;
class PASN_Sequence;
class PASN_Array;
class H323SignalPDU;
class H323Connection;
class PSSLCertificate;
#include "ptlib_extras.h"
#include <ptlib/pluginmgr.h>
#include <list>
/** This abtract class embodies an H.235 authentication mechanism.
NOTE: descendants must have a Clone() function for correct operation.
*/
class H235Authenticator : public PObject
{
PCLASSINFO(H235Authenticator, PObject);
public:
H235Authenticator();
virtual void PrintOn(
ostream & strm
) const;
#ifdef H323_H235
static H235Authenticator * CreateAuthenticator(const PString & authname, ///< Feature Name Expression
PPluginManager * pluginMgr = NULL ///< Plugin Manager
);
static H235Authenticator * CreateAuthenticatorByID(const PString & identifier
);
struct Capability {
const char * m_identifier;
const char * m_cipher;
const char * m_description;
};
typedef struct {
std::list<Capability> capabilityList;
} Capabilities;
static PBoolean GetAuthenticatorCapabilities(const PString & deviceName,
Capabilities * caps,
PPluginManager * pluginMgr = NULL);
#endif
virtual const char * GetName() const = 0;
static PStringArray GetAuthenticatorList();
virtual PBoolean IsMatch(const PString & /*identifier*/) const { return false; }
virtual PBoolean PrepareTokens(
PASN_Array & clearTokens,
PASN_Array & cryptoTokens
);
virtual H235_ClearToken * CreateClearToken();
virtual H225_CryptoH323Token * CreateCryptoToken();
virtual PBoolean Finalise(
PBYTEArray & rawPDU
);
enum ValidationResult {
e_OK = 0, ///< Security parameters and Msg are ok, no security attacks
e_Absent, ///< Security parameters are expected but absent
e_Error, ///< Security parameters are present but incorrect
e_InvalidTime,///< Security parameters indicate peer has bad real time clock
e_BadPassword,///< Security parameters indicate bad password in token
e_ReplyAttack,///< Security parameters indicate an attack was made
e_Disabled ///< Security is disabled by local system
};
virtual ValidationResult ValidateTokens(
const PASN_Array & clearTokens,
const PASN_Array & cryptoTokens,
const PBYTEArray & rawPDU
);
virtual ValidationResult ValidateClearToken(
const H235_ClearToken & clearToken
);
virtual ValidationResult ValidateCryptoToken(
const H225_CryptoH323Token & cryptoToken,
const PBYTEArray & rawPDU
);
virtual PBoolean IsCapability(
const H235_AuthenticationMechanism & mechansim,
const PASN_ObjectId & algorithmOID
) = 0;
virtual PBoolean SetCapability(
H225_ArrayOf_AuthenticationMechanism & mechansims,
H225_ArrayOf_PASN_ObjectId & algorithmOIDs
) = 0;
virtual PBoolean UseGkAndEpIdentifiers() const;
virtual PBoolean IsSecuredPDU(
unsigned rasPDU,
PBoolean received
) const;
virtual PBoolean IsSecuredSignalPDU(
unsigned signalPDU,
PBoolean received
) const;
virtual PBoolean IsActive() const;
virtual void Enable(
PBoolean enab = TRUE
) { enabled = enab; }
virtual void Disable() { enabled = FALSE; }
virtual const PString & GetRemoteId() const { return remoteId; }
virtual void SetRemoteId(const PString & id) { remoteId = id; }
virtual const PString & GetLocalId() const { return localId; }
virtual void SetLocalId(const PString & id) { localId = id; }
virtual const PString & GetPassword() const { return password; }
virtual void SetPassword(const PString & pw) { password = pw; }
virtual int GetTimestampGracePeriod() const { return timestampGracePeriod; }
virtual void SetTimestampGracePeriod(int grace) { timestampGracePeriod = grace; }
enum Application {
GKAdmission, ///< To Be Used for GK Admission
EPAuthentication, ///< To Be Used for EP Authentication
LRQOnly, ///< To Be Used for Location Request Authentication
MediaEncryption, ///< To Be Used for MediaEncryption
AnyApplication, ///< To Be Used for Any Application
};
Application GetApplication() { return usage; } // Get Authentication Application
virtual void SetConnection(H323Connection * con); // Set the connection for EPAuthentication
virtual PBoolean GetAlgorithms(PStringList & algorithms) const; // Get the supported Algorithm OIDs
virtual PBoolean GetAlgorithmDetails(const PString & algorithm, ///< Algorithm OID
PString & sslName, ///< SSL Description
PString & description ///< Human Description
);
protected:
PBoolean AddCapability(
unsigned mechanism,
const PString & oid,
H225_ArrayOf_AuthenticationMechanism & mechansims,
H225_ArrayOf_PASN_ObjectId & algorithmOIDs
);
PBoolean enabled;
PString remoteId; // ID of remote entity
PString localId; // ID of local entity
PString password; // shared secret
unsigned sentRandomSequenceNumber;
unsigned lastRandomSequenceNumber;
unsigned lastTimestamp;
int timestampGracePeriod;
Application usage; ///* Authenticator's Application
H323Connection * connection; ///* CallToken of the Connection for EP Authentication
PMutex mutex;
};
PDECLARE_LIST(H235Authenticators, H235Authenticator)
#ifdef DOC_PLUS_PLUS
{
#endif
public:
// GKAdmission
void PreparePDU(
H323TransactionPDU & pdu,
PASN_Array & clearTokens,
unsigned clearOptionalField,
PASN_Array & cryptoTokens,
unsigned cryptoOptionalField
) const;
H235Authenticator::ValidationResult ValidatePDU(
const H323TransactionPDU & pdu,
const PASN_Array & clearTokens,
unsigned clearOptionalField,
const PASN_Array & cryptoTokens,
unsigned cryptoOptionalField,
const PBYTEArray & rawPDU
) const;
// EPAuthentication
void PrepareSignalPDU(
unsigned code,
PASN_Array & clearTokens,
PASN_Array & cryptoTokens
) const;
H235Authenticator::ValidationResult ValidateSignalPDU(
unsigned code,
const PASN_Array & clearTokens,
const PASN_Array & cryptoTokens,
const PBYTEArray & rawPDU
) const;
#ifdef H323_H235
PBoolean CreateAuthenticators(const PASN_Array & clearTokens, const PASN_Array & cryptoTokens);
PBoolean CreateAuthenticator(const PString & name);
PBoolean SupportsEncryption(PStringArray & list) const;
PBoolean SupportsEncryption() const;
PBoolean GetAlgorithms(PStringList & algorithms) const;
PBoolean GetAlgorithmDetails(const PString & algorithm, PString & sslName, PString & description);
protected:
void CreateAuthenticatorsByID(const PStringArray & identifiers);
#endif
};
class H235AuthenticatorInfo : public PObject
{
PCLASSINFO(H235AuthenticatorInfo, PObject);
public:
H235AuthenticatorInfo(PString username,PString password,PBoolean ishashed);
H235AuthenticatorInfo(PSSLCertificate * cert);
PString UserName;
PString Password;
PBoolean isHashed;
PSSLCertificate * Certificate;
};
PDECLARE_LIST(H235AuthenticatorList, H235AuthenticatorInfo)
#ifdef DOC_PLUS_PLUS
{
#endif
PBoolean HasUserName(PString UserName) const;
void LoadPassword(PString UserName, PString & pass) const;
void Add(PString username, PString password, PBoolean isHashed = FALSE);
PString PasswordEncrypt(const PString &clear) const;
PString PasswordDecrypt(const PString &encrypt) const;
};
/** Dictionary of Addresses and Associated Security Info */
H323DICTIONARY(H235AuthenticatorDict,PString,H235AuthenticatorInfo);
/** This class embodies a simple MD5 based authentication.
The users password is concatenated with the 4 byte timestamp and 4 byte
random fields and an MD5 generated and sent/verified
*/
class H235AuthSimpleMD5 : public H235Authenticator
{
PCLASSINFO(H235AuthSimpleMD5, H235Authenticator);
public:
H235AuthSimpleMD5();
PObject * Clone() const;
virtual const char * GetName() const;
static PStringArray GetAuthenticatorNames();
#ifdef H323_H235
static PBoolean GetAuthenticationCapabilities(Capabilities * ids);
#endif
virtual PBoolean IsMatch(const PString & identifier) const;
virtual H225_CryptoH323Token * CreateCryptoToken();
virtual ValidationResult ValidateCryptoToken(
const H225_CryptoH323Token & cryptoToken,
const PBYTEArray & rawPDU
);
virtual PBoolean IsCapability(
const H235_AuthenticationMechanism & mechansim,
const PASN_ObjectId & algorithmOID
);
virtual PBoolean SetCapability(
H225_ArrayOf_AuthenticationMechanism & mechansim,
H225_ArrayOf_PASN_ObjectId & algorithmOIDs
);
virtual PBoolean IsSecuredPDU(
unsigned rasPDU,
PBoolean received
) const;
virtual PBoolean IsSecuredSignalPDU(
unsigned rasPDU,
PBoolean received
) const;
};
////////////////////////////////////////////////////
#ifdef H323_H235
/// PFactory Loader
typedef H235AuthSimpleMD5 H235_AuthenticatorMD5;
#ifndef _WIN32_WCE
PPLUGIN_STATIC_LOAD(MD5,H235Authenticator);
#endif
#endif
/** This class embodies a RADIUS compatible based authentication (aka Cisco
Access Token or CAT).
The users password is concatenated with the 4 byte timestamp and 1 byte
random fields and an MD5 generated and sent/verified via the challenge
field.
*/
class H235AuthCAT : public H235Authenticator
{
PCLASSINFO(H235AuthCAT, H235Authenticator);
public:
H235AuthCAT();
PObject * Clone() const;
virtual const char * GetName() const;
virtual H235_ClearToken * CreateClearToken();
virtual ValidationResult ValidateClearToken(
const H235_ClearToken & clearToken
);
virtual PBoolean IsCapability(
const H235_AuthenticationMechanism & mechansim,
const PASN_ObjectId & algorithmOID
);
virtual PBoolean SetCapability(
H225_ArrayOf_AuthenticationMechanism & mechansim,
H225_ArrayOf_PASN_ObjectId & algorithmOIDs
);
virtual PBoolean IsSecuredPDU(
unsigned rasPDU,
PBoolean received
) const;
};
#if P_SSL
/** This class embodies the H.235 "base line" from H235.1.
*/
class H2351_Authenticator : public H235Authenticator
{
PCLASSINFO(H2351_Authenticator, H235Authenticator);
public:
H2351_Authenticator();
PObject * Clone() const;
virtual const char * GetName() const;
static PStringArray GetAuthenticatorNames();
#ifdef H323_H235
static PBoolean GetAuthenticationCapabilities(Capabilities * ids);
#endif
virtual PBoolean IsMatch(const PString & identifier) const;
virtual H225_CryptoH323Token * CreateCryptoToken();
virtual PBoolean Finalise(
PBYTEArray & rawPDU
);
virtual ValidationResult ValidateCryptoToken(
const H225_CryptoH323Token & cryptoToken,
const PBYTEArray & rawPDU
);
virtual PBoolean IsCapability(
const H235_AuthenticationMechanism & mechansim,
const PASN_ObjectId & algorithmOID
);
virtual PBoolean SetCapability(
H225_ArrayOf_AuthenticationMechanism & mechansim,
H225_ArrayOf_PASN_ObjectId & algorithmOIDs
);
virtual PBoolean IsSecuredPDU(
unsigned rasPDU,
PBoolean received
) const;
virtual PBoolean IsSecuredSignalPDU(
unsigned rasPDU,
PBoolean received
) const;
virtual PBoolean UseGkAndEpIdentifiers() const;
};
typedef H2351_Authenticator H235AuthProcedure1; // Backwards interoperability
//////////////////////////////////////////////////////////////////////////////
#ifdef H323_H235
typedef H2351_Authenticator H235_AuthenticatorStd1;
#ifndef _WIN32_WCE
PPLUGIN_STATIC_LOAD(Std1,H235Authenticator);
#endif
#endif
template <class className> class H235PluginServiceDescriptor : public PDevicePluginServiceDescriptor
{
public:
virtual PObject * CreateInstance(int /*userData*/) const { return new className; }
virtual PStringArray GetDeviceNames(int /*userData*/) const {
return className::GetAuthenticatorNames();
}
virtual bool ValidateDeviceName(const PString & deviceName, int /*userData*/) const {
return (deviceName == className::GetAuthenticatorNames()[0]);
}
#ifdef H323_H235
virtual bool GetDeviceCapabilities(const PString & /*deviceName*/, void * capabilities) const {
return className::GetAuthenticationCapabilities((H235Authenticator::Capabilities *)capabilities);
}
#endif
};
#define H235SECURITY(name) \
static H235PluginServiceDescriptor<H235_Authenticator##name> H235_Authenticator##name##_descriptor; \
PCREATE_PLUGIN(name, H235Authenticator, &H235_Authenticator##name##_descriptor); \
#endif
#endif //__H323_H235AUTH_H
/////////////////////////////////////////////////////////////////////////////
|