Kannel: Open Source WAP and SMS gateway  svn-r5335
wtls_pdu.h
Go to the documentation of this file.
1 /* ====================================================================
2  * The Kannel Software License, Version 1.0
3  *
4  * Copyright (c) 2001-2018 Kannel Group
5  * Copyright (c) 1998-2001 WapIT Ltd.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Kannel Group (http://www.kannel.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Kannel" and "Kannel Group" must not be used to
28  * endorse or promote products derived from this software without
29  * prior written permission. For written permission, please
30  * contact org@kannel.org.
31  *
32  * 5. Products derived from this software may not be called "Kannel",
33  * nor may "Kannel" appear in their name, without prior written
34  * permission of the Kannel Group.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS
40  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
41  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
42  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
45  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
46  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Kannel Group. For more information on
51  * the Kannel Group, please see <http://www.kannel.org/>.
52  *
53  * Portions of this software are based upon software originally written at
54  * WapIT Ltd., Helsinki, Finland for the Kannel project.
55  */
56 
57 /* wtls_pdu.h - definitions for unpacked WTLS protocol data units
58  *
59  * Nikos Balkanas, Inaccess Networks (2009)
60  */
61 
62 #ifndef PDU_H
63 #define PDU_H
64 
65 #include "gwlib/list.h"
66 #include "gwlib/octstr.h"
67 #include "wtls.h"
68 
69 typedef enum wtls_pdu_modes {
75 
76 typedef enum handshake_type {
86  finished = 20
88 
89 typedef enum compmethod {
92 
93 typedef enum certificateformat {
94  WTLSCert = 1,
98 
99 typedef enum sig_algo {
104 
105 typedef enum keyex_suite {
122 
123 typedef enum pubkey_algo {
128 
129 typedef enum identifier_type {
130  null = 0,
134  x509_name = 255
136 
137 typedef enum public_key_type {
138  rsa_key = 2,
139  ecdh_key = 3,
141 } PublicKeyType;
142 
143 typedef enum ecbasistype {
148 } ECBasisType;
149 
150 typedef enum ecfield {
153 } ECField;
154 
155 typedef struct random {
158 } Random;
159 
160 typedef struct ecpoint {
162 } ECPoint;
163 
165 
166 typedef struct dhpublickey {
168 } DHPublicKey;
169 
170 typedef struct rsa_public_key {
173 } RSAPublicKey;
174 
175 typedef struct public_key {
176  /* ecdh */
178  /* ecdsa */
180  /* rsa */
182 } PublicKey;
183 
184 typedef struct identifier {
186  /* text */
187  int charset;
189  /* binary */
191  /* key_hash_sha */
193  /* x509 */
195 } Identifier;
196 
197 typedef struct eccurve {
201 } ECCurve;
202 
203 typedef struct dh_parameters {
204  int dh_e;
207 } DHParameters;
208 
209 typedef struct ec_parameters {
211  /* case ec_prime_p */
213  /* case ec_characteristic_two */
214  int m;
216  /* case ec_basis_onb : nothing */
217  /* case ec_trinomial */
218  int k;
219  /* case ec_pentanomial */
220  int k1;
221  int k2;
222  int k3;
223  /* case ec_basis_polynomial */
229 } ECParameters;
230 
231 typedef struct parameter_set {
232  long length;
233  /* rsa: empty */
234  /* diffie-hellman */
236  /* eliptic curve */
238 } ParameterSet;
239 
240 typedef struct parameter_specifier {
244 
245 typedef struct key_exchange_id {
249 } KeyExchangeId;
250 
251 typedef struct signature {
252  /* case anonymous */
253  /* nothing */
254  /* case ecdsa_sha and rsa_sha */
256 } Signature;
257 
258 typedef struct to_be_signed_cert {
269 
270 typedef struct wtls_cert {
274 
275 typedef struct rsa_secret {
278 } RSASecret;
279 
280 typedef struct rsa_encrypted_secret {
283 
284 typedef struct cipher_suite {
286  int mac_algo;
287 } CipherSuite;
288 
289 typedef struct cert_request {
290  List *trusted_authorities; // List of KeyExchangeIds
292 
293 typedef struct cert_verify {
296 
297 typedef struct hello_request {
298  int dummy; /* nothing here */
299 } HelloRequest;
300 
301 typedef struct client_hello {
307  List *ciphersuites; // list of CipherSuites
309  int snmode;
310  int krefresh;
311 } ClientHello;
312 
313 typedef struct server_hello {
320  int snmode;
321  int krefresh;
322 } ServerHello;
323 
324 typedef struct certificate {
326  /* case WTLS */
328  /* case X509 */
330  /* X968 */
332 } Certificate;
333 
334 typedef struct server_key_exchange {
336  /* case rsa_anon */
338  /* case dh_anon */
340  /* case ecdh_anon */
343 
344 typedef struct client_key_exchange {
345  /* case rsa and rsa_anon */
347  /* case dh_anon */
349  /* case ecdh_anon and ecdh_ecdsa */
352 
353 typedef struct finished {
355 } Finished;
356 
357 typedef struct server_hello_done {
358  int dummy; /* nothing here */
360 
361 typedef struct cc {
362  int change;
363 } ChangeCipher;
364 
365 typedef enum {
369 } AlertLevel;
370 
371 typedef enum {
405 
406 typedef struct alert {
407  int level;
410 } Alert;
411 
412 typedef struct certificates {
414 } Certificates;
415 
416 typedef struct handshake {
418  int length;
419  /* case hello_request */
420 
421  /* case client_hello */
423  /* case server_hello */
425  /* case certificate */
427  /* case server_key_exchange */
429  /* case certificate_request */
431  /* case server_hello_done */
433  /* case certificate_verify */
435  /* case client_key_exchange */
437  /* case finished */
439 } Handshake;
440 
441 typedef struct application {
443 } Application;
444 
445 typedef struct wtls_pdu {
446  int type;
447  int reserved;
448  int cipher;
449  int snMode;
450  int seqNum;
451  int rlen;
452 
453  union {
458  } u;
459 } wtls_PDU;
460 
461 typedef struct wtls_payload {
462  int type;
463  int reserved;
464  int cipher;
465  int snMode;
466  int seqNum;
467  int rlen;
468 
470 } wtls_Payload;
471 
472 /* Prototypes */
475 void wtls_pdu_dump(wtls_PDU * msg, int level);
477 wtls_Payload *wtls_pdu_pack(wtls_PDU * pdu, WTLSMachine * wtls_machine);
478 
481 void wtls_payload_dump(wtls_Payload * msg, int level);
482 void wtls_pldList_destroy(List * pldList);
484 
486 Octstr *wtls_pack_payloadlist(List * payloadlist, int seqnum);
487 
488 #endif /* PDU_H */
wtls_pdu_modes
Definition: wtls_pdu.h:69
Octstr * dh_Y
Definition: wtls_pdu.h:167
Certificates * certificates
Definition: wtls_pdu.h:426
Octstr * order
Definition: wtls_pdu.h:227
AlertDescription desc
Definition: wtls_pdu.h:408
ServerHelloDone * server_hello_done
Definition: wtls_pdu.h:432
struct dh_parameters DHParameters
struct identifier Identifier
ServerHello * server_hello
Definition: wtls_pdu.h:424
ECPublicKey * ecdh_params
Definition: wtls_pdu.h:341
long gmt_unix_time
Definition: wtls_pdu.h:156
int certificate_version
Definition: wtls_pdu.h:259
wtls_Payload * wtls_pdu_pack(wtls_PDU *pdu, WTLSMachine *wtls_machine)
Definition: wtls_pdu.h:361
keyex_suite
Definition: wtls_pdu.h:105
wtls_PDU * wtls_pdu_create(int type)
int charset
Definition: wtls_pdu.h:187
Octstr * dh_g
Definition: wtls_pdu.h:206
struct parameter_specifier ParameterSpecifier
ClientKeyExchange * client_key_exchange
Definition: wtls_pdu.h:436
struct wtls_payload wtls_Payload
struct ec_parameters ECParameters
enum pubkey_algo PublicKeyAlgorithm
void wtls_payload_destroy(wtls_Payload *payload)
struct public_key PublicKey
struct rsa_public_key RSAPublicKey
Identifier * issuer
Definition: wtls_pdu.h:261
SignatureAlgorithm signature_algo
Definition: wtls_pdu.h:260
List * sha_hash
Definition: wtls_pdu.h:255
struct cc ChangeCipher
Random * random
Definition: wtls_pdu.h:303
struct handshake Handshake
ECPublicKey * ecdsa_pubkey
Definition: wtls_pdu.h:179
struct certificates Certificates
int cipher
Definition: wtls_pdu.h:448
struct hello_request HelloRequest
struct parameter_set ParameterSet
void wtls_payload_dump(wtls_Payload *msg, int level)
Finished * finished
Definition: wtls_pdu.h:438
PublicKeyType pubkey_type
Definition: wtls_pdu.h:265
struct client_hello ClientHello
ToBeSignedCertificate * tobesigned_cert
Definition: wtls_pdu.h:271
List * random
Definition: wtls_pdu.h:277
List * client_key_ids
Definition: wtls_pdu.h:305
int length
Definition: wtls_pdu.h:418
identifier_type
Definition: wtls_pdu.h:129
compmethod
Definition: wtls_pdu.h:89
Octstr * rsa_exponent
Definition: wtls_pdu.h:171
ECParameters * ecparams
Definition: wtls_pdu.h:237
CertificateFormat certificateformat
Definition: wtls_pdu.h:325
struct cert_request CertificateRequest
enum ecbasistype ECBasisType
int krefresh
Definition: wtls_pdu.h:310
int type
Definition: smsc_cimd2.c:215
long valid_not_after
Definition: wtls_pdu.h:263
struct to_be_signed_cert ToBeSignedCertificate
DHPublicKey * dh_params
Definition: wtls_pdu.h:339
Octstr * b
Definition: wtls_pdu.h:199
Octstr * session_id
Definition: wtls_pdu.h:316
Octstr * wtls_payload_pack(wtls_Payload *payload, int seqnum)
struct ecpoint ECPoint
AlertDescription
Definition: wtls_pdu.h:371
Alert alert
Definition: wtls_pdu.h:455
List * certList
Definition: wtls_pdu.h:413
ParameterSpecifier * param_specif
Definition: wtls_pdu.h:247
enum keyex_suite KeyExchangeSuite
ECBasisType basis
Definition: wtls_pdu.h:215
Octstr * distinguished_name
Definition: wtls_pdu.h:194
Octstr * seed
Definition: wtls_pdu.h:200
Octstr * key_hash
Definition: wtls_pdu.h:192
DHPublicKey * dh_anon_params
Definition: wtls_pdu.h:348
List * comp_methods
Definition: wtls_pdu.h:308
int snMode
Definition: wtls_pdu.h:449
Octstr * data
Definition: wtls_pdu.h:469
void wtls_pldList_destroy(List *pldList)
void wtls_pdu_dump(wtls_PDU *msg, int level)
Octstr * random_bytes
Definition: wtls_pdu.h:157
int reserved
Definition: wtls_pdu.h:447
int key_exchange_suite
Definition: wtls_pdu.h:246
CertificateRequest * certificate_request
Definition: wtls_pdu.h:430
union wtls_pdu::@93 u
Application application
Definition: wtls_pdu.h:457
struct server_key_exchange ServerKeyExchange
ChangeCipher cc
Definition: wtls_pdu.h:454
List * ciphersuites
Definition: wtls_pdu.h:307
ParameterSpecifier * param_spec
Definition: wtls_pdu.h:335
Octstr * a
Definition: wtls_pdu.h:198
static Octstr * payload
Definition: mtbatch.c:104
Octstr * wtls_pack_payloadlist(List *payloadlist, int seqnum)
struct server_hello_done ServerHelloDone
Octstr * dh_p
Definition: wtls_pdu.h:205
struct server_hello ServerHello
Octstr * x968_certificate
Definition: wtls_pdu.h:331
ECCurve * curve
Definition: wtls_pdu.h:225
int reserved
Definition: wtls_pdu.h:463
void wtls_pdu_destroy(wtls_PDU *msg)
Octstr * x509_certificate
Definition: wtls_pdu.h:329
struct eccurve ECCurve
Random * random
Definition: wtls_pdu.h:315
ServerKeyExchange * server_key_exchange
Definition: wtls_pdu.h:428
wtls_Payload * wtls_payload_unpack(Octstr *data)
Octstr * chksum
Definition: wtls_pdu.h:409
ECPoint ECPublicKey
Definition: wtls_pdu.h:164
Octstr * verify_data
Definition: wtls_pdu.h:354
int serverversion
Definition: wtls_pdu.h:314
struct finished Finished
struct application Application
Octstr * cofactor
Definition: wtls_pdu.h:228
ECPublicKey * ecdh_params
Definition: wtls_pdu.h:350
DHParameters * dhparams
Definition: wtls_pdu.h:235
WTLSCertificate * wtls_certificate
Definition: wtls_pdu.h:327
struct cipher_suite CipherSuite
int krefresh
Definition: wtls_pdu.h:321
struct signature Signature
CipherSuite * ciphersuite
Definition: wtls_pdu.h:318
enum sig_algo SignatureAlgorithm
struct client_key_exchange ClientKeyExchange
Identifier * identifier
Definition: wtls_pdu.h:248
Octstr * irreducible
Definition: wtls_pdu.h:224
int client_key_id
Definition: wtls_pdu.h:317
ParameterSpecifier * param_spec
Definition: wtls_pdu.h:266
Signature * signature
Definition: wtls_pdu.h:294
struct alert Alert
int client_version
Definition: wtls_pdu.h:276
struct certificate Certificate
int level
Definition: wtls_pdu.h:407
RSAPublicKey * rsa_pubkey
Definition: wtls_pdu.h:181
RSAPublicKey * rsa_params
Definition: wtls_pdu.h:337
struct wtls_pdu wtls_PDU
ECPoint * base
Definition: wtls_pdu.h:226
ecbasistype
Definition: wtls_pdu.h:143
Definition: octstr.c:118
List * trusted_key_ids
Definition: wtls_pdu.h:306
long valid_not_before
Definition: wtls_pdu.h:262
int change
Definition: wtls_pdu.h:362
CertificateVerify * cert_verify
Definition: wtls_pdu.h:434
Octstr * prime_p
Definition: wtls_pdu.h:212
ParameterSet * param_set
Definition: wtls_pdu.h:242
ECPublicKey * ecdh_pubkey
Definition: wtls_pdu.h:177
Handshake handshake
Definition: wtls_pdu.h:456
struct rsa_secret RSASecret
Identifier * subject
Definition: wtls_pdu.h:264
List * trusted_authorities
Definition: wtls_pdu.h:290
int mac_algo
Definition: wtls_pdu.h:286
Octstr * session_id
Definition: wtls_pdu.h:304
struct cert_verify CertificateVerify
struct rsa_encrypted_secret RSAEncryptedSecret
HandshakeType msg_type
Definition: wtls_pdu.h:417
CompressionMethod comp_method
Definition: wtls_pdu.h:319
enum handshake_type HandshakeType
ClientHello * client_hello
Definition: wtls_pdu.h:422
ECField field
Definition: wtls_pdu.h:210
public_key_type
Definition: wtls_pdu.h:137
Octstr * data
Definition: wtls_pdu.h:442
certificateformat
Definition: wtls_pdu.h:93
struct dhpublickey DHPublicKey
pubkey_algo
Definition: wtls_pdu.h:123
RSAEncryptedSecret * rsa_params
Definition: wtls_pdu.h:346
Definition: wtls_pdu.h:130
int rlen
Definition: wtls_pdu.h:451
Octstr * rsa_modulus
Definition: wtls_pdu.h:172
Definition: wtls_pdu.h:114
int seqNum
Definition: wtls_pdu.h:450
enum compmethod CompressionMethod
handshake_type
Definition: wtls_pdu.h:76
List * wtls_unpack_payloadlist(Octstr *data)
sig_algo
Definition: wtls_pdu.h:99
enum certificateformat CertificateFormat
Octstr * identifier
Definition: wtls_pdu.h:190
int clientversion
Definition: wtls_pdu.h:302
IdentifierType id_type
Definition: wtls_pdu.h:185
struct key_exchange_id KeyExchangeId
struct wtls_cert WTLSCertificate
Octstr * point
Definition: wtls_pdu.h:161
int bulk_cipher_algo
Definition: wtls_pdu.h:285
PublicKey * pubkey
Definition: wtls_pdu.h:267
Definition: list.c:102
ecfield
Definition: wtls_pdu.h:150
Signature * signature
Definition: wtls_pdu.h:272
enum public_key_type PublicKeyType
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
struct random Random
enum ecfield ECField
Definition: wtls_pdu.h:131
int type
Definition: wtls_pdu.h:446
AlertLevel
Definition: wtls_pdu.h:365
Octstr * name
Definition: wtls_pdu.h:188
enum identifier_type IdentifierType
wtls_PDU * wtls_pdu_unpack(wtls_Payload *payload, WTLSMachine *wtls_machine)
Octstr * encrypted_secret
Definition: wtls_pdu.h:281
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.