From 30f8e4e85b6a337291b09d55d8edc15e422b6341 Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Tue, 5 Jul 2016 22:45:35 -0400 Subject: Attempt to add resource management, for multiple cores of the same type. Find a suitable core, and mark it busy. Don't forget to release it as soon as you're done. This has a knock-on effect of un-const'ing core arguments and struct fields in a lot of places, and it moves some core checks around. --- pbkdf2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'pbkdf2.c') diff --git a/pbkdf2.c b/pbkdf2.c index f361328..690831f 100644 --- a/pbkdf2.c +++ b/pbkdf2.c @@ -46,7 +46,7 @@ * if and when we get clever about reusing HMAC state for speed. */ -static hal_error_t do_hmac(const hal_core_t *core, +static hal_error_t do_hmac(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, @@ -78,7 +78,7 @@ static hal_error_t do_hmac(const hal_core_t *core, * Derive a key from a passphrase using the PBKDF2 algorithm. */ -hal_error_t hal_pbkdf2(const hal_core_t *core, +hal_error_t hal_pbkdf2(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, @@ -108,6 +108,13 @@ hal_error_t hal_pbkdf2(const hal_core_t *core, memset(result, 0, sizeof(result)); memset(mac, 0, sizeof(mac)); +#if 1 + /* HACK - find the second sha256 core, to avoid interfering with rpc. + */ + core = hal_core_find(descriptor->core_name, NULL); + core = hal_core_find(descriptor->core_name, core); +#endif + /* * We probably should check here to see whether the password is * longer than the HMAC block size, and, if so, we should hash the -- cgit v1.2.3