xref: /freebsd/contrib/wpa/src/tls/tlsv1_server_i.h (revision f4b37ed0f8b307b1f3f0f630ca725d68f1dff30d)
1 /*
2  * TLSv1 server - internal structures
3  * Copyright (c) 2006-2007, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef TLSV1_SERVER_I_H
10 #define TLSV1_SERVER_I_H
11 
12 struct tlsv1_server {
13 	enum {
14 		CLIENT_HELLO, SERVER_HELLO, SERVER_CERTIFICATE,
15 		SERVER_KEY_EXCHANGE, SERVER_CERTIFICATE_REQUEST,
16 		SERVER_HELLO_DONE, CLIENT_CERTIFICATE, CLIENT_KEY_EXCHANGE,
17 		CERTIFICATE_VERIFY, CHANGE_CIPHER_SPEC, CLIENT_FINISHED,
18 		SERVER_CHANGE_CIPHER_SPEC, SERVER_FINISHED,
19 		ESTABLISHED, FAILED
20 	} state;
21 
22 	struct tlsv1_record_layer rl;
23 
24 	u8 session_id[TLS_SESSION_ID_MAX_LEN];
25 	size_t session_id_len;
26 	u8 client_random[TLS_RANDOM_LEN];
27 	u8 server_random[TLS_RANDOM_LEN];
28 	u8 master_secret[TLS_MASTER_SECRET_LEN];
29 
30 	u8 alert_level;
31 	u8 alert_description;
32 
33 	struct crypto_public_key *client_rsa_key;
34 
35 	struct tls_verify_hash verify;
36 
37 #define MAX_CIPHER_COUNT 30
38 	u16 cipher_suites[MAX_CIPHER_COUNT];
39 	size_t num_cipher_suites;
40 
41 	u16 cipher_suite;
42 
43 	struct tlsv1_credentials *cred;
44 
45 	int verify_peer;
46 	u16 client_version;
47 
48 	u8 *session_ticket;
49 	size_t session_ticket_len;
50 
51 	tlsv1_server_session_ticket_cb session_ticket_cb;
52 	void *session_ticket_cb_ctx;
53 
54 	void (*log_cb)(void *ctx, const char *msg);
55 	void *log_cb_ctx;
56 
57 	int use_session_ticket;
58 
59 	u8 *dh_secret;
60 	size_t dh_secret_len;
61 
62 #ifdef CONFIG_TESTING_OPTIONS
63 	u32 test_flags;
64 	int test_failure_reported;
65 #endif /* CONFIG_TESTING_OPTIONS */
66 };
67 
68 
69 void tlsv1_server_log(struct tlsv1_server *conn, const char *fmt, ...)
70 PRINTF_FORMAT(2, 3);
71 
72 void tlsv1_server_alert(struct tlsv1_server *conn, u8 level, u8 description);
73 int tlsv1_server_derive_keys(struct tlsv1_server *conn,
74 			     const u8 *pre_master_secret,
75 			     size_t pre_master_secret_len);
76 u8 * tlsv1_server_handshake_write(struct tlsv1_server *conn, size_t *out_len);
77 u8 * tlsv1_server_send_alert(struct tlsv1_server *conn, u8 level,
78 			     u8 description, size_t *out_len);
79 int tlsv1_server_process_handshake(struct tlsv1_server *conn, u8 ct,
80 				   const u8 *buf, size_t *len);
81 void tlsv1_server_get_dh_p(struct tlsv1_server *conn, const u8 **dh_p,
82 			   size_t *dh_p_len);
83 
84 #endif /* TLSV1_SERVER_I_H */
85