tlsv1_client_i.h
Go to the documentation of this file.00001
00016 #ifndef TLSV1_CLIENT_I_H
00017 #define TLSV1_CLIENT_I_H
00018
00019 struct tlsv1_client {
00020 enum {
00021 CLIENT_HELLO, SERVER_HELLO, SERVER_CERTIFICATE,
00022 SERVER_KEY_EXCHANGE, SERVER_CERTIFICATE_REQUEST,
00023 SERVER_HELLO_DONE, CLIENT_KEY_EXCHANGE, CHANGE_CIPHER_SPEC,
00024 SERVER_CHANGE_CIPHER_SPEC, SERVER_FINISHED, ACK_FINISHED,
00025 ESTABLISHED, FAILED
00026 } state;
00027
00028 struct tlsv1_record_layer rl;
00029
00030 u8 session_id[TLS_SESSION_ID_MAX_LEN];
00031 size_t session_id_len;
00032 u8 client_random[TLS_RANDOM_LEN];
00033 u8 server_random[TLS_RANDOM_LEN];
00034 u8 master_secret[TLS_MASTER_SECRET_LEN];
00035
00036 u8 alert_level;
00037 u8 alert_description;
00038
00039 unsigned int certificate_requested:1;
00040 unsigned int session_resumed:1;
00041 unsigned int session_ticket_included:1;
00042 unsigned int use_session_ticket:1;
00043
00044 struct crypto_public_key *server_rsa_key;
00045
00046 struct tls_verify_hash verify;
00047
00048 #define MAX_CIPHER_COUNT 30
00049 u16 cipher_suites[MAX_CIPHER_COUNT];
00050 size_t num_cipher_suites;
00051
00052 u16 prev_cipher_suite;
00053
00054 u8 *client_hello_ext;
00055 size_t client_hello_ext_len;
00056
00057
00058 u8 *dh_p;
00059 size_t dh_p_len;
00060
00061 u8 *dh_g;
00062 size_t dh_g_len;
00063
00064 u8 *dh_ys;
00065 size_t dh_ys_len;
00066
00067 struct tlsv1_credentials *cred;
00068
00069 tlsv1_client_session_ticket_cb session_ticket_cb;
00070 void *session_ticket_cb_ctx;
00071 };
00072
00073
00074 void tls_alert(struct tlsv1_client *conn, u8 level, u8 description);
00075 void tlsv1_client_free_dh(struct tlsv1_client *conn);
00076 int tls_derive_pre_master_secret(u8 *pre_master_secret);
00077 int tls_derive_keys(struct tlsv1_client *conn,
00078 const u8 *pre_master_secret, size_t pre_master_secret_len);
00079 u8 * tls_send_client_hello(struct tlsv1_client *conn, size_t *out_len);
00080 u8 * tlsv1_client_send_alert(struct tlsv1_client *conn, u8 level,
00081 u8 description, size_t *out_len);
00082 u8 * tlsv1_client_handshake_write(struct tlsv1_client *conn, size_t *out_len,
00083 int no_appl_data);
00084 int tlsv1_client_process_handshake(struct tlsv1_client *conn, u8 ct,
00085 const u8 *buf, size_t *len,
00086 u8 **out_data, size_t *out_len);
00087
00088 #endif
00089