diff options
author | Rob Austein <sra@hactrn.net> | 2017-12-13 14:15:45 -0500 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2017-12-13 14:17:46 -0500 |
commit | bc167c214e97ed35f39d088a7dee3f1a9511340e (patch) | |
tree | 7143f5fef99dfe4f605f42664ffc58b904589a5f /tests | |
parent | e5d8d558e954addf0e26ff887e9494d216da2225 (diff) | |
parent | 238e33e53195385dac51e18fffd0f4511244c560 (diff) |
Merge branch systolic_crt into master.
This branch was sitting for long enough that master had been through a
cleanup pass, so beware of accidental reversions.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-rsa.c | 19 | ||||
-rw-r--r-- | tests/test-trng.c | 1 |
2 files changed, 15 insertions, 5 deletions
diff --git a/tests/test-rsa.c b/tests/test-rsa.c index f4e7a8f..176ba03 100644 --- a/tests/test-rsa.c +++ b/tests/test-rsa.c @@ -56,12 +56,21 @@ static int test_modexp(hal_core_t *core, const rsa_tc_bn_t * const exp, /* Exponent */ const rsa_tc_bn_t * const val) /* Expected result */ { - uint8_t result[tc->n.len]; + uint8_t result[tc->n.len], C[tc->n.len], F[tc->n.len]; printf("%s test for %lu-bit RSA key\n", kind, (unsigned long) tc->size); - if (hal_modexp(core, msg->val, msg->len, exp->val, exp->len, - tc->n.val, tc->n.len, result, sizeof(result)) != HAL_OK) + hal_modexp_arg_t args = { + .core = core, + .msg = msg->val, .msg_len = msg->len, + .exp = exp->val, .exp_len = exp->len, + .mod = tc->n.val, .mod_len = tc->n.len, + .result = result, .result_len = sizeof(result), + .coeff = C, .coeff_len = sizeof(C), + .mont = F, .mont_len = sizeof(F) + }; + + if (hal_modexp(1, &args) != HAL_OK) return printf("ModExp failed\n"), 0; if (memcmp(result, val->val, val->len)) @@ -98,7 +107,7 @@ static int test_decrypt(hal_core_t *core, uint8_t result[tc->n.len]; - if ((err = hal_rsa_decrypt(core, key, tc->m.val, tc->m.len, result, sizeof(result))) != HAL_OK) + if ((err = hal_rsa_decrypt(core, NULL, key, tc->m.val, tc->m.len, result, sizeof(result))) != HAL_OK) printf("RSA CRT failed: %s\n", hal_error_string(err)); const int mismatch = (err == HAL_OK && memcmp(result, tc->s.val, tc->s.len) != 0); @@ -165,7 +174,7 @@ static int test_gen(hal_core_t *core, uint8_t result[tc->n.len]; - if ((err = hal_rsa_decrypt(core, key1, tc->m.val, tc->m.len, result, sizeof(result))) != HAL_OK) + if ((err = hal_rsa_decrypt(core, NULL, key1, tc->m.val, tc->m.len, result, sizeof(result))) != HAL_OK) printf("RSA CRT failed: %s\n", hal_error_string(err)); snprintf(fn, sizeof(fn), "test-rsa-sig-%04lu.der", (unsigned long) tc->size); diff --git a/tests/test-trng.c b/tests/test-trng.c index f570752..45dec56 100644 --- a/tests/test-trng.c +++ b/tests/test-trng.c @@ -43,6 +43,7 @@ #include <sys/time.h> #include <hal.h> +#include <hal_internal.h> #include <verilog_constants.h> #ifndef WAIT_FOR_CSPRNG_VALID |