Add KDF interface and HKDF implementation

This commit is contained in:
Lucas Gabriel Vuotto 2024-06-18 14:30:06 +00:00
parent cef67c9f09
commit 5eb28b420d
9 changed files with 570 additions and 7 deletions

View file

@ -69,6 +69,8 @@ struct lc_cipher_impl;
struct lc_hash_ctx;
struct lc_hash_impl;
struct lc_kdf_impl;
/*
* Parameters.
*/
@ -111,6 +113,19 @@ struct lc_xchacha20_poly1305_params {
uint8_t nonce[LC_XCHACHA20_NONCELEN];
};
/* KDF. */
struct lc_hkdf_params {
struct lc_hash_ctx *hash;
struct lc_auth_ctx *hmac;
uint8_t *ikm;
size_t ikmlen;
uint8_t *info;
size_t infolen;
uint8_t *salt;
size_t saltlen;
};
/*
* Constant-time operations.
@ -194,6 +209,16 @@ const struct lc_aead_impl *lc_aead_impl_chacha20_poly1305(void);
const struct lc_aead_impl *lc_aead_impl_xchacha20_poly1305(void);
/*
* Key derivation functions.
*/
int lc_kdf(const struct lc_kdf_impl *, uint8_t *, size_t *, void *,
size_t);
const struct lc_kdf_impl *lc_kdf_impl_hkdf(void);
/*
* Utilities.
*/