mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
e92a7164e3
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.
60 lines
1.5 KiB
C
60 lines
1.5 KiB
C
/*
|
||
* 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.
|
||
* NIST’s 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 */
|