• 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 	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 	int use_session_ticket;
55 
56 	u8 *dh_secret;
57 	size_t dh_secret_len;
58 };
59 
60 
61 void tlsv1_server_alert(struct tlsv1_server *conn, u8 level, u8 description);
62 int tlsv1_server_derive_keys(struct tlsv1_server *conn,
63 			     const u8 *pre_master_secret,
64 			     size_t pre_master_secret_len);
65 u8 * tlsv1_server_handshake_write(struct tlsv1_server *conn, size_t *out_len);
66 u8 * tlsv1_server_send_alert(struct tlsv1_server *conn, u8 level,
67 			     u8 description, size_t *out_len);
68 int tlsv1_server_process_handshake(struct tlsv1_server *conn, u8 ct,
69 				   const u8 *buf, size_t *len);
70 
71 #endif /* TLSV1_SERVER_I_H */
72