1 /* 2 * TLSv1 server - internal structures 3 * Copyright (c) 2006-2007, Jouni Malinen <j@w1.fi> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License version 2 as 7 * published by the Free Software Foundation. 8 * 9 * Alternatively, this software may be distributed under the terms of BSD 10 * license. 11 * 12 * See README and COPYING for more details. 13 */ 14 15 #ifndef TLSV1_SERVER_I_H 16 #define TLSV1_SERVER_I_H 17 18 struct tlsv1_server { 19 enum { 20 CLIENT_HELLO, SERVER_HELLO, SERVER_CERTIFICATE, 21 SERVER_KEY_EXCHANGE, SERVER_CERTIFICATE_REQUEST, 22 SERVER_HELLO_DONE, CLIENT_CERTIFICATE, CLIENT_KEY_EXCHANGE, 23 CERTIFICATE_VERIFY, CHANGE_CIPHER_SPEC, CLIENT_FINISHED, 24 SERVER_CHANGE_CIPHER_SPEC, SERVER_FINISHED, 25 ESTABLISHED, FAILED 26 } state; 27 28 struct tlsv1_record_layer rl; 29 30 u8 session_id[TLS_SESSION_ID_MAX_LEN]; 31 size_t session_id_len; 32 u8 client_random[TLS_RANDOM_LEN]; 33 u8 server_random[TLS_RANDOM_LEN]; 34 u8 master_secret[TLS_MASTER_SECRET_LEN]; 35 36 u8 alert_level; 37 u8 alert_description; 38 39 struct crypto_public_key *client_rsa_key; 40 41 struct tls_verify_hash verify; 42 43 #define MAX_CIPHER_COUNT 30 44 u16 cipher_suites[MAX_CIPHER_COUNT]; 45 size_t num_cipher_suites; 46 47 u16 cipher_suite; 48 49 struct tlsv1_credentials *cred; 50 51 int verify_peer; 52 u16 client_version; 53 54 u8 *session_ticket; 55 size_t session_ticket_len; 56 57 tlsv1_server_session_ticket_cb session_ticket_cb; 58 void *session_ticket_cb_ctx; 59 60 int use_session_ticket; 61 62 u8 *dh_secret; 63 size_t dh_secret_len; 64 }; 65 66 67 void tlsv1_server_alert(struct tlsv1_server *conn, u8 level, u8 description); 68 int tlsv1_server_derive_keys(struct tlsv1_server *conn, 69 const u8 *pre_master_secret, 70 size_t pre_master_secret_len); 71 u8 * tlsv1_server_handshake_write(struct tlsv1_server *conn, size_t *out_len); 72 u8 * tlsv1_server_send_alert(struct tlsv1_server *conn, u8 level, 73 u8 description, size_t *out_len); 74 int tlsv1_server_process_handshake(struct tlsv1_server *conn, u8 ct, 75 const u8 *buf, size_t *len); 76 77 #endif /* TLSV1_SERVER_I_H */ 78