diff options
author | markus <> | 2001-04-22 23:33:04 +0000 |
---|---|---|
committer | markus <> | 2001-04-22 23:33:04 +0000 |
commit | 7bdbb2116dd933f7b4639bd9028ed79bfc1c12f9 (patch) | |
tree | e47df92f7c825b0ee11be9f1d7f53a4fba7859af | |
parent | 0bb3e562ad53319ea23679c1be3ae6b91f792384 (diff) | |
download | openbsd-7bdbb2116dd933f7b4639bd9028ed79bfc1c12f9.tar.gz openbsd-7bdbb2116dd933f7b4639bd9028ed79bfc1c12f9.tar.bz2 openbsd-7bdbb2116dd933f7b4639bd9028ed79bfc1c12f9.zip |
CRT and DH+SSL fix from 0.9.6a, ok provos@/deraadt@
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_eay.c | 12 | ||||
-rw-r--r-- | src/lib/libssl/s3_srvr.c | 1 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/rsa/rsa_eay.c | 12 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/s3_srvr.c | 1 |
4 files changed, 24 insertions, 2 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 | } |
diff --git a/src/lib/libssl/s3_srvr.c b/src/lib/libssl/s3_srvr.c index bb8cfb31e5..d04232960e 100644 --- a/src/lib/libssl/s3_srvr.c +++ b/src/lib/libssl/s3_srvr.c | |||
@@ -1414,6 +1414,7 @@ static int ssl3_get_client_key_exchange(SSL *s) | |||
1414 | s->session->master_key_length= | 1414 | s->session->master_key_length= |
1415 | s->method->ssl3_enc->generate_master_secret(s, | 1415 | s->method->ssl3_enc->generate_master_secret(s, |
1416 | s->session->master_key,p,i); | 1416 | s->session->master_key,p,i); |
1417 | memset(p,0,i); | ||
1417 | } | 1418 | } |
1418 | else | 1419 | else |
1419 | #endif | 1420 | #endif |
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_eay.c b/src/lib/libssl/src/crypto/rsa/rsa_eay.c index 8b8a1e279a..ccaa62b239 100644 --- a/src/lib/libssl/src/crypto/rsa/rsa_eay.c +++ b/src/lib/libssl/src/crypto/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 | } |
diff --git a/src/lib/libssl/src/ssl/s3_srvr.c b/src/lib/libssl/src/ssl/s3_srvr.c index bb8cfb31e5..d04232960e 100644 --- a/src/lib/libssl/src/ssl/s3_srvr.c +++ b/src/lib/libssl/src/ssl/s3_srvr.c | |||
@@ -1414,6 +1414,7 @@ static int ssl3_get_client_key_exchange(SSL *s) | |||
1414 | s->session->master_key_length= | 1414 | s->session->master_key_length= |
1415 | s->method->ssl3_enc->generate_master_secret(s, | 1415 | s->method->ssl3_enc->generate_master_secret(s, |
1416 | s->session->master_key,p,i); | 1416 | s->session->master_key,p,i); |
1417 | memset(p,0,i); | ||
1417 | } | 1418 | } |
1418 | else | 1419 | else |
1419 | #endif | 1420 | #endif |