diff options
| author | pvalchev <> | 2006-10-04 07:10:32 +0000 |
|---|---|---|
| committer | pvalchev <> | 2006-10-04 07:10:32 +0000 |
| commit | 2ae4a931445dd6121f260bcc0af2dde32a871cd0 (patch) | |
| tree | 79c58b0010b91a2778efdc406095e24c85a41ae1 /src/lib/libcrypto/rsa/rsa_eay.c | |
| parent | c2d940ce6f2c3ef66262b7c1953e6286cf68b267 (diff) | |
| download | openbsd-2ae4a931445dd6121f260bcc0af2dde32a871cd0.tar.gz openbsd-2ae4a931445dd6121f260bcc0af2dde32a871cd0.tar.bz2 openbsd-2ae4a931445dd6121f260bcc0af2dde32a871cd0.zip | |
openssl security fixes, diff from markus@, ok & "commit it" djm@
http://www.openssl.org/news/secadv_20060928.txt for more
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_eay.c')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_eay.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c index be4ac96ce3..610889dc80 100644 --- a/src/lib/libcrypto/rsa/rsa_eay.c +++ b/src/lib/libcrypto/rsa/rsa_eay.c | |||
| @@ -295,6 +295,28 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, | |||
| 295 | BN_init(&f); | 295 | BN_init(&f); |
| 296 | BN_init(&ret); | 296 | BN_init(&ret); |
| 297 | 297 | ||
| 298 | if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS) | ||
| 299 | { | ||
| 300 | RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_MODULUS_TOO_LARGE); | ||
| 301 | return -1; | ||
| 302 | } | ||
| 303 | |||
| 304 | if (BN_ucmp(rsa->n, rsa->e) <= 0) | ||
| 305 | { | ||
| 306 | RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE); | ||
| 307 | return -1; | ||
| 308 | } | ||
| 309 | |||
| 310 | /* for large moduli, enforce exponent limit */ | ||
| 311 | if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS) | ||
| 312 | { | ||
| 313 | if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS) | ||
| 314 | { | ||
| 315 | RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE); | ||
| 316 | return -1; | ||
| 317 | } | ||
| 318 | } | ||
| 319 | |||
| 298 | if ((ctx=BN_CTX_new()) == NULL) goto err; | 320 | if ((ctx=BN_CTX_new()) == NULL) goto err; |
| 299 | num=BN_num_bytes(rsa->n); | 321 | num=BN_num_bytes(rsa->n); |
| 300 | if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL) | 322 | if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL) |
| @@ -576,6 +598,28 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from, | |||
| 576 | unsigned char *buf=NULL; | 598 | unsigned char *buf=NULL; |
| 577 | BN_CTX *ctx=NULL; | 599 | BN_CTX *ctx=NULL; |
| 578 | 600 | ||
| 601 | if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS) | ||
| 602 | { | ||
| 603 | RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_MODULUS_TOO_LARGE); | ||
| 604 | return -1; | ||
| 605 | } | ||
| 606 | |||
| 607 | if (BN_ucmp(rsa->n, rsa->e) <= 0) | ||
| 608 | { | ||
| 609 | RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_BAD_E_VALUE); | ||
| 610 | return -1; | ||
| 611 | } | ||
| 612 | |||
| 613 | /* for large moduli, enforce exponent limit */ | ||
| 614 | if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS) | ||
| 615 | { | ||
| 616 | if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS) | ||
| 617 | { | ||
| 618 | RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_BAD_E_VALUE); | ||
| 619 | return -1; | ||
| 620 | } | ||
| 621 | } | ||
| 622 | |||
| 579 | BN_init(&f); | 623 | BN_init(&f); |
| 580 | BN_init(&ret); | 624 | BN_init(&ret); |
| 581 | ctx=BN_CTX_new(); | 625 | ctx=BN_CTX_new(); |
