wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tlsv1_record.h
Go to the documentation of this file.
1 
5 #ifndef TLSV1_RECORD_H
6 #define TLSV1_RECORD_H
7 
8 #include "crypto/crypto.h"
9 
10 #define TLS_MAX_WRITE_MAC_SECRET_LEN 32
11 #define TLS_MAX_WRITE_KEY_LEN 32
12 #define TLS_MAX_IV_LEN 16
13 #define TLS_MAX_KEY_BLOCK_LEN (2 * (TLS_MAX_WRITE_MAC_SECRET_LEN + \
14  TLS_MAX_WRITE_KEY_LEN + TLS_MAX_IV_LEN))
15 
16 #define TLS_SEQ_NUM_LEN 8
17 #define TLS_RECORD_HEADER_LEN 5
18 
19 /* ContentType */
20 enum {
21  TLS_CONTENT_TYPE_CHANGE_CIPHER_SPEC = 20,
22  TLS_CONTENT_TYPE_ALERT = 21,
23  TLS_CONTENT_TYPE_HANDSHAKE = 22,
24  TLS_CONTENT_TYPE_APPLICATION_DATA = 23
25 };
26 
28  u16 tls_version;
29 
30  u8 write_mac_secret[TLS_MAX_WRITE_MAC_SECRET_LEN];
31  u8 read_mac_secret[TLS_MAX_WRITE_MAC_SECRET_LEN];
32  u8 write_key[TLS_MAX_WRITE_KEY_LEN];
33  u8 read_key[TLS_MAX_WRITE_KEY_LEN];
34  u8 write_iv[TLS_MAX_IV_LEN];
35  u8 read_iv[TLS_MAX_IV_LEN];
36 
37  size_t hash_size;
38  size_t key_material_len;
39  size_t iv_size; /* also block_size */
40 
41  enum crypto_hash_alg hash_alg;
42  enum crypto_cipher_alg cipher_alg;
43 
44  u8 write_seq_num[TLS_SEQ_NUM_LEN];
45  u8 read_seq_num[TLS_SEQ_NUM_LEN];
46 
47  u16 cipher_suite;
48  u16 write_cipher_suite;
49  u16 read_cipher_suite;
50 
51  struct crypto_cipher *write_cbc;
52  struct crypto_cipher *read_cbc;
53 };
54 
55 
57  u16 cipher_suite);
60 int tlsv1_record_send(struct tlsv1_record_layer *rl, u8 content_type, u8 *buf,
61  size_t buf_size, const u8 *payload, size_t payload_len,
62  size_t *out_len);
64  const u8 *in_data, size_t in_len,
65  u8 *out_data, size_t *out_len, u8 *alert);
66 
67 #endif /* TLSV1_RECORD_H */
int tlsv1_record_change_read_cipher(struct tlsv1_record_layer *rl)
TLS record layer: Change read cipher.
Definition: tlsv1_record.c:105
Wrapper functions for crypto libraries.
int tlsv1_record_change_write_cipher(struct tlsv1_record_layer *rl)
TLS record layer: Change write cipher.
Definition: tlsv1_record.c:71
Definition: crypto_gnutls.c:185
int tlsv1_record_send(struct tlsv1_record_layer *rl, u8 content_type, u8 *buf, size_t buf_size, const u8 *payload, size_t payload_len, size_t *out_len)
TLS record layer: Send a message.
Definition: tlsv1_record.c:146
Definition: tlsv1_record.h:27
int tlsv1_record_receive(struct tlsv1_record_layer *rl, const u8 *in_data, size_t in_len, u8 *out_data, size_t *out_len, u8 *alert)
TLS record layer: Process a received message.
Definition: tlsv1_record.c:274
int tlsv1_record_set_cipher_suite(struct tlsv1_record_layer *rl, u16 cipher_suite)
TLS record layer: Set cipher suite.
Definition: tlsv1_record.c:26