aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pbkdf2.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-06-21 22:41:34 -0400
committerRob Austein <sra@hactrn.net>2015-06-21 22:41:34 -0400
commit4dd62d61e4da99f2c6f905f2700208bfc2e6a0ff (patch)
tree55176807e200559ff53160f66f718e83dd876a70 /tests/test-pbkdf2.c
parentbca97e11e8cd4e8236eef3cdabf659963ce9f0cc (diff)
Check for hash core present before running PBKDF2 tests.
Diffstat (limited to 'tests/test-pbkdf2.c')
-rw-r--r--tests/test-pbkdf2.c29
1 files changed, 22 insertions, 7 deletions
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;
}
/*