Files

September 25, 2016 ยท View on GitHub

FileDescription
pbkdf2_hmac.cContains the implementation for the PBKDF2-HMAC algorithm, as described in RFC 2898.
pbkdf2_hmac.hHeader file for the PBKDF2-HMAC algorithm.
pbkdf2_hmac_test.cRFC 6070 test vectors.
pbkdf2_hmac_test.hHeader file for verifying against the RFC 6070 test vectors.
main.cMain program that verifies the implementation against the RFC 6070 test vectors.

Usage example

HCRYPTPROV provider    = NULL;
HCRYPTHASH hash_sha256 = NULL;
int        result      = 0;

char salt_data[] = "SALT";

CryptAcquireContext(provider, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT);
CryptCreateHash(provider, CALG_SHA_256, NULL, 0, &hash_sha256);

result = pbkdf2_derive_bytes_hmac(
    hash_sha256,            /* Initial hash           */
    64,                     /* Hash inner block size  */
    16384,                  /* Iteration count        */
    passwd_len,             /* Password length        */
    passwd_data,            /* Password bytes         */
    sizeof(salt_data) - 1,  /* Salt length            */
    (const BYTE*)salt_data, /* Salt data              */
    64,                     /* Length of output bytes */
    out_bytes               /* Output buffer          */
);

if(result != 0) {
    /* Failed to derive bytes. */
}

CryptDestroyHash(hash_sha256);
CryptReleaseContext(provider, 0);

License

See the LICENSE file for the license.