7 #include <openssl/ec.h>
8 #include <openssl/x509.h>
11 #define CRYPTO_CERT_FILENAME "certificate.pem"
12 #define CRYPTO_PRIVKEY_FILENAME "private-key.pem"
13 #define CRYPTO_ENTROPY_FILENAME "entropy"
47 const unsigned char *
data,
int size,
48 unsigned char **buffer);
60 const unsigned char *
data,
int data_len,
61 unsigned char **buffer);
82 const unsigned char *digest,
84 unsigned char **signature);
96 const unsigned char *digest,
98 unsigned char **signature);
109 unsigned char **hash);
119 unsigned char **buffer);
129 unsigned char **buffer);
178 const char *private_key,
const uint8_t entropy[48],
size_t crypto_aes_decrypt(struct crypto_core *core, const unsigned char *data, int size, unsigned char **buffer)
Decrypt data using AES.
Definition: crypto.c:59
int crypto_ec_key_to_bytes(EC_KEY *key, unsigned char **buffer)
Get the ec key bytes.
Definition: crypto.c:188
EC_KEY * crypto_ec_generate_key(void)
Generate an ec pair key.
Definition: crypto.c:401
bool crypto_new_from_dir(const char *dirpath, struct crypto_core **core_ref)
Setup a crypto core from a dir.
Definition: crypto.c:652
void crypto_free(struct crypto_core *core)
Release the memory allocated by the crypto_core.
Definition: crypto.c:696
EC_KEY * crypto_ec_pubkey_from_priv(EC_KEY *privkey)
Get the ec public key from its private key.
Definition: crypto.c:554
EC_KEY * crypto_ec_bytes_to_key(const unsigned char *buffer, long size)
Get the ec key from ec key bytes.
Definition: crypto.c:48
EC_KEY * privkey
Definition: crypto.h:22
int crypto_x509_get_bytes(struct crypto_core *core, unsigned char **buffer)
Get the x509 certificate bytes.
Definition: crypto.c:309
uint8_t data[(64-7)]
Definition: packet.h:45
size_t crypto_hash(const void *data, size_t data_len, unsigned char **hash)
Hash data using sha256.
Definition: crypto.c:260
size_t crypto_aes_encrypt(struct crypto_core *core, const unsigned char *data, int data_len, unsigned char **buffer)
Encrypt data using AES.
Definition: crypto.c:125
uint8_t entropy[48]
Definition: crypto.h:24
X509 * cert
Definition: crypto.h:21
Crypto core of the U2F device.
Definition: crypto.h:19
unsigned int crypto_ec_sign(struct crypto_core *core, const unsigned char *digest, int digest_len, unsigned char **signature)
Sign a digest.
Definition: crypto.c:251
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.
Definition: crypto.c:578
bool crypto_new_ephemeral(struct crypto_core **core_ref)
Instantiate a new ephemeral crypto core.
Definition: crypto.c:614
EC_KEY * pubkey
Definition: crypto.h:23
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.
Definition: crypto.c:197
size_t crypto_ec_pubkey_to_bytes(const EC_KEY *key, unsigned char **buffer)
Get the ec key bytes.
Definition: crypto.c:291