Introduce params structs

This will allow for greater flexibility in the future and a big refactor
in ChaCha20-Poly1305.
This commit is contained in:
Lucas Gabriel Vuotto 2024-06-07 18:40:14 +00:00
parent 23735c2902
commit ccc2836fa8
1 changed files with 42 additions and 0 deletions

View File

@ -43,6 +43,48 @@
#define LC_XCHACHA20_NONCELEN 24
/*
* Arguments.
*/
/* Authentication */
struct lc_hmac_params {
size_t keylen;
const uint8_t *key;
};
struct lc_poly1305_params {
const uint8_t key[LC_POLY1305_KEYLEN];
};
/* Ciphers. */
struct lc_chacha20_params {
const uint8_t key[LC_CHACHA20_KEYLEN];
const uint8_t nonce[LC_CHACHA20_NONCELEN];
uint32_t counter;
};
struct lc_xchacha20_params {
const uint8_t key[LC_XCHACHA20_KEYLEN];
const uint8_t nonce[LC_XCHACHA20_NONCELEN];
uint32_t counter;
};
/* AEAD. */
struct lc_chacha20_poly1305_params {
const uint8_t key[LC_CHACHA20_KEYLEN];
const uint8_t nonce[LC_CHACHA20_NONCELEN];
};
struct lc_xchacha20_poly1305_params {
const uint8_t key[LC_XCHACHA20_KEYLEN];
const uint8_t nonce[LC_XCHACHA20_NONCELEN];
};
/*
* Constant-time operations.
*/