mirror of
https://github.com/opnsense/src.git
synced 2026-02-18 18:20:26 -05:00
pkcs5v2: Add pkcs5v2_genkey_raw function
This is like pkcs5v2_genkey but takes a "passphrase" as a buffer and length rather than a NUL-terminated string. Reviwed by: pjd MFC after: 1 week Sponsored by: Amazon Differential Revision: https://reviews.freebsd.org/D46633 (cherry picked from commit 8ce291a335bc751e7a89691eebfb9f9da65b82ac)
This commit is contained in:
parent
0a8ff19896
commit
8d2d49bdb5
2 changed files with 14 additions and 2 deletions
|
|
@ -52,13 +52,22 @@ void
|
|||
pkcs5v2_genkey(uint8_t *key, unsigned keylen, const uint8_t *salt,
|
||||
size_t saltsize, const char *passphrase, u_int iterations)
|
||||
{
|
||||
|
||||
pkcs5v2_genkey_raw(key, keylen, salt, saltsize, passphrase,
|
||||
strlen(passphrase), iterations);
|
||||
}
|
||||
|
||||
void
|
||||
pkcs5v2_genkey_raw(uint8_t *key, unsigned keylen, const uint8_t *salt,
|
||||
size_t saltsize, const uint8_t *passphrase, size_t passlen,
|
||||
u_int iterations)
|
||||
{
|
||||
uint8_t md[SHA512_MDLEN], saltcount[saltsize + sizeof(uint32_t)];
|
||||
uint8_t *counter, *keyp;
|
||||
u_int i, bsize, passlen;
|
||||
u_int i, bsize;
|
||||
uint32_t count;
|
||||
struct hmac_ctx startpoint, ctx;
|
||||
|
||||
passlen = strlen(passphrase);
|
||||
bzero(key, keylen);
|
||||
bcopy(salt, saltcount, saltsize);
|
||||
counter = saltcount + saltsize;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@
|
|||
#define _PKCS5V2_H_
|
||||
void pkcs5v2_genkey(uint8_t *key, unsigned keylen, const uint8_t *salt,
|
||||
size_t saltsize, const char *passphrase, u_int iterations);
|
||||
void pkcs5v2_genkey_raw(uint8_t *key, unsigned keylen, const uint8_t *salt,
|
||||
size_t saltsize, const uint8_t *passphrase, size_t passlen,
|
||||
u_int iterations);
|
||||
#ifndef _KERNEL
|
||||
int pkcs5v2_calculate(int usecs);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue