Libu2f-emu
0.0.0
Universal 2nd Factor (U2F) Emulation C Library
|
#include <stdbool.h>
#include <stdint.h>
#include <openssl/ec.h>
#include <openssl/x509.h>
Go to the source code of this file.
Data Structures | |
struct | crypto_core |
Crypto core of the U2F device. More... | |
Macros | |
#define | CRYPTO_CERT_FILENAME "certificate.pem" |
#define | CRYPTO_PRIVKEY_FILENAME "private-key.pem" |
#define | CRYPTO_ENTROPY_FILENAME "entropy" |
Functions | |
EC_KEY * | crypto_ec_bytes_to_key (const unsigned char *buffer, long size) |
Get the ec key from ec key bytes. More... | |
size_t | crypto_aes_decrypt (struct crypto_core *core, const unsigned char *data, int size, unsigned char **buffer) |
Decrypt data using AES. More... | |
size_t | crypto_aes_encrypt (struct crypto_core *core, const unsigned char *data, int data_len, unsigned char **buffer) |
Encrypt data using AES. More... | |
int | crypto_ec_key_to_bytes (EC_KEY *key, unsigned char **buffer) |
Get the ec key bytes. More... | |
unsigned int | crypto_ec_sign_with_key (EC_KEY *key, const unsigned char *digest, int digest_len, unsigned char **signature) |
Sign a digest with a specific key. More... | |
unsigned int | crypto_ec_sign (struct crypto_core *core, const unsigned char *digest, int digest_len, unsigned char **signature) |
Sign a digest. More... | |
size_t | crypto_hash (const void *data, size_t data_len, unsigned char **hash) |
Hash data using sha256. More... | |
size_t | crypto_ec_pubkey_to_bytes (const EC_KEY *key, unsigned char **buffer) |
Get the ec key bytes. More... | |
int | crypto_x509_get_bytes (struct crypto_core *core, unsigned char **buffer) |
Get the x509 certificate bytes. More... | |
EC_KEY * | crypto_ec_pubkey_from_priv (EC_KEY *privkey) |
Get the ec public key from its private key. More... | |
EC_KEY * | crypto_ec_generate_key (void) |
Generate an ec pair key. More... | |
bool | crypto_new_from_dir (const char *dirpath, struct crypto_core **core_ref) |
Setup a crypto core from a dir. More... | |
bool | crypto_new_ephemeral (struct crypto_core **core_ref) |
Instantiate a new ephemeral crypto core. More... | |
bool | crypto_new (const char *certificate, const char *private_key, const uint8_t entropy[48], struct crypto_core **core_ref) |
Instantiate a new crypto core. More... | |
void | crypto_free (struct crypto_core *core) |
Release the memory allocated by the crypto_core. More... | |
#define CRYPTO_CERT_FILENAME "certificate.pem" |
#define CRYPTO_ENTROPY_FILENAME "entropy" |
#define CRYPTO_PRIVKEY_FILENAME "private-key.pem" |
size_t crypto_aes_decrypt | ( | struct crypto_core * | core, |
const unsigned char * | data, | ||
int | size, | ||
unsigned char ** | buffer | ||
) |
Decrypt data using AES.
core | The crypto core. |
data | The data to decrypt. |
size | The data size. |
buffer | The resulting buffer where clear data is put. |
size_t crypto_aes_encrypt | ( | struct crypto_core * | core, |
const unsigned char * | data, | ||
int | data_len, | ||
unsigned char ** | buffer | ||
) |
Encrypt data using AES.
core | The crypto core. |
data | The data to encrypt. |
data_len | The data size. |
buffer | The resulting buffer where cipher data is put. |
EC_KEY* crypto_ec_bytes_to_key | ( | const unsigned char * | buffer, |
long | size | ||
) |
Get the ec key from ec key bytes.
buffer | The buffer containing the ec key bytes. |
size | The size of the buffer. |
EC_KEY* crypto_ec_generate_key | ( | void | ) |
Generate an ec pair key.
int crypto_ec_key_to_bytes | ( | EC_KEY * | key, |
unsigned char ** | buffer | ||
) |
Get the ec key bytes.
key | The ec key. |
buffer | The buffer use to put the bytes |
EC_KEY* crypto_ec_pubkey_from_priv | ( | EC_KEY * | privkey | ) |
Get the ec public key from its private key.
privkey | the ec privkey. |
size_t crypto_ec_pubkey_to_bytes | ( | const EC_KEY * | key, |
unsigned char ** | buffer | ||
) |
Get the ec key bytes.
key | The ec key. |
buffer | The buffer use to put the bytes. |
unsigned int crypto_ec_sign | ( | struct crypto_core * | core, |
const unsigned char * | digest, | ||
int | digest_len, | ||
unsigned char ** | signature | ||
) |
Sign a digest.
core | The crypto core. |
digest | The digest. |
digest_len | The digest length? |
signature | The ref buffer to put the signature. |
unsigned int crypto_ec_sign_with_key | ( | EC_KEY * | key, |
const unsigned char * | digest, | ||
int | digest_len, | ||
unsigned char ** | signature | ||
) |
Sign a digest with a specific key.
key | The ec key. |
digest | The digest. |
digest_len | The digest len. |
signature | The ref buffer to put the signature. |
void crypto_free | ( | struct crypto_core * | core | ) |
Release the memory allocated by the crypto_core.
core | The crypto core to release. |
size_t crypto_hash | ( | const void * | data, |
size_t | data_len, | ||
unsigned char ** | hash | ||
) |
Hash data using sha256.
data | The data. |
data_len | The data length. |
hash | The ref buffer to put the hash. |
bool crypto_new | ( | const char * | certificate, |
const char * | private_key, | ||
const uint8_t | entropy[48], | ||
struct crypto_core ** | core_ref | ||
) |
Instantiate a new crypto core.
certificate | PEM ec certificate. |
private_key | PEM ec Private key of the certificate. |
entropy | Random bits used in encryption. |
core_ref | The crypto core reference. |
bool crypto_new_ephemeral | ( | struct crypto_core ** | core_ref | ) |
Instantiate a new ephemeral crypto core.
core_ref | The crypto core reference. |
bool crypto_new_from_dir | ( | const char * | dirpath, |
struct crypto_core ** | core_ref | ||
) |
Setup a crypto core from a dir.
dirpath | The path of the setup directory. |
core_ref | The crypto core to setup. |
int crypto_x509_get_bytes | ( | struct crypto_core * | core, |
unsigned char ** | buffer | ||
) |
Get the x509 certificate bytes.
core | The crypto core. |
buffer | The buffer to put the bytes. |