1 /* 2 * TLS v1.0/v1.1/v1.2 server (RFC 2246, RFC 4346, RFC 5246) 3 * Copyright (c) 2006-2019, 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_H 10 #define TLSV1_SERVER_H 11 12 #include "tlsv1_cred.h" 13 14 struct tlsv1_server; 15 16 int tlsv1_server_global_init(void); 17 void tlsv1_server_global_deinit(void); 18 struct tlsv1_server * tlsv1_server_init(struct tlsv1_credentials *cred); 19 void tlsv1_server_deinit(struct tlsv1_server *conn); 20 int tlsv1_server_established(struct tlsv1_server *conn); 21 int tlsv1_server_prf(struct tlsv1_server *conn, const char *label, 22 const u8 *context, size_t context_len, 23 int server_random_first, u8 *out, size_t out_len); 24 u8 * tlsv1_server_handshake(struct tlsv1_server *conn, 25 const u8 *in_data, size_t in_len, size_t *out_len); 26 int tlsv1_server_encrypt(struct tlsv1_server *conn, 27 const u8 *in_data, size_t in_len, 28 u8 *out_data, size_t out_len); 29 int tlsv1_server_decrypt(struct tlsv1_server *conn, 30 const u8 *in_data, size_t in_len, 31 u8 *out_data, size_t out_len); 32 int tlsv1_server_get_cipher(struct tlsv1_server *conn, char *buf, 33 size_t buflen); 34 int tlsv1_server_shutdown(struct tlsv1_server *conn); 35 int tlsv1_server_resumed(struct tlsv1_server *conn); 36 int tlsv1_server_get_random(struct tlsv1_server *conn, struct tls_random *data); 37 int tlsv1_server_get_keyblock_size(struct tlsv1_server *conn); 38 int tlsv1_server_set_cipher_list(struct tlsv1_server *conn, u8 *ciphers); 39 int tlsv1_server_set_verify(struct tlsv1_server *conn, int verify_peer); 40 41 typedef int (*tlsv1_server_session_ticket_cb) 42 (void *ctx, const u8 *ticket, size_t len, const u8 *client_random, 43 const u8 *server_random, u8 *master_secret); 44 45 void tlsv1_server_set_session_ticket_cb(struct tlsv1_server *conn, 46 tlsv1_server_session_ticket_cb cb, 47 void *ctx); 48 49 void tlsv1_server_set_log_cb(struct tlsv1_server *conn, 50 void (*cb)(void *ctx, const char *msg), void *ctx); 51 52 int tlsv1_server_get_failed(struct tlsv1_server *conn); 53 int tlsv1_server_get_read_alerts(struct tlsv1_server *conn); 54 int tlsv1_server_get_write_alerts(struct tlsv1_server *conn); 55 56 void tlsv1_server_set_test_flags(struct tlsv1_server *conn, u32 flags); 57 58 #endif /* TLSV1_SERVER_H */ 59