Libu2f-emu  0.0.0
Universal 2nd Factor (U2F) Emulation C Library
Macros | Functions
payload.c File Reference
#include <stdlib.h>
#include <string.h>
#include "payload.h"
Include dependency graph for payload.c:

Macros

#define FLOOR_NB(nb, m)   ((nb) & ~((m) - 1))
 
#define CEIL_NB(nb, m)   FLOOR_NB(nb + m - 1, m)
 

Functions

struct payloadpayload_new_with_capacity (uint16_t capacity)
 Allocate and initialize a new payload with a capacity. More...
 
struct payloadpayload_new (void)
 Allocate and initialize a new payload with a default capacity. More...
 
struct payloadpayload_new_from_data (const uint8_t *data, size_t size)
 Allocate and initialize a new payload from data. More...
 
bool payload_add_data (struct payload *payload, const uint8_t *data, size_t size)
 Add data to a payload. More...
 
void payload_free (struct payload *payload)
 Free a payload. More...
 

Macro Definition Documentation

#define CEIL_NB (   nb,
 
)    FLOOR_NB(nb + m - 1, m)
#define FLOOR_NB (   nb,
 
)    ((nb) & ~((m) - 1))

Function Documentation

bool payload_add_data ( struct payload payload,
const uint8_t *  data,
size_t  size 
)

Add data to a payload.

Parameters
payloadThe payload to add data to.
dataThe data to add.
sizeThe size of the data.
Returns
Success: true. Failure: false.
void payload_free ( struct payload payload)

Free a payload.

Parameters
payloadThe payload to free.
struct payload* payload_new ( void  )

Allocate and initialize a new payload with a default capacity.

Returns
Success: The new allocated and initialiazed payload. Failure: NULL.
struct payload* payload_new_from_data ( const uint8_t *  data,
size_t  size 
)

Allocate and initialize a new payload from data.

Parameters
dataThe data to put in the payload.
sizeThe size of the data.
Returns
Success: The new allocated and initialized payload. Failure: NULL.
struct payload* payload_new_with_capacity ( uint16_t  capacity)

Allocate and initialize a new payload with a capacity.

Parameters
capacityThe capacity of the payload.
Returns
Success: The new allocated and initialiazed payload. Failure: NULL.