wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Typedefs | Functions
tlsv1_client.h File Reference

TLS v1.0/v1.1/v1.2 client (RFC 2246, RFC 4346, RFC 5246) More...

#include "tlsv1_cred.h"

Go to the source code of this file.

Typedefs

typedef int(* tlsv1_client_session_ticket_cb )(void *ctx, const u8 *ticket, size_t len, const u8 *client_random, const u8 *server_random, u8 *master_secret)
 

Functions

int tlsv1_client_global_init (void)
 Initialize TLSv1 client. More...
 
void tlsv1_client_global_deinit (void)
 Deinitialize TLSv1 client. More...
 
struct tlsv1_clienttlsv1_client_init (void)
 Initialize TLSv1 client connection. More...
 
void tlsv1_client_deinit (struct tlsv1_client *conn)
 Deinitialize TLSv1 client connection. More...
 
int tlsv1_client_established (struct tlsv1_client *conn)
 Check whether connection has been established. More...
 
int tlsv1_client_prf (struct tlsv1_client *conn, const char *label, int server_random_first, u8 *out, size_t out_len)
 Use TLS-PRF to derive keying material. More...
 
u8 * tlsv1_client_handshake (struct tlsv1_client *conn, const u8 *in_data, size_t in_len, size_t *out_len, u8 **appl_data, size_t *appl_data_len, int *need_more_data)
 Process TLS handshake. More...
 
int tlsv1_client_encrypt (struct tlsv1_client *conn, const u8 *in_data, size_t in_len, u8 *out_data, size_t out_len)
 Encrypt data into TLS tunnel. More...
 
struct wpabuftlsv1_client_decrypt (struct tlsv1_client *conn, const u8 *in_data, size_t in_len, int *need_more_data)
 Decrypt data from TLS tunnel. More...
 
int tlsv1_client_get_cipher (struct tlsv1_client *conn, char *buf, size_t buflen)
 Get current cipher name. More...
 
int tlsv1_client_shutdown (struct tlsv1_client *conn)
 Shutdown TLS connection. More...
 
int tlsv1_client_resumed (struct tlsv1_client *conn)
 Was session resumption used. More...
 
int tlsv1_client_hello_ext (struct tlsv1_client *conn, int ext_type, const u8 *data, size_t data_len)
 Set TLS extension for ClientHello. More...
 
int tlsv1_client_get_random (struct tlsv1_client *conn, struct tls_random *data)
 Get random data from TLS connection. More...
 
int tlsv1_client_get_keyblock_size (struct tlsv1_client *conn)
 Get TLS key_block size. More...
 
int tlsv1_client_set_cipher_list (struct tlsv1_client *conn, u8 *ciphers)
 Configure acceptable cipher suites. More...
 
int tlsv1_client_set_cred (struct tlsv1_client *conn, struct tlsv1_credentials *cred)
 Set client credentials. More...
 
void tlsv1_client_set_time_checks (struct tlsv1_client *conn, int enabled)
 
void tlsv1_client_set_session_ticket_cb (struct tlsv1_client *conn, tlsv1_client_session_ticket_cb cb, void *ctx)
 

Detailed Description

TLS v1.0/v1.1/v1.2 client (RFC 2246, RFC 4346, RFC 5246)

Function Documentation

struct wpabuf* tlsv1_client_decrypt ( struct tlsv1_client conn,
const u8 *  in_data,
size_t  in_len,
int *  need_more_data 
)

Decrypt data from TLS tunnel.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
in_dataPointer to input buffer (encrypted TLS data)
in_lenInput buffer length
need_more_dataSet to 1 if more data would be needed to complete processing
Returns
Decrypted data or NULL on failure

This function is used after TLS handshake has been completed successfully to receive data from the encrypted tunnel.

void tlsv1_client_deinit ( struct tlsv1_client conn)

Deinitialize TLSv1 client connection.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
int tlsv1_client_encrypt ( struct tlsv1_client conn,
const u8 *  in_data,
size_t  in_len,
u8 *  out_data,
size_t  out_len 
)

Encrypt data into TLS tunnel.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
in_dataPointer to plaintext data to be encrypted
in_lenInput buffer length
out_dataPointer to output buffer (encrypted TLS data)
out_lenMaximum out_data length
Returns
Number of bytes written to out_data, -1 on failure

This function is used after TLS handshake has been completed successfully to send data in the encrypted tunnel.

int tlsv1_client_established ( struct tlsv1_client conn)

Check whether connection has been established.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
Returns
1 if connection is established, 0 if not
int tlsv1_client_get_cipher ( struct tlsv1_client conn,
char *  buf,
size_t  buflen 
)

Get current cipher name.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
bufBuffer for the cipher name
buflenbuf size
Returns
0 on success, -1 on failure

Get the name of the currently used cipher.

int tlsv1_client_get_keyblock_size ( struct tlsv1_client conn)

Get TLS key_block size.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
Returns
Size of the key_block for the negotiated cipher suite or -1 on failure
int tlsv1_client_get_random ( struct tlsv1_client conn,
struct tls_random keys 
)

Get random data from TLS connection.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
keysStructure of random data (filled on success)
Returns
0 on success, -1 on failure
void tlsv1_client_global_deinit ( void  )

Deinitialize TLSv1 client.

This function can be used to deinitialize the TLSv1 client that was initialized by calling tlsv1_client_global_init(). No TLSv1 client functions can be called after this before calling tlsv1_client_global_init() again.

int tlsv1_client_global_init ( void  )

Initialize TLSv1 client.

Returns
0 on success, -1 on failure

This function must be called before using any other TLSv1 client functions.

u8* tlsv1_client_handshake ( struct tlsv1_client conn,
const u8 *  in_data,
size_t  in_len,
size_t *  out_len,
u8 **  appl_data,
size_t *  appl_data_len,
int *  need_more_data 
)

Process TLS handshake.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
in_dataInput data from TLS peer
in_lenInput data length
out_lenLength of the output buffer.
appl_dataPointer to application data pointer, or NULL if dropped
appl_data_lenPointer to variable that is set to appl_data length
need_more_dataSet to 1 if more data would be needed to complete processing
Returns
Pointer to output data, NULL on failure
int tlsv1_client_hello_ext ( struct tlsv1_client conn,
int  ext_type,
const u8 *  data,
size_t  data_len 
)

Set TLS extension for ClientHello.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
ext_typeExtension type
dataExtension payload (NULL to remove extension)
data_lenExtension payload length
Returns
0 on success, -1 on failure
struct tlsv1_client* tlsv1_client_init ( void  )

Initialize TLSv1 client connection.

Returns
Pointer to TLSv1 client connection data or NULL on failure
int tlsv1_client_prf ( struct tlsv1_client conn,
const char *  label,
int  server_random_first,
u8 *  out,
size_t  out_len 
)

Use TLS-PRF to derive keying material.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
labelLabel (e.g., description of the key) for PRF
server_random_firstseed is 0 = client_random|server_random, 1 = server_random|client_random
outBuffer for output data from TLS-PRF
out_lenLength of the output buffer
Returns
0 on success, -1 on failure
int tlsv1_client_resumed ( struct tlsv1_client conn)

Was session resumption used.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
Returns
1 if current session used session resumption, 0 if not
int tlsv1_client_set_cipher_list ( struct tlsv1_client conn,
u8 *  ciphers 
)

Configure acceptable cipher suites.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
ciphersZero (TLS_CIPHER_NONE) terminated list of allowed ciphers (TLS_CIPHER_*).
Returns
0 on success, -1 on failure
int tlsv1_client_set_cred ( struct tlsv1_client conn,
struct tlsv1_credentials cred 
)

Set client credentials.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
credCredentials from tlsv1_cred_alloc()
Returns
0 on success, -1 on failure

On success, the client takes ownership of the credentials block and caller must not free it. On failure, caller is responsible for freeing the credential block.

int tlsv1_client_shutdown ( struct tlsv1_client conn)

Shutdown TLS connection.

Parameters
connTLSv1 client connection data from tlsv1_client_init()
Returns
0 on success, -1 on failure