From e92a7164e3547a6324e161e4704fabeb6d8c5e44 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Fri, 18 Nov 2022 13:51:32 +0100 Subject: [PATCH] sys/hash/pbkdf2: Accept passwd as `void *` instead of `uint8_t *` Having to cast a password provided as `const char *` to `const uint8_t *` is a needless pain in the ass when using the API. Hence, fix it by accepting passwords and salts as `const void *` instead. --- sys/hashes/pbkdf2.c | 4 ++-- sys/include/hashes/pbkdf2.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/hashes/pbkdf2.c b/sys/hashes/pbkdf2.c index 4e89f391be..ab580a0005 100644 --- a/sys/hashes/pbkdf2.c +++ b/sys/hashes/pbkdf2.c @@ -43,8 +43,8 @@ static void inplace_xor_digests(uint8_t *d1, const uint8_t *d2) } } -void pbkdf2_sha256(const uint8_t *password, size_t password_len, - const uint8_t *salt, size_t salt_len, +void pbkdf2_sha256(const void *password, size_t password_len, + const void *salt, size_t salt_len, int iterations, uint8_t *output) { diff --git a/sys/include/hashes/pbkdf2.h b/sys/include/hashes/pbkdf2.h index 11483ff2ab..8e8541c72c 100644 --- a/sys/include/hashes/pbkdf2.h +++ b/sys/include/hashes/pbkdf2.h @@ -47,8 +47,8 @@ extern "C" { * recommended 10000 * @param[out] output array of size PBKDF2_KEY_SIZE */ -void pbkdf2_sha256(const uint8_t *password, size_t password_len, - const uint8_t *salt, size_t salt_len, +void pbkdf2_sha256(const void *password, size_t password_len, + const void *salt, size_t salt_len, int iterations, uint8_t *output);