wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
tlsv1_record.c File Reference

TLSv1 Record Protocol. More...

#include "includes.h"
#include "common.h"
#include "crypto/md5.h"
#include "crypto/sha1.h"
#include "crypto/sha256.h"
#include "tlsv1_common.h"
#include "tlsv1_record.h"

Functions

int tlsv1_record_set_cipher_suite (struct tlsv1_record_layer *rl, u16 cipher_suite)
 TLS record layer: Set cipher suite. More...
 
int tlsv1_record_change_write_cipher (struct tlsv1_record_layer *rl)
 TLS record layer: Change write cipher. More...
 
int tlsv1_record_change_read_cipher (struct tlsv1_record_layer *rl)
 TLS record layer: Change read cipher. More...
 
int tlsv1_record_send (struct tlsv1_record_layer *rl, u8 content_type, u8 *buf, size_t buf_size, const u8 *payload, size_t payload_len, size_t *out_len)
 TLS record layer: Send a message. More...
 
int tlsv1_record_receive (struct tlsv1_record_layer *rl, const u8 *in_data, size_t in_len, u8 *out_data, size_t *out_len, u8 *alert)
 TLS record layer: Process a received message. More...
 

Detailed Description

TLSv1 Record Protocol.

Function Documentation

int tlsv1_record_change_read_cipher ( struct tlsv1_record_layer rl)

TLS record layer: Change read cipher.

Parameters
rlPointer to TLS record layer data
Returns
0 on success (cipher changed), -1 on failure

This function changes TLS record layer to use the new cipher suite configured with tlsv1_record_set_cipher_suite() for reading.

int tlsv1_record_change_write_cipher ( struct tlsv1_record_layer rl)

TLS record layer: Change write cipher.

Parameters
rlPointer to TLS record layer data
Returns
0 on success (cipher changed), -1 on failure

This function changes TLS record layer to use the new cipher suite configured with tlsv1_record_set_cipher_suite() for writing.

int tlsv1_record_receive ( struct tlsv1_record_layer rl,
const u8 *  in_data,
size_t  in_len,
u8 *  out_data,
size_t *  out_len,
u8 *  alert 
)

TLS record layer: Process a received message.

Parameters
rlPointer to TLS record layer data
in_dataReceived data
in_lenLength of the received data
out_dataBuffer for output data (must be at least as long as in_data)
out_lenSet to maximum out_data length by caller; used to return the length of the used data
alertBuffer for returning an alert value on failure
Returns
Number of bytes used from in_data on success, 0 if record was not complete (more data needed), or -1 on failure

This function decrypts the received message, verifies HMAC and TLS record layer header.

int tlsv1_record_send ( struct tlsv1_record_layer rl,
u8  content_type,
u8 *  buf,
size_t  buf_size,
const u8 *  payload,
size_t  payload_len,
size_t *  out_len 
)

TLS record layer: Send a message.

Parameters
rlPointer to TLS record layer data
content_typeContent type (TLS_CONTENT_TYPE_*)
bufBuffer for the generated TLS message (needs to have extra space for header, IV (TLS v1.1), and HMAC)
buf_sizeMaximum buf size
payloadPayload to be sent
payload_lenLength of the payload
out_lenBuffer for returning the used buf length
Returns
0 on success, -1 on failure

This function fills in the TLS record layer header, adds HMAC, and encrypts the data using the current write cipher.

int tlsv1_record_set_cipher_suite ( struct tlsv1_record_layer rl,
u16  cipher_suite 
)

TLS record layer: Set cipher suite.

Parameters
rlPointer to TLS record layer data
cipher_suiteNew cipher suite
Returns
0 on success, -1 on failure

This function is used to prepare TLS record layer for cipher suite change. tlsv1_record_change_write_cipher() and tlsv1_record_change_read_cipher() functions can then be used to change the currently used ciphers.