Pyrogenesis  trunk
Functions
pkcs5_pbkdf2.cpp File Reference
#include "precompiled.h"
#include "pkcs5_pbkdf2.h"
#include "sha.h"
Include dependency graph for pkcs5_pbkdf2.cpp:

Functions

static void hmac_sha256 (unsigned char(&digest)[SHA_DIGEST_SIZE], const unsigned char *text, size_t text_len, const unsigned char *key, size_t key_len)
 Copyright (c) 2008 Damien Bergamini damie.nosp@m.n.be.nosp@m.rgami.nosp@m.ni@f.nosp@m.ree.f.nosp@m.r More...
 
int pbkdf2 (unsigned char(&output)[SHA_DIGEST_SIZE], const unsigned char *key, size_t key_len, const unsigned char *salt, size_t salt_len, unsigned rounds)
 Simple PBKDF2 implementation for hard to crack passwords. More...
 

Function Documentation

static void hmac_sha256 ( unsigned char(&)  digest[SHA_DIGEST_SIZE],
const unsigned char *  text,
size_t  text_len,
const unsigned char *  key,
size_t  key_len 
)
static

Copyright (c) 2008 Damien Bergamini damie.nosp@m.n.be.nosp@m.rgami.nosp@m.ni@f.nosp@m.ree.f.nosp@m.r

Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

int pbkdf2 ( unsigned char(&)  output[SHA_DIGEST_SIZE],
const unsigned char *  key,
size_t  key_len,
const unsigned char *  salt,
size_t  salt_len,
unsigned  iterations 
)

Simple PBKDF2 implementation for hard to crack passwords.

Parameters
outputThe output buffer for the digested hash
keyThe initial key we want to hash
key_lenLength of the key in bytes
saltThe salt we use to iteratively hash the key.
salt_lenLength of the salt in bytes
iterationsNumber of salting iterations
Returns
0 on success, -1 on error