OPAL  Version 3.18.8
h235auth.h
Go to the documentation of this file.
1 /*
2  * h235auth.h
3  *
4  * H.235 authorisation PDU's
5  *
6  * Open H323 Library
7  *
8  * Copyright (c) 1998-2001 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open H323 Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Contributor(s): Fürbass Franz <franz.fuerbass@infonova.at>
25  */
26 
27 #ifndef OPAL_H323_H235AUTH_H
28 #define OPAL_H323_H235AUTH_H
29 
30 #ifdef P_USE_PRAGMA
31 #pragma interface
32 #endif
33 
34 #include <opal_config.h>
35 
36 #if OPAL_H323
37 
38 #include <ptlib/pfactory.h>
39 
40 
41 class H323TransactionPDU;
42 class H225_CryptoH323Token;
43 class H225_ArrayOf_AuthenticationMechanism;
44 class H225_ArrayOf_PASN_ObjectId;
45 class H235_ClearToken;
46 class H235_AuthenticationMechanism;
47 class PASN_ObjectId;
48 class PASN_Sequence;
49 class PASN_Array;
50 
51 
55 class H235Authenticator : public PObject
56 {
57  PCLASSINFO(H235Authenticator, PObject);
58  public:
60 
61  virtual void PrintOn(
62  ostream & strm
63  ) const;
64 
65  virtual const char * GetName() const = 0;
66 
67  virtual PBoolean PrepareTokens(
68  PASN_Array & clearTokens,
69  PASN_Array & cryptoTokens,
70  unsigned rasPDU
71  );
72 
73  virtual H235_ClearToken * CreateClearToken(unsigned rasPDU);
74  virtual H235_ClearToken * CreateClearToken();
75  virtual H225_CryptoH323Token * CreateCryptoToken(bool digits, unsigned rasPDU);
76  virtual H225_CryptoH323Token * CreateCryptoToken(bool digits);
77 
78  virtual PBoolean Finalise(
79  PBYTEArray & rawPDU
80  );
81 
83  e_OK = 0,
90  };
91 
93  const PASN_Array & clearTokens,
94  const PASN_Array & cryptoTokens,
95  const PBYTEArray & rawPDU
96  );
97 
99  const H235_ClearToken & clearToken
100  );
101 
103  const H225_CryptoH323Token & cryptoToken,
104  const PBYTEArray & rawPDU
105  );
106 
107  virtual PBoolean IsCapability(
108  const H235_AuthenticationMechanism & mechansim,
109  const PASN_ObjectId & algorithmOID
110  ) = 0;
111 
112  virtual PBoolean SetCapability(
113  H225_ArrayOf_AuthenticationMechanism & mechansims,
114  H225_ArrayOf_PASN_ObjectId & algorithmOIDs
115  ) = 0;
116 
117  virtual PBoolean UseGkAndEpIdentifiers() const;
118 
119  virtual PBoolean IsSecuredPDU(
120  unsigned rasPDU,
121  PBoolean received
122  ) const;
123 
124  void Enable(
125  PBoolean enab = true
126  ) { m_enabled = enab; }
127  void Disable() { m_enabled = false; }
128  bool IsEnabled() const { return m_enabled; }
129 
130  const PString & GetRemoteId() const { return remoteId; }
131  void SetRemoteId(const PString & id) { remoteId = id; }
132 
133  const PString & GetLocalId() const { return localId; }
134  void SetLocalId(const PString & id) { localId = id; }
135 
136  const PString & GetPassword() const { return password; }
137  void SetPassword(const PString & pw) { password = pw; }
138 
139  enum Application {
144  };
145 
147 
148 
149  protected:
150  PINDEX AddCapabilityIfNeeded(
151  unsigned mechanism,
152  const PString & oid,
153  H225_ArrayOf_AuthenticationMechanism & mechansims,
154  H225_ArrayOf_PASN_ObjectId & algorithmOIDs
155  );
156 
157  bool m_enabled;
158 
159  PString remoteId; // ID of remote entity
160  PString localId; // ID of local entity
161  PString password; // shared secret
162 
165  unsigned lastTimestamp;
167 
169 
170  PDECLARE_MUTEX(mutex);
171 
172  private:
173  P_REMOVE_VIRTUAL(H225_CryptoH323Token *,CreateCryptoToken(),NULL);
174  P_REMOVE_VIRTUAL(PBoolean,PrepareTokens(PASN_Array &,PASN_Array &),false);
175 };
176 
177 
178 PDECLARE_LIST(H235Authenticators, H235Authenticator)
179  protected:
180  void InternalPreparePDU(
181  H323TransactionPDU & pdu,
182  PASN_Array & clearTokens,
183  unsigned clearOptionalField,
184  PASN_Array & cryptoTokens,
185  unsigned cryptoOptionalField
186  );
187  H235Authenticator::ValidationResult InternalValidatePDU(
188  const H323TransactionPDU & pdu,
189  const PASN_Array & clearTokens,
190  unsigned clearOptionalField,
191  const PASN_Array & cryptoTokens,
192  unsigned cryptoOptionalField,
193  const PBYTEArray & rawPDU
194  );
195  public:
196  template <class RAS> void PreparePDU(H323TransactionPDU & pdu, RAS & ras)
197  {
198  InternalPreparePDU(pdu, ras.m_tokens, RAS::e_tokens, ras.m_cryptoTokens, RAS::e_cryptoTokens);
199  }
200  template <class RAS> H235Authenticator::ValidationResult ValidatePDU(const H323TransactionPDU & pdu,const RAS & ras, const PBYTEArray & rawPDU)
201  {
202  return InternalValidatePDU(pdu, ras.m_tokens, RAS::e_tokens, ras.m_cryptoTokens, RAS::e_cryptoTokens, rawPDU);
203  }
204 };
205 
206 
207 
208 
214 {
216  public:
218 
219  PObject * Clone() const;
220 
221  virtual const char * GetName() const;
222 
223  virtual H225_CryptoH323Token * CreateCryptoToken(bool digits);
224 
226  const H225_CryptoH323Token & cryptoToken,
227  const PBYTEArray & rawPDU
228  );
229 
230  virtual PBoolean IsCapability(
231  const H235_AuthenticationMechanism & mechansim,
232  const PASN_ObjectId & algorithmOID
233  );
234 
235  virtual PBoolean SetCapability(
236  H225_ArrayOf_AuthenticationMechanism & mechansim,
237  H225_ArrayOf_PASN_ObjectId & algorithmOIDs
238  );
239 
240  virtual PBoolean IsSecuredPDU(
241  unsigned rasPDU,
242  PBoolean received
243  ) const;
244 };
245 
247 
248 
256 {
257  PCLASSINFO(H235AuthCAT, H235Authenticator);
258  public:
259  H235AuthCAT();
260 
261  PObject * Clone() const;
262 
263  virtual const char * GetName() const;
264 
265  virtual H235_ClearToken * CreateClearToken();
266 
268  const H235_ClearToken & clearToken
269  );
270 
271  virtual PBoolean IsCapability(
272  const H235_AuthenticationMechanism & mechansim,
273  const PASN_ObjectId & algorithmOID
274  );
275 
276  virtual PBoolean SetCapability(
277  H225_ArrayOf_AuthenticationMechanism & mechansim,
278  H225_ArrayOf_PASN_ObjectId & algorithmOIDs
279  );
280 
281  virtual PBoolean IsSecuredPDU(
282  unsigned rasPDU,
283  PBoolean received
284  ) const;
285 };
286 
288 
289 
290 #if OPAL_PTLIB_SSL
291 
294 class H235AuthPwd_DES_ECB : public H235Authenticator
295 {
296  PCLASSINFO(H235AuthPwd_DES_ECB, H235Authenticator);
297  public:
298  H235AuthPwd_DES_ECB();
299 
300  PObject * Clone() const;
301 
302  virtual const char * GetName() const;
303 
304  virtual H235_ClearToken * CreateClearToken(unsigned rasPDU);
305  virtual H225_CryptoH323Token * CreateCryptoToken(bool digits, unsigned rasPDU);
306 
307  virtual ValidationResult ValidateClearToken(
308  const H235_ClearToken & clearToken
309  );
310  virtual ValidationResult ValidateCryptoToken(
311  const H225_CryptoH323Token & cryptoToken,
312  const PBYTEArray & rawPDU
313  );
314 
315  virtual PBoolean SetCapability(
316  H225_ArrayOf_AuthenticationMechanism & mechansim,
317  H225_ArrayOf_PASN_ObjectId & algorithmOIDs
318  );
319 
320  virtual PBoolean IsCapability(
321  const H235_AuthenticationMechanism & mechansim,
322  const PASN_ObjectId & algorithmOID
323  );
324 
325  virtual PBoolean IsSecuredPDU(
326  unsigned rasPDU,
327  PBoolean received
328  ) const;
329 
330  protected:
331  bool EncryptToken(PBYTEArray & encryptedToken);
332 
333  PBYTEArray m_encodedToken;
334 };
335 
336 PFACTORY_LOAD(H235AuthPwd_DES_ECB);
337 
338 
341 class H235AuthProcedure1 : public H235Authenticator
342 {
343  PCLASSINFO(H235AuthProcedure1, H235Authenticator);
344  public:
345  H235AuthProcedure1();
346 
347  PObject * Clone() const;
348 
349  virtual const char * GetName() const;
350 
351  virtual H225_CryptoH323Token * CreateCryptoToken(bool digits);
352 
353  virtual PBoolean Finalise(
354  PBYTEArray & rawPDU
355  );
356 
357  virtual ValidationResult ValidateCryptoToken(
358  const H225_CryptoH323Token & cryptoToken,
359  const PBYTEArray & rawPDU
360  );
361 
362  virtual PBoolean IsCapability(
363  const H235_AuthenticationMechanism & mechansim,
364  const PASN_ObjectId & algorithmOID
365  );
366 
367  virtual PBoolean SetCapability(
368  H225_ArrayOf_AuthenticationMechanism & mechansim,
369  H225_ArrayOf_PASN_ObjectId & algorithmOIDs
370  );
371 
372  virtual PBoolean UseGkAndEpIdentifiers() const;
373 };
374 
375 PFACTORY_LOAD(H235AuthProcedure1);
376 
377 #endif // OPAL_PTLIB_SSL
378 
379 #endif // OPAL_H323
380 
381 #endif //OPAL_H323_H235AUTH_H
382 
383 
void SetLocalId(const PString &id)
Definition: h235auth.h:134
Security parameters indicate an attack was made.
Definition: h235auth.h:89
virtual PBoolean IsCapability(const H235_AuthenticationMechanism &mechansim, const PASN_ObjectId &algorithmOID)=0
To Be Used for GK Admission.
Definition: h235auth.h:140
To Be Used for Any Application.
Definition: h235auth.h:143
PString password
Definition: h235auth.h:161
Security parameters indicate bad password in token.
Definition: h235auth.h:88
Application
Definition: h235auth.h:139
unsigned lastRandomSequenceNumber
Definition: h235auth.h:164
PINDEX AddCapabilityIfNeeded(unsigned mechanism, const PString &oid, H225_ArrayOf_AuthenticationMechanism &mechansims, H225_ArrayOf_PASN_ObjectId &algorithmOIDs)
void SetRemoteId(const PString &id)
Definition: h235auth.h:131
virtual ValidationResult ValidateClearToken(const H235_ClearToken &clearToken)
virtual PBoolean IsCapability(const H235_AuthenticationMechanism &mechansim, const PASN_ObjectId &algorithmOID)
To Be Used for Location Request Authentication.
Definition: h235auth.h:142
const PString & GetRemoteId() const
Definition: h235auth.h:130
virtual PBoolean Finalise(PBYTEArray &rawPDU)
const PString & GetLocalId() const
Definition: h235auth.h:133
const PString & GetPassword() const
Definition: h235auth.h:136
virtual H235_ClearToken * CreateClearToken()
To Be Used for EP Authentication.
Definition: h235auth.h:141
virtual ValidationResult ValidateClearToken(const H235_ClearToken &clearToken)
PObject * Clone() const
Application usage
Authenticator&#39;s Application.
Definition: h235auth.h:168
bool m_enabled
Definition: h235auth.h:157
void InternalPreparePDU(H323TransactionPDU &pdu, PASN_Array &clearTokens, unsigned clearOptionalField, PASN_Array &cryptoTokens, unsigned cryptoOptionalField)
PFACTORY_LOAD(OpalPluginCodecManager)
Application GetApplication()
Get Authentication Application.
Definition: h235auth.h:146
H235Authenticator::ValidationResult InternalValidatePDU(const H323TransactionPDU &pdu, const PASN_Array &clearTokens, unsigned clearOptionalField, const PASN_Array &cryptoTokens, unsigned cryptoOptionalField, const PBYTEArray &rawPDU)
PString localId
Definition: h235auth.h:160
PObject * Clone() const
PString remoteId
Definition: h235auth.h:159
Security parameters are present but incorrect.
Definition: h235auth.h:86
unsigned sentRandomSequenceNumber
Definition: h235auth.h:163
virtual ValidationResult ValidateCryptoToken(const H225_CryptoH323Token &cryptoToken, const PBYTEArray &rawPDU)
virtual H225_CryptoH323Token * CreateCryptoToken(bool digits)
virtual PBoolean IsSecuredPDU(unsigned rasPDU, PBoolean received) const
Definition: h235auth.h:255
virtual const char * GetName() const =0
virtual const char * GetName() const
void Disable()
Definition: h235auth.h:127
void Enable(PBoolean enab=true)
Definition: h235auth.h:124
virtual void PrintOn(ostream &strm) const
virtual PBoolean SetCapability(H225_ArrayOf_AuthenticationMechanism &mechansims, H225_ArrayOf_PASN_ObjectId &algorithmOIDs)=0
virtual PBoolean IsCapability(const H235_AuthenticationMechanism &mechansim, const PASN_ObjectId &algorithmOID)
virtual ValidationResult ValidateCryptoToken(const H225_CryptoH323Token &cryptoToken, const PBYTEArray &rawPDU)
Definition: h235auth.h:83
virtual H225_CryptoH323Token * CreateCryptoToken(bool digits, unsigned rasPDU)
unsigned lastTimestamp
Definition: h235auth.h:165
int timestampGracePeriod
Definition: h235auth.h:166
Security parameters are expected but absent.
Definition: h235auth.h:85
Definition: h235auth.h:55
virtual ValidationResult ValidateTokens(const PASN_Array &clearTokens, const PASN_Array &cryptoTokens, const PBYTEArray &rawPDU)
Definition: h323trans.h:47
ValidationResult
Definition: h235auth.h:82
virtual PBoolean UseGkAndEpIdentifiers() const
H235Authenticator::ValidationResult ValidatePDU(const H323TransactionPDU &pdu, const RAS &ras, const PBYTEArray &rawPDU)
Definition: h235auth.h:200
virtual PBoolean IsSecuredPDU(unsigned rasPDU, PBoolean received) const
bool IsEnabled() const
Definition: h235auth.h:128
virtual H235_ClearToken * CreateClearToken()
virtual PBoolean PrepareTokens(PASN_Array &clearTokens, PASN_Array &cryptoTokens, unsigned rasPDU)
virtual PBoolean SetCapability(H225_ArrayOf_AuthenticationMechanism &mechansim, H225_ArrayOf_PASN_ObjectId &algorithmOIDs)
virtual const char * GetName() const
Definition: h235auth.h:213
virtual PBoolean SetCapability(H225_ArrayOf_AuthenticationMechanism &mechansim, H225_ArrayOf_PASN_ObjectId &algorithmOIDs)
virtual PBoolean IsSecuredPDU(unsigned rasPDU, PBoolean received) const
Security parameters and Msg are ok, no security attacks.
Definition: h235auth.h:84
void SetPassword(const PString &pw)
Definition: h235auth.h:137
Security parameters indicate peer has bad real time clock.
Definition: h235auth.h:87
void PreparePDU(H323TransactionPDU &pdu, RAS &ras)
Definition: h235auth.h:196