1 /*
2  * TLS v1.0/v1.1/v1.2 client (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_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 		     const u8 *context, size_t context_len,
23 		     int server_random_first, u8 *out, size_t out_len);
24 u8 * tlsv1_client_handshake(struct tlsv1_client *conn,
25 			    const u8 *in_data, size_t in_len,
26 			    size_t *out_len, u8 **appl_data,
27 			    size_t *appl_data_len, int *need_more_data);
28 int tlsv1_client_encrypt(struct tlsv1_client *conn,
29 			 const u8 *in_data, size_t in_len,
30 			 u8 *out_data, size_t out_len);
31 struct wpabuf * tlsv1_client_decrypt(struct tlsv1_client *conn,
32 				     const u8 *in_data, size_t in_len,
33 				     int *need_more_data);
34 int tlsv1_client_get_cipher(struct tlsv1_client *conn, char *buf,
35 			    size_t buflen);
36 int tlsv1_client_shutdown(struct tlsv1_client *conn);
37 int tlsv1_client_resumed(struct tlsv1_client *conn);
38 int tlsv1_client_hello_ext(struct tlsv1_client *conn, int ext_type,
39 			   const u8 *data, size_t data_len);
40 int tlsv1_client_get_random(struct tlsv1_client *conn, struct tls_random *data);
41 int tlsv1_client_get_keyblock_size(struct tlsv1_client *conn);
42 int tlsv1_client_set_cipher_list(struct tlsv1_client *conn, u8 *ciphers);
43 int tlsv1_client_set_cred(struct tlsv1_client *conn,
44 			  struct tlsv1_credentials *cred);
45 void tlsv1_client_set_flags(struct tlsv1_client *conn, unsigned int flags);
46 
47 typedef int (*tlsv1_client_session_ticket_cb)
48 (void *ctx, const u8 *ticket, size_t len, const u8 *client_random,
49  const u8 *server_random, u8 *master_secret);
50 
51 void tlsv1_client_set_session_ticket_cb(struct tlsv1_client *conn,
52 					tlsv1_client_session_ticket_cb cb,
53 					void *ctx);
54 
55 void tlsv1_client_set_cb(struct tlsv1_client *conn,
56 			 void (*event_cb)(void *ctx, enum tls_event ev,
57 					  union tls_event_data *data),
58 			 void *cb_ctx,
59 			 int cert_in_cb);
60 int tlsv1_client_get_version(struct tlsv1_client *conn, char *buf,
61 			     size_t buflen);
62 
63 #endif /* TLSV1_CLIENT_H */
64