aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-06-26 22:51:44 -0400
committerRob Austein <sra@hactrn.net>2015-06-26 22:51:44 -0400
commit66c47cc25dbc0c122f6929d855feba3494459a08 (patch)
tree1f5c9b4e5d4951a40b8aa5caf6fbb2a0fb8327b7 /tests
parent10dfb62866134658e1ad97914b3d1c3a7b0d7f50 (diff)
Verify signature in key generation test.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-rsa.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/test-rsa.c b/tests/test-rsa.c
index 594687c..0fd2002 100644
--- a/tests/test-rsa.c
+++ b/tests/test-rsa.c
@@ -113,7 +113,7 @@ static int test_decrypt(const char * const kind, const rsa_tc_t * const tc)
const int mismatch = (err == HAL_OK && memcmp(result, tc->s.val, tc->s.len) != 0);
if (mismatch)
- printf("MISMATCH\n");
+ printf("MISMATCH\n");
hal_rsa_key_clear(key);
@@ -147,7 +147,7 @@ static int test_gen(const char * const kind, const rsa_tc_t * const tc)
printf("Getting DER length of RSA key failed: %s\n", hal_error_string(err));
return 0;
}
-
+
uint8_t der[der_len];
if ((err = hal_rsa_key_to_der(key1, der, &der_len, sizeof(der))) != HAL_OK) {
@@ -206,10 +206,21 @@ static int test_gen(const char * const kind, const rsa_tc_t * const tc)
return 0;
}
+ if (err != HAL_OK) /* Deferred failure from hal_rsa_decrypt(), above */
+ return 0;
+
+ if ((err = hal_rsa_encrypt(key1, result, sizeof(result), result, sizeof(result))) != HAL_OK)
+ printf("RSA signature check failed: %s\n", hal_error_string(err));
+
+ const int mismatch = (err == HAL_OK && memcmp(result, tc->m.val, tc->m.len) != 0);
+
+ if (mismatch)
+ printf("MISMATCH\n");
+
hal_rsa_key_clear(key1);
hal_rsa_key_clear(key2);
- return err == HAL_OK;
+ return err == HAL_OK && !mismatch;
}
/*