16 #include <sys/types.h>
18 #define AES_BLOCK_SIZE 16
19 #define IV_SIZE AES_BLOCK_SIZE
21 #define AES_KEY_SIZE 32
22 #define MAX_KEY_ITERATIONS 1000
24 #define MAX_CERT_FIELD_SIZE 64
76 int crypto_buf2key(
const uint8_t *buf,
int buf_size,
const uint8_t *salt,
77 int salt_size, uint8_t *key,
int key_size);
89 ssize_t
crypto_encrypt(
const uint8_t *in,
int in_size,
const uint8_t *key,
90 const uint8_t *iv, uint8_t *out);
102 ssize_t
crypto_decrypt(uint8_t *in,
int in_size, uint8_t *key, uint8_t *iv,
136 size_t key_size,
char **cert);
149 size_t in_size, uint8_t **out);
ssize_t crypto_sign_data(uint8_t *key, size_t key_size, uint8_t *in, size_t in_size, uint8_t **out)
Signs a buffer with a private key string.
Definition: cryptou.c:545
int crypto_genkey(uint8_t *buf, int key_size)
Generate a random key.
Definition: cryptou.c:46
CRYPTO_KEY_TYPE
Definition: cryptou.h:35
@ CRYPTO_KEY_EC
Definition: cryptou.h:35
@ CRYPTO_KEY_RSA
Definition: cryptou.h:35
@ CRYPTO_KEY_NONE
Definition: cryptou.h:35
#define MAX_CERT_FIELD_SIZE
Definition: cryptou.h:24
int crypto_gensalt(uint8_t *buf, int salt_size)
Generate salt.
Definition: cryptou.c:42
int crypto_buf2key(const uint8_t *buf, int buf_size, const uint8_t *salt, int salt_size, uint8_t *key, int key_size)
Transforms a secret buf into a key.
Definition: cryptou.c:50
ssize_t crypto_encrypt(const uint8_t *in, int in_size, const uint8_t *key, const uint8_t *iv, uint8_t *out)
Encrypts a buffer with AES CBC 256.
Definition: cryptou.c:61
int crypto_geniv(uint8_t *buf, int iv_size)
Generate IV.
Definition: cryptou.c:40
int crypto_generate_cert_str(struct certificate_meta *meta, uint8_t *key, size_t key_size, char **cert)
Generates a pair of private key and certificate strings.
Definition: cryptou.c:440
int crypto_generate_privkey_str(enum CRYPTO_KEY_TYPE type, int bits, char **key)
Generate a private RSA key string.
Definition: cryptou.c:384
ssize_t crypto_decrypt(uint8_t *in, int in_size, uint8_t *key, uint8_t *iv, uint8_t *out)
Decrypts a buffer with AES CBC 256.
Definition: cryptou.c:116
int crypto_generate_pubkey_str(uint8_t *key, size_t key_size, char **pub)
Generates a public key string from a private key.
Definition: cryptou.c:412
bool meta
Definition: log.c:59