summaryrefslogtreecommitdiff
path: root/deps/openssl/openssl/crypto/dh/dh_check.c
diff options
context:
space:
mode:
authorMyles Borins <mborins@us.ibm.com>2016-01-29 11:30:16 -0800
committerShigeki Ohtsu <ohtsu@iij.ad.jp>2016-01-31 15:07:12 +0900
commit1f434787fcb36b2dea36dbfebc8ff7f899b6d262 (patch)
tree89fbd0f262a3ba0a2557df53a30e1a3807e1a3b4 /deps/openssl/openssl/crypto/dh/dh_check.c
parent6cbbfef994930bc47581d592124e82b58e55ac7b (diff)
downloadandroid-node-v8-1f434787fcb36b2dea36dbfebc8ff7f899b6d262.tar.gz
android-node-v8-1f434787fcb36b2dea36dbfebc8ff7f899b6d262.tar.bz2
android-node-v8-1f434787fcb36b2dea36dbfebc8ff7f899b6d262.zip
deps: upgrade openssl sources to 1.0.2f
This replaces all sources of openssl-1.0.2f.tar.gz into deps/openssl/openssl Fix: https://github.com/nodejs/node/issues/4857 PR-URL: https://github.com/nodejs/node/pull/4961 Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp> deps: copy openssl header files to include dir All symlink files in deps/openssl/openssl/include/openssl/ are removed and replaced with real header files to avoid issues on Windows. Two files of opensslconf.h in crypto and include dir are replaced to refer config/opensslconf.h. Fix: https://github.com/nodejs/node/issues/4857 PR-URL: https://github.com/nodejs/node/pull/4961 Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp> deps: fix openssl assembly error on ia32 win32 `x86masm.pl` was mistakenly using .486 instruction set, why `cpuid` (and perhaps others) are requiring .686 . Fixes: https://github.com/nodejs/node/issues/589 PR-URL: https://github.com/nodejs/node/pull/1389 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp> deps: fix asm build error of openssl in x86_win32 See https://mta.openssl.org/pipermail/openssl-dev/2015-February/000651.html iojs needs to stop using masm and move to nasm or yasm on Win32. Fixes: https://github.com/nodejs/node/issues/589 PR-URL: https://github.com/nodejs/node/pull/1389 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> openssl: fix keypress requirement in apps on win32 Reapply b910613792dac946b295855963869933a9089044 . Fixes: https://github.com/nodejs/node/issues/589 PR-URL: https://github.com/nodejs/node/pull/1389 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> docs: update openssl UPDATING guide the guide is now current with the steps taken to update openssl to v1.0.2f PR-URL: https://github.com/nodejs/node/pull/4961 Reviewed-By: Myles Borins <mborins@us.ibm.com>
Diffstat (limited to 'deps/openssl/openssl/crypto/dh/dh_check.c')
-rw-r--r--deps/openssl/openssl/crypto/dh/dh_check.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/deps/openssl/openssl/crypto/dh/dh_check.c b/deps/openssl/openssl/crypto/dh/dh_check.c
index 347467c6a4..5adedc0d26 100644
--- a/deps/openssl/openssl/crypto/dh/dh_check.c
+++ b/deps/openssl/openssl/crypto/dh/dh_check.c
@@ -151,23 +151,38 @@ int DH_check(const DH *dh, int *ret)
int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)
{
int ok = 0;
- BIGNUM *q = NULL;
+ BIGNUM *tmp = NULL;
+ BN_CTX *ctx = NULL;
*ret = 0;
- q = BN_new();
- if (q == NULL)
+ ctx = BN_CTX_new();
+ if (ctx == NULL)
goto err;
- BN_set_word(q, 1);
- if (BN_cmp(pub_key, q) <= 0)
+ BN_CTX_start(ctx);
+ tmp = BN_CTX_get(ctx);
+ if (tmp == NULL)
+ goto err;
+ BN_set_word(tmp, 1);
+ if (BN_cmp(pub_key, tmp) <= 0)
*ret |= DH_CHECK_PUBKEY_TOO_SMALL;
- BN_copy(q, dh->p);
- BN_sub_word(q, 1);
- if (BN_cmp(pub_key, q) >= 0)
+ BN_copy(tmp, dh->p);
+ BN_sub_word(tmp, 1);
+ if (BN_cmp(pub_key, tmp) >= 0)
*ret |= DH_CHECK_PUBKEY_TOO_LARGE;
+ if (dh->q != NULL) {
+ /* Check pub_key^q == 1 mod p */
+ if (!BN_mod_exp(tmp, pub_key, dh->q, dh->p, ctx))
+ goto err;
+ if (!BN_is_one(tmp))
+ *ret |= DH_CHECK_PUBKEY_INVALID;
+ }
+
ok = 1;
err:
- if (q != NULL)
- BN_free(q);
+ if (ctx != NULL) {
+ BN_CTX_end(ctx);
+ BN_CTX_free(ctx);
+ }
return (ok);
}