-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathfastpbkdf2.c
38 lines (33 loc) · 1.29 KB
/
fastpbkdf2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-License-Identifier: GPL-3.0-only
/*
* Copyright (c) 2023 Dengfeng Liu <liudf0716@gmail.com>
*/
#include <string.h>
#include <assert.h>
#include <openssl/evp.h>
#include <openssl/core_names.h>
#include "fastpbkdf2.h"
void fastpbkdf2_hmac_sha1(const uint8_t *pw, size_t npw,
const uint8_t *salt, size_t nsalt,
uint32_t iterations,
uint8_t *out, size_t nout) {
PKCS5_PBKDF2_HMAC((const char *)pw, npw,
salt, nsalt, iterations,
EVP_sha1(), nout, out);
}
void fastpbkdf2_hmac_sha256(const uint8_t *pw, size_t npw,
const uint8_t *salt, size_t nsalt,
uint32_t iterations,
uint8_t *out, size_t nout) {
PKCS5_PBKDF2_HMAC((const char *)pw, npw,
salt, nsalt, iterations,
EVP_sha256(), nout, out);
}
void fastpbkdf2_hmac_sha512(const uint8_t *pw, size_t npw,
const uint8_t *salt, size_t nsalt,
uint32_t iterations,
uint8_t *out, size_t nout) {
PKCS5_PBKDF2_HMAC((const char *)pw, npw,
salt, nsalt, iterations,
EVP_sha512(), nout, out);
}