|
Packit |
141393 |
/*
|
|
Packit |
141393 |
* fast-pbkdf2 - Optimal PBKDF2-HMAC calculation
|
|
Packit |
141393 |
* Written in 2015 by Joseph Birr-Pixton <jpixton@gmail.com>
|
|
Packit |
141393 |
* Ported to cryptonite in 2017 by Nicolas Di Prima <nicolas@primetype.co.uk>
|
|
Packit |
141393 |
*
|
|
Packit |
141393 |
* To the extent possible under law, the author(s) have dedicated all
|
|
Packit |
141393 |
* copyright and related and neighboring rights to this software to the
|
|
Packit |
141393 |
* public domain worldwide. This software is distributed without any
|
|
Packit |
141393 |
* warranty.
|
|
Packit |
141393 |
*
|
|
Packit |
141393 |
* You should have received a copy of the CC0 Public Domain Dedication
|
|
Packit |
141393 |
* along with this software. If not, see
|
|
Packit |
141393 |
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
Packit |
141393 |
*/
|
|
Packit |
141393 |
|
|
Packit |
141393 |
#include <assert.h>
|
|
Packit |
141393 |
#include <string.h>
|
|
Packit |
141393 |
|
|
Packit |
141393 |
#include "cryptonite_pbkdf2.h"
|
|
Packit |
141393 |
#include "cryptonite_bitfn.h"
|
|
Packit |
141393 |
#include "cryptonite_align.h"
|
|
Packit |
141393 |
#include "cryptonite_sha1.h"
|
|
Packit |
141393 |
#include "cryptonite_sha256.h"
|
|
Packit |
141393 |
#include "cryptonite_sha512.h"
|
|
Packit |
141393 |
|
|
Packit |
141393 |
/* --- MSVC doesn't support C99 --- */
|
|
Packit |
141393 |
#ifdef _MSC_VER
|
|
Packit |
141393 |
#define restrict
|
|
Packit |
141393 |
#define _Pragma __pragma
|
|
Packit |
141393 |
#endif
|
|
Packit |
141393 |
|
|
Packit |
141393 |
/* --- Common useful things --- */
|
|
Packit |
141393 |
#define MIN(a, b) ((a) > (b)) ? (b) : (a)
|
|
Packit |
141393 |
|
|
Packit |
141393 |
/* Prepare block (of blocksz bytes) to contain md padding denoting a msg-size
|
|
Packit |
141393 |
* message (in bytes). block has a prefix of used bytes.
|
|
Packit |
141393 |
*
|
|
Packit |
141393 |
* Message length is expressed in 32 bits (so suitable for sha1, sha256, sha512). */
|
|
Packit |
141393 |
static inline void md_pad(uint8_t *block, size_t blocksz, size_t used, size_t msg)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
memset(block + used, 0, blocksz - used - 4);
|
|
Packit |
141393 |
block[used] = 0x80;
|
|
Packit |
141393 |
block += blocksz - 4;
|
|
Packit |
141393 |
store_be32(block, (uint32_t) (msg * 8));
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
/* Internal function/type names for hash-specific things. */
|
|
Packit |
141393 |
#define HMAC_CTX(_name) HMAC_ ## _name ## _ctx
|
|
Packit |
141393 |
#define HMAC_INIT(_name) HMAC_ ## _name ## _init
|
|
Packit |
141393 |
#define HMAC_UPDATE(_name) HMAC_ ## _name ## _update
|
|
Packit |
141393 |
#define HMAC_FINAL(_name) HMAC_ ## _name ## _final
|
|
Packit |
141393 |
|
|
Packit |
141393 |
#define PBKDF2_F(_name) pbkdf2_f_ ## _name
|
|
Packit |
141393 |
#define PBKDF2(_name) pbkdf2_ ## _name
|
|
Packit |
141393 |
|
|
Packit |
141393 |
/* This macro expands to decls for the whole implementation for a given
|
|
Packit |
141393 |
* hash function. Arguments are:
|
|
Packit |
141393 |
*
|
|
Packit |
141393 |
* _name like 'sha1', added to symbol names
|
|
Packit |
141393 |
* _blocksz block size, in bytes
|
|
Packit |
141393 |
* _hashsz digest output, in bytes
|
|
Packit |
141393 |
* _ctx hash context type
|
|
Packit |
141393 |
* _init hash context initialisation function
|
|
Packit |
141393 |
* args: (_ctx *c)
|
|
Packit |
141393 |
* _update hash context update function
|
|
Packit |
141393 |
* args: (_ctx *c, const void *data, size_t ndata)
|
|
Packit |
141393 |
* _final hash context finish function
|
|
Packit |
141393 |
* args: (void *out, _ctx *c)
|
|
Packit |
141393 |
* _xform hash context raw block update function
|
|
Packit |
141393 |
* args: (_ctx *c, const void *data)
|
|
Packit |
141393 |
* _xcpy hash context raw copy function (only need copy hash state)
|
|
Packit |
141393 |
* args: (_ctx * restrict out, const _ctx *restrict in)
|
|
Packit |
141393 |
* _xtract hash context state extraction
|
|
Packit |
141393 |
* args: args (_ctx *restrict c, uint8_t *restrict out)
|
|
Packit |
141393 |
* _xxor hash context xor function (only need xor hash state)
|
|
Packit |
141393 |
* args: (_ctx *restrict out, const _ctx *restrict in)
|
|
Packit |
141393 |
*
|
|
Packit |
141393 |
* The resulting function is named PBKDF2(_name).
|
|
Packit |
141393 |
*/
|
|
Packit |
141393 |
#define DECL_PBKDF2(_name, _blocksz, _hashsz, _ctx, \
|
|
Packit |
141393 |
_init, _update, _xform, _final, _xcpy, _xtract, _xxor) \
|
|
Packit |
141393 |
typedef struct { \
|
|
Packit |
141393 |
_ctx inner; \
|
|
Packit |
141393 |
_ctx outer; \
|
|
Packit |
141393 |
} HMAC_CTX(_name); \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
static inline void HMAC_INIT(_name)(HMAC_CTX(_name) *ctx, \
|
|
Packit |
141393 |
const uint8_t *key, size_t nkey) \
|
|
Packit |
141393 |
{ \
|
|
Packit |
141393 |
/* Prepare key: */ \
|
|
Packit |
141393 |
uint8_t k[_blocksz]; \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* Shorten long keys. */ \
|
|
Packit |
141393 |
if (nkey > _blocksz) \
|
|
Packit |
141393 |
{ \
|
|
Packit |
141393 |
_init(&ctx->inner); \
|
|
Packit |
141393 |
_update(&ctx->inner, key, nkey); \
|
|
Packit |
141393 |
_final(&ctx->inner, k); \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
key = k; \
|
|
Packit |
141393 |
nkey = _hashsz; \
|
|
Packit |
141393 |
} \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* Standard doesn't cover case where blocksz < hashsz. */ \
|
|
Packit |
141393 |
assert(nkey <= _blocksz); \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* Right zero-pad short keys. */ \
|
|
Packit |
141393 |
if (k != key) \
|
|
Packit |
141393 |
memcpy(k, key, nkey); \
|
|
Packit |
141393 |
if (_blocksz > nkey) \
|
|
Packit |
141393 |
memset(k + nkey, 0, _blocksz - nkey); \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* Start inner hash computation */ \
|
|
Packit |
141393 |
uint8_t blk_inner[_blocksz]; \
|
|
Packit |
141393 |
uint8_t blk_outer[_blocksz]; \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
for (size_t i = 0; i < _blocksz; i++) \
|
|
Packit |
141393 |
{ \
|
|
Packit |
141393 |
blk_inner[i] = 0x36 ^ k[i]; \
|
|
Packit |
141393 |
blk_outer[i] = 0x5c ^ k[i]; \
|
|
Packit |
141393 |
} \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
_init(&ctx->inner); \
|
|
Packit |
141393 |
_update(&ctx->inner, blk_inner, sizeof blk_inner); \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* And outer. */ \
|
|
Packit |
141393 |
_init(&ctx->outer); \
|
|
Packit |
141393 |
_update(&ctx->outer, blk_outer, sizeof blk_outer); \
|
|
Packit |
141393 |
} \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
static inline void HMAC_UPDATE(_name)(HMAC_CTX(_name) *ctx, \
|
|
Packit |
141393 |
const void *data, size_t ndata) \
|
|
Packit |
141393 |
{ \
|
|
Packit |
141393 |
_update(&ctx->inner, data, ndata); \
|
|
Packit |
141393 |
} \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
static inline void HMAC_FINAL(_name)(HMAC_CTX(_name) *ctx, \
|
|
Packit |
141393 |
uint8_t out[_hashsz]) \
|
|
Packit |
141393 |
{ \
|
|
Packit |
141393 |
_final(&ctx->inner, out); \
|
|
Packit |
141393 |
_update(&ctx->outer, out, _hashsz); \
|
|
Packit |
141393 |
_final(&ctx->outer, out); \
|
|
Packit |
141393 |
} \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* --- PBKDF2 --- */ \
|
|
Packit |
141393 |
static inline void PBKDF2_F(_name)(const HMAC_CTX(_name) *startctx, \
|
|
Packit |
141393 |
uint32_t counter, \
|
|
Packit |
141393 |
const uint8_t *salt, size_t nsalt, \
|
|
Packit |
141393 |
uint32_t iterations, \
|
|
Packit |
141393 |
uint8_t *out) \
|
|
Packit |
141393 |
{ \
|
|
Packit |
141393 |
uint8_t countbuf[4]; \
|
|
Packit |
141393 |
store_be32(countbuf, counter); \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* Prepare loop-invariant padding block. */ \
|
|
Packit |
141393 |
uint8_t Ublock[_blocksz]; \
|
|
Packit |
141393 |
md_pad(Ublock, _blocksz, _hashsz, _blocksz + _hashsz); \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* First iteration: \
|
|
Packit |
141393 |
* U_1 = PRF(P, S || INT_32_BE(i)) \
|
|
Packit |
141393 |
*/ \
|
|
Packit |
141393 |
HMAC_CTX(_name) ctx = *startctx; \
|
|
Packit |
141393 |
HMAC_UPDATE(_name)(&ctx, salt, nsalt); \
|
|
Packit |
141393 |
HMAC_UPDATE(_name)(&ctx, countbuf, sizeof countbuf); \
|
|
Packit |
141393 |
HMAC_FINAL(_name)(&ctx, Ublock); \
|
|
Packit |
141393 |
_ctx result = ctx.outer; \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* Subsequent iterations: \
|
|
Packit |
141393 |
* U_c = PRF(P, U_{c-1}) \
|
|
Packit |
141393 |
*/ \
|
|
Packit |
141393 |
for (uint32_t i = 1; i < iterations; i++) \
|
|
Packit |
141393 |
{ \
|
|
Packit |
141393 |
/* Complete inner hash with previous U */ \
|
|
Packit |
141393 |
_xcpy(&ctx.inner, &startctx->inner); \
|
|
Packit |
141393 |
_xform(&ctx.inner, Ublock); \
|
|
Packit |
141393 |
_xtract(&ctx.inner, Ublock); \
|
|
Packit |
141393 |
/* Complete outer hash with inner output */ \
|
|
Packit |
141393 |
_xcpy(&ctx.outer, &startctx->outer); \
|
|
Packit |
141393 |
_xform(&ctx.outer, Ublock); \
|
|
Packit |
141393 |
_xtract(&ctx.outer, Ublock); \
|
|
Packit |
141393 |
_xxor(&result, &ctx.outer); \
|
|
Packit |
141393 |
} \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* Reform result into output buffer. */ \
|
|
Packit |
141393 |
_xtract(&result, out); \
|
|
Packit |
141393 |
} \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
static inline void PBKDF2(_name)(const uint8_t *pw, size_t npw, \
|
|
Packit |
141393 |
const uint8_t *salt, size_t nsalt, \
|
|
Packit |
141393 |
uint32_t iterations, \
|
|
Packit |
141393 |
uint8_t *out, size_t nout) \
|
|
Packit |
141393 |
{ \
|
|
Packit |
141393 |
assert(iterations); \
|
|
Packit |
141393 |
assert(out && nout); \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* Starting point for inner loop. */ \
|
|
Packit |
141393 |
HMAC_CTX(_name) ctx; \
|
|
Packit |
141393 |
HMAC_INIT(_name)(&ctx, pw, npw); \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
/* How many blocks do we need? */ \
|
|
Packit |
141393 |
uint32_t blocks_needed = (uint32_t)(nout + _hashsz - 1) / _hashsz; \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
for (uint32_t counter = 1; counter <= blocks_needed; counter++) \
|
|
Packit |
141393 |
{ \
|
|
Packit |
141393 |
uint8_t block[_hashsz]; \
|
|
Packit |
141393 |
PBKDF2_F(_name)(&ctx, counter, salt, nsalt, iterations, block); \
|
|
Packit |
141393 |
\
|
|
Packit |
141393 |
size_t offset = (counter - 1) * _hashsz; \
|
|
Packit |
141393 |
size_t taken = MIN(nout - offset, _hashsz); \
|
|
Packit |
141393 |
memcpy(out + offset, block, taken); \
|
|
Packit |
141393 |
} \
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
static inline void sha1_extract(struct sha1_ctx *restrict ctx, uint8_t *restrict out)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
store_be32(out , ctx->h[0]);
|
|
Packit |
141393 |
store_be32(out+4 , ctx->h[1]);
|
|
Packit |
141393 |
store_be32(out+8 , ctx->h[2]);
|
|
Packit |
141393 |
store_be32(out+12, ctx->h[3]);
|
|
Packit |
141393 |
store_be32(out+16, ctx->h[4]);
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
static inline void sha1_cpy(struct sha1_ctx *restrict out, const struct sha1_ctx *restrict in)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
out->h[0] = in->h[0];
|
|
Packit |
141393 |
out->h[1] = in->h[1];
|
|
Packit |
141393 |
out->h[2] = in->h[2];
|
|
Packit |
141393 |
out->h[3] = in->h[3];
|
|
Packit |
141393 |
out->h[4] = in->h[4];
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
static inline void sha1_xor(struct sha1_ctx *restrict out, const struct sha1_ctx *restrict in)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
out->h[0] ^= in->h[0];
|
|
Packit |
141393 |
out->h[1] ^= in->h[1];
|
|
Packit |
141393 |
out->h[2] ^= in->h[2];
|
|
Packit |
141393 |
out->h[3] ^= in->h[3];
|
|
Packit |
141393 |
out->h[4] ^= in->h[4];
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
void cryptonite_sha1_transform(struct sha1_ctx* ctx, uint8_t block[SHA1_BLOCK_SIZE])
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
cryptonite_sha1_update(ctx, block, SHA1_BLOCK_SIZE);
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
DECL_PBKDF2(sha1,
|
|
Packit |
141393 |
SHA1_BLOCK_SIZE,
|
|
Packit |
141393 |
SHA1_DIGEST_SIZE,
|
|
Packit |
141393 |
struct sha1_ctx,
|
|
Packit |
141393 |
cryptonite_sha1_init,
|
|
Packit |
141393 |
cryptonite_sha1_update,
|
|
Packit |
141393 |
cryptonite_sha1_transform,
|
|
Packit |
141393 |
cryptonite_sha1_finalize,
|
|
Packit |
141393 |
sha1_cpy,
|
|
Packit |
141393 |
sha1_extract,
|
|
Packit |
141393 |
sha1_xor);
|
|
Packit |
141393 |
|
|
Packit |
141393 |
static inline void sha256_extract(struct sha256_ctx *restrict ctx, uint8_t *restrict out)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
store_be32(out , ctx->h[0]);
|
|
Packit |
141393 |
store_be32(out+4 , ctx->h[1]);
|
|
Packit |
141393 |
store_be32(out+8 , ctx->h[2]);
|
|
Packit |
141393 |
store_be32(out+12, ctx->h[3]);
|
|
Packit |
141393 |
store_be32(out+16, ctx->h[4]);
|
|
Packit |
141393 |
store_be32(out+20, ctx->h[5]);
|
|
Packit |
141393 |
store_be32(out+24, ctx->h[6]);
|
|
Packit |
141393 |
store_be32(out+28, ctx->h[7]);
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
static inline void sha256_cpy(struct sha256_ctx *restrict out, const struct sha256_ctx *restrict in)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
out->h[0] = in->h[0];
|
|
Packit |
141393 |
out->h[1] = in->h[1];
|
|
Packit |
141393 |
out->h[2] = in->h[2];
|
|
Packit |
141393 |
out->h[3] = in->h[3];
|
|
Packit |
141393 |
out->h[4] = in->h[4];
|
|
Packit |
141393 |
out->h[5] = in->h[5];
|
|
Packit |
141393 |
out->h[6] = in->h[6];
|
|
Packit |
141393 |
out->h[7] = in->h[7];
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
static inline void sha256_xor(struct sha256_ctx *restrict out, const struct sha256_ctx *restrict in)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
out->h[0] ^= in->h[0];
|
|
Packit |
141393 |
out->h[1] ^= in->h[1];
|
|
Packit |
141393 |
out->h[2] ^= in->h[2];
|
|
Packit |
141393 |
out->h[3] ^= in->h[3];
|
|
Packit |
141393 |
out->h[4] ^= in->h[4];
|
|
Packit |
141393 |
out->h[5] ^= in->h[5];
|
|
Packit |
141393 |
out->h[6] ^= in->h[6];
|
|
Packit |
141393 |
out->h[7] ^= in->h[7];
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
void cryptonite_sha256_transform(struct sha256_ctx* ctx, uint8_t block[SHA256_BLOCK_SIZE])
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
cryptonite_sha256_update(ctx, block, SHA256_BLOCK_SIZE);
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
DECL_PBKDF2(sha256,
|
|
Packit |
141393 |
SHA256_BLOCK_SIZE,
|
|
Packit |
141393 |
SHA256_DIGEST_SIZE,
|
|
Packit |
141393 |
struct sha256_ctx,
|
|
Packit |
141393 |
cryptonite_sha256_init,
|
|
Packit |
141393 |
cryptonite_sha256_update,
|
|
Packit |
141393 |
cryptonite_sha256_transform,
|
|
Packit |
141393 |
cryptonite_sha256_finalize,
|
|
Packit |
141393 |
sha256_cpy,
|
|
Packit |
141393 |
sha256_extract,
|
|
Packit |
141393 |
sha256_xor);
|
|
Packit |
141393 |
|
|
Packit |
141393 |
static inline void sha512_extract(struct sha512_ctx *restrict ctx, uint8_t *restrict out)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
store_be64(out , ctx->h[0]);
|
|
Packit |
141393 |
store_be64(out+8 , ctx->h[1]);
|
|
Packit |
141393 |
store_be64(out+16, ctx->h[2]);
|
|
Packit |
141393 |
store_be64(out+24, ctx->h[3]);
|
|
Packit |
141393 |
store_be64(out+32, ctx->h[4]);
|
|
Packit |
141393 |
store_be64(out+40, ctx->h[5]);
|
|
Packit |
141393 |
store_be64(out+48, ctx->h[6]);
|
|
Packit |
141393 |
store_be64(out+56, ctx->h[7]);
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
static inline void sha512_cpy(struct sha512_ctx *restrict out, const struct sha512_ctx *restrict in)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
out->h[0] = in->h[0];
|
|
Packit |
141393 |
out->h[1] = in->h[1];
|
|
Packit |
141393 |
out->h[2] = in->h[2];
|
|
Packit |
141393 |
out->h[3] = in->h[3];
|
|
Packit |
141393 |
out->h[4] = in->h[4];
|
|
Packit |
141393 |
out->h[5] = in->h[5];
|
|
Packit |
141393 |
out->h[6] = in->h[6];
|
|
Packit |
141393 |
out->h[7] = in->h[7];
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
static inline void sha512_xor(struct sha512_ctx *restrict out, const struct sha512_ctx *restrict in)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
out->h[0] ^= in->h[0];
|
|
Packit |
141393 |
out->h[1] ^= in->h[1];
|
|
Packit |
141393 |
out->h[2] ^= in->h[2];
|
|
Packit |
141393 |
out->h[3] ^= in->h[3];
|
|
Packit |
141393 |
out->h[4] ^= in->h[4];
|
|
Packit |
141393 |
out->h[5] ^= in->h[5];
|
|
Packit |
141393 |
out->h[6] ^= in->h[6];
|
|
Packit |
141393 |
out->h[7] ^= in->h[7];
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
void cryptonite_sha512_transform(struct sha512_ctx* ctx, uint8_t block[SHA512_BLOCK_SIZE])
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
cryptonite_sha512_update(ctx, block, SHA512_BLOCK_SIZE);
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
DECL_PBKDF2(sha512,
|
|
Packit |
141393 |
SHA512_BLOCK_SIZE,
|
|
Packit |
141393 |
SHA512_DIGEST_SIZE,
|
|
Packit |
141393 |
struct sha512_ctx,
|
|
Packit |
141393 |
cryptonite_sha512_init,
|
|
Packit |
141393 |
cryptonite_sha512_update,
|
|
Packit |
141393 |
cryptonite_sha512_transform,
|
|
Packit |
141393 |
cryptonite_sha512_finalize,
|
|
Packit |
141393 |
sha512_cpy,
|
|
Packit |
141393 |
sha512_extract,
|
|
Packit |
141393 |
sha512_xor);
|
|
Packit |
141393 |
|
|
Packit |
141393 |
void cryptonite_fastpbkdf2_hmac_sha1( const uint8_t *pw, size_t npw
|
|
Packit |
141393 |
, const uint8_t *salt, size_t nsalt
|
|
Packit |
141393 |
, uint32_t iterations
|
|
Packit |
141393 |
, uint8_t *out, size_t nout
|
|
Packit |
141393 |
)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
PBKDF2(sha1)(pw, npw, salt, nsalt, iterations, out, nout);
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
void cryptonite_fastpbkdf2_hmac_sha256( const uint8_t *pw, size_t npw
|
|
Packit |
141393 |
, const uint8_t *salt, size_t nsalt
|
|
Packit |
141393 |
, uint32_t iterations
|
|
Packit |
141393 |
, uint8_t *out, size_t nout
|
|
Packit |
141393 |
)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
PBKDF2(sha256)(pw, npw, salt, nsalt, iterations, out, nout);
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
void cryptonite_fastpbkdf2_hmac_sha512( const uint8_t *pw, size_t npw
|
|
Packit |
141393 |
, const uint8_t *salt, size_t nsalt
|
|
Packit |
141393 |
, uint32_t iterations
|
|
Packit |
141393 |
, uint8_t *out, size_t nout
|
|
Packit |
141393 |
)
|
|
Packit |
141393 |
{
|
|
Packit |
141393 |
PBKDF2(sha512)(pw, npw, salt, nsalt, iterations, out, nout);
|
|
Packit |
141393 |
}
|