OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

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:
63 H235Authenticator();
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
83 enum ValidationResult {
84 e_OK = 0,
85 e_Absent,
86 e_Error,
87 e_InvalidTime,
88 e_BadPassword,
89 e_ReplyAttack,
90 e_Disabled
91 };
92
93 virtual ValidationResult ValidateTokens(
94 const PASN_Array & clearTokens,
95 const PASN_Array & cryptoTokens,
96 const PBYTEArray & rawPDU
97 );
98
99 virtual ValidationResult ValidateClearToken(
100 const H235_ClearToken & clearToken
101 );
102
103 virtual ValidationResult ValidateCryptoToken(
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
156 unsigned sentRandomSequenceNumber;
157 unsigned lastRandomSequenceNumber;
158 unsigned lastTimestamp;
159 int timestampGracePeriod;
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
178 H235Authenticator::ValidationResult ValidatePDU(
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
195 class H235AuthSimpleMD5 : public H235Authenticator
196 {
197 PCLASSINFO(H235AuthSimpleMD5, H235Authenticator);
198 public:
199 H235AuthSimpleMD5();
200
201 PObject * Clone() const;
202
203 virtual const char * GetName() const;
204
205 virtual H225_CryptoH323Token * CreateCryptoToken(bool digits);
206
207 virtual ValidationResult ValidateCryptoToken(
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
228 PFACTORY_LOAD(H235AuthSimpleMD5);
229
230
237 class H235AuthCAT : public H235Authenticator
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
249 virtual ValidationResult ValidateClearToken(
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
269 PFACTORY_LOAD(H235AuthCAT);
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
292 virtual ValidationResult ValidateCryptoToken(
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