From ccc2836fa8b3fb17e7e077996a58c7e0c99f702b Mon Sep 17 00:00:00 2001 From: Lucas Gabriel Vuotto Date: Fri, 7 Jun 2024 18:40:14 +0000 Subject: [PATCH] Introduce params structs This will allow for greater flexibility in the future and a big refactor in ChaCha20-Poly1305. --- lilcrypto.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/lilcrypto.h b/lilcrypto.h index cf7710d..a4511eb 100644 --- a/lilcrypto.h +++ b/lilcrypto.h @@ -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. */