1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/include/hashes/pbkdf2.h
Marian Buschsieweke e92a7164e3
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.
2022-11-18 13:51:32 +01:00

60 lines
1.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright (C) 2019 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup sys_hashes_pbkdf2 PBKDF2
* @ingroup sys_hashes
* @brief PBKDF2 key derivation implementation.
* @{
*
* @file
* @brief PBKDF2 key derivation implementation.
*
* @author Juan I Carrano <j.carrano@fu-berlin.de>
*
* @}
*/
#ifndef HASHES_PBKDF2_H
#define HASHES_PBKDF2_H
#include "hashes/sha256.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief PBKDF2 key size length
*
* @note Currently only one derived key length is supported (32)
*/
#define PBKDF2_KEY_SIZE SHA256_DIGEST_LENGTH
/**
* @brief Create a key from a password and hash using PBKDF2.
*
* @param[in] password password pointer
* @param[in] password_len length of password
* @param[in] salt salt pointer
* @param[in] salt_len salt length, recommended 64bit
* @param[in] iterations number of rounds. Must be >1.
* NISTs detailed guide (Appendix A.2.2),
* recommended 10000
* @param[out] output array of size PBKDF2_KEY_SIZE
*/
void pbkdf2_sha256(const void *password, size_t password_len,
const void *salt, size_t salt_len,
int iterations,
uint8_t *output);
#ifdef __cplusplus
}
#endif
#endif /* HASHES_PBKDF2_H */