• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 	int read_alerts, write_alerts;
34 
35 	struct crypto_public_key *client_rsa_key;
36 
37 	struct tls_verify_hash verify;
38 
39 #define MAX_CIPHER_COUNT 30
40 	u16 cipher_suites[MAX_CIPHER_COUNT];
41 	size_t num_cipher_suites;
42 
43 	u16 cipher_suite;
44 
45 	struct tlsv1_credentials *cred;
46 
47 	int verify_peer;
48 	u16 client_version;
49 
50 	u8 *session_ticket;
51 	size_t session_ticket_len;
52 
53 	tlsv1_server_session_ticket_cb session_ticket_cb;
54 	void *session_ticket_cb_ctx;
55 
56 	void (*log_cb)(void *ctx, const char *msg);
57 	void *log_cb_ctx;
58 
59 	int use_session_ticket;
60 	unsigned int status_request:1;
61 	unsigned int status_request_v2:1;
62 	unsigned int status_request_multi:1;
63 
64 	u8 *dh_secret;
65 	size_t dh_secret_len;
66 
67 #ifdef CONFIG_TESTING_OPTIONS
68 	u32 test_flags;
69 	int test_failure_reported;
70 #endif /* CONFIG_TESTING_OPTIONS */
71 };
72 
73 
74 void tlsv1_server_log(struct tlsv1_server *conn, const char *fmt, ...)
75 PRINTF_FORMAT(2, 3);
76 
77 void tlsv1_server_alert(struct tlsv1_server *conn, u8 level, u8 description);
78 int tlsv1_server_derive_keys(struct tlsv1_server *conn,
79 			     const u8 *pre_master_secret,
80 			     size_t pre_master_secret_len);
81 u8 * tlsv1_server_handshake_write(struct tlsv1_server *conn, size_t *out_len);
82 u8 * tlsv1_server_send_alert(struct tlsv1_server *conn, u8 level,
83 			     u8 description, size_t *out_len);
84 int tlsv1_server_process_handshake(struct tlsv1_server *conn, u8 ct,
85 				   const u8 *buf, size_t *len);
86 void tlsv1_server_get_dh_p(struct tlsv1_server *conn, const u8 **dh_p,
87 			   size_t *dh_p_len);
88 
89 #endif /* TLSV1_SERVER_I_H */
90