[Cryptech-Commits] [sw/libhal] 47/58: Check for hash core present before running PBKDF2 tests.
git at cryptech.is
git at cryptech.is
Tue Jul 7 18:25:31 UTC 2015
This is an automated email from the git hooks/post-receive script.
sra at hactrn.net pushed a commit to branch master
in repository sw/libhal.
commit 4dd62d61e4da99f2c6f905f2700208bfc2e6a0ff
Author: Rob Austein <sra at hactrn.net>
Date: Sun Jun 21 22:41:34 2015 -0400
Check for hash core present before running PBKDF2 tests.
---
tests/test-pbkdf2.c | 29 ++++++++++++++++++++++-------
1 file 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;
}
/*
More information about the Commits
mailing list