1 /* 2 * TLS v1.0/v1.1/v1.2 client (RFC 2246, RFC 4346, RFC 5246) 3 * Copyright (c) 2006-2011, 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_CLIENT_H 10 #define TLSV1_CLIENT_H 11 12 #include "tlsv1_cred.h" 13 14 struct tlsv1_client; 15 16 int tlsv1_client_global_init(void); 17 void tlsv1_client_global_deinit(void); 18 struct tlsv1_client * tlsv1_client_init(void); 19 void tlsv1_client_deinit(struct tlsv1_client *conn); 20 int tlsv1_client_established(struct tlsv1_client *conn); 21 int tlsv1_client_prf(struct tlsv1_client *conn, const char *label, 22 int server_random_first, u8 *out, size_t out_len); 23 u8 * tlsv1_client_handshake(struct tlsv1_client *conn, 24 const u8 *in_data, size_t in_len, 25 size_t *out_len, u8 **appl_data, 26 size_t *appl_data_len, int *need_more_data); 27 int tlsv1_client_encrypt(struct tlsv1_client *conn, 28 const u8 *in_data, size_t in_len, 29 u8 *out_data, size_t out_len); 30 struct wpabuf * tlsv1_client_decrypt(struct tlsv1_client *conn, 31 const u8 *in_data, size_t in_len, 32 int *need_more_data); 33 int tlsv1_client_get_cipher(struct tlsv1_client *conn, char *buf, 34 size_t buflen); 35 int tlsv1_client_shutdown(struct tlsv1_client *conn); 36 int tlsv1_client_resumed(struct tlsv1_client *conn); 37 int tlsv1_client_hello_ext(struct tlsv1_client *conn, int ext_type, 38 const u8 *data, size_t data_len); 39 int tlsv1_client_get_random(struct tlsv1_client *conn, struct tls_random *data); 40 int tlsv1_client_get_keyblock_size(struct tlsv1_client *conn); 41 int tlsv1_client_set_cipher_list(struct tlsv1_client *conn, u8 *ciphers); 42 int tlsv1_client_set_cred(struct tlsv1_client *conn, 43 struct tlsv1_credentials *cred); 44 void tlsv1_client_set_flags(struct tlsv1_client *conn, unsigned int flags); 45 46 typedef int (*tlsv1_client_session_ticket_cb) 47 (void *ctx, const u8 *ticket, size_t len, const u8 *client_random, 48 const u8 *server_random, u8 *master_secret); 49 50 void tlsv1_client_set_session_ticket_cb(struct tlsv1_client *conn, 51 tlsv1_client_session_ticket_cb cb, 52 void *ctx); 53 54 void tlsv1_client_set_cb(struct tlsv1_client *conn, 55 void (*event_cb)(void *ctx, enum tls_event ev, 56 union tls_event_data *data), 57 void *cb_ctx, 58 int cert_in_cb); 59 int tlsv1_client_get_version(struct tlsv1_client *conn, char *buf, 60 size_t buflen); 61 62 #endif /* TLSV1_CLIENT_H */ 63