diff options
author | Rob Austein <sra@hactrn.net> | 2015-10-04 22:31:47 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-10-04 22:31:47 -0400 |
commit | b3bbd3dbccef8c499e980490203cd5085dd13a98 (patch) | |
tree | 68091332d4e2429fcc9a8533bf2e26b2d49ab791 /pbkdf2.c | |
parent | e164eecc55dd96efc98d2c723e96aaaecdcfda13 (diff) |
Whack libhal API to use current configure_core_selector mechanism.
Compiles, not yet tested.
Diffstat (limited to 'pbkdf2.c')
-rw-r--r-- | pbkdf2.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -43,13 +43,15 @@ #include <sys/ioctl.h> #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; |