aboutsummaryrefslogtreecommitdiff
path: root/modexp.c
diff options
context:
space:
mode:
Diffstat (limited to 'modexp.c')
-rw-r--r--modexp.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/modexp.c b/modexp.c
index d8e2904..8fea2ea 100644
--- a/modexp.c
+++ b/modexp.c
@@ -391,6 +391,7 @@ hal_error_t hal_modexpng(hal_modexpng_arg_t *a)
goto fail;
}
else {
+ /* set blinding factors to (1,1) */
uint8_t one[a->mod_len]; memset(one, 0, sizeof(one)); one[sizeof(one) - 1] = 1;
if ((err = set_buffer(a->core, MODEXPNG_ADDR_BANK_X, one, sizeof(one))) != HAL_OK ||
(err = set_buffer(a->core, MODEXPNG_ADDR_BANK_Y, one, sizeof(one))) != HAL_OK)
@@ -417,7 +418,10 @@ hal_error_t hal_modexpng(hal_modexpng_arg_t *a)
if ((err = hal_io_zero(a->core)) != HAL_OK ||
(err = hal_io_next(a->core)) != HAL_OK ||
(err = hal_io_wait_valid(a->core)) != HAL_OK ||
- (err = get_buffer(a->core, MODEXPNG_ADDR_BANK_S, a->result, a->result_len)) != HAL_OK)
+ (err = get_buffer(a->core, MODEXPNG_ADDR_BANK_S, a->result, a->result_len)) != HAL_OK ||
+ ((a->bf != NULL && a->ubf != NULL) &&
+ ((err = get_buffer(a->core, MODEXPNG_ADDR_BANK_XM, a->ubf, a->ubf_len)) != HAL_OK ||
+ (err = get_buffer(a->core, MODEXPNG_ADDR_BANK_YM, a->bf, a->bf_len)) != HAL_OK)))
goto fail;
fail: