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

Macros

#define U2F_CHA_PARAM_SIZE   32
 
#define U2F_APP_PARAM_SIZE   32
 

Functions

struct registration_params __attribute__ ((__packed__))
 
static void register_response_reserved (struct payload *payload)
 Add reserved byte to the register response payload. More...
 
static void register_response_pubkey (struct payload *payload, const EC_KEY *pubkey)
 Add pubkey bytes to the register response. More...
 
static void register_response_key_handle (struct payload *payload, const uint8_t *key_handle_cipher, size_t key_handle_cipher_size)
 Add ciphered key handle to the register response payload. More...
 
static void register_reponse_x509 (struct payload *payload, const uint8_t *x509_buffer, size_t x509_buffer_size)
 Add x509 bytes to the register response payload. More...
 
static void register_response_signature (struct crypto_core *crypto_core, struct payload *payload, const uint8_t *key_handle_cipher, size_t key_handle_cipher_size, const EC_KEY *pubkey, const struct registration_params *params)
 Add signature to the register response. More...
 
static void register_response_sw (struct payload *payload, uint32_t status)
 Add status code to the authentification response payload. More...
 
static uint8_t * register_build_plain_key_handle (EC_KEY *privkey, const struct registration_params *params, size_t *size)
 Build the plain key handle. More...
 
static uint8_t * register_encrypt_key_handle (struct crypto_core *crypto_core, const uint8_t *key_handle, size_t key_handle_size, size_t *size)
 Encrypt the key handle. More...
 
struct payloadraw_register (u2f_emu_vdev *vdev, const uint8_t *apdu, size_t size)
 Handle registration request. More...
 

Variables

uint8_t challenge_param [32]
 
uint8_t application_param [32]
 

Macro Definition Documentation

#define U2F_APP_PARAM_SIZE   32
#define U2F_CHA_PARAM_SIZE   32

Function Documentation

struct registration_params __attribute__ ( (__packed__)  )
struct payload* raw_register ( u2f_emu_vdev vdev,
const uint8_t *  apdu,
size_t  size 
)

Handle registration request.

Parameters
vdevThe virtual device.
apduThe apdu data.
sizeThe apdu data size.
Returns
The response payload.
static uint8_t* register_build_plain_key_handle ( EC_KEY *  privkey,
const struct registration_params *  params,
size_t *  size 
)
static

Build the plain key handle.

Parameters
privkeyThe private key.
paramsThe register params.
sizeThe ref size of the plain key handle.
Returns
The plain key handle.
static uint8_t* register_encrypt_key_handle ( struct crypto_core crypto_core,
const uint8_t *  key_handle,
size_t  key_handle_size,
size_t *  size 
)
static

Encrypt the key handle.

Parameters
crypto_coreThe crypto core.
key_handleThe key handle.
key_handle_sizeThe key handle size.
sizeThe ref size of the ciphered key handle.
Returns
The ciphered key handle.
static void register_reponse_x509 ( struct payload payload,
const uint8_t *  x509_buffer,
size_t  x509_buffer_size 
)
static

Add x509 bytes to the register response payload.

Parameters
payloadThe response payload.
x509_bufferThe x509 buffer.
x509_buffer_sizeThe x509 buffer size.
static void register_response_key_handle ( struct payload payload,
const uint8_t *  key_handle_cipher,
size_t  key_handle_cipher_size 
)
static

Add ciphered key handle to the register response payload.

Parameters
payloadThe response payload.
key_handle_cipherThe ciphered key handle
key_handle_cipher_sizeThe ciphered key handle size
static void register_response_pubkey ( struct payload payload,
const EC_KEY *  pubkey 
)
static

Add pubkey bytes to the register response.

Parameters
payloadThe response payload.
pubkeyThe pubkey.
static void register_response_reserved ( struct payload payload)
static

Add reserved byte to the register response payload.

Parameters
payloadThe response payload.
static void register_response_signature ( struct crypto_core crypto_core,
struct payload payload,
const uint8_t *  key_handle_cipher,
size_t  key_handle_cipher_size,
const EC_KEY *  pubkey,
const struct registration_params *  params 
)
static

Add signature to the register response.

Parameters
crypto_coreThe crypto core.
payloadThe response payload.
key_handle_cipherThe ciphered key handle.
key_handle_cipher_sizeThe ciphered key handle size.
pubkeyThe pubkey.
paramsThe register params.
static void register_response_sw ( struct payload payload,
uint32_t  status 
)
static

Add status code to the authentification response payload.

Parameters
payloadThe response payload.
statusThe status code.

Variable Documentation

uint8_t application_param[32]

SHA-256 App Id

uint8_t challenge_param[32]

SHA-256 client data