Home | History | Annotate | Download | only in tls
      1 /*
      2  * TLSv1 server - internal structures
      3  * Copyright (c) 2006-2007, Jouni Malinen <j (at) 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 	unsigned int status_request:1;
     59 	unsigned int status_request_v2:1;
     60 	unsigned int status_request_multi:1;
     61 
     62 	u8 *dh_secret;
     63 	size_t dh_secret_len;
     64 
     65 #ifdef CONFIG_TESTING_OPTIONS
     66 	u32 test_flags;
     67 	int test_failure_reported;
     68 #endif /* CONFIG_TESTING_OPTIONS */
     69 };
     70 
     71 
     72 void tlsv1_server_log(struct tlsv1_server *conn, const char *fmt, ...)
     73 PRINTF_FORMAT(2, 3);
     74 
     75 void tlsv1_server_alert(struct tlsv1_server *conn, u8 level, u8 description);
     76 int tlsv1_server_derive_keys(struct tlsv1_server *conn,
     77 			     const u8 *pre_master_secret,
     78 			     size_t pre_master_secret_len);
     79 u8 * tlsv1_server_handshake_write(struct tlsv1_server *conn, size_t *out_len);
     80 u8 * tlsv1_server_send_alert(struct tlsv1_server *conn, u8 level,
     81 			     u8 description, size_t *out_len);
     82 int tlsv1_server_process_handshake(struct tlsv1_server *conn, u8 ct,
     83 				   const u8 *buf, size_t *len);
     84 void tlsv1_server_get_dh_p(struct tlsv1_server *conn, const u8 **dh_p,
     85 			   size_t *dh_p_len);
     86 
     87 #endif /* TLSV1_SERVER_I_H */
     88