1189251Ssam/*
2252726Srpaulo * TLS v1.0/v1.1/v1.2 client (RFC 2246, RFC 4346, RFC 5246)
3252726Srpaulo * Copyright (c) 2006-2011, Jouni Malinen <j@w1.fi>
4189251Ssam *
5252726Srpaulo * This software may be distributed under the terms of the BSD license.
6252726Srpaulo * See README for more details.
7189251Ssam */
8189251Ssam
9189251Ssam#ifndef TLSV1_CLIENT_H
10189251Ssam#define TLSV1_CLIENT_H
11189251Ssam
12189251Ssam#include "tlsv1_cred.h"
13189251Ssam
14189251Ssamstruct tlsv1_client;
15189251Ssam
16189251Ssamint tlsv1_client_global_init(void);
17189251Ssamvoid tlsv1_client_global_deinit(void);
18189251Ssamstruct tlsv1_client * tlsv1_client_init(void);
19189251Ssamvoid tlsv1_client_deinit(struct tlsv1_client *conn);
20189251Ssamint tlsv1_client_established(struct tlsv1_client *conn);
21189251Ssamint tlsv1_client_prf(struct tlsv1_client *conn, const char *label,
22189251Ssam		     int server_random_first, u8 *out, size_t out_len);
23189251Ssamu8 * tlsv1_client_handshake(struct tlsv1_client *conn,
24189251Ssam			    const u8 *in_data, size_t in_len,
25189251Ssam			    size_t *out_len, u8 **appl_data,
26252726Srpaulo			    size_t *appl_data_len, int *need_more_data);
27189251Ssamint tlsv1_client_encrypt(struct tlsv1_client *conn,
28189251Ssam			 const u8 *in_data, size_t in_len,
29189251Ssam			 u8 *out_data, size_t out_len);
30252726Srpaulostruct wpabuf * tlsv1_client_decrypt(struct tlsv1_client *conn,
31252726Srpaulo				     const u8 *in_data, size_t in_len,
32252726Srpaulo				     int *need_more_data);
33189251Ssamint tlsv1_client_get_cipher(struct tlsv1_client *conn, char *buf,
34189251Ssam			    size_t buflen);
35189251Ssamint tlsv1_client_shutdown(struct tlsv1_client *conn);
36189251Ssamint tlsv1_client_resumed(struct tlsv1_client *conn);
37189251Ssamint tlsv1_client_hello_ext(struct tlsv1_client *conn, int ext_type,
38189251Ssam			   const u8 *data, size_t data_len);
39189251Ssamint tlsv1_client_get_keys(struct tlsv1_client *conn, struct tls_keys *keys);
40189251Ssamint tlsv1_client_get_keyblock_size(struct tlsv1_client *conn);
41189251Ssamint tlsv1_client_set_cipher_list(struct tlsv1_client *conn, u8 *ciphers);
42189251Ssamint tlsv1_client_set_cred(struct tlsv1_client *conn,
43189251Ssam			  struct tlsv1_credentials *cred);
44252726Srpaulovoid tlsv1_client_set_time_checks(struct tlsv1_client *conn, int enabled);
45189251Ssam
46189251Ssamtypedef int (*tlsv1_client_session_ticket_cb)
47189251Ssam(void *ctx, const u8 *ticket, size_t len, const u8 *client_random,
48189251Ssam const u8 *server_random, u8 *master_secret);
49189251Ssam
50189251Ssamvoid tlsv1_client_set_session_ticket_cb(struct tlsv1_client *conn,
51189251Ssam					tlsv1_client_session_ticket_cb cb,
52189251Ssam					void *ctx);
53189251Ssam
54189251Ssam#endif /* TLSV1_CLIENT_H */
55