diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_eay.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c index 8b8a1e279a..ccaa62b239 100644 --- a/src/lib/libcrypto/rsa/rsa_eay.c +++ b/src/lib/libcrypto/rsa/rsa_eay.c | |||
| @@ -419,7 +419,7 @@ err: | |||
| 419 | static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa) | 419 | static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa) |
| 420 | { | 420 | { |
| 421 | const RSA_METHOD *meth; | 421 | const RSA_METHOD *meth; |
| 422 | BIGNUM r1,m1; | 422 | BIGNUM r1,m1,vrfy; |
| 423 | int ret=0; | 423 | int ret=0; |
| 424 | BN_CTX *ctx; | 424 | BN_CTX *ctx; |
| 425 | 425 | ||
| @@ -427,6 +427,7 @@ static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa) | |||
| 427 | if ((ctx=BN_CTX_new()) == NULL) goto err; | 427 | if ((ctx=BN_CTX_new()) == NULL) goto err; |
| 428 | BN_init(&m1); | 428 | BN_init(&m1); |
| 429 | BN_init(&r1); | 429 | BN_init(&r1); |
| 430 | BN_init(&vrfy); | ||
| 430 | 431 | ||
| 431 | if (rsa->flags & RSA_FLAG_CACHE_PRIVATE) | 432 | if (rsa->flags & RSA_FLAG_CACHE_PRIVATE) |
| 432 | { | 433 | { |
| @@ -474,10 +475,19 @@ static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa) | |||
| 474 | if (!BN_mul(&r1,r0,rsa->q,ctx)) goto err; | 475 | if (!BN_mul(&r1,r0,rsa->q,ctx)) goto err; |
| 475 | if (!BN_add(r0,&r1,&m1)) goto err; | 476 | if (!BN_add(r0,&r1,&m1)) goto err; |
| 476 | 477 | ||
| 478 | if (rsa->e && rsa->n) | ||
| 479 | { | ||
| 480 | if (!meth->bn_mod_exp(&vrfy,r0,rsa->e,rsa->n,ctx,NULL)) goto err; | ||
| 481 | if (BN_cmp(I, &vrfy) != 0) | ||
| 482 | { | ||
| 483 | if (!meth->bn_mod_exp(r0,I,rsa->d,rsa->n,ctx,NULL)) goto err; | ||
| 484 | } | ||
| 485 | } | ||
| 477 | ret=1; | 486 | ret=1; |
| 478 | err: | 487 | err: |
| 479 | BN_clear_free(&m1); | 488 | BN_clear_free(&m1); |
| 480 | BN_clear_free(&r1); | 489 | BN_clear_free(&r1); |
| 490 | BN_clear_free(&vrfy); | ||
| 481 | BN_CTX_free(ctx); | 491 | BN_CTX_free(ctx); |
| 482 | return(ret); | 492 | return(ret); |
| 483 | } | 493 | } |
