18d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/* 28d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * TLSv1 server - internal structures 38d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Copyright (c) 2006-2007, Jouni Malinen <j@w1.fi> 48d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * 5c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * This software may be distributed under the terms of the BSD license. 6c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * See README for more details. 78d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */ 88d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 98d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifndef TLSV1_SERVER_I_H 108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#define TLSV1_SERVER_I_H 118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstruct tlsv1_server { 138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt enum { 148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt CLIENT_HELLO, SERVER_HELLO, SERVER_CERTIFICATE, 158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt SERVER_KEY_EXCHANGE, SERVER_CERTIFICATE_REQUEST, 168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt SERVER_HELLO_DONE, CLIENT_CERTIFICATE, CLIENT_KEY_EXCHANGE, 178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt CERTIFICATE_VERIFY, CHANGE_CIPHER_SPEC, CLIENT_FINISHED, 188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt SERVER_CHANGE_CIPHER_SPEC, SERVER_FINISHED, 198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt ESTABLISHED, FAILED 208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } state; 218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct tlsv1_record_layer rl; 238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 session_id[TLS_SESSION_ID_MAX_LEN]; 258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt size_t session_id_len; 268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 client_random[TLS_RANDOM_LEN]; 278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 server_random[TLS_RANDOM_LEN]; 288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 master_secret[TLS_MASTER_SECRET_LEN]; 298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 alert_level; 318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 alert_description; 328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct crypto_public_key *client_rsa_key; 348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct tls_verify_hash verify; 368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#define MAX_CIPHER_COUNT 30 388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u16 cipher_suites[MAX_CIPHER_COUNT]; 398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt size_t num_cipher_suites; 408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u16 cipher_suite; 428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct tlsv1_credentials *cred; 448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt int verify_peer; 468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u16 client_version; 478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 *session_ticket; 498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt size_t session_ticket_len; 508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tlsv1_server_session_ticket_cb session_ticket_cb; 528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt void *session_ticket_cb_ctx; 538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 54818ea489ef32dcdc7c098d8a336d6e1dd8996112Dmitry Shmidt void (*log_cb)(void *ctx, const char *msg); 55818ea489ef32dcdc7c098d8a336d6e1dd8996112Dmitry Shmidt void *log_cb_ctx; 56818ea489ef32dcdc7c098d8a336d6e1dd8996112Dmitry Shmidt 578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt int use_session_ticket; 58d97138ded63ac5388da3a2b63dea563c8b44c8ecDmitry Shmidt unsigned int status_request:1; 59d97138ded63ac5388da3a2b63dea563c8b44c8ecDmitry Shmidt unsigned int status_request_v2:1; 60d97138ded63ac5388da3a2b63dea563c8b44c8ecDmitry Shmidt unsigned int status_request_multi:1; 618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 *dh_secret; 638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt size_t dh_secret_len; 64818ea489ef32dcdc7c098d8a336d6e1dd8996112Dmitry Shmidt 65818ea489ef32dcdc7c098d8a336d6e1dd8996112Dmitry Shmidt#ifdef CONFIG_TESTING_OPTIONS 66818ea489ef32dcdc7c098d8a336d6e1dd8996112Dmitry Shmidt u32 test_flags; 67818ea489ef32dcdc7c098d8a336d6e1dd8996112Dmitry Shmidt int test_failure_reported; 68818ea489ef32dcdc7c098d8a336d6e1dd8996112Dmitry Shmidt#endif /* CONFIG_TESTING_OPTIONS */ 698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}; 708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 72818ea489ef32dcdc7c098d8a336d6e1dd8996112Dmitry Shmidtvoid tlsv1_server_log(struct tlsv1_server *conn, const char *fmt, ...) 73818ea489ef32dcdc7c098d8a336d6e1dd8996112Dmitry ShmidtPRINTF_FORMAT(2, 3); 74818ea489ef32dcdc7c098d8a336d6e1dd8996112Dmitry Shmidt 758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid tlsv1_server_alert(struct tlsv1_server *conn, u8 level, u8 description); 768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint tlsv1_server_derive_keys(struct tlsv1_server *conn, 778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *pre_master_secret, 788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt size_t pre_master_secret_len); 798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtu8 * tlsv1_server_handshake_write(struct tlsv1_server *conn, size_t *out_len); 808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtu8 * tlsv1_server_send_alert(struct tlsv1_server *conn, u8 level, 818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 description, size_t *out_len); 828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint tlsv1_server_process_handshake(struct tlsv1_server *conn, u8 ct, 838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *buf, size_t *len); 84b36ed7cd946148d829f311de8fe53ea3ffaaffe3Dmitry Shmidtvoid tlsv1_server_get_dh_p(struct tlsv1_server *conn, const u8 **dh_p, 85b36ed7cd946148d829f311de8fe53ea3ffaaffe3Dmitry Shmidt size_t *dh_p_len); 868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* TLSV1_SERVER_I_H */ 88