From b3bbd3dbccef8c499e980490203cd5085dd13a98 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 4 Oct 2015 22:31:47 -0400 Subject: Whack libhal API to use current configure_core_selector mechanism. Compiles, not yet tested. --- pbkdf2.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'pbkdf2.c') diff --git a/pbkdf2.c b/pbkdf2.c index 4ad1e3a..def5067 100644 --- a/pbkdf2.c +++ b/pbkdf2.c @@ -43,13 +43,15 @@ #include #include "hal.h" +#include "verilog_constants.h" /* * Utility to encapsulate the HMAC operations. May need refactoring * if and when we get clever about reusing HMAC state for speed. */ -static hal_error_t do_hmac(const hal_hash_descriptor_t * const d, +static hal_error_t do_hmac(const hal_core_t *core, + const hal_hash_descriptor_t * const d, const uint8_t * const pw, const size_t pw_len, const uint8_t * const data, const size_t data_len, const uint32_t block, @@ -61,7 +63,7 @@ static hal_error_t do_hmac(const hal_hash_descriptor_t * const d, hal_hmac_state_t *s; hal_error_t err; - if ((err = hal_hmac_initialize(d, &s, sb, sizeof(sb), pw, pw_len)) != HAL_OK) + if ((err = hal_hmac_initialize(core, d, &s, sb, sizeof(sb), pw, pw_len)) != HAL_OK) return err; if ((err = hal_hmac_update(s, data, data_len)) != HAL_OK) @@ -80,7 +82,8 @@ static hal_error_t do_hmac(const hal_hash_descriptor_t * const d, * Derive a key from a passphrase using the PBKDF2 algorithm. */ -hal_error_t hal_pbkdf2(const hal_hash_descriptor_t * const descriptor, +hal_error_t hal_pbkdf2(const hal_core_t *core, + const hal_hash_descriptor_t * const descriptor, const uint8_t * const password, const size_t password_length, const uint8_t * const salt, const size_t salt_length, uint8_t * derived_key, size_t derived_key_length, @@ -129,8 +132,8 @@ hal_error_t hal_pbkdf2(const hal_hash_descriptor_t * const descriptor, * This seeds the result, and constitutes iteration one. */ - if ((err = do_hmac(descriptor, password, password_length, salt, salt_length, - block, mac, sizeof(mac))) != HAL_OK) + if ((err = do_hmac(core, descriptor, password, password_length, + salt, salt_length, block, mac, sizeof(mac))) != HAL_OK) return err; memcpy(result, mac, descriptor->digest_length); @@ -142,7 +145,7 @@ hal_error_t hal_pbkdf2(const hal_hash_descriptor_t * const descriptor, for (iteration = 2; iteration <= iterations_desired; iteration++) { - if ((err = do_hmac(descriptor, password, password_length, + if ((err = do_hmac(core, descriptor, password, password_length, mac, descriptor->digest_length, 0, mac, sizeof(mac))) != HAL_OK) return err; -- cgit v1.2.3