aboutsummaryrefslogtreecommitdiff
path: root/pbkdf2.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2015-11-13 17:53:30 -0500
committerPaul Selkirk <paul@psgd.org>2015-11-13 17:53:30 -0500
commita7037d918cbf60bd829e44ccc6d1522f55d5d8b1 (patch)
tree708a05da632c4ed5b8bd3601c39e3b0c0cf41ea7 /pbkdf2.c
parent49ac8847de1120a4ae7b72747ee259bc0f5ffb3c (diff)
parent6ed2c92afd94c08a07f31a7bec345baef07bdf19 (diff)
Merge branch 'config_core_selector'
Diffstat (limited to 'pbkdf2.c')
-rw-r--r--pbkdf2.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/pbkdf2.c b/pbkdf2.c
index 1c43fe4..85273f0 100644
--- a/pbkdf2.c
+++ b/pbkdf2.c
@@ -37,13 +37,15 @@
#include <stdint.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,
@@ -55,7 +57,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)
@@ -74,7 +76,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,
@@ -123,8 +126,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);
@@ -136,7 +139,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;