OPAL  Version 3.10.10
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  * $Revision: 24838 $
27  * $Author: rjongbloed $
28  * $Date: 2010-10-28 18:14:16 -0500 (Thu, 28 Oct 2010) $
29  */
30 
31 #ifndef OPAL_H323_H235AUTH_H
32 #define OPAL_H323_H235AUTH_H
33 
34 #ifdef P_USE_PRAGMA
35 #pragma interface
36 #endif
37 
38 #include <opal/buildopts.h>
39 
40 #if OPAL_H323
41 
42 #include <ptlib/pfactory.h>
43 
44 
45 class H323TransactionPDU;
46 class H225_CryptoH323Token;
47 class H225_ArrayOf_AuthenticationMechanism;
48 class H225_ArrayOf_PASN_ObjectId;
49 class H235_ClearToken;
50 class H235_AuthenticationMechanism;
51 class PASN_ObjectId;
52 class PASN_Sequence;
53 class PASN_Array;
54 
55 
59 class H235Authenticator : public PObject
60 {
61  PCLASSINFO(H235Authenticator, PObject);
62  public:
64 
65  virtual void PrintOn(
66  ostream & strm
67  ) const;
68 
69  virtual const char * GetName() const = 0;
70 
71  virtual PBoolean PrepareTokens(
72  PASN_Array & clearTokens,
73  PASN_Array & cryptoTokens
74  );
75 
76  virtual H235_ClearToken * CreateClearToken();
77  virtual H225_CryptoH323Token * CreateCryptoToken(bool digits);
78 
79  virtual PBoolean Finalise(
80  PBYTEArray & rawPDU
81  );
82 
84  e_OK = 0,
91  };
92 
94  const PASN_Array & clearTokens,
95  const PASN_Array & cryptoTokens,
96  const PBYTEArray & rawPDU
97  );
98 
100  const H235_ClearToken & clearToken
101  );
102 
104  const H225_CryptoH323Token & cryptoToken,
105  const PBYTEArray & rawPDU
106  );
107 
108  virtual PBoolean IsCapability(
109  const H235_AuthenticationMechanism & mechansim,
110  const PASN_ObjectId & algorithmOID
111  ) = 0;
112 
113  virtual PBoolean SetCapability(
114  H225_ArrayOf_AuthenticationMechanism & mechansims,
115  H225_ArrayOf_PASN_ObjectId & algorithmOIDs
116  ) = 0;
117 
118  virtual PBoolean UseGkAndEpIdentifiers() const;
119 
120  virtual PBoolean IsSecuredPDU(
121  unsigned rasPDU,
122  PBoolean received
123  ) const;
124 
125  virtual PBoolean IsActive() const;
126 
127  void Enable(
128  PBoolean enab = true
129  ) { enabled = enab; }
130  void Disable() { enabled = false; }
131 
132  const PString & GetRemoteId() const { return remoteId; }
133  void SetRemoteId(const PString & id) { remoteId = id; }
134 
135  const PString & GetLocalId() const { return localId; }
136  void SetLocalId(const PString & id) { localId = id; }
137 
138  const PString & GetPassword() const { return password; }
139  void SetPassword(const PString & pw) { password = pw; }
140 
141 
142  protected:
143  PBoolean AddCapability(
144  unsigned mechanism,
145  const PString & oid,
146  H225_ArrayOf_AuthenticationMechanism & mechansims,
147  H225_ArrayOf_PASN_ObjectId & algorithmOIDs
148  );
149 
150  PBoolean enabled;
151 
152  PString remoteId; // ID of remote entity
153  PString localId; // ID of local entity
154  PString password; // shared secret
155 
158  unsigned lastTimestamp;
160 
161  PMutex mutex;
162 
163  private:
164  P_REMOVE_VIRTUAL(H225_CryptoH323Token *,CreateCryptoToken(),NULL);
165 };
166 
167 
168 PDECLARE_LIST(H235Authenticators, H235Authenticator)
169  public:
170  void PreparePDU(
171  H323TransactionPDU & pdu,
172  PASN_Array & clearTokens,
173  unsigned clearOptionalField,
174  PASN_Array & cryptoTokens,
175  unsigned cryptoOptionalField
176  );
177 
179  const H323TransactionPDU & pdu,
180  const PASN_Array & clearTokens,
181  unsigned clearOptionalField,
182  const PASN_Array & cryptoTokens,
183  unsigned cryptoOptionalField,
184  const PBYTEArray & rawPDU
185  );
186 };
187 
188 
189 
190 
196 {
198  public:
200 
201  PObject * Clone() const;
202 
203  virtual const char * GetName() const;
204 
205  virtual H225_CryptoH323Token * CreateCryptoToken(bool digits);
206 
208  const H225_CryptoH323Token & cryptoToken,
209  const PBYTEArray & rawPDU
210  );
211 
212  virtual PBoolean IsCapability(
213  const H235_AuthenticationMechanism & mechansim,
214  const PASN_ObjectId & algorithmOID
215  );
216 
217  virtual PBoolean SetCapability(
218  H225_ArrayOf_AuthenticationMechanism & mechansim,
219  H225_ArrayOf_PASN_ObjectId & algorithmOIDs
220  );
221 
222  virtual PBoolean IsSecuredPDU(
223  unsigned rasPDU,
224  PBoolean received
225  ) const;
226 };
227 
229 
230 
238 {
239  PCLASSINFO(H235AuthCAT, H235Authenticator);
240  public:
241  H235AuthCAT();
242 
243  PObject * Clone() const;
244 
245  virtual const char * GetName() const;
246 
247  virtual H235_ClearToken * CreateClearToken();
248 
250  const H235_ClearToken & clearToken
251  );
252 
253  virtual PBoolean IsCapability(
254  const H235_AuthenticationMechanism & mechansim,
255  const PASN_ObjectId & algorithmOID
256  );
257 
258  virtual PBoolean SetCapability(
259  H225_ArrayOf_AuthenticationMechanism & mechansim,
260  H225_ArrayOf_PASN_ObjectId & algorithmOIDs
261  );
262 
263  virtual PBoolean IsSecuredPDU(
264  unsigned rasPDU,
265  PBoolean received
266  ) const;
267 };
268 
270 
271 
272 #if OPAL_PTLIB_SSL
273 
276 class H235AuthProcedure1 : public H235Authenticator
277 {
278  PCLASSINFO(H235AuthProcedure1, H235Authenticator);
279  public:
280  H235AuthProcedure1();
281 
282  PObject * Clone() const;
283 
284  virtual const char * GetName() const;
285 
286  virtual H225_CryptoH323Token * CreateCryptoToken(bool digits);
287 
288  virtual PBoolean Finalise(
289  PBYTEArray & rawPDU
290  );
291 
293  const H225_CryptoH323Token & cryptoToken,
294  const PBYTEArray & rawPDU
295  );
296 
297  virtual PBoolean IsCapability(
298  const H235_AuthenticationMechanism & mechansim,
299  const PASN_ObjectId & algorithmOID
300  );
301 
302  virtual PBoolean SetCapability(
303  H225_ArrayOf_AuthenticationMechanism & mechansim,
304  H225_ArrayOf_PASN_ObjectId & algorithmOIDs
305  );
306 
307  virtual PBoolean UseGkAndEpIdentifiers() const;
308 };
309 
310 PFACTORY_LOAD(H235AuthProcedure1);
311 
312 #endif // OPAL_PTLIB_SSL
313 
314 #endif // OPAL_H323
315 
316 #endif //OPAL_H323_H235AUTH_H
317 
318 
void SetLocalId(const PString &id)
Definition: h235auth.h:136
Security parameters indicate an attack was made.
Definition: h235auth.h:90
virtual PBoolean IsCapability(const H235_AuthenticationMechanism &mechansim, const PASN_ObjectId &algorithmOID)=0
PString password
Definition: h235auth.h:154
Security parameters indicate bad password in token.
Definition: h235auth.h:89
virtual H225_CryptoH323Token * CreateCryptoToken(bool digits)
unsigned lastRandomSequenceNumber
Definition: h235auth.h:157
void SetRemoteId(const PString &id)
Definition: h235auth.h:133
virtual PBoolean Finalise(PBYTEArray &rawPDU)
virtual ValidationResult ValidateClearToken(const H235_ClearToken &clearToken)
const PString & GetPassword() const
Definition: h235auth.h:138
PString localId
Definition: h235auth.h:153
PString remoteId
Definition: h235auth.h:152
void PreparePDU(H323TransactionPDU &pdu, PASN_Array &clearTokens, unsigned clearOptionalField, PASN_Array &cryptoTokens, unsigned cryptoOptionalField)
Security parameters are present but incorrect.
Definition: h235auth.h:87
virtual void PrintOn(ostream &strm) const
virtual PBoolean PrepareTokens(PASN_Array &clearTokens, PASN_Array &cryptoTokens)
unsigned sentRandomSequenceNumber
Definition: h235auth.h:156
virtual ValidationResult ValidateCryptoToken(const H225_CryptoH323Token &cryptoToken, const PBYTEArray &rawPDU)
Definition: h235auth.h:237
virtual const char * GetName() const =0
const PString & GetRemoteId() const
Definition: h235auth.h:132
void Disable()
Definition: h235auth.h:130
void Enable(PBoolean enab=true)
Definition: h235auth.h:127
virtual PBoolean SetCapability(H225_ArrayOf_AuthenticationMechanism &mechansims, H225_ArrayOf_PASN_ObjectId &algorithmOIDs)=0
PBoolean AddCapability(unsigned mechanism, const PString &oid, H225_ArrayOf_AuthenticationMechanism &mechansims, H225_ArrayOf_PASN_ObjectId &algorithmOIDs)
Definition: h235auth.h:84
unsigned lastTimestamp
Definition: h235auth.h:158
int timestampGracePeriod
Definition: h235auth.h:159
Security parameters are expected but absent.
Definition: h235auth.h:86
Definition: h235auth.h:59
virtual ValidationResult ValidateTokens(const PASN_Array &clearTokens, const PASN_Array &cryptoTokens, const PBYTEArray &rawPDU)
Definition: h323trans.h:51
ValidationResult
Definition: h235auth.h:83
PMutex mutex
Definition: h235auth.h:161
virtual PBoolean IsActive() const
virtual PBoolean UseGkAndEpIdentifiers() const
H235Authenticator::ValidationResult ValidatePDU(const H323TransactionPDU &pdu, const PASN_Array &clearTokens, unsigned clearOptionalField, const PASN_Array &cryptoTokens, unsigned cryptoOptionalField, const PBYTEArray &rawPDU)
virtual H235_ClearToken * CreateClearToken()
PFACTORY_LOAD(H235AuthSimpleMD5)
PBoolean enabled
Definition: h235auth.h:150
const PString & GetLocalId() const
Definition: h235auth.h:135
Definition: h235auth.h:195
virtual PBoolean IsSecuredPDU(unsigned rasPDU, PBoolean received) const
Security parameters and Msg are ok, no security attacks.
Definition: h235auth.h:85
void SetPassword(const PString &pw)
Definition: h235auth.h:139
Security parameters indicate peer has bad real time clock.
Definition: h235auth.h:88