aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core.c7
-rw-r--r--rsa.c10
2 files changed, 16 insertions, 1 deletions
diff --git a/core.c b/core.c
index e170210..0905541 100644
--- a/core.c
+++ b/core.c
@@ -254,6 +254,13 @@ hal_error_t hal_core_alloc2(const char *name1, hal_core_t **pcore1, hal_core_lru
{
const int clear = pcore1 != NULL && *pcore1 == NULL;
+ if (name1 == name2 || strcmp(name1, name2) == 0) {
+ hal_core_t *core1;
+ if (((core1 = hal_core_find(name1, NULL)) == NULL) ||
+ (hal_core_find(name1, core1) == NULL))
+ return HAL_ERROR_CORE_NOT_FOUND;
+ }
+
for (;;) {
hal_error_t err = hal_core_alloc_no_wait(name1, pcore1, pomace1);
diff --git a/rsa.c b/rsa.c
index 1b5de7d..9776b08 100644
--- a/rsa.c
+++ b/rsa.c
@@ -539,7 +539,15 @@ static hal_error_t rsa_crt(hal_core_t *core1, hal_core_t *core2, hal_rsa_key_t *
*/
if ((err = modexp2(precalc, msg,
core1, key->dP, key->p, m1, key->pC, sizeof(key->pC), key->pF, sizeof(key->pF),
- core2, key->dQ, key->q, m2, key->qC, sizeof(key->qC), key->qF, sizeof(key->qF))) != HAL_OK)
+ core2, key->dQ, key->q, m2, key->qC, sizeof(key->qC), key->qF, sizeof(key->qF))) == HAL_ERROR_CORE_NOT_FOUND) {
+ /* Couldn't get two modexp cores, fall back to trying with one. */
+ if ((err = modexp(core1, precalc, msg, key->dP, key->p, m1,
+ key->pC, sizeof(key->pC), key->pF, sizeof(key->pF))) != HAL_OK ||
+ (err = modexp(core1, precalc, msg, key->dQ, key->q, m2,
+ key->qC, sizeof(key->qC), key->qF, sizeof(key->qF))) != HAL_OK)
+ goto fail;
+ }
+ else if (err != HAL_OK)
goto fail;
if (precalc)