From 4dd62d61e4da99f2c6f905f2700208bfc2e6a0ff Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 21 Jun 2015 22:41:34 -0400 Subject: Check for hash core present before running PBKDF2 tests. --- tests/test-pbkdf2.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/test-pbkdf2.c b/tests/test-pbkdf2.c index 477dfe2..5403612 100644 --- a/tests/test-pbkdf2.c +++ b/tests/test-pbkdf2.c @@ -200,16 +200,31 @@ static int _test_pbkdf2(const uint8_t * const pwd, const size_t pwd_len, int main (int argc, char *argv[]) { + hal_error_t err = hal_hash_core_present(hal_hash_sha1); int ok = 1; - ok &= test_pbkdf2(1); - ok &= test_pbkdf2(2); - ok &= test_pbkdf2(3); - ok &= test_pbkdf2(4); - ok &= test_pbkdf2(5); - ok &= test_pbkdf2(6); + switch (err) { + + case HAL_OK: + ok &= test_pbkdf2(1); + ok &= test_pbkdf2(2); + ok &= test_pbkdf2(3); + ok &= test_pbkdf2(4); + ok &= test_pbkdf2(5); + ok &= test_pbkdf2(6); + break; + + case HAL_ERROR_IO_UNEXPECTED: + printf("SHA-1 core not present, not testing PBKDF2\n"); + break; + + default: + printf("Unexpected error while probing for hash core: %s\n", hal_error_string(err)); + ok = 0; + break; + } - return !ok; + return !ok; } /* -- cgit v1.2.3