From e6bdf57820121b6eac9f35c8ef53a4e7a76205e1 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 20 May 2018 18:18:40 -0400 Subject: Better hal_core_alloc() semantics, assert() and printf() cleanup. Various fixes extracted from the abandoned(-for-now?) reuse-cores branch, principally: * Change hal_core_alloc*() to support core reuse and to pick the least-recently-used core of a particular type otherwise; * Replace assert() and printf() calls with hal_assert() and hal_log(), respectively. assert() is particularly useless on the HSM, since it sends its error message into hyperspace then hangs the HSM. --- pbkdf2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pbkdf2.c') diff --git a/pbkdf2.c b/pbkdf2.c index 0a1e57e..607a0fb 100644 --- a/pbkdf2.c +++ b/pbkdf2.c @@ -53,7 +53,7 @@ static hal_error_t do_hmac(hal_core_t *core, const uint32_t block, uint8_t * mac, const size_t mac_len) { - assert(d != NULL && pw != NULL && data != NULL && mac != NULL); + hal_assert(d != NULL && pw != NULL && data != NULL && mac != NULL); uint8_t sb[d->hmac_state_length]; hal_hmac_state_t *s; @@ -96,9 +96,9 @@ hal_error_t hal_pbkdf2(hal_core_t *core, iterations_desired == 0) return HAL_ERROR_BAD_ARGUMENTS; - assert(sizeof(statebuf) >= descriptor->hmac_state_length); - assert(sizeof(result) >= descriptor->digest_length); - assert(sizeof(mac) >= descriptor->digest_length); + hal_assert(sizeof(statebuf) >= descriptor->hmac_state_length); + hal_assert(sizeof(result) >= descriptor->digest_length); + hal_assert(sizeof(mac) >= descriptor->digest_length); /* Output length check per RFC 2989 5.2. */ if ((uint64_t) derived_key_length > ((uint64_t) 0xFFFFFFFF) * descriptor->block_length) -- cgit v1.2.3