Compare commits
3 Commits
openssl-1.
...
openssl-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2653d15ab4 | ||
|
|
e6c823a7e5 | ||
|
|
4155d3c2bd |
116
CHANGES
116
CHANGES
@@ -7,6 +7,122 @@
|
||||
https://github.com/openssl/openssl/commits/ and pick the appropriate
|
||||
release branch.
|
||||
|
||||
Changes between 1.0.2s and 1.0.2t [10 Sep 2019]
|
||||
|
||||
*) For built-in EC curves, ensure an EC_GROUP built from the curve name is
|
||||
used even when parsing explicit parameters, when loading a serialized key
|
||||
or calling `EC_GROUP_new_from_ecpkparameters()`/
|
||||
`EC_GROUP_new_from_ecparameters()`.
|
||||
This prevents bypass of security hardening and performance gains,
|
||||
especially for curves with specialized EC_METHODs.
|
||||
By default, if a key encoded with explicit parameters is loaded and later
|
||||
serialized, the output is still encoded with explicit parameters, even if
|
||||
internally a "named" EC_GROUP is used for computation.
|
||||
[Nicola Tuveri]
|
||||
|
||||
*) Compute ECC cofactors if not provided during EC_GROUP construction. Before
|
||||
this change, EC_GROUP_set_generator would accept order and/or cofactor as
|
||||
NULL. After this change, only the cofactor parameter can be NULL. It also
|
||||
does some minimal sanity checks on the passed order.
|
||||
(CVE-2019-1547)
|
||||
[Billy Bob Brumley]
|
||||
|
||||
*) Fixed a padding oracle in PKCS7_dataDecode and CMS_decrypt_set1_pkey.
|
||||
An attack is simple, if the first CMS_recipientInfo is valid but the
|
||||
second CMS_recipientInfo is chosen ciphertext. If the second
|
||||
recipientInfo decodes to PKCS #1 v1.5 form plaintext, the correct
|
||||
encryption key will be replaced by garbage, and the message cannot be
|
||||
decoded, but if the RSA decryption fails, the correct encryption key is
|
||||
used and the recipient will not notice the attack.
|
||||
As a work around for this potential attack the length of the decrypted
|
||||
key must be equal to the cipher default key length, in case the
|
||||
certifiate is not given and all recipientInfo are tried out.
|
||||
The old behaviour can be re-enabled in the CMS code by setting the
|
||||
CMS_DEBUG_DECRYPT flag.
|
||||
(CVE-2019-1563)
|
||||
[Bernd Edlinger]
|
||||
|
||||
*) Document issue with installation paths in diverse Windows builds
|
||||
|
||||
'/usr/local/ssl' is an unsafe prefix for location to install OpenSSL
|
||||
binaries and run-time config file.
|
||||
(CVE-2019-1552)
|
||||
[Richard Levitte]
|
||||
|
||||
Changes between 1.0.2r and 1.0.2s [28 May 2019]
|
||||
|
||||
*) Change the default RSA, DSA and DH size to 2048 bit instead of 1024.
|
||||
This changes the size when using the genpkey app when no size is given. It
|
||||
fixes an omission in earlier changes that changed all RSA, DSA and DH
|
||||
generation apps to use 2048 bits by default.
|
||||
[Kurt Roeckx]
|
||||
|
||||
*) Add FIPS support for Android Arm 64-bit
|
||||
|
||||
Support for Android Arm 64-bit was added to the OpenSSL FIPS Object
|
||||
Module in Version 2.0.10. For some reason, the corresponding target
|
||||
'android64-aarch64' was missing OpenSSL 1.0.2, whence it could not be
|
||||
built with FIPS support on Android Arm 64-bit. This omission has been
|
||||
fixed.
|
||||
[Matthias St. Pierre]
|
||||
|
||||
Changes between 1.0.2q and 1.0.2r [26 Feb 2019]
|
||||
|
||||
*) 0-byte record padding oracle
|
||||
|
||||
If an application encounters a fatal protocol error and then calls
|
||||
SSL_shutdown() twice (once to send a close_notify, and once to receive one)
|
||||
then OpenSSL can respond differently to the calling application if a 0 byte
|
||||
record is received with invalid padding compared to if a 0 byte record is
|
||||
received with an invalid MAC. If the application then behaves differently
|
||||
based on that in a way that is detectable to the remote peer, then this
|
||||
amounts to a padding oracle that could be used to decrypt data.
|
||||
|
||||
In order for this to be exploitable "non-stitched" ciphersuites must be in
|
||||
use. Stitched ciphersuites are optimised implementations of certain
|
||||
commonly used ciphersuites. Also the application must call SSL_shutdown()
|
||||
twice even if a protocol error has occurred (applications should not do
|
||||
this but some do anyway).
|
||||
|
||||
This issue was discovered by Juraj Somorovsky, Robert Merget and Nimrod
|
||||
Aviram, with additional investigation by Steven Collison and Andrew
|
||||
Hourselt. It was reported to OpenSSL on 10th December 2018.
|
||||
(CVE-2019-1559)
|
||||
[Matt Caswell]
|
||||
|
||||
*) Move strictness check from EVP_PKEY_asn1_new() to EVP_PKEY_asn1_add0().
|
||||
[Richard Levitte]
|
||||
|
||||
Changes between 1.0.2p and 1.0.2q [20 Nov 2018]
|
||||
|
||||
*) Microarchitecture timing vulnerability in ECC scalar multiplication
|
||||
|
||||
OpenSSL ECC scalar multiplication, used in e.g. ECDSA and ECDH, has been
|
||||
shown to be vulnerable to a microarchitecture timing side channel attack.
|
||||
An attacker with sufficient access to mount local timing attacks during
|
||||
ECDSA signature generation could recover the private key.
|
||||
|
||||
This issue was reported to OpenSSL on 26th October 2018 by Alejandro
|
||||
Cabrera Aldaya, Billy Brumley, Sohaib ul Hassan, Cesar Pereida Garcia and
|
||||
Nicola Tuveri.
|
||||
(CVE-2018-5407)
|
||||
[Billy Brumley]
|
||||
|
||||
*) Timing vulnerability in DSA signature generation
|
||||
|
||||
The OpenSSL DSA signature algorithm has been shown to be vulnerable to a
|
||||
timing side channel attack. An attacker could use variations in the signing
|
||||
algorithm to recover the private key.
|
||||
|
||||
This issue was reported to OpenSSL on 16th October 2018 by Samuel Weiser.
|
||||
(CVE-2018-0734)
|
||||
[Paul Dale]
|
||||
|
||||
*) Resolve a compatibility issue in EC_GROUP handling with the FIPS Object
|
||||
Module, accidentally introduced while backporting security fixes from the
|
||||
development branch and hindering the use of ECC in FIPS mode.
|
||||
[Nicola Tuveri]
|
||||
|
||||
Changes between 1.0.2o and 1.0.2p [14 Aug 2018]
|
||||
|
||||
*) Client DoS due to large DH parameter
|
||||
|
||||
@@ -118,7 +118,7 @@ my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare
|
||||
# -Wincompatible-pointer-types-discards-qualifiers, -Wcast-align,
|
||||
# -Wunreachable-code -Wunused-parameter -Wlanguage-extension-token
|
||||
# -Wextended-offsetof
|
||||
my $clang_disabled_warnings = "-Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token -Wno-extended-offsetof";
|
||||
my $clang_disabled_warnings = "-Wno-unknown-warning-option -Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token -Wno-extended-offsetof";
|
||||
|
||||
# These are used in addition to $gcc_devteam_warn when the compiler is clang.
|
||||
# TODO(openssl-team): fix problems and investigate if (at least) the
|
||||
@@ -128,7 +128,7 @@ my $clang_disabled_warnings = "-Wno-unused-parameter -Wno-missing-field-initiali
|
||||
# -Wincompatible-pointer-types-discards-qualifiers, -Wcast-align,
|
||||
# -Wunreachable-code -Wunused-parameter -Wlanguage-extension-token
|
||||
# -Wextended-offsetof
|
||||
my $clang_devteam_warn = "-Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token -Wno-extended-offsetof -Qunused-arguments";
|
||||
my $clang_devteam_warn = "-Wno-unknown-warning-option -Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token -Wno-extended-offsetof -Qunused-arguments";
|
||||
|
||||
# Warn that "make depend" should be run?
|
||||
my $warn_make_depend = 0;
|
||||
@@ -475,6 +475,7 @@ my %table=(
|
||||
"android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"android64-aarch64","gcc:-mandroid -fPIC -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-pie%-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
|
||||
#### *BSD [do see comment about ${BSDthreads} above!]
|
||||
"BSD-generic32","gcc:-O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
|
||||
@@ -33,8 +33,18 @@
|
||||
running in a DOS box under Windows. If so, just close the BASH
|
||||
shell, go back to Windows, and restart BASH. Then run "make" again.
|
||||
|
||||
RUN-TIME CAVEAT LECTOR
|
||||
--------------
|
||||
CAVEAT LECTOR
|
||||
-------------
|
||||
|
||||
### Default install and config paths
|
||||
|
||||
./Configure defaults to '/usr/local/ssl' as installation top. This is
|
||||
suitable for Unix, but not for Windows, where this usually is a world
|
||||
writable directory and therefore accessible for change by untrusted users.
|
||||
It is therefore recommended to set your own --prefix or --openssldir to
|
||||
some location that is not world writeable (see the example above)
|
||||
|
||||
### Entropy
|
||||
|
||||
Quoting FAQ:
|
||||
|
||||
|
||||
24
INSTALL.W32
24
INSTALL.W32
@@ -34,6 +34,17 @@
|
||||
get it all to work. See the trouble shooting section later on for if (when?)
|
||||
it goes wrong.
|
||||
|
||||
CAVEAT LECTOR
|
||||
-------------
|
||||
|
||||
### Default install and config paths
|
||||
|
||||
./Configure defaults to '/usr/local/ssl' as installation top. This is
|
||||
suitable for Unix, but not for Windows, where this usually is a world
|
||||
writable directory and therefore accessible for change by untrusted users.
|
||||
It is therefore recommended to set your own --prefix or --openssldir to
|
||||
some location that is not world writeable (see the example above)
|
||||
|
||||
Visual C++
|
||||
----------
|
||||
|
||||
@@ -104,7 +115,7 @@
|
||||
---------------------
|
||||
|
||||
* Configure for building with Borland Builder:
|
||||
> perl Configure BC-32
|
||||
> perl Configure BC-32 --prefix=c:\some\openssl\dir
|
||||
|
||||
* Create the appropriate makefile
|
||||
> ms\do_nasm
|
||||
@@ -196,7 +207,7 @@
|
||||
|
||||
* Compile OpenSSL:
|
||||
|
||||
$ ./config
|
||||
$ ./config --prefix=c:/some/openssl/dir
|
||||
[...]
|
||||
$ make
|
||||
[...]
|
||||
@@ -206,7 +217,11 @@
|
||||
and openssl.exe application in apps directory.
|
||||
|
||||
It is also possible to cross-compile it on Linux by configuring
|
||||
with './Configure --cross-compile-prefix=i386-mingw32- mingw ...'.
|
||||
like this:
|
||||
|
||||
$ ./Configure --cross-compile-prefix=i386-mingw32- \
|
||||
--prefix=c:/some/openssl/dir mingw ...
|
||||
|
||||
'make test' is naturally not applicable then.
|
||||
|
||||
libcrypto.a and libssl.a are the static libraries. To use the DLLs,
|
||||
@@ -240,6 +255,9 @@
|
||||
$ copy /b out32dll\libeay32.dll c:\openssl\bin
|
||||
$ copy /b out32dll\openssl.exe c:\openssl\bin
|
||||
|
||||
("c:\openssl" should be whatever you specified to --prefix when
|
||||
configuring the build)
|
||||
|
||||
Of course, you can choose another device than c:. C: is used here
|
||||
because that's usually the first (and often only) harddisk device.
|
||||
Note: in the modssl INSTALL.Win32, p: is used rather than c:.
|
||||
|
||||
12
INSTALL.W64
12
INSTALL.W64
@@ -30,6 +30,14 @@
|
||||
Neither of these is actually big deal and hardly encountered
|
||||
in real-life applications.
|
||||
|
||||
### Default install and config paths
|
||||
|
||||
./Configure defaults to '/usr/local/ssl' as installation top. This is
|
||||
suitable for Unix, but not for Windows, where this usually is a world
|
||||
writable directory and therefore accessible for change by untrusted users.
|
||||
It is therefore recommended to set your own --prefix or --openssldir to
|
||||
some location that is not world writeable (see the example above)
|
||||
|
||||
Compiling procedure
|
||||
-------------------
|
||||
|
||||
@@ -43,7 +51,7 @@
|
||||
|
||||
To build for Win64/x64:
|
||||
|
||||
> perl Configure VC-WIN64A
|
||||
> perl Configure VC-WIN64A --prefix=c:\some\openssl\dir
|
||||
> ms\do_win64a
|
||||
> nmake -f ms\ntdll.mak
|
||||
> cd out32dll
|
||||
@@ -51,7 +59,7 @@
|
||||
|
||||
To build for Win64/IA64:
|
||||
|
||||
> perl Configure VC-WIN64I
|
||||
> perl Configure VC-WIN64I --prefix=c:\some\openssl\dir
|
||||
> ms\do_win64i
|
||||
> nmake -f ms\ntdll.mak
|
||||
> cd out32dll
|
||||
|
||||
13
INSTALL.WCE
13
INSTALL.WCE
@@ -35,6 +35,17 @@
|
||||
redirects IO to active sync link, while PortSDK - to NT-like console
|
||||
driver on the handheld itself.
|
||||
|
||||
CAVEAT LECTOR
|
||||
-------------
|
||||
|
||||
### Default install and config paths
|
||||
|
||||
./Configure defaults to '/usr/local/ssl' as installation top. This is
|
||||
suitable for Unix, but not for Windows, where this usually is a world
|
||||
writable directory and therefore accessible for change by untrusted users.
|
||||
It is therefore recommended to set your own --prefix or --openssldir to
|
||||
some location that is not world writeable (see the example above)
|
||||
|
||||
Building
|
||||
--------
|
||||
|
||||
@@ -61,7 +72,7 @@
|
||||
|
||||
Next you should run Configure:
|
||||
|
||||
> perl Configure VC-CE
|
||||
> perl Configure VC-CE --prefix=c:\some\openssl\dir
|
||||
|
||||
Next you need to build the Makefiles:
|
||||
|
||||
|
||||
32
MINFO
32
MINFO
@@ -8,9 +8,9 @@ BASEADDR=0xFB00000
|
||||
BASENAME=openssl
|
||||
BF_ENC=bf-586.o
|
||||
BN_ASM=bn-586.o co-586.o x86-mont.o x86-gf2m.o
|
||||
BUILDENV=LC_ALL=C PLATFORM='VC-WIN32' PROCESSOR='' CC='cl' CFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM' AS='cl' ASFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c' AR='ar r' NM='nm' RANLIB='true' RC='windres' CROSS_COMPILE='' PERL='perl' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha hmac ripemd whrlpool des aes rc2 rc4 bf cast camellia seed modes bn ec rsa dsa ecdsa dh ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/ssl/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local/ssl' OPENSSLDIR='/usr/local/ssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_IDEA -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='' SHLIB_TARGET='' PEX_LIBS='' EX_LIBS='' CPUID_OBJ='x86cpuid.o' BN_ASM='bn-586.o co-586.o x86-mont.o x86-gf2m.o' EC_ASM='' DES_ENC='des-586.o crypt586.o' AES_ENC='aes-586.o vpaes-x86.o aesni-x86.o' CMLL_ENC='cmll-x86.o' BF_ENC='bf-586.o' CAST_ENC='cast-586.o' RC4_ENC='rc4-586.o' RC5_ENC='rc5-586.o' SHA1_ASM_OBJ='sha1-586.o sha256-586.o sha512-586.o' MD5_ASM_OBJ='md5-586.o' RMD160_ASM_OBJ='rmd-586.o' WP_ASM_OBJ='wp_block.o wp-mmx.o' MODES_ASM_OBJ='ghash-x86.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='win32n' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES=
|
||||
BUILD_CMD=if [ -d "$$dir" ]; then ( cd $$dir && echo "making $$target in $$dir..." && TOP= && unset TOP $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ && -e LC_ALL=C PLATFORM='VC-WIN32' PROCESSOR='' CC='cl' CFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM' AS='cl' ASFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c' AR='ar r' NM='nm' RANLIB='true' RC='windres' CROSS_COMPILE='' PERL='perl' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha hmac ripemd whrlpool des aes rc2 rc4 bf cast camellia seed modes bn ec rsa dsa ecdsa dh ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/ssl/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local/ssl' OPENSSLDIR='/usr/local/ssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_IDEA -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='' SHLIB_TARGET='' PEX_LIBS='' EX_LIBS='' CPUID_OBJ='x86cpuid.o' BN_ASM='bn-586.o co-586.o x86-mont.o x86-gf2m.o' EC_ASM='' DES_ENC='des-586.o crypt586.o' AES_ENC='aes-586.o vpaes-x86.o aesni-x86.o' CMLL_ENC='cmll-x86.o' BF_ENC='bf-586.o' CAST_ENC='cast-586.o' RC4_ENC='rc4-586.o' RC5_ENC='rc5-586.o' SHA1_ASM_OBJ='sha1-586.o sha256-586.o sha512-586.o' MD5_ASM_OBJ='md5-586.o' RMD160_ASM_OBJ='rmd-586.o' WP_ASM_OBJ='wp_block.o wp-mmx.o' MODES_ASM_OBJ='ghash-x86.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='win32n' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES= TOP=.. DIR=$$dir $$target ) || exit 1; fi
|
||||
BUILD_ONE_CMD=if expr " crypto ssl engines apps test tools " : ".* $$dir " >/dev/null 2>&1; then if [ -d "$$dir" ]; then ( cd $$dir && echo "making $$target in $$dir..." && TOP= && unset TOP $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ && -e LC_ALL=C PLATFORM='VC-WIN32' PROCESSOR='' CC='cl' CFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM' AS='cl' ASFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c' AR='ar r' NM='nm' RANLIB='true' RC='windres' CROSS_COMPILE='' PERL='perl' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha hmac ripemd whrlpool des aes rc2 rc4 bf cast camellia seed modes bn ec rsa dsa ecdsa dh ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/ssl/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local/ssl' OPENSSLDIR='/usr/local/ssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_IDEA -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='' SHLIB_TARGET='' PEX_LIBS='' EX_LIBS='' CPUID_OBJ='x86cpuid.o' BN_ASM='bn-586.o co-586.o x86-mont.o x86-gf2m.o' EC_ASM='' DES_ENC='des-586.o crypt586.o' AES_ENC='aes-586.o vpaes-x86.o aesni-x86.o' CMLL_ENC='cmll-x86.o' BF_ENC='bf-586.o' CAST_ENC='cast-586.o' RC4_ENC='rc4-586.o' RC5_ENC='rc5-586.o' SHA1_ASM_OBJ='sha1-586.o sha256-586.o sha512-586.o' MD5_ASM_OBJ='md5-586.o' RMD160_ASM_OBJ='rmd-586.o' WP_ASM_OBJ='wp_block.o wp-mmx.o' MODES_ASM_OBJ='ghash-x86.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='win32n' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES= TOP=.. DIR=$$dir $$target ) || exit 1; fi; fi
|
||||
BUILDENV=LC_ALL=C PLATFORM='VC-WIN32' PROCESSOR='' CC='cl' CFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM' AS='cl' ASFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c' AR='ar r' NM='nm' RANLIB='true' RC='windres' CROSS_COMPILE='' PERL='C:\Perl64\bin\perl.exe' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha hmac ripemd whrlpool des aes rc2 rc4 bf cast camellia seed modes bn ec rsa dsa ecdsa dh ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/ssl/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local/ssl' OPENSSLDIR='/usr/local/ssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_IDEA -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='' SHLIB_TARGET='' PEX_LIBS='' EX_LIBS='' CPUID_OBJ='x86cpuid.o' BN_ASM='bn-586.o co-586.o x86-mont.o x86-gf2m.o' EC_ASM='' DES_ENC='des-586.o crypt586.o' AES_ENC='aes-586.o vpaes-x86.o aesni-x86.o' CMLL_ENC='cmll-x86.o' BF_ENC='bf-586.o' CAST_ENC='cast-586.o' RC4_ENC='rc4-586.o' RC5_ENC='rc5-586.o' SHA1_ASM_OBJ='sha1-586.o sha256-586.o sha512-586.o' MD5_ASM_OBJ='md5-586.o' RMD160_ASM_OBJ='rmd-586.o' WP_ASM_OBJ='wp_block.o wp-mmx.o' MODES_ASM_OBJ='ghash-x86.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='win32n' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES=
|
||||
BUILD_CMD=if [ -d "$$dir" ]; then ( cd $$dir && echo "making $$target in $$dir..." && TOP= && unset TOP $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ && -e LC_ALL=C PLATFORM='VC-WIN32' PROCESSOR='' CC='cl' CFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM' AS='cl' ASFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c' AR='ar r' NM='nm' RANLIB='true' RC='windres' CROSS_COMPILE='' PERL='C:\Perl64\bin\perl.exe' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha hmac ripemd whrlpool des aes rc2 rc4 bf cast camellia seed modes bn ec rsa dsa ecdsa dh ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/ssl/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local/ssl' OPENSSLDIR='/usr/local/ssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_IDEA -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='' SHLIB_TARGET='' PEX_LIBS='' EX_LIBS='' CPUID_OBJ='x86cpuid.o' BN_ASM='bn-586.o co-586.o x86-mont.o x86-gf2m.o' EC_ASM='' DES_ENC='des-586.o crypt586.o' AES_ENC='aes-586.o vpaes-x86.o aesni-x86.o' CMLL_ENC='cmll-x86.o' BF_ENC='bf-586.o' CAST_ENC='cast-586.o' RC4_ENC='rc4-586.o' RC5_ENC='rc5-586.o' SHA1_ASM_OBJ='sha1-586.o sha256-586.o sha512-586.o' MD5_ASM_OBJ='md5-586.o' RMD160_ASM_OBJ='rmd-586.o' WP_ASM_OBJ='wp_block.o wp-mmx.o' MODES_ASM_OBJ='ghash-x86.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='win32n' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES= TOP=.. DIR=$$dir $$target ) || exit 1; fi
|
||||
BUILD_ONE_CMD=if expr " crypto ssl engines apps test tools " : ".* $$dir " >/dev/null 2>&1; then if [ -d "$$dir" ]; then ( cd $$dir && echo "making $$target in $$dir..." && TOP= && unset TOP $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ && -e LC_ALL=C PLATFORM='VC-WIN32' PROCESSOR='' CC='cl' CFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM' AS='cl' ASFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c' AR='ar r' NM='nm' RANLIB='true' RC='windres' CROSS_COMPILE='' PERL='C:\Perl64\bin\perl.exe' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha hmac ripemd whrlpool des aes rc2 rc4 bf cast camellia seed modes bn ec rsa dsa ecdsa dh ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/ssl/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local/ssl' OPENSSLDIR='/usr/local/ssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_IDEA -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='' SHLIB_TARGET='' PEX_LIBS='' EX_LIBS='' CPUID_OBJ='x86cpuid.o' BN_ASM='bn-586.o co-586.o x86-mont.o x86-gf2m.o' EC_ASM='' DES_ENC='des-586.o crypt586.o' AES_ENC='aes-586.o vpaes-x86.o aesni-x86.o' CMLL_ENC='cmll-x86.o' BF_ENC='bf-586.o' CAST_ENC='cast-586.o' RC4_ENC='rc4-586.o' RC5_ENC='rc5-586.o' SHA1_ASM_OBJ='sha1-586.o sha256-586.o sha512-586.o' MD5_ASM_OBJ='md5-586.o' RMD160_ASM_OBJ='rmd-586.o' WP_ASM_OBJ='wp_block.o wp-mmx.o' MODES_ASM_OBJ='ghash-x86.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='win32n' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES= TOP=.. DIR=$$dir $$target ) || exit 1; fi; fi
|
||||
CAST_ENC=cast-586.o
|
||||
CC=cl
|
||||
CFLAG=-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM
|
||||
@@ -53,12 +53,12 @@ MANSUFFIX=
|
||||
MD5_ASM_OBJ=md5-586.o
|
||||
MINOR=0.2
|
||||
MODES_ASM_OBJ=ghash-x86.o
|
||||
NAME=openssl-1.0.2p
|
||||
NAME=openssl-1.0.2t
|
||||
NM=nm
|
||||
ONEDIRS=out tmp
|
||||
OPENSSLDIR=/usr/local/ssl
|
||||
OPTIONS=no-ec_nistp_64_gcc_128 no-gmp no-idea no-jpake no-krb5 no-libunbound no-md2 no-mdc2 no-rc5 no-rfc3779 no-sctp no-shared no-ssl-trace no-ssl2 no-store no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic
|
||||
PERL=perl
|
||||
PERL=C:\Perl64\bin\perl.exe
|
||||
PERLASM_SCHEME=win32n
|
||||
PEX_LIBS=
|
||||
PLATFORM=VC-WIN32
|
||||
@@ -67,7 +67,7 @@ RANLIB=true
|
||||
RC=windres
|
||||
RC4_ENC=rc4-586.o
|
||||
RC5_ENC=rc5-586.o
|
||||
RECURSIVE_BUILD_CMD=for dir in crypto ssl engines apps test tools; do if [ -d "$$dir" ]; then ( cd $$dir && echo "making $$target in $$dir..." && TOP= && unset TOP $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ && -e LC_ALL=C PLATFORM='VC-WIN32' PROCESSOR='' CC='cl' CFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM' AS='cl' ASFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c' AR='ar r' NM='nm' RANLIB='true' RC='windres' CROSS_COMPILE='' PERL='perl' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha hmac ripemd whrlpool des aes rc2 rc4 bf cast camellia seed modes bn ec rsa dsa ecdsa dh ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/ssl/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local/ssl' OPENSSLDIR='/usr/local/ssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_IDEA -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='' SHLIB_TARGET='' PEX_LIBS='' EX_LIBS='' CPUID_OBJ='x86cpuid.o' BN_ASM='bn-586.o co-586.o x86-mont.o x86-gf2m.o' EC_ASM='' DES_ENC='des-586.o crypt586.o' AES_ENC='aes-586.o vpaes-x86.o aesni-x86.o' CMLL_ENC='cmll-x86.o' BF_ENC='bf-586.o' CAST_ENC='cast-586.o' RC4_ENC='rc4-586.o' RC5_ENC='rc5-586.o' SHA1_ASM_OBJ='sha1-586.o sha256-586.o sha512-586.o' MD5_ASM_OBJ='md5-586.o' RMD160_ASM_OBJ='rmd-586.o' WP_ASM_OBJ='wp_block.o wp-mmx.o' MODES_ASM_OBJ='ghash-x86.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='win32n' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES= TOP=.. DIR=$$dir $$target ) || exit 1; fi; done
|
||||
RECURSIVE_BUILD_CMD=for dir in crypto ssl engines apps test tools; do if [ -d "$$dir" ]; then ( cd $$dir && echo "making $$target in $$dir..." && TOP= && unset TOP $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ && -e LC_ALL=C PLATFORM='VC-WIN32' PROCESSOR='' CC='cl' CFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM' AS='cl' ASFLAG='-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c' AR='ar r' NM='nm' RANLIB='true' RC='windres' CROSS_COMPILE='' PERL='C:\Perl64\bin\perl.exe' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha hmac ripemd whrlpool des aes rc2 rc4 bf cast camellia seed modes bn ec rsa dsa ecdsa dh ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/local/ssl/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local/ssl' OPENSSLDIR='/usr/local/ssl' LIBDIR='lib' MAKEDEPEND='$$$./util/domd $$$. -MD makedepend' DEPFLAG='-DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_IDEA -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS' MAKEDEPPROG='makedepend' SHARED_LDFLAGS='' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='' SHARED_LIBS='' SHLIB_EXT='' SHLIB_TARGET='' PEX_LIBS='' EX_LIBS='' CPUID_OBJ='x86cpuid.o' BN_ASM='bn-586.o co-586.o x86-mont.o x86-gf2m.o' EC_ASM='' DES_ENC='des-586.o crypt586.o' AES_ENC='aes-586.o vpaes-x86.o aesni-x86.o' CMLL_ENC='cmll-x86.o' BF_ENC='bf-586.o' CAST_ENC='cast-586.o' RC4_ENC='rc4-586.o' RC5_ENC='rc5-586.o' SHA1_ASM_OBJ='sha1-586.o sha256-586.o sha512-586.o' MD5_ASM_OBJ='md5-586.o' RMD160_ASM_OBJ='rmd-586.o' WP_ASM_OBJ='wp_block.o wp-mmx.o' MODES_ASM_OBJ='ghash-x86.o' ENGINES_ASM_OBJ='' PERLASM_SCHEME='win32n' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="$}" THIS=$ MAKEFILE=Makefile MAKEOVERRIDES= TOP=.. DIR=$$dir $$target ) || exit 1; fi; done
|
||||
RMD160_ASM_OBJ=rmd-586.o
|
||||
SDIRS=objects md4 md5 sha hmac ripemd whrlpool des aes rc2 rc4 bf cast camellia seed modes bn ec rsa dsa ecdsa dh ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac
|
||||
SHA1_ASM_OBJ=sha1-586.o sha256-586.o sha512-586.o
|
||||
@@ -85,19 +85,19 @@ SHLIB_TARGET=
|
||||
SHLIB_VERSION_HISTORY=
|
||||
SHLIB_VERSION_NUMBER=1.0.0
|
||||
TAR=tar
|
||||
TARFILE=../openssl-1.0.2p.tar
|
||||
TARFILE=../openssl-1.0.2t.tar
|
||||
TARFLAGS=--no-recursion
|
||||
TAR_COMMAND=tar --no-recursion --files-from ../openssl-1.0.2p.tar.list --owner 0 --group 0 --transform 's|^|openssl-1.0.2p/|' -cvf -
|
||||
TAR_COMMAND=tar --no-recursion --files-from ../openssl-1.0.2t.tar.list --owner 0 --group 0 --transform 's|^|openssl-1.0.2t/|' -cvf -
|
||||
TESTS=alltests
|
||||
TOP=.
|
||||
VERSION=1.0.2p
|
||||
VERSION=1.0.2t
|
||||
WDIRS=windows
|
||||
WP_ASM_OBJ=wp_block.o wp-mmx.o
|
||||
ZLIB_INCLUDE=
|
||||
RELATIVE_DIRECTORY=
|
||||
RELATIVE_DIRECTORY=crypto
|
||||
AFLAGS=-I. -I.. -I../include -DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM
|
||||
ALL=Makefile README crypto-lib.com install.com cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h constant_time_locl.h bn_int.h crypto.h opensslv.h opensslconf.h ebcdic.h symhacks.h ossl_typ.h
|
||||
ALL=Makefile README crypto-lib.com install.com cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c getenv.c cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h constant_time_locl.h bn_int.h crypto.h opensslv.h opensslconf.h ebcdic.h symhacks.h ossl_typ.h
|
||||
AR=ar r
|
||||
ASFLAGS=-I. -I.. -I../include -DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM
|
||||
CC=cl
|
||||
@@ -112,9 +112,9 @@ HEADER=cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h constant_tim
|
||||
INCLUDE=-I. -I.. -I../include
|
||||
INCLUDES=-I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include
|
||||
LIB=../libcrypto.a
|
||||
LIBOBJ=cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o cpt_err.o ebcdic.o uid.o o_time.o o_str.o o_dir.o o_fips.o o_init.o fips_ers.o x86cpuid.o
|
||||
LIBOBJ=cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o cpt_err.o ebcdic.o uid.o o_time.o o_str.o o_dir.o o_fips.o o_init.o fips_ers.o getenv.o x86cpuid.o
|
||||
LIBS=
|
||||
LIBSRC=cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c
|
||||
LIBSRC=cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c getenv.c
|
||||
MAKEDEPEND=../util/domd .. -MD makedepend
|
||||
MAKEDEPPROG=makedepend
|
||||
MAKEFILE=Makefile
|
||||
@@ -122,7 +122,7 @@ PEX_LIBS=
|
||||
RECURSIVE_MAKE=[ -n "objects md4 md5 sha hmac ripemd whrlpool des aes rc2 rc4 bf cast camellia seed modes bn ec rsa dsa ecdsa dh ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac" ] && for i in objects md4 md5 sha hmac ripemd whrlpool des aes rc2 rc4 bf cast camellia seed modes bn ec rsa dsa ecdsa dh ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac ; do (cd $$i && echo "making $$target in crypto/$$i..." && -e TOP=../.. DIR=$$i INCLUDES='-I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include ' $$target ) || exit 1; done;
|
||||
RM=rm -f
|
||||
SHARED_LIB=libcrypto
|
||||
SRC=cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c
|
||||
SRC=cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c getenv.c
|
||||
TEST=constant_time_test.c
|
||||
TOP=..
|
||||
RELATIVE_DIRECTORY=
|
||||
@@ -852,7 +852,7 @@ LIB=../../libcrypto.a
|
||||
LIBOBJ=o_names.o obj_dat.o obj_lib.o obj_err.o obj_xref.o
|
||||
LIBSRC=o_names.c obj_dat.c obj_lib.c obj_err.c obj_xref.c
|
||||
MAKEFILE=Makefile
|
||||
PERL=perl
|
||||
PERL=C:\Perl64\bin\perl.exe
|
||||
SRC=o_names.c obj_dat.c obj_lib.c obj_err.c obj_xref.c
|
||||
TEST=
|
||||
TOP=../..
|
||||
@@ -1315,7 +1315,7 @@ LIBCRYPTO=-L.. -lcrypto
|
||||
LIBKRB5=
|
||||
LIBSSL=-L.. -lssl
|
||||
MAKEFILE=Makefile
|
||||
PERL=perl
|
||||
PERL=C:\Perl64\bin\perl.exe
|
||||
PEX_LIBS=
|
||||
PROGRAM=openssl
|
||||
PROGS=openssl.c
|
||||
@@ -1421,7 +1421,7 @@ MD5TEST=md5test
|
||||
MDC2TEST=mdc2test
|
||||
METHTEST=methtest
|
||||
OBJ=bntest.o ectest.o ecdsatest.o ecdhtest.o ideatest.o md2test.o md4test.o md5test.o hmactest.o wp_test.o rc2test.o rc4test.o rc5test.o destest.o shatest.o sha1test.o sha256t.o sha512t.o mdc2test.o rmdtest.o randtest.o dhtest.o enginetest.o casttest.o bftest.o ssltest.o dsatest.o exptest.o rsa_test.o evp_test.o evp_extra_test.o igetest.o jpaketest.o asn1test.o v3nametest.o heartbeat_test.o constant_time_test.o verify_extra_test.o clienthellotest.o sslv2conftest.o dtlstest.o ssltestlib.o bad_dtls_test.o fatalerrtest.o x509_time_test.o
|
||||
PERL=perl
|
||||
PERL=C:\Perl64\bin\perl.exe
|
||||
PEX_LIBS=
|
||||
RANDTEST=randtest
|
||||
RC2TEST=rc2test
|
||||
|
||||
6
Makefile
6
Makefile
@@ -4,7 +4,7 @@
|
||||
## Makefile for OpenSSL
|
||||
##
|
||||
|
||||
VERSION=1.0.2p
|
||||
VERSION=1.0.2t
|
||||
MAJOR=1
|
||||
MINOR=0.2
|
||||
SHLIB_VERSION_NUMBER=1.0.0
|
||||
@@ -70,7 +70,7 @@ AR= ar $(ARFLAGS) r
|
||||
RANLIB= true
|
||||
RC= windres
|
||||
NM= nm
|
||||
PERL= perl
|
||||
PERL= C:\Perl64\bin\perl.exe
|
||||
TAR= tar
|
||||
TARFLAGS= --no-recursion
|
||||
MAKEDEPPROG=makedepend
|
||||
@@ -521,7 +521,7 @@ $(TARFILE).list:
|
||||
find * \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \
|
||||
\! -name '*.so' \! -name '*.so.*' \! -name 'openssl' \
|
||||
\( \! -name '*test' -o -name bctest -o -name pod2mantest \) \
|
||||
\! -name '.#*' \! -name '*~' \! -type l \
|
||||
\! -name '.#*' \! -name '*.bak' \! -name '*~' \! -type l \
|
||||
| sort > $(TARFILE).list
|
||||
|
||||
tar: $(TARFILE).list
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
## Makefile for OpenSSL
|
||||
##
|
||||
|
||||
VERSION=1.0.2p
|
||||
VERSION=1.0.2t
|
||||
MAJOR=1
|
||||
MINOR=0.2
|
||||
SHLIB_VERSION_NUMBER=1.0.0
|
||||
@@ -70,7 +70,7 @@ AR= ar $(ARFLAGS) r
|
||||
RANLIB= true
|
||||
RC= windres
|
||||
NM= nm
|
||||
PERL= perl
|
||||
PERL= C:\Perl64\bin\perl.exe
|
||||
TAR= tar
|
||||
TARFLAGS= --no-recursion
|
||||
MAKEDEPPROG=makedepend
|
||||
@@ -521,7 +521,7 @@ $(TARFILE).list:
|
||||
find * \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \
|
||||
\! -name '*.so' \! -name '*.so.*' \! -name 'openssl' \
|
||||
\( \! -name '*test' -o -name bctest -o -name pod2mantest \) \
|
||||
\! -name '.#*' \! -name '*~' \! -type l \
|
||||
\! -name '.#*' \! -name '*.bak' \! -name '*~' \! -type l \
|
||||
| sort > $(TARFILE).list
|
||||
|
||||
tar: $(TARFILE).list
|
||||
|
||||
@@ -519,7 +519,7 @@ $(TARFILE).list:
|
||||
find * \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \
|
||||
\! -name '*.so' \! -name '*.so.*' \! -name 'openssl' \
|
||||
\( \! -name '*test' -o -name bctest -o -name pod2mantest \) \
|
||||
\! -name '.#*' \! -name '*~' \! -type l \
|
||||
\! -name '.#*' \! -name '*.bak' \! -name '*~' \! -type l \
|
||||
| sort > $(TARFILE).list
|
||||
|
||||
tar: $(TARFILE).list
|
||||
|
||||
24
NEWS
24
NEWS
@@ -5,6 +5,30 @@
|
||||
This file gives a brief overview of the major changes between each OpenSSL
|
||||
release. For more details please read the CHANGES file.
|
||||
|
||||
Major changes between OpenSSL 1.0.2s and OpenSSL 1.0.2t [10 Sep 2019]
|
||||
|
||||
o Fixed a padding oracle in PKCS7_dataDecode and CMS_decrypt_set1_pkey
|
||||
(CVE-2019-1563)
|
||||
o For built-in EC curves, ensure an EC_GROUP built from the curve name is
|
||||
used even when parsing explicit parameters
|
||||
o Compute ECC cofactors if not provided during EC_GROUP construction
|
||||
(CVE-2019-1547)
|
||||
o Document issue with installation paths in diverse Windows builds
|
||||
(CVE-2019-1552)
|
||||
|
||||
Major changes between OpenSSL 1.0.2r and OpenSSL 1.0.2s [28 May 2019]
|
||||
|
||||
o None
|
||||
|
||||
Major changes between OpenSSL 1.0.2q and OpenSSL 1.0.2r [26 Feb 2019]
|
||||
|
||||
o 0-byte record padding oracle (CVE-2019-1559)
|
||||
|
||||
Major changes between OpenSSL 1.0.2p and OpenSSL 1.0.2q [20 Nov 2018]
|
||||
|
||||
o Microarchitecture timing vulnerability in ECC scalar multiplication (CVE-2018-5407)
|
||||
o Timing vulnerability in DSA signature generation (CVE-2018-0734)
|
||||
|
||||
Major changes between OpenSSL 1.0.2o and OpenSSL 1.0.2p [14 Aug 2018]
|
||||
|
||||
o Client DoS due to large DH parameter (CVE-2018-0732)
|
||||
|
||||
4
README
4
README
@@ -1,7 +1,7 @@
|
||||
|
||||
OpenSSL 1.0.2p 14 Aug 2018
|
||||
OpenSSL 1.0.2t 10 Sep 2019
|
||||
|
||||
Copyright (c) 1998-2018 The OpenSSL Project
|
||||
Copyright (c) 1998-2019 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -659,8 +659,7 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
BIO_printf(bio_err, "Generating a %ld bit %s private key\n",
|
||||
newkey, keyalgstr);
|
||||
BIO_printf(bio_err, "Generating a %s private key\n", keyalgstr);
|
||||
|
||||
EVP_PKEY_CTX_set_cb(genctx, genpkey_cb);
|
||||
EVP_PKEY_CTX_set_app_data(genctx, bio_err);
|
||||
|
||||
2
config
2
config
@@ -871,6 +871,7 @@ case "$GUESSOS" in
|
||||
*-*-qnx6) OUT="QNX6" ;;
|
||||
x86-*-android|i?86-*-android) OUT="android-x86" ;;
|
||||
armv[7-9]*-*-android) OUT="android-armv7" ;;
|
||||
aarch64-*-android) OUT="android64-aarch64" ;;
|
||||
*) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
|
||||
esac
|
||||
|
||||
@@ -992,5 +993,6 @@ if [ $? = "0" ]; then
|
||||
fi
|
||||
else
|
||||
echo "This system ($OUT) is not supported. See file INSTALL for details."
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
|
||||
@@ -36,9 +36,11 @@ TEST=constant_time_test.c
|
||||
LIB= $(TOP)/libcrypto.a
|
||||
SHARED_LIB= libcrypto$(SHLIB_EXT)
|
||||
LIBSRC= cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c \
|
||||
ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c
|
||||
ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c \
|
||||
getenv.c
|
||||
LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o cpt_err.o ebcdic.o \
|
||||
uid.o o_time.o o_str.o o_dir.o o_fips.o o_init.o fips_ers.o $(CPUID_OBJ)
|
||||
uid.o o_time.o o_str.o o_dir.o o_fips.o o_init.o fips_ers.o getenv.o \
|
||||
$(CPUID_OBJ)
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
@@ -178,6 +180,13 @@ ex_data.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
|
||||
ex_data.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
|
||||
ex_data.o: ex_data.c
|
||||
fips_ers.o: ../include/openssl/opensslconf.h fips_ers.c
|
||||
getenv.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
getenv.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
|
||||
getenv.o: ../include/openssl/err.h ../include/openssl/lhash.h
|
||||
getenv.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
getenv.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
|
||||
getenv.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
|
||||
getenv.o: getenv.c
|
||||
mem.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
mem.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
|
||||
mem.o: ../include/openssl/err.h ../include/openssl/lhash.h
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !__ASSEMBLER__
|
||||
# ifndef __ASSEMBLER__
|
||||
extern unsigned int OPENSSL_armcap_P;
|
||||
# endif
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <signal.h>
|
||||
#include <crypto.h>
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include "arm_arch.h"
|
||||
|
||||
unsigned int OPENSSL_armcap_P = 0;
|
||||
|
||||
@@ -234,6 +234,21 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
|
||||
|
||||
int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth)
|
||||
{
|
||||
/*
|
||||
* One of the following must be true:
|
||||
*
|
||||
* pem_str == NULL AND ASN1_PKEY_ALIAS is set
|
||||
* pem_str != NULL AND ASN1_PKEY_ALIAS is clear
|
||||
*
|
||||
* Anything else is an error and may lead to a corrupt ASN1 method table
|
||||
*/
|
||||
if (!((ameth->pem_str == NULL
|
||||
&& (ameth->pkey_flags & ASN1_PKEY_ALIAS) != 0)
|
||||
|| (ameth->pem_str != NULL
|
||||
&& (ameth->pkey_flags & ASN1_PKEY_ALIAS) == 0))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (app_methods == NULL) {
|
||||
app_methods = sk_EVP_PKEY_ASN1_METHOD_new(ameth_cmp);
|
||||
if (!app_methods)
|
||||
@@ -305,18 +320,6 @@ EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,
|
||||
} else
|
||||
ameth->info = NULL;
|
||||
|
||||
/*
|
||||
* One of the following must be true:
|
||||
*
|
||||
* pem_str == NULL AND ASN1_PKEY_ALIAS is set
|
||||
* pem_str != NULL AND ASN1_PKEY_ALIAS is clear
|
||||
*
|
||||
* Anything else is an error and may lead to a corrupt ASN1 method table
|
||||
*/
|
||||
if (!((pem_str == NULL && (flags & ASN1_PKEY_ALIAS) != 0)
|
||||
|| (pem_str != NULL && (flags & ASN1_PKEY_ALIAS) == 0)))
|
||||
goto err;
|
||||
|
||||
if (pem_str) {
|
||||
ameth->pem_str = BUF_strdup(pem_str);
|
||||
if (!ameth->pem_str)
|
||||
|
||||
@@ -56,6 +56,9 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#define _BSD_SOURCE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
@@ -83,6 +86,11 @@ NETDB_DEFINE_CONTEXT
|
||||
static int wsa_init_done = 0;
|
||||
# endif
|
||||
|
||||
# if defined(__GLIBC__)
|
||||
# define HAVE_GETHOSTBYNAME_R
|
||||
# define GETHOSTNAME_R_BUF (2 * 1024)
|
||||
# endif
|
||||
|
||||
/*
|
||||
* WSAAPI specifier is required to make indirect calls to run-time
|
||||
* linked WinSock 2 functions used in this module, to be specific
|
||||
@@ -116,7 +124,12 @@ int BIO_get_host_ip(const char *str, unsigned char *ip)
|
||||
int i;
|
||||
int err = 1;
|
||||
int locked = 0;
|
||||
struct hostent *he;
|
||||
struct hostent *he = NULL;
|
||||
# ifdef HAVE_GETHOSTBYNAME_R
|
||||
char buf[GETHOSTNAME_R_BUF];
|
||||
struct hostent hostent;
|
||||
int h_errnop;
|
||||
# endif
|
||||
|
||||
i = get_ip(str, ip);
|
||||
if (i < 0) {
|
||||
@@ -138,10 +151,18 @@ int BIO_get_host_ip(const char *str, unsigned char *ip)
|
||||
if (i > 0)
|
||||
return (1);
|
||||
|
||||
/* if gethostbyname_r is supported, use it. */
|
||||
# ifdef HAVE_GETHOSTBYNAME_R
|
||||
memset(&hostent, 0x00, sizeof(hostent));
|
||||
/* gethostbyname_r() sets |he| to NULL on error, we check it further down */
|
||||
gethostbyname_r(str, &hostent, buf, sizeof(buf), &he, &h_errnop);
|
||||
# else
|
||||
/* do a gethostbyname */
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME);
|
||||
locked = 1;
|
||||
he = BIO_gethostbyname(str);
|
||||
# endif
|
||||
|
||||
if (he == NULL) {
|
||||
BIOerr(BIO_F_BIO_GET_HOST_IP, BIO_R_BAD_HOSTNAME_LOOKUP);
|
||||
goto err;
|
||||
|
||||
@@ -361,12 +361,16 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
} else
|
||||
_setmode(fd, _O_BINARY);
|
||||
}
|
||||
# elif defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
# elif defined(OPENSSL_SYS_OS2)
|
||||
int fd = fileno((FILE *)ptr);
|
||||
if (num & BIO_FP_TEXT)
|
||||
setmode(fd, O_TEXT);
|
||||
else
|
||||
setmode(fd, O_BINARY);
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
int fd = fileno((FILE *)ptr);
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
setmode(fd, O_BINARY);
|
||||
# endif
|
||||
}
|
||||
break;
|
||||
@@ -389,11 +393,14 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_OS2)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
strcat(p, "b");
|
||||
else
|
||||
strcat(p, "t");
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
strcat(p, "b");
|
||||
# endif
|
||||
# if defined(OPENSSL_SYS_NETWARE)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
|
||||
@@ -297,8 +297,8 @@ bn_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bn_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bn_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
bn_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_lib.o: ../../include/openssl/symhacks.h ../bn_int.h ../cryptlib.h bn_lcl.h
|
||||
bn_lib.o: bn_lib.c
|
||||
bn_lib.o: ../../include/openssl/symhacks.h ../bn_int.h ../constant_time_locl.h
|
||||
bn_lib.o: ../cryptlib.h bn_lcl.h bn_lib.c
|
||||
bn_mod.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_mod.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_mod.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
|
||||
@@ -55,12 +55,6 @@
|
||||
* machine.
|
||||
*/
|
||||
|
||||
# if defined(_WIN64) || !defined(__LP64__)
|
||||
# define BN_ULONG unsigned long long
|
||||
# else
|
||||
# define BN_ULONG unsigned long
|
||||
# endif
|
||||
|
||||
# undef mul
|
||||
# undef mul_add
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* crypto/bn/bn_blind.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -206,11 +206,16 @@ int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx)
|
||||
if (!BN_BLINDING_create_param(b, NULL, NULL, ctx, NULL, NULL))
|
||||
goto err;
|
||||
} else if (!(b->flags & BN_BLINDING_NO_UPDATE)) {
|
||||
if (!BN_mod_mul(b->A, b->A, b->A, b->mod, ctx))
|
||||
if (b->m_ctx != NULL) {
|
||||
if (!bn_mul_mont_fixed_top(b->Ai, b->Ai, b->Ai, b->m_ctx, ctx)
|
||||
|| !bn_mul_mont_fixed_top(b->A, b->A, b->A, b->m_ctx, ctx))
|
||||
goto err;
|
||||
if (!BN_mod_mul(b->Ai, b->Ai, b->Ai, b->mod, ctx))
|
||||
} else {
|
||||
if (!BN_mod_mul(b->Ai, b->Ai, b->Ai, b->mod, ctx)
|
||||
|| !BN_mod_mul(b->A, b->A, b->A, b->mod, ctx))
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
err:
|
||||
@@ -241,13 +246,13 @@ int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx)
|
||||
else if (!BN_BLINDING_update(b, ctx))
|
||||
return (0);
|
||||
|
||||
if (r != NULL) {
|
||||
if (!BN_copy(r, b->Ai))
|
||||
ret = 0;
|
||||
}
|
||||
if (r != NULL && (BN_copy(r, b->Ai) == NULL))
|
||||
return 0;
|
||||
|
||||
if (!BN_mod_mul(n, n, b->A, b->mod, ctx))
|
||||
ret = 0;
|
||||
if (b->m_ctx != NULL)
|
||||
ret = BN_mod_mul_montgomery(n, n, b->A, b->m_ctx, ctx);
|
||||
else
|
||||
ret = BN_mod_mul(n, n, b->A, b->mod, ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -264,14 +269,29 @@ int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,
|
||||
|
||||
bn_check_top(n);
|
||||
|
||||
if (r != NULL)
|
||||
ret = BN_mod_mul(n, n, r, b->mod, ctx);
|
||||
else {
|
||||
if (b->Ai == NULL) {
|
||||
if (r == NULL && (r = b->Ai) == NULL) {
|
||||
BNerr(BN_F_BN_BLINDING_INVERT_EX, BN_R_NOT_INITIALIZED);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx);
|
||||
|
||||
if (b->m_ctx != NULL) {
|
||||
/* ensure that BN_mod_mul_montgomery takes pre-defined path */
|
||||
if (n->dmax >= r->top) {
|
||||
size_t i, rtop = r->top, ntop = n->top;
|
||||
BN_ULONG mask;
|
||||
|
||||
for (i = 0; i < rtop; i++) {
|
||||
mask = (BN_ULONG)0 - ((i - ntop) >> (8 * sizeof(i) - 1));
|
||||
n->d[i] &= mask;
|
||||
}
|
||||
mask = (BN_ULONG)0 - ((rtop - ntop) >> (8 * sizeof(ntop) - 1));
|
||||
/* always true, if (rtop >= ntop) n->top = r->top; */
|
||||
n->top = (int)(rtop & ~mask) | (ntop & mask);
|
||||
n->flags |= (BN_FLG_FIXED_TOP & ~mask);
|
||||
}
|
||||
ret = BN_mod_mul_montgomery(n, n, r, b->m_ctx, ctx);
|
||||
} else {
|
||||
ret = BN_mod_mul(n, n, r, b->mod, ctx);
|
||||
}
|
||||
|
||||
bn_check_top(n);
|
||||
@@ -366,14 +386,19 @@ BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
|
||||
} while (1);
|
||||
|
||||
if (ret->bn_mod_exp != NULL && ret->m_ctx != NULL) {
|
||||
if (!ret->bn_mod_exp
|
||||
(ret->A, ret->A, ret->e, ret->mod, ctx, ret->m_ctx))
|
||||
if (!ret->bn_mod_exp(ret->A, ret->A, ret->e, ret->mod, ctx, ret->m_ctx))
|
||||
goto err;
|
||||
} else {
|
||||
if (!BN_mod_exp(ret->A, ret->A, ret->e, ret->mod, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (ret->m_ctx != NULL) {
|
||||
if (!bn_to_mont_fixed_top(ret->Ai, ret->Ai, ret->m_ctx, ctx)
|
||||
|| !bn_to_mont_fixed_top(ret->A, ret->A, ret->m_ctx, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
return ret;
|
||||
err:
|
||||
if (b == NULL && ret != NULL) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* crypto/bn/bn_ctx.c */
|
||||
/* Written by Ulf Moeller for the OpenSSL project. */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -299,6 +299,8 @@ BIGNUM *BN_CTX_get(BN_CTX *ctx)
|
||||
}
|
||||
/* OK, make sure the returned bignum is "zero" */
|
||||
BN_zero(ret);
|
||||
/* clear BN_FLG_CONSTTIME if leaked from previous frames */
|
||||
ret->flags &= (~BN_FLG_CONSTTIME);
|
||||
ctx->used++;
|
||||
CTXDBG_RET(ctx, ret);
|
||||
return ret;
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
#include "constant_time_locl.h"
|
||||
|
||||
const char BN_version[] = "Big Number" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
@@ -187,13 +188,57 @@ int BN_num_bits_word(BN_ULONG l)
|
||||
return bits;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function still leaks `a->dmax`: it's caller's responsibility to
|
||||
* expand the input `a` in advance to a public length.
|
||||
*/
|
||||
static inline
|
||||
int bn_num_bits_consttime(const BIGNUM *a)
|
||||
{
|
||||
int j, ret;
|
||||
unsigned int mask, past_i;
|
||||
int i = a->top - 1;
|
||||
bn_check_top(a);
|
||||
|
||||
for (j = 0, past_i = 0, ret = 0; j < a->dmax; j++) {
|
||||
mask = constant_time_eq_int(i, j); /* 0xff..ff if i==j, 0x0 otherwise */
|
||||
|
||||
ret += BN_BITS2 & (~mask & ~past_i);
|
||||
ret += BN_num_bits_word(a->d[j]) & mask;
|
||||
|
||||
past_i |= mask; /* past_i will become 0xff..ff after i==j */
|
||||
}
|
||||
|
||||
/*
|
||||
* if BN_is_zero(a) => i is -1 and ret contains garbage, so we mask the
|
||||
* final result.
|
||||
*/
|
||||
mask = ~(constant_time_eq_int(i, ((int)-1)));
|
||||
|
||||
return ret & mask;
|
||||
}
|
||||
|
||||
int BN_num_bits(const BIGNUM *a)
|
||||
{
|
||||
int i = a->top - 1;
|
||||
bn_check_top(a);
|
||||
|
||||
if (a->flags & BN_FLG_CONSTTIME) {
|
||||
/*
|
||||
* We assume that BIGNUMs flagged as CONSTTIME have also been expanded
|
||||
* so that a->dmax is not leaking secret information.
|
||||
*
|
||||
* In other words, it's the caller's responsibility to ensure `a` has
|
||||
* been preallocated in advance to a public length if we hit this
|
||||
* branch.
|
||||
*
|
||||
*/
|
||||
return bn_num_bits_consttime(a);
|
||||
}
|
||||
|
||||
if (BN_is_zero(a))
|
||||
return 0;
|
||||
|
||||
return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
|
||||
}
|
||||
|
||||
@@ -613,30 +658,54 @@ BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
typedef enum {big, little} endianess_t;
|
||||
|
||||
/* ignore negative */
|
||||
static int bn2binpad(const BIGNUM *a, unsigned char *to, int tolen)
|
||||
static
|
||||
int bn2binpad(const BIGNUM *a, unsigned char *to, int tolen, endianess_t endianess)
|
||||
{
|
||||
int n;
|
||||
size_t i, inc, lasti, j;
|
||||
size_t i, lasti, j, atop, mask;
|
||||
BN_ULONG l;
|
||||
|
||||
/*
|
||||
* In case |a| is fixed-top, BN_num_bytes can return bogus length,
|
||||
* but it's assumed that fixed-top inputs ought to be "nominated"
|
||||
* even for padded output, so it works out...
|
||||
*/
|
||||
n = BN_num_bytes(a);
|
||||
if (tolen == -1)
|
||||
if (tolen == -1) {
|
||||
tolen = n;
|
||||
else if (tolen < n)
|
||||
return -1;
|
||||
} else if (tolen < n) { /* uncommon/unlike case */
|
||||
BIGNUM temp = *a;
|
||||
|
||||
if (n == 0) {
|
||||
bn_correct_top(&temp);
|
||||
n = BN_num_bytes(&temp);
|
||||
if (tolen < n)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Swipe through whole available data and don't give away padded zero. */
|
||||
atop = a->dmax * BN_BYTES;
|
||||
if (atop == 0) {
|
||||
OPENSSL_cleanse(to, tolen);
|
||||
return tolen;
|
||||
}
|
||||
|
||||
lasti = n - 1;
|
||||
for (i = 0, inc = 1, j = tolen; j > 0;) {
|
||||
lasti = atop - 1;
|
||||
atop = a->top * BN_BYTES;
|
||||
if (endianess == big)
|
||||
to += tolen; /* start from the end of the buffer */
|
||||
for (i = 0, j = 0; j < (size_t)tolen; j++) {
|
||||
unsigned char val;
|
||||
l = a->d[i / BN_BYTES];
|
||||
to[--j] = (unsigned char)(l >> (8 * (i % BN_BYTES)) & (0 - inc));
|
||||
inc = (i - lasti) >> (8 * sizeof(i) - 1);
|
||||
i += inc; /* stay on top limb */
|
||||
mask = 0 - ((j - atop) >> (8 * sizeof(i) - 1));
|
||||
val = (unsigned char)(l >> (8 * (i % BN_BYTES)) & mask);
|
||||
if (endianess == big)
|
||||
*--to = val;
|
||||
else
|
||||
*to++ = val;
|
||||
i += (i - lasti) >> (8 * sizeof(i) - 1); /* stay on last limb */
|
||||
}
|
||||
|
||||
return tolen;
|
||||
@@ -646,21 +715,66 @@ int bn_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen)
|
||||
{
|
||||
if (tolen < 0)
|
||||
return -1;
|
||||
return bn2binpad(a, to, tolen);
|
||||
return bn2binpad(a, to, tolen, big);
|
||||
}
|
||||
|
||||
int BN_bn2bin(const BIGNUM *a, unsigned char *to)
|
||||
{
|
||||
int n, i;
|
||||
BN_ULONG l;
|
||||
|
||||
bn_check_top(a);
|
||||
n = i = BN_num_bytes(a);
|
||||
while (i--) {
|
||||
l = a->d[i / BN_BYTES];
|
||||
*(to++) = (unsigned char)(l >> (8 * (i % BN_BYTES))) & 0xff;
|
||||
return bn2binpad(a, to, -1, big);
|
||||
}
|
||||
return (n);
|
||||
|
||||
BIGNUM *bn_lebin2bn(const unsigned char *s, int len, BIGNUM *ret)
|
||||
{
|
||||
unsigned int i, m;
|
||||
unsigned int n;
|
||||
BN_ULONG l;
|
||||
BIGNUM *bn = NULL;
|
||||
|
||||
if (ret == NULL)
|
||||
ret = bn = BN_new();
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
bn_check_top(ret);
|
||||
s += len;
|
||||
/* Skip trailing zeroes. */
|
||||
for ( ; len > 0 && s[-1] == 0; s--, len--)
|
||||
continue;
|
||||
n = len;
|
||||
if (n == 0) {
|
||||
ret->top = 0;
|
||||
return ret;
|
||||
}
|
||||
i = ((n - 1) / BN_BYTES) + 1;
|
||||
m = ((n - 1) % (BN_BYTES));
|
||||
if (bn_wexpand(ret, (int)i) == NULL) {
|
||||
BN_free(bn);
|
||||
return NULL;
|
||||
}
|
||||
ret->top = i;
|
||||
ret->neg = 0;
|
||||
l = 0;
|
||||
while (n--) {
|
||||
s--;
|
||||
l = (l << 8L) | *s;
|
||||
if (m-- == 0) {
|
||||
ret->d[--i] = l;
|
||||
l = 0;
|
||||
m = BN_BYTES - 1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* need to call this due to clear byte at top if avoiding having the top
|
||||
* bit set (-ve number)
|
||||
*/
|
||||
bn_correct_top(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bn_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen)
|
||||
{
|
||||
if (tolen < 0)
|
||||
return -1;
|
||||
return bn2binpad(a, to, tolen, little);
|
||||
}
|
||||
|
||||
int BN_ucmp(const BIGNUM *a, const BIGNUM *b)
|
||||
@@ -822,6 +936,9 @@ int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n)
|
||||
int i;
|
||||
BN_ULONG aa, bb;
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
|
||||
aa = a[n - 1];
|
||||
bb = b[n - 1];
|
||||
if (aa != bb)
|
||||
@@ -889,6 +1006,38 @@ void BN_consttime_swap(BN_ULONG condition, BIGNUM *a, BIGNUM *b, int nwords)
|
||||
a->top ^= t;
|
||||
b->top ^= t;
|
||||
|
||||
t = (a->neg ^ b->neg) & condition;
|
||||
a->neg ^= t;
|
||||
b->neg ^= t;
|
||||
|
||||
/*-
|
||||
* BN_FLG_STATIC_DATA: indicates that data may not be written to. Intention
|
||||
* is actually to treat it as it's read-only data, and some (if not most)
|
||||
* of it does reside in read-only segment. In other words observation of
|
||||
* BN_FLG_STATIC_DATA in BN_consttime_swap should be treated as fatal
|
||||
* condition. It would either cause SEGV or effectively cause data
|
||||
* corruption.
|
||||
*
|
||||
* BN_FLG_MALLOCED: refers to BN structure itself, and hence must be
|
||||
* preserved.
|
||||
*
|
||||
* BN_FLG_SECURE: must be preserved, because it determines how x->d was
|
||||
* allocated and hence how to free it.
|
||||
*
|
||||
* BN_FLG_CONSTTIME: sufficient to mask and swap
|
||||
*
|
||||
* BN_FLG_FIXED_TOP: indicates that we haven't called bn_correct_top() on
|
||||
* the data, so the d array may be padded with additional 0 values (i.e.
|
||||
* top could be greater than the minimal value that it could be). We should
|
||||
* be swapping it
|
||||
*/
|
||||
|
||||
#define BN_CONSTTIME_SWAP_FLAGS (BN_FLG_CONSTTIME | BN_FLG_FIXED_TOP)
|
||||
|
||||
t = ((a->flags ^ b->flags) & BN_CONSTTIME_SWAP_FLAGS) & condition;
|
||||
a->flags ^= t;
|
||||
b->flags ^= t;
|
||||
|
||||
#define BN_CONSTTIME_SWAP(ind) \
|
||||
do { \
|
||||
t = (a->d[ind] ^ b->d[ind]) & condition; \
|
||||
|
||||
@@ -197,6 +197,7 @@ int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
((volatile BN_ULONG *)tp)[i] = 0;
|
||||
}
|
||||
r->top = mtop;
|
||||
r->flags |= BN_FLG_FIXED_TOP;
|
||||
r->neg = 0;
|
||||
|
||||
if (tp != storage)
|
||||
@@ -224,6 +225,70 @@ int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||
return BN_nnmod(r, r, m, ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* BN_mod_sub variant that may be used if both a and b are non-negative,
|
||||
* a is less than m, while b is of same bit width as m. It's implemented
|
||||
* as subtraction followed by two conditional additions.
|
||||
*
|
||||
* 0 <= a < m
|
||||
* 0 <= b < 2^w < 2*m
|
||||
*
|
||||
* after subtraction
|
||||
*
|
||||
* -2*m < r = a - b < m
|
||||
*
|
||||
* Thus it takes up to two conditional additions to make |r| positive.
|
||||
*/
|
||||
int bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *m)
|
||||
{
|
||||
size_t i, ai, bi, mtop = m->top;
|
||||
BN_ULONG borrow, carry, ta, tb, mask, *rp;
|
||||
const BN_ULONG *ap, *bp;
|
||||
|
||||
if (bn_wexpand(r, m->top) == NULL)
|
||||
return 0;
|
||||
|
||||
rp = r->d;
|
||||
ap = a->d != NULL ? a->d : rp;
|
||||
bp = b->d != NULL ? b->d : rp;
|
||||
|
||||
for (i = 0, ai = 0, bi = 0, borrow = 0; i < mtop;) {
|
||||
mask = (BN_ULONG)0 - ((i - a->top) >> (8 * sizeof(i) - 1));
|
||||
ta = ap[ai] & mask;
|
||||
|
||||
mask = (BN_ULONG)0 - ((i - b->top) >> (8 * sizeof(i) - 1));
|
||||
tb = bp[bi] & mask;
|
||||
rp[i] = ta - tb - borrow;
|
||||
if (ta != tb)
|
||||
borrow = (ta < tb);
|
||||
|
||||
i++;
|
||||
ai += (i - a->dmax) >> (8 * sizeof(i) - 1);
|
||||
bi += (i - b->dmax) >> (8 * sizeof(i) - 1);
|
||||
}
|
||||
ap = m->d;
|
||||
for (i = 0, mask = 0 - borrow, carry = 0; i < mtop; i++) {
|
||||
ta = ((ap[i] & mask) + carry) & BN_MASK2;
|
||||
carry = (ta < carry);
|
||||
rp[i] = (rp[i] + ta) & BN_MASK2;
|
||||
carry += (rp[i] < ta);
|
||||
}
|
||||
borrow -= carry;
|
||||
for (i = 0, mask = 0 - borrow, carry = 0; i < mtop; i++) {
|
||||
ta = ((ap[i] & mask) + carry) & BN_MASK2;
|
||||
carry = (ta < carry);
|
||||
rp[i] = (rp[i] + ta) & BN_MASK2;
|
||||
carry += (rp[i] < ta);
|
||||
}
|
||||
|
||||
r->top = mtop;
|
||||
r->flags |= BN_FLG_FIXED_TOP;
|
||||
r->neg = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* BN_mod_sub variant that may be used if both a and b are non-negative and
|
||||
* less than m
|
||||
|
||||
@@ -164,10 +164,10 @@ int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
|
||||
bn_check_top(tmp);
|
||||
if (a == b) {
|
||||
if (!BN_sqr(tmp, a, ctx))
|
||||
if (!bn_sqr_fixed_top(tmp, a, ctx))
|
||||
goto err;
|
||||
} else {
|
||||
if (!BN_mul(tmp, a, b, ctx))
|
||||
if (!bn_mul_fixed_top(tmp, a, b, ctx))
|
||||
goto err;
|
||||
}
|
||||
/* reduce from aRR to aR */
|
||||
@@ -190,6 +190,7 @@ static int bn_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)
|
||||
BIGNUM *n;
|
||||
BN_ULONG *ap, *np, *rp, n0, v, carry;
|
||||
int nl, max, i;
|
||||
unsigned int rtop;
|
||||
|
||||
n = &(mont->N);
|
||||
nl = n->top;
|
||||
@@ -207,12 +208,10 @@ static int bn_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)
|
||||
rp = r->d;
|
||||
|
||||
/* clear the top words of T */
|
||||
# if 1
|
||||
for (i = r->top; i < max; i++) /* memset? XXX */
|
||||
rp[i] = 0;
|
||||
# else
|
||||
memset(&(rp[r->top]), 0, (max - r->top) * sizeof(BN_ULONG));
|
||||
# endif
|
||||
for (rtop = r->top, i = 0; i < max; i++) {
|
||||
v = (BN_ULONG)0 - ((i - rtop) >> (8 * sizeof(rtop) - 1));
|
||||
rp[i] &= v;
|
||||
}
|
||||
|
||||
r->top = max;
|
||||
r->flags |= BN_FLG_FIXED_TOP;
|
||||
@@ -262,6 +261,18 @@ static int bn_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)
|
||||
|
||||
int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
int retn;
|
||||
|
||||
retn = bn_from_mont_fixed_top(ret, a, mont, ctx);
|
||||
bn_correct_top(ret);
|
||||
bn_check_top(ret);
|
||||
|
||||
return retn;
|
||||
}
|
||||
|
||||
int bn_from_mont_fixed_top(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
int retn = 0;
|
||||
#ifdef MONT_WORD
|
||||
@@ -270,8 +281,6 @@ int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||
BN_CTX_start(ctx);
|
||||
if ((t = BN_CTX_get(ctx)) && BN_copy(t, a)) {
|
||||
retn = bn_from_montgomery_word(ret, t, mont);
|
||||
bn_correct_top(ret);
|
||||
bn_check_top(ret);
|
||||
}
|
||||
BN_CTX_end(ctx);
|
||||
#else /* !MONT_WORD */
|
||||
|
||||
@@ -935,6 +935,16 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
|
||||
#endif /* BN_RECURSION */
|
||||
|
||||
int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
|
||||
{
|
||||
int ret = bn_mul_fixed_top(r, a, b, ctx);
|
||||
|
||||
bn_correct_top(r);
|
||||
bn_check_top(r);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bn_mul_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
|
||||
{
|
||||
int ret = 0;
|
||||
int top, al, bl;
|
||||
@@ -1042,7 +1052,7 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
|
||||
#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
|
||||
end:
|
||||
#endif
|
||||
bn_correct_top(rr);
|
||||
rr->flags |= BN_FLG_FIXED_TOP;
|
||||
if (r != rr && BN_copy(r, rr) == NULL)
|
||||
goto err;
|
||||
|
||||
|
||||
@@ -65,6 +65,16 @@
|
||||
* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96
|
||||
*/
|
||||
int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
|
||||
{
|
||||
int ret = bn_sqr_fixed_top(r, a, ctx);
|
||||
|
||||
bn_correct_top(r);
|
||||
bn_check_top(r);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bn_sqr_fixed_top(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
|
||||
{
|
||||
int max, al;
|
||||
int ret = 0;
|
||||
@@ -136,7 +146,7 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
|
||||
|
||||
rr->neg = 0;
|
||||
rr->top = max;
|
||||
bn_correct_top(rr);
|
||||
rr->flags |= BN_FLG_FIXED_TOP;
|
||||
if (r != rr && BN_copy(r, rr) == NULL)
|
||||
goto err;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 2005.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2005 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2005-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -223,8 +223,10 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
|
||||
for (i = 0; i < 1000; i++) {
|
||||
if (!BN_rand(Xq, nbits, 1, 0))
|
||||
goto err;
|
||||
|
||||
/* Check that |Xp - Xq| > 2^(nbits - 100) */
|
||||
BN_sub(t, Xp, Xq);
|
||||
if (!BN_sub(t, Xp, Xq))
|
||||
goto err;
|
||||
if (BN_num_bits(t) > (nbits - 100))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,10 @@
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#ifndef OSSL_NELEM
|
||||
# define OSSL_NELEM(x) (sizeof(x)/sizeof(x[0]))
|
||||
#endif
|
||||
|
||||
const int num0 = 100; /* number of tests */
|
||||
const int num1 = 50; /* additional tests for some functions */
|
||||
const int num2 = 5; /* number of tests for slow functions */
|
||||
@@ -123,6 +127,7 @@ int test_gf2m_mod_solve_quad(BIO *bp, BN_CTX *ctx);
|
||||
int test_kron(BIO *bp, BN_CTX *ctx);
|
||||
int test_sqrt(BIO *bp, BN_CTX *ctx);
|
||||
int rand_neg(void);
|
||||
static int test_ctx_consttime_flag(void);
|
||||
static int results = 0;
|
||||
|
||||
static unsigned char lst[] =
|
||||
@@ -330,6 +335,15 @@ int main(int argc, char *argv[])
|
||||
goto err;
|
||||
(void)BIO_flush(out);
|
||||
#endif
|
||||
|
||||
/* silently flush any pre-existing error on the stack */
|
||||
ERR_clear_error();
|
||||
|
||||
message(out, "BN_CTX_get BN_FLG_CONSTTIME");
|
||||
if (!test_ctx_consttime_flag())
|
||||
goto err;
|
||||
(void)BIO_flush(out);
|
||||
|
||||
BN_CTX_free(ctx);
|
||||
BIO_free(out);
|
||||
|
||||
@@ -2158,3 +2172,90 @@ int rand_neg(void)
|
||||
|
||||
return (sign[(neg++) % 8]);
|
||||
}
|
||||
|
||||
static int test_ctx_set_ct_flag(BN_CTX *c)
|
||||
{
|
||||
int st = 0;
|
||||
size_t i;
|
||||
BIGNUM *b[15];
|
||||
|
||||
BN_CTX_start(c);
|
||||
for (i = 0; i < OSSL_NELEM(b); i++) {
|
||||
if (NULL == (b[i] = BN_CTX_get(c))) {
|
||||
fprintf(stderr, "ERROR: BN_CTX_get() failed.\n");
|
||||
goto err;
|
||||
}
|
||||
if (i % 2 == 1)
|
||||
BN_set_flags(b[i], BN_FLG_CONSTTIME);
|
||||
}
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
BN_CTX_end(c);
|
||||
return st;
|
||||
}
|
||||
|
||||
static int test_ctx_check_ct_flag(BN_CTX *c)
|
||||
{
|
||||
int st = 0;
|
||||
size_t i;
|
||||
BIGNUM *b[30];
|
||||
|
||||
BN_CTX_start(c);
|
||||
for (i = 0; i < OSSL_NELEM(b); i++) {
|
||||
if (NULL == (b[i] = BN_CTX_get(c))) {
|
||||
fprintf(stderr, "ERROR: BN_CTX_get() failed.\n");
|
||||
goto err;
|
||||
}
|
||||
if (BN_get_flags(b[i], BN_FLG_CONSTTIME) != 0) {
|
||||
fprintf(stderr, "ERROR: BN_FLG_CONSTTIME should not be set.\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
BN_CTX_end(c);
|
||||
return st;
|
||||
}
|
||||
|
||||
static int test_ctx_consttime_flag(void)
|
||||
{
|
||||
/*-
|
||||
* The constant-time flag should not "leak" among BN_CTX frames:
|
||||
*
|
||||
* - test_ctx_set_ct_flag() starts a frame in the given BN_CTX and
|
||||
* sets the BN_FLG_CONSTTIME flag on some of the BIGNUMs obtained
|
||||
* from the frame before ending it.
|
||||
* - test_ctx_check_ct_flag() then starts a new frame and gets a
|
||||
* number of BIGNUMs from it. In absence of leaks, none of the
|
||||
* BIGNUMs in the new frame should have BN_FLG_CONSTTIME set.
|
||||
*
|
||||
* In actual BN_CTX usage inside libcrypto the leak could happen at
|
||||
* any depth level in the BN_CTX stack, with varying results
|
||||
* depending on the patterns of sibling trees of nested function
|
||||
* calls sharing the same BN_CTX object, and the effect of
|
||||
* unintended BN_FLG_CONSTTIME on the called BN_* functions.
|
||||
*
|
||||
* This simple unit test abstracts away this complexity and verifies
|
||||
* that the leak does not happen between two sibling functions
|
||||
* sharing the same BN_CTX object at the same level of nesting.
|
||||
*
|
||||
*/
|
||||
BN_CTX *c = NULL;
|
||||
int st = 0;
|
||||
|
||||
if (NULL == (c = BN_CTX_new())) {
|
||||
fprintf(stderr, "ERROR: BN_CTX_new() failed.\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!test_ctx_set_ct_flag(c)
|
||||
|| !test_ctx_check_ct_flag(c))
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
BN_CTX_free(c);
|
||||
return st;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,18 @@
|
||||
*/
|
||||
int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||
int bn_from_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||
BN_CTX *ctx);
|
||||
int bn_to_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||
BN_CTX *ctx);
|
||||
int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *m);
|
||||
int bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *m);
|
||||
int bn_mul_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
int bn_sqr_fixed_top(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
|
||||
|
||||
int bn_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen);
|
||||
|
||||
BIGNUM *bn_lebin2bn(const unsigned char *s, int len, BIGNUM *ret);
|
||||
int bn_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen);
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
/* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
|
||||
#define CFLAGS "compiler: cl /MD /Ox /O2 /Ob2 -DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DOPENSSL_USE_APPLINK -I. -DOPENSSL_NO_IDEA -DOPENSSL_NO_RC5 -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_SSL2 -DOPENSSL_NO_KRB5 -DOPENSSL_NO_JPAKE -DOPENSSL_NO_WEAK_SSL_CIPHERS -DOPENSSL_NO_STATIC_ENGINE "
|
||||
#define PLATFORM "VC-WIN32"
|
||||
#define DATE "Tue Aug 14 16:04:24 2018"
|
||||
#define DATE "Mon Sep 16 10:27:05 2019"
|
||||
#endif
|
||||
#ifdef MK1MF_PLATFORM_BC_NT
|
||||
/* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
|
||||
#define CFLAGS "compiler: bcc32 -DWIN32_LEAN_AND_MEAN -q -w-ccc -w-rch -w-pia -w-aus -w-par -w-inl -c -tWC -tWM -DOPENSSL_SYSNAME_WIN32 -DL_ENDIAN -DDSO_WIN32 -D_stricmp=stricmp -D_strnicmp=strnicmp -O2 -ff -fp -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM -DOPENSSL_NO_IDEA -DOPENSSL_NO_RC5 -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_SSL2 -DOPENSSL_NO_KRB5 -DOPENSSL_NO_JPAKE -DOPENSSL_NO_WEAK_SSL_CIPHERS -DOPENSSL_NO_DYNAMIC_ENGINE "
|
||||
#define PLATFORM "BC-NT"
|
||||
#define DATE "Tue Aug 14 16:04:24 2018"
|
||||
#define DATE "Mon Sep 16 10:27:05 2019"
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2008 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2008-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -422,6 +422,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms,
|
||||
unsigned char *ek = NULL;
|
||||
size_t eklen;
|
||||
int ret = 0;
|
||||
size_t fixlen = 0;
|
||||
CMS_EncryptedContentInfo *ec;
|
||||
ec = cms->d.envelopedData->encryptedContentInfo;
|
||||
|
||||
@@ -430,6 +431,19 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cms->d.envelopedData->encryptedContentInfo->havenocert
|
||||
&& !cms->d.envelopedData->encryptedContentInfo->debug) {
|
||||
X509_ALGOR *calg = ec->contentEncryptionAlgorithm;
|
||||
const EVP_CIPHER *ciph = EVP_get_cipherbyobj(calg->algorithm);
|
||||
|
||||
if (ciph == NULL) {
|
||||
CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_UNKNOWN_CIPHER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fixlen = EVP_CIPHER_key_length(ciph);
|
||||
}
|
||||
|
||||
ktri->pctx = EVP_PKEY_CTX_new(pkey, NULL);
|
||||
if (!ktri->pctx)
|
||||
return 0;
|
||||
@@ -460,7 +474,9 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms,
|
||||
|
||||
if (EVP_PKEY_decrypt(ktri->pctx, ek, &eklen,
|
||||
ktri->encryptedKey->data,
|
||||
ktri->encryptedKey->length) <= 0) {
|
||||
ktri->encryptedKey->length) <= 0
|
||||
|| eklen == 0
|
||||
|| (fixlen != 0 && eklen != fixlen)) {
|
||||
CMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT, CMS_R_CMS_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2008 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2008-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -172,6 +172,8 @@ struct CMS_EncryptedContentInfo_st {
|
||||
size_t keylen;
|
||||
/* Set to 1 if we are debugging decrypt and don't fake keys for MMA */
|
||||
int debug;
|
||||
/* Set to 1 if we have no cert and need extra safety measures for MMA */
|
||||
int havenocert;
|
||||
};
|
||||
|
||||
struct CMS_RecipientInfo_st {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2008 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2008-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -737,6 +737,10 @@ int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert,
|
||||
cms->d.envelopedData->encryptedContentInfo->debug = 1;
|
||||
else
|
||||
cms->d.envelopedData->encryptedContentInfo->debug = 0;
|
||||
if (!cert)
|
||||
cms->d.envelopedData->encryptedContentInfo->havenocert = 1;
|
||||
else
|
||||
cms->d.envelopedData->encryptedContentInfo->havenocert = 0;
|
||||
if (!pk && !cert && !dcont && !out)
|
||||
return 1;
|
||||
if (pk && !CMS_decrypt_set1_pkey(cms, pk, cert))
|
||||
|
||||
@@ -80,12 +80,13 @@ clean:
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
conf_api.o: ../../e_os.h ../../include/openssl/bio.h
|
||||
conf_api.o: ../../include/openssl/conf.h ../../include/openssl/conf_api.h
|
||||
conf_api.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
conf_api.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
|
||||
conf_api.o: ../../include/openssl/conf_api.h ../../include/openssl/crypto.h
|
||||
conf_api.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
conf_api.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
conf_api.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
conf_api.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
conf_api.o: ../../include/openssl/symhacks.h conf_api.c
|
||||
conf_api.o: ../../include/openssl/symhacks.h ../cryptlib.h conf_api.c
|
||||
conf_def.o: ../../e_os.h ../../include/openssl/bio.h
|
||||
conf_def.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
|
||||
conf_def.o: ../../include/openssl/conf_api.h ../../include/openssl/crypto.h
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/conf_api.h>
|
||||
#include "e_os.h"
|
||||
@@ -141,7 +142,7 @@ char *_CONF_get_string(const CONF *conf, const char *section,
|
||||
if (v != NULL)
|
||||
return (v->value);
|
||||
if (strcmp(section, "ENV") == 0) {
|
||||
p = getenv(name);
|
||||
p = ossl_safe_getenv(name);
|
||||
if (p != NULL)
|
||||
return (p);
|
||||
}
|
||||
@@ -154,7 +155,7 @@ char *_CONF_get_string(const CONF *conf, const char *section,
|
||||
else
|
||||
return (NULL);
|
||||
} else
|
||||
return (getenv(name));
|
||||
return (ossl_safe_getenv(name));
|
||||
}
|
||||
|
||||
#if 0 /* There's no way to provide error checking
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 2001.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2001 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2001-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -530,7 +530,7 @@ char *CONF_get1_default_config_file(void)
|
||||
char *file;
|
||||
int len;
|
||||
|
||||
file = getenv("OPENSSL_CONF");
|
||||
file = ossl_safe_getenv("OPENSSL_CONF");
|
||||
if (file)
|
||||
return BUF_strdup(file);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Based on previous work by Bodo Moeller, Emilia Kasper, Adam Langley
|
||||
* (Google).
|
||||
* ====================================================================
|
||||
* Copyright (c) 2014 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2014-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -185,11 +185,29 @@ static inline unsigned char constant_time_eq_int_8(int a, int b)
|
||||
return constant_time_eq_8((unsigned)(a), (unsigned)(b));
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the value unmodified, but avoids optimizations.
|
||||
* The barriers prevent the compiler from narrowing down the
|
||||
* possible value range of the mask and ~mask in the select
|
||||
* statements, which avoids the recognition of the select
|
||||
* and turning it into a conditional load or branch.
|
||||
*/
|
||||
static inline unsigned int value_barrier(unsigned int a)
|
||||
{
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
|
||||
unsigned int r;
|
||||
__asm__("" : "=r"(r) : "0"(a));
|
||||
#else
|
||||
volatile unsigned int r = a;
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline unsigned int constant_time_select(unsigned int mask,
|
||||
unsigned int a,
|
||||
unsigned int b)
|
||||
{
|
||||
return (mask & a) | (~mask & b);
|
||||
return (value_barrier(mask) & a) | (value_barrier(~mask) & b);
|
||||
}
|
||||
|
||||
static inline unsigned char constant_time_select_8(unsigned char mask,
|
||||
@@ -204,6 +222,12 @@ static inline int constant_time_select_int(unsigned int mask, int a, int b)
|
||||
return (int)(constant_time_select(mask, (unsigned)(a), (unsigned)(b)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Expected usage pattern is to unconditionally set error and then
|
||||
* wipe it if there was no actual error. |clear| is 1 or 0.
|
||||
*/
|
||||
void err_clear_last_constant_time(int clear);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -104,6 +104,10 @@ void OPENSSL_showfatal(const char *fmta, ...);
|
||||
void *OPENSSL_stderr(void);
|
||||
extern int OPENSSL_NONPIC_relocated;
|
||||
|
||||
char *ossl_safe_getenv(const char *);
|
||||
|
||||
unsigned long OPENSSL_rdtsc(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -214,7 +214,8 @@ $! The contents of these variables are copied from the LIBOBJ variable in the
|
||||
$! corresponding Makefile from each corresponding subdirectory, with .o stripped
|
||||
$! and spaces replaced with commas.
|
||||
$ LIB_ = "cryptlib,mem,mem_dbg,cversion,ex_data,cpt_err,ebcdic,"+ -
|
||||
"uid,o_time,o_str,o_dir,o_fips,o_init,fips_ers,mem_clr"
|
||||
"uid,o_time,o_str,o_dir,o_fips,o_init,fips_ers,mem_clr,"+ -
|
||||
"getenv"
|
||||
$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err,obj_xref"
|
||||
$ LIB_MD2 = "md2_dgst,md2_one"
|
||||
$ LIB_MD4 = "md4_dgst,md4_one"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 2006.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006-2018 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2006-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -101,7 +101,7 @@ static int pkey_dh_init(EVP_PKEY_CTX *ctx)
|
||||
dctx = OPENSSL_malloc(sizeof(DH_PKEY_CTX));
|
||||
if (!dctx)
|
||||
return 0;
|
||||
dctx->prime_len = 1024;
|
||||
dctx->prime_len = 2048;
|
||||
dctx->subprime_len = -1;
|
||||
dctx->generator = 2;
|
||||
dctx->use_dsa = 0;
|
||||
|
||||
@@ -435,6 +435,12 @@ int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N,
|
||||
|
||||
EVP_MD_CTX_init(&mctx);
|
||||
|
||||
/* make sure L > N, otherwise we'll get trapped in an infinite loop */
|
||||
if (L <= N) {
|
||||
DSAerr(DSA_F_DSA_BUILTIN_PARAMGEN2, DSA_R_INVALID_PARAMETERS);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (evpmd == NULL) {
|
||||
if (N == 160)
|
||||
evpmd = EVP_sha1();
|
||||
|
||||
@@ -73,6 +73,8 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len,
|
||||
DSA_SIG *sig, DSA *dsa);
|
||||
static int dsa_init(DSA *dsa);
|
||||
static int dsa_finish(DSA *dsa);
|
||||
static BIGNUM *dsa_mod_inverse_fermat(const BIGNUM *k, const BIGNUM *q,
|
||||
BN_CTX *ctx);
|
||||
|
||||
static DSA_METHOD openssl_dsa_meth = {
|
||||
"OpenSSL DSA method",
|
||||
@@ -279,7 +281,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
|
||||
goto err;
|
||||
|
||||
/* Preallocate space */
|
||||
q_bits = BN_num_bits(dsa->q);
|
||||
q_bits = BN_num_bits(dsa->q) + sizeof(dsa->q->d[0]) * 16;
|
||||
if (!BN_set_bit(&k, q_bits)
|
||||
|| !BN_set_bit(&l, q_bits)
|
||||
|| !BN_set_bit(&m, q_bits))
|
||||
@@ -293,9 +295,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
|
||||
|
||||
if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) {
|
||||
BN_set_flags(&k, BN_FLG_CONSTTIME);
|
||||
BN_set_flags(&l, BN_FLG_CONSTTIME);
|
||||
}
|
||||
|
||||
|
||||
if (dsa->flags & DSA_FLAG_CACHE_MONT_P) {
|
||||
if (!BN_MONT_CTX_set_locked(&dsa->method_mont_p,
|
||||
CRYPTO_LOCK_DSA, dsa->p, ctx))
|
||||
@@ -334,7 +336,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
|
||||
goto err;
|
||||
|
||||
/* Compute part of 's = inv(k) (m + xr) mod q' */
|
||||
if ((kinv = BN_mod_inverse(NULL, &k, dsa->q, ctx)) == NULL)
|
||||
if ((kinv = dsa_mod_inverse_fermat(&k, dsa->q, ctx)) == NULL)
|
||||
goto err;
|
||||
|
||||
if (*kinvp != NULL)
|
||||
@@ -468,3 +470,31 @@ static int dsa_finish(DSA *dsa)
|
||||
BN_MONT_CTX_free(dsa->method_mont_p);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the inverse of k modulo q.
|
||||
* Since q is prime, Fermat's Little Theorem applies, which reduces this to
|
||||
* mod-exp operation. Both the exponent and modulus are public information
|
||||
* so a mod-exp that doesn't leak the base is sufficient. A newly allocated
|
||||
* BIGNUM is returned which the caller must free.
|
||||
*/
|
||||
static BIGNUM *dsa_mod_inverse_fermat(const BIGNUM *k, const BIGNUM *q,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *res = NULL;
|
||||
BIGNUM *r, e;
|
||||
|
||||
if ((r = BN_new()) == NULL)
|
||||
return NULL;
|
||||
|
||||
BN_init(&e);
|
||||
|
||||
if (BN_set_word(r, 2)
|
||||
&& BN_sub(&e, q, r)
|
||||
&& BN_mod_exp_mont(r, k, &e, q, ctx, NULL))
|
||||
res = r;
|
||||
else
|
||||
BN_free(r);
|
||||
BN_free(&e);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 2006.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006-2018 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2006-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -69,8 +69,8 @@
|
||||
|
||||
typedef struct {
|
||||
/* Parameter gen parameters */
|
||||
int nbits; /* size of p in bits (default: 1024) */
|
||||
int qbits; /* size of q in bits (default: 160) */
|
||||
int nbits; /* size of p in bits (default: 2048) */
|
||||
int qbits; /* size of q in bits (default: 224) */
|
||||
const EVP_MD *pmd; /* MD for parameter generation */
|
||||
/* Keygen callback info */
|
||||
int gentmp[2];
|
||||
@@ -84,8 +84,8 @@ static int pkey_dsa_init(EVP_PKEY_CTX *ctx)
|
||||
dctx = OPENSSL_malloc(sizeof(DSA_PKEY_CTX));
|
||||
if (!dctx)
|
||||
return 0;
|
||||
dctx->nbits = 1024;
|
||||
dctx->qbits = 160;
|
||||
dctx->nbits = 2048;
|
||||
dctx->qbits = 224;
|
||||
dctx->pmd = NULL;
|
||||
dctx->md = NULL;
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ ec_curve.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
ec_curve.o: ../../include/openssl/obj_mac.h ../../include/openssl/opensslconf.h
|
||||
ec_curve.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
ec_curve.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
ec_curve.o: ../../include/openssl/symhacks.h ec_curve.c ec_lcl.h
|
||||
ec_curve.o: ../../include/openssl/symhacks.h ../bn_int.h ec_curve.c ec_lcl.h
|
||||
ec_cvt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
ec_cvt.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
|
||||
ec_cvt.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* \author Originally written by Bodo Moeller for the OpenSSL project
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -1073,6 +1073,7 @@ int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
void ERR_load_EC_strings(void);
|
||||
|
||||
/* Error codes for the EC functions. */
|
||||
@@ -1270,6 +1271,7 @@ void ERR_load_EC_strings(void);
|
||||
# define EC_R_SLOT_FULL 108
|
||||
# define EC_R_UNDEFINED_GENERATOR 113
|
||||
# define EC_R_UNDEFINED_ORDER 128
|
||||
# define EC_R_UNKNOWN_COFACTOR 152
|
||||
# define EC_R_UNKNOWN_GROUP 129
|
||||
# define EC_R_UNKNOWN_ORDER 114
|
||||
# define EC_R_UNSUPPORTED_FIELD 131
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -299,7 +299,7 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
point_conversion_form_t form;
|
||||
int y_bit;
|
||||
int y_bit, m;
|
||||
BN_CTX *new_ctx = NULL;
|
||||
BIGNUM *x, *y, *yxi;
|
||||
size_t field_len, enc_len;
|
||||
@@ -332,7 +332,8 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
return EC_POINT_set_to_infinity(group, point);
|
||||
}
|
||||
|
||||
field_len = (EC_GROUP_get_degree(group) + 7) / 8;
|
||||
m = EC_GROUP_get_degree(group);
|
||||
field_len = (m + 7) / 8;
|
||||
enc_len =
|
||||
(form ==
|
||||
POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2 * field_len;
|
||||
@@ -357,7 +358,7 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
|
||||
if (!BN_bin2bn(buf + 1, field_len, x))
|
||||
goto err;
|
||||
if (BN_ucmp(x, &group->field) >= 0) {
|
||||
if (BN_num_bits(x) > m) {
|
||||
ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);
|
||||
goto err;
|
||||
}
|
||||
@@ -369,7 +370,7 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
} else {
|
||||
if (!BN_bin2bn(buf + 1 + field_len, field_len, y))
|
||||
goto err;
|
||||
if (BN_ucmp(y, &group->field) >= 0) {
|
||||
if (BN_num_bits(y) > m) {
|
||||
ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);
|
||||
goto err;
|
||||
}
|
||||
@@ -382,16 +383,14 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* EC_POINT_set_affine_coordinates_GF2m is responsible for checking that
|
||||
* the point is on the curve.
|
||||
*/
|
||||
if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* test required by X9.62 */
|
||||
if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
|
||||
ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_POINT_IS_NOT_ON_CURVE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
|
||||
@@ -601,7 +601,7 @@ static int ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
|
||||
|
||||
case ASN1_PKEY_CTRL_DEFAULT_MD_NID:
|
||||
*(int *)arg2 = NID_sha256;
|
||||
return 2;
|
||||
return 1;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Written by Nils Larsch for the OpenSSL project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000-2003 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2000-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -695,10 +695,12 @@ ECPKPARAMETERS *ec_asn1_group2pkparameters(const EC_GROUP *group,
|
||||
static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
|
||||
{
|
||||
int ok = 0, tmp;
|
||||
EC_GROUP *ret = NULL;
|
||||
EC_GROUP *ret = NULL, *dup = NULL;
|
||||
BIGNUM *p = NULL, *a = NULL, *b = NULL;
|
||||
EC_POINT *point = NULL;
|
||||
long field_bits;
|
||||
int curve_name = NID_undef;
|
||||
BN_CTX *ctx = NULL;
|
||||
|
||||
if (!params->fieldID || !params->fieldID->fieldType ||
|
||||
!params->fieldID->p.ptr) {
|
||||
@@ -914,13 +916,75 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if the explicit parameters group just created matches one of the
|
||||
* built-in curves.
|
||||
*
|
||||
* We create a copy of the group just built, so that we can remove optional
|
||||
* fields for the lookup: we do this to avoid the possibility that one of
|
||||
* the optional parameters is used to force the library into using a less
|
||||
* performant and less secure EC_METHOD instead of the specialized one.
|
||||
* In any case, `seed` is not really used in any computation, while a
|
||||
* cofactor different from the one in the built-in table is just
|
||||
* mathematically wrong anyway and should not be used.
|
||||
*/
|
||||
if ((ctx = BN_CTX_new()) == NULL) {
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
if ((dup = EC_GROUP_dup(ret)) == NULL
|
||||
|| EC_GROUP_set_seed(dup, NULL, 0) != 1
|
||||
|| !EC_GROUP_set_generator(dup, point, a, NULL)) {
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
if ((curve_name = ec_curve_nid_from_params(dup, ctx)) != NID_undef) {
|
||||
/*
|
||||
* The input explicit parameters successfully matched one of the
|
||||
* built-in curves: often for built-in curves we have specialized
|
||||
* methods with better performance and hardening.
|
||||
*
|
||||
* In this case we replace the `EC_GROUP` created through explicit
|
||||
* parameters with one created from a named group.
|
||||
*/
|
||||
EC_GROUP *named_group = NULL;
|
||||
|
||||
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
/*
|
||||
* NID_wap_wsg_idm_ecid_wtls12 and NID_secp224r1 are both aliases for
|
||||
* the same curve, we prefer the SECP nid when matching explicit
|
||||
* parameters as that is associated with a specialized EC_METHOD.
|
||||
*/
|
||||
if (curve_name == NID_wap_wsg_idm_ecid_wtls12)
|
||||
curve_name = NID_secp224r1;
|
||||
#endif /* !def(OPENSSL_NO_EC_NISTP_64_GCC_128) */
|
||||
|
||||
if ((named_group = EC_GROUP_new_by_curve_name(curve_name)) == NULL) {
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
EC_GROUP_free(ret);
|
||||
ret = named_group;
|
||||
|
||||
/*
|
||||
* Set the flag so that EC_GROUPs created from explicit parameters are
|
||||
* serialized using explicit parameters by default.
|
||||
*
|
||||
* 0x0 = OPENSSL_EC_EXPLICIT_CURVE
|
||||
*/
|
||||
EC_GROUP_set_asn1_flag(ret, 0x0);
|
||||
}
|
||||
|
||||
ok = 1;
|
||||
|
||||
err:if (!ok) {
|
||||
err:
|
||||
if (!ok) {
|
||||
if (ret)
|
||||
EC_GROUP_clear_free(ret);
|
||||
EC_GROUP_free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
if (dup)
|
||||
EC_GROUP_free(dup);
|
||||
|
||||
if (p)
|
||||
BN_free(p);
|
||||
@@ -930,6 +994,8 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
|
||||
BN_free(b);
|
||||
if (point)
|
||||
EC_POINT_free(point);
|
||||
if (ctx)
|
||||
BN_CTX_free(ctx);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
@@ -990,7 +1056,7 @@ EC_GROUP *d2i_ECPKParameters(EC_GROUP **a, const unsigned char **in, long len)
|
||||
}
|
||||
|
||||
if (a && *a)
|
||||
EC_GROUP_clear_free(*a);
|
||||
EC_GROUP_free(*a);
|
||||
if (a)
|
||||
*a = group;
|
||||
|
||||
@@ -1040,7 +1106,7 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
|
||||
|
||||
if (priv_key->parameters) {
|
||||
if (ret->group)
|
||||
EC_GROUP_clear_free(ret->group);
|
||||
EC_GROUP_free(ret->group);
|
||||
ret->group = ec_asn1_pkparameters2group(priv_key->parameters);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Written by Nils Larsch for the OpenSSL project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2010 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -75,6 +75,8 @@
|
||||
#include <openssl/obj_mac.h>
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
#include "bn_int.h"
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
# include <openssl/fips.h>
|
||||
#endif
|
||||
@@ -3246,3 +3248,115 @@ int EC_curve_nist2nid(const char *name)
|
||||
}
|
||||
return NID_undef;
|
||||
}
|
||||
|
||||
#define NUM_BN_FIELDS 6
|
||||
/*
|
||||
* Validates EC domain parameter data for known named curves.
|
||||
* This can be used when a curve is loaded explicitly (without a curve
|
||||
* name) or to validate that domain parameters have not been modified.
|
||||
*
|
||||
* Returns: The nid associated with the found named curve, or NID_undef
|
||||
* if not found. If there was an error it returns -1.
|
||||
*/
|
||||
int ec_curve_nid_from_params(const EC_GROUP *group, BN_CTX *ctx)
|
||||
{
|
||||
int ret = -1, nid, len, field_type, param_len;
|
||||
size_t i, seed_len;
|
||||
const unsigned char *seed, *params_seed, *params;
|
||||
unsigned char *param_bytes = NULL;
|
||||
const EC_CURVE_DATA *data;
|
||||
const EC_POINT *generator = NULL;
|
||||
const EC_METHOD *meth;
|
||||
const BIGNUM *cofactor = NULL;
|
||||
/* An array of BIGNUMs for (p, a, b, x, y, order) */
|
||||
BIGNUM *bn[NUM_BN_FIELDS] = {NULL, NULL, NULL, NULL, NULL, NULL};
|
||||
|
||||
meth = EC_GROUP_method_of(group);
|
||||
if (meth == NULL)
|
||||
return -1;
|
||||
/* Use the optional named curve nid as a search field */
|
||||
nid = EC_GROUP_get_curve_name(group);
|
||||
field_type = EC_METHOD_get_field_type(meth);
|
||||
seed_len = EC_GROUP_get_seed_len(group);
|
||||
seed = EC_GROUP_get0_seed(group);
|
||||
cofactor = &group->cofactor;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
/*
|
||||
* The built-in curves contains data fields (p, a, b, x, y, order) that are
|
||||
* all zero-padded to be the same size. The size of the padding is
|
||||
* determined by either the number of bytes in the field modulus (p) or the
|
||||
* EC group order, whichever is larger.
|
||||
*/
|
||||
param_len = BN_num_bytes(&group->order);
|
||||
len = BN_num_bytes(&group->field);
|
||||
if (len > param_len)
|
||||
param_len = len;
|
||||
|
||||
/* Allocate space to store the padded data for (p, a, b, x, y, order) */
|
||||
param_bytes = OPENSSL_malloc(param_len * NUM_BN_FIELDS);
|
||||
if (param_bytes == NULL)
|
||||
goto end;
|
||||
|
||||
/* Create the bignums */
|
||||
for (i = 0; i < NUM_BN_FIELDS; ++i) {
|
||||
if ((bn[i] = BN_CTX_get(ctx)) == NULL)
|
||||
goto end;
|
||||
}
|
||||
/*
|
||||
* Fill in the bn array with the same values as the internal curves
|
||||
* i.e. the values are p, a, b, x, y, order.
|
||||
*/
|
||||
/* Get p, a & b */
|
||||
if (!(ec_group_get_curve(group, bn[0], bn[1], bn[2], ctx)
|
||||
&& ((generator = EC_GROUP_get0_generator(group)) != NULL)
|
||||
/* Get x & y */
|
||||
&& ec_point_get_affine_coordinates(group, generator, bn[3], bn[4], ctx)
|
||||
/* Get order */
|
||||
&& EC_GROUP_get_order(group, bn[5], ctx)))
|
||||
goto end;
|
||||
|
||||
/*
|
||||
* Convert the bignum array to bytes that are joined together to form
|
||||
* a single buffer that contains data for all fields.
|
||||
* (p, a, b, x, y, order) are all zero padded to be the same size.
|
||||
*/
|
||||
for (i = 0; i < NUM_BN_FIELDS; ++i) {
|
||||
if (bn_bn2binpad(bn[i], ¶m_bytes[i*param_len], param_len) <= 0)
|
||||
goto end;
|
||||
}
|
||||
|
||||
for (i = 0; i < curve_list_length; i++) {
|
||||
const ec_list_element curve = curve_list[i];
|
||||
|
||||
data = curve.data;
|
||||
/* Get the raw order byte data */
|
||||
params_seed = (const unsigned char *)(data + 1); /* skip header */
|
||||
params = params_seed + data->seed_len;
|
||||
|
||||
/* Look for unique fields in the fixed curve data */
|
||||
if (data->field_type == field_type
|
||||
&& param_len == data->param_len
|
||||
&& (nid <= 0 || nid == curve.nid)
|
||||
/* check the optional cofactor (ignore if its zero) */
|
||||
&& (BN_is_zero(cofactor)
|
||||
|| BN_is_word(cofactor, (const BN_ULONG)curve.data->cofactor))
|
||||
/* Check the optional seed (ignore if its not set) */
|
||||
&& (data->seed_len == 0 || seed_len == 0
|
||||
|| ((size_t)data->seed_len == seed_len
|
||||
&& memcmp(params_seed, seed, seed_len) == 0))
|
||||
/* Check that the groups params match the built-in curve params */
|
||||
&& memcmp(param_bytes, params, param_len * NUM_BN_FIELDS)
|
||||
== 0) {
|
||||
ret = curve.nid;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
/* Gets here if the group was not found */
|
||||
ret = NID_undef;
|
||||
end:
|
||||
OPENSSL_free(param_bytes);
|
||||
BN_CTX_end(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* crypto/ec/ec_err.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2015 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -310,6 +310,7 @@ static ERR_STRING_DATA EC_str_reasons[] = {
|
||||
{ERR_REASON(EC_R_SLOT_FULL), "slot full"},
|
||||
{ERR_REASON(EC_R_UNDEFINED_GENERATOR), "undefined generator"},
|
||||
{ERR_REASON(EC_R_UNDEFINED_ORDER), "undefined order"},
|
||||
{ERR_REASON(EC_R_UNKNOWN_COFACTOR), "unknown cofactor"},
|
||||
{ERR_REASON(EC_R_UNKNOWN_GROUP), "unknown group"},
|
||||
{ERR_REASON(EC_R_UNKNOWN_ORDER), "unknown order"},
|
||||
{ERR_REASON(EC_R_UNSUPPORTED_FIELD), "unsupported field"},
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Originally written by Bodo Moeller for the OpenSSL project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2010 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -214,7 +214,7 @@ struct ec_group_st {
|
||||
int asn1_flag; /* flag to control the asn1 encoding */
|
||||
/*
|
||||
* Kludge: upper bit of ans1_flag is used to denote structure
|
||||
* version. Is set, then last field is present. This is done
|
||||
* version. If set, then last field is present. This is done
|
||||
* for interoperation with FIPS code.
|
||||
*/
|
||||
#define EC_GROUP_ASN1_FLAG_MASK 0x7fffffff
|
||||
@@ -549,7 +549,6 @@ void ec_GFp_nistp_points_make_affine_internal(size_t num, void *point_array,
|
||||
void ec_GFp_nistp_recode_scalar_bits(unsigned char *sign,
|
||||
unsigned char *digit, unsigned char in);
|
||||
#endif
|
||||
int ec_precompute_mont_data(EC_GROUP *);
|
||||
|
||||
#ifdef ECP_NISTZ256_ASM
|
||||
/** Returns GFp methods using montgomery multiplication, with x86-64 optimized
|
||||
@@ -566,3 +565,18 @@ EC_GROUP *FIPS_ec_group_new_curve_gf2m(const BIGNUM *p, const BIGNUM *a,
|
||||
const BIGNUM *b, BN_CTX *ctx);
|
||||
EC_GROUP *FIPS_ec_group_new_by_curve_name(int nid);
|
||||
#endif
|
||||
|
||||
int ec_curve_nid_from_params(const EC_GROUP *group, BN_CTX *ctx);
|
||||
|
||||
/*
|
||||
* The next 2 functions are just internal wrappers around the omonimous
|
||||
* functions with either the `_GFp` or the `_GF2m` suffix.
|
||||
*
|
||||
* They are meant to facilitate backporting of code from newer branches, where
|
||||
* the public API includes a "field agnostic" version of these 2 functions.
|
||||
*/
|
||||
int ec_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
|
||||
BIGNUM *b, BN_CTX *ctx);
|
||||
int ec_point_get_affine_coordinates(const EC_GROUP *group,
|
||||
const EC_POINT *point, BIGNUM *x,
|
||||
BIGNUM *y, BN_CTX *ctx);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Originally written by Bodo Moeller for the OpenSSL project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2018 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -70,6 +70,10 @@
|
||||
|
||||
const char EC_version[] = "EC" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static int ec_precompute_mont_data(EC_GROUP *group);
|
||||
|
||||
/* functions for EC_GROUP objects */
|
||||
|
||||
EC_GROUP *EC_GROUP_new(const EC_METHOD *meth)
|
||||
@@ -290,6 +294,67 @@ int EC_METHOD_get_field_type(const EC_METHOD *meth)
|
||||
return meth->field_type;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Try computing cofactor from the generator order (n) and field cardinality (q).
|
||||
* This works for all curves of cryptographic interest.
|
||||
*
|
||||
* Hasse thm: q + 1 - 2*sqrt(q) <= n*h <= q + 1 + 2*sqrt(q)
|
||||
* h_min = (q + 1 - 2*sqrt(q))/n
|
||||
* h_max = (q + 1 + 2*sqrt(q))/n
|
||||
* h_max - h_min = 4*sqrt(q)/n
|
||||
* So if n > 4*sqrt(q) holds, there is only one possible value for h:
|
||||
* h = \lfloor (h_min + h_max)/2 \rceil = \lfloor (q + 1)/n \rceil
|
||||
*
|
||||
* Otherwise, zero cofactor and return success.
|
||||
*/
|
||||
static int ec_guess_cofactor(EC_GROUP *group) {
|
||||
int ret = 0;
|
||||
BN_CTX *ctx = NULL;
|
||||
BIGNUM *q = NULL;
|
||||
|
||||
/*-
|
||||
* If the cofactor is too large, we cannot guess it.
|
||||
* The RHS of below is a strict overestimate of lg(4 * sqrt(q))
|
||||
*/
|
||||
if (BN_num_bits(&group->order) <= (BN_num_bits(&group->field) + 1) / 2 + 3) {
|
||||
/* default to 0 */
|
||||
BN_zero(&group->cofactor);
|
||||
/* return success */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((ctx = BN_CTX_new()) == NULL)
|
||||
return 0;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
if ((q = BN_CTX_get(ctx)) == NULL)
|
||||
goto err;
|
||||
|
||||
/* set q = 2**m for binary fields; q = p otherwise */
|
||||
if (group->meth->field_type == NID_X9_62_characteristic_two_field) {
|
||||
BN_zero(q);
|
||||
if (!BN_set_bit(q, BN_num_bits(&group->field) - 1))
|
||||
goto err;
|
||||
} else {
|
||||
if (!BN_copy(q, &group->field))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* compute h = \lfloor (q + 1)/n \rceil = \lfloor (q + 1 + n/2)/n \rfloor */
|
||||
if (!BN_rshift1(&group->cofactor, &group->order) /* n/2 */
|
||||
|| !BN_add(&group->cofactor, &group->cofactor, q) /* q + n/2 */
|
||||
/* q + 1 + n/2 */
|
||||
|| !BN_add(&group->cofactor, &group->cofactor, BN_value_one())
|
||||
/* (q + 1 + n/2)/n */
|
||||
|| !BN_div(&group->cofactor, NULL, &group->cofactor, &group->order, ctx))
|
||||
goto err;
|
||||
ret = 1;
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
|
||||
const BIGNUM *order, const BIGNUM *cofactor)
|
||||
{
|
||||
@@ -298,6 +363,33 @@ int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* require group->field >= 1 */
|
||||
if (BN_is_zero(&group->field) || BN_is_negative(&group->field)) {
|
||||
ECerr(EC_F_EC_GROUP_SET_GENERATOR, EC_R_INVALID_FIELD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-
|
||||
* - require order >= 1
|
||||
* - enforce upper bound due to Hasse thm: order can be no more than one bit
|
||||
* longer than field cardinality
|
||||
*/
|
||||
if (order == NULL || BN_is_zero(order) || BN_is_negative(order)
|
||||
|| BN_num_bits(order) > BN_num_bits(&group->field) + 1) {
|
||||
ECerr(EC_F_EC_GROUP_SET_GENERATOR, EC_R_INVALID_GROUP_ORDER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Unfortunately the cofactor is an optional field in many standards.
|
||||
* Internally, the lib uses 0 cofactor as a marker for "unknown cofactor".
|
||||
* So accept cofactor == NULL or cofactor >= 0.
|
||||
*/
|
||||
if (cofactor != NULL && BN_is_negative(cofactor)) {
|
||||
ECerr(EC_F_EC_GROUP_SET_GENERATOR, EC_R_UNKNOWN_COFACTOR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (group->generator == NULL) {
|
||||
group->generator = EC_POINT_new(group);
|
||||
if (group->generator == NULL)
|
||||
@@ -306,29 +398,37 @@ int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
|
||||
if (!EC_POINT_copy(group->generator, generator))
|
||||
return 0;
|
||||
|
||||
if (order != NULL) {
|
||||
if (!BN_copy(&group->order, order))
|
||||
return 0;
|
||||
} else
|
||||
BN_zero(&group->order);
|
||||
|
||||
if (cofactor != NULL) {
|
||||
/* Either take the provided positive cofactor, or try to compute it */
|
||||
if (cofactor != NULL && !BN_is_zero(cofactor)) {
|
||||
if (!BN_copy(&group->cofactor, cofactor))
|
||||
return 0;
|
||||
} else
|
||||
} else if (!ec_guess_cofactor(group)) {
|
||||
BN_zero(&group->cofactor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
/*-
|
||||
* Access to the `mont_data` field of an EC_GROUP struct should always be
|
||||
* guarded by an EC_GROUP_VERSION(group) check to avoid OOB accesses, as the
|
||||
* group might come from the FIPS module, which does not define the
|
||||
* `mont_data` field inside the EC_GROUP structure.
|
||||
*/
|
||||
if (EC_GROUP_VERSION(group)) {
|
||||
/*-
|
||||
* Some groups have an order with
|
||||
* factors of two, which makes the Montgomery setup fail.
|
||||
* |group->mont_data| will be NULL in this case.
|
||||
*/
|
||||
if (BN_is_odd(&group->order)) {
|
||||
if (BN_is_odd(&group->order))
|
||||
return ec_precompute_mont_data(group);
|
||||
}
|
||||
|
||||
BN_MONT_CTX_free(group->mont_data);
|
||||
group->mont_data = NULL;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -860,7 +960,15 @@ int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,
|
||||
EC_R_INCOMPATIBLE_OBJECTS);
|
||||
return 0;
|
||||
}
|
||||
return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
|
||||
if (!group->meth->point_set_affine_coordinates(group, point, x, y, ctx))
|
||||
return 0;
|
||||
|
||||
if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
|
||||
ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP,
|
||||
EC_R_POINT_IS_NOT_ON_CURVE);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
@@ -878,7 +986,15 @@ int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group,
|
||||
EC_R_INCOMPATIBLE_OBJECTS);
|
||||
return 0;
|
||||
}
|
||||
return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
|
||||
if (!group->meth->point_set_affine_coordinates(group, point, x, y, ctx))
|
||||
return 0;
|
||||
|
||||
if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
|
||||
ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M,
|
||||
EC_R_POINT_IS_NOT_ON_CURVE);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1098,18 +1214,23 @@ int EC_GROUP_have_precompute_mult(const EC_GROUP *group)
|
||||
* been performed */
|
||||
}
|
||||
|
||||
/*
|
||||
/*-
|
||||
* ec_precompute_mont_data sets |group->mont_data| from |group->order| and
|
||||
* returns one on success. On error it returns zero.
|
||||
*
|
||||
* Note: this function must be called only after verifying that
|
||||
* EC_GROUP_VERSION(group) returns true.
|
||||
* The reason for this is that access to the `mont_data` field of an EC_GROUP
|
||||
* struct should always be guarded by an EC_GROUP_VERSION(group) check to avoid
|
||||
* OOB accesses, as the group might come from the FIPS module, which does not
|
||||
* define the `mont_data` field inside the EC_GROUP structure.
|
||||
*/
|
||||
static
|
||||
int ec_precompute_mont_data(EC_GROUP *group)
|
||||
{
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
int ret = 0;
|
||||
|
||||
if (!EC_GROUP_VERSION(group))
|
||||
goto err;
|
||||
|
||||
if (group->mont_data) {
|
||||
BN_MONT_CTX_free(group->mont_data);
|
||||
group->mont_data = NULL;
|
||||
@@ -1136,3 +1257,60 @@ int ec_precompute_mont_data(EC_GROUP *group)
|
||||
BN_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is just a wrapper around the public functions
|
||||
* - EC_GROUP_get_curve_GF2m
|
||||
* - EC_GROUP_get_curve_GFp
|
||||
*
|
||||
* It is meant to facilitate backporting of code from newer branches, where
|
||||
* the public API includes a "field agnostic" version of it.
|
||||
*/
|
||||
int ec_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
|
||||
BIGNUM *b, BN_CTX *ctx)
|
||||
{
|
||||
int field_nid;
|
||||
|
||||
field_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(group));
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
if (field_nid == NID_X9_62_characteristic_two_field) {
|
||||
return EC_GROUP_get_curve_GF2m(group, p, a, b, ctx);
|
||||
} else
|
||||
#endif /* !def(OPENSSL_NO_EC2M) */
|
||||
if (field_nid == NID_X9_62_prime_field) {
|
||||
return EC_GROUP_get_curve_GFp(group, p, a, b, ctx);
|
||||
} else {
|
||||
/* this should never happen */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This is just a wrapper around the public functions
|
||||
* - EC_POINT_get_affine_coordinates_GF2m
|
||||
* - EC_POINT_get_affine_coordinates_GFp
|
||||
*
|
||||
* It is meant to facilitate backporting of code from newer branches, where
|
||||
* the public API includes a "field agnostic" version of it.
|
||||
*/
|
||||
int ec_point_get_affine_coordinates(const EC_GROUP *group,
|
||||
const EC_POINT *point, BIGNUM *x,
|
||||
BIGNUM *y, BN_CTX *ctx)
|
||||
{
|
||||
int field_nid;
|
||||
|
||||
field_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(group));
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
if (field_nid == NID_X9_62_characteristic_two_field) {
|
||||
return EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx);
|
||||
} else
|
||||
#endif /* !def(OPENSSL_NO_EC2M) */
|
||||
if (field_nid == NID_X9_62_prime_field) {
|
||||
return EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx);
|
||||
} else {
|
||||
/* this should never happen */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -310,6 +310,224 @@ static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len)
|
||||
return r;
|
||||
}
|
||||
|
||||
#define EC_POINT_BN_set_flags(P, flags) do { \
|
||||
BN_set_flags(&(P)->X, (flags)); \
|
||||
BN_set_flags(&(P)->Y, (flags)); \
|
||||
BN_set_flags(&(P)->Z, (flags)); \
|
||||
} while(0)
|
||||
|
||||
/*-
|
||||
* This functions computes (in constant time) a point multiplication over the
|
||||
* EC group.
|
||||
*
|
||||
* At a high level, it is Montgomery ladder with conditional swaps.
|
||||
*
|
||||
* It performs either a fixed scalar point multiplication
|
||||
* (scalar * generator)
|
||||
* when point is NULL, or a generic scalar point multiplication
|
||||
* (scalar * point)
|
||||
* when point is not NULL.
|
||||
*
|
||||
* scalar should be in the range [0,n) otherwise all constant time bets are off.
|
||||
*
|
||||
* NB: This says nothing about EC_POINT_add and EC_POINT_dbl,
|
||||
* which of course are not constant time themselves.
|
||||
*
|
||||
* The product is stored in r.
|
||||
*
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
static int ec_mul_consttime(const EC_GROUP *group, EC_POINT *r,
|
||||
const BIGNUM *scalar, const EC_POINT *point,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
int i, cardinality_bits, group_top, kbit, pbit, Z_is_one;
|
||||
EC_POINT *s = NULL;
|
||||
BIGNUM *k = NULL;
|
||||
BIGNUM *lambda = NULL;
|
||||
BIGNUM *cardinality = NULL;
|
||||
BN_CTX *new_ctx = NULL;
|
||||
int ret = 0;
|
||||
|
||||
if (ctx == NULL && (ctx = new_ctx = BN_CTX_new()) == NULL)
|
||||
return 0;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
s = EC_POINT_new(group);
|
||||
if (s == NULL)
|
||||
goto err;
|
||||
|
||||
if (point == NULL) {
|
||||
if (!EC_POINT_copy(s, group->generator))
|
||||
goto err;
|
||||
} else {
|
||||
if (!EC_POINT_copy(s, point))
|
||||
goto err;
|
||||
}
|
||||
|
||||
EC_POINT_BN_set_flags(s, BN_FLG_CONSTTIME);
|
||||
|
||||
cardinality = BN_CTX_get(ctx);
|
||||
lambda = BN_CTX_get(ctx);
|
||||
k = BN_CTX_get(ctx);
|
||||
if (k == NULL || !BN_mul(cardinality, &group->order, &group->cofactor, ctx))
|
||||
goto err;
|
||||
|
||||
/*
|
||||
* Group cardinalities are often on a word boundary.
|
||||
* So when we pad the scalar, some timing diff might
|
||||
* pop if it needs to be expanded due to carries.
|
||||
* So expand ahead of time.
|
||||
*/
|
||||
cardinality_bits = BN_num_bits(cardinality);
|
||||
group_top = cardinality->top;
|
||||
if ((bn_wexpand(k, group_top + 2) == NULL)
|
||||
|| (bn_wexpand(lambda, group_top + 2) == NULL))
|
||||
goto err;
|
||||
|
||||
if (!BN_copy(k, scalar))
|
||||
goto err;
|
||||
|
||||
BN_set_flags(k, BN_FLG_CONSTTIME);
|
||||
|
||||
if ((BN_num_bits(k) > cardinality_bits) || (BN_is_negative(k))) {
|
||||
/*-
|
||||
* this is an unusual input, and we don't guarantee
|
||||
* constant-timeness
|
||||
*/
|
||||
if (!BN_nnmod(k, k, cardinality, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!BN_add(lambda, k, cardinality))
|
||||
goto err;
|
||||
BN_set_flags(lambda, BN_FLG_CONSTTIME);
|
||||
if (!BN_add(k, lambda, cardinality))
|
||||
goto err;
|
||||
/*
|
||||
* lambda := scalar + cardinality
|
||||
* k := scalar + 2*cardinality
|
||||
*/
|
||||
kbit = BN_is_bit_set(lambda, cardinality_bits);
|
||||
BN_consttime_swap(kbit, k, lambda, group_top + 2);
|
||||
|
||||
group_top = group->field.top;
|
||||
if ((bn_wexpand(&s->X, group_top) == NULL)
|
||||
|| (bn_wexpand(&s->Y, group_top) == NULL)
|
||||
|| (bn_wexpand(&s->Z, group_top) == NULL)
|
||||
|| (bn_wexpand(&r->X, group_top) == NULL)
|
||||
|| (bn_wexpand(&r->Y, group_top) == NULL)
|
||||
|| (bn_wexpand(&r->Z, group_top) == NULL))
|
||||
goto err;
|
||||
|
||||
/* top bit is a 1, in a fixed pos */
|
||||
if (!EC_POINT_copy(r, s))
|
||||
goto err;
|
||||
|
||||
EC_POINT_BN_set_flags(r, BN_FLG_CONSTTIME);
|
||||
|
||||
if (!EC_POINT_dbl(group, s, s, ctx))
|
||||
goto err;
|
||||
|
||||
pbit = 0;
|
||||
|
||||
#define EC_POINT_CSWAP(c, a, b, w, t) do { \
|
||||
BN_consttime_swap(c, &(a)->X, &(b)->X, w); \
|
||||
BN_consttime_swap(c, &(a)->Y, &(b)->Y, w); \
|
||||
BN_consttime_swap(c, &(a)->Z, &(b)->Z, w); \
|
||||
t = ((a)->Z_is_one ^ (b)->Z_is_one) & (c); \
|
||||
(a)->Z_is_one ^= (t); \
|
||||
(b)->Z_is_one ^= (t); \
|
||||
} while(0)
|
||||
|
||||
/*-
|
||||
* The ladder step, with branches, is
|
||||
*
|
||||
* k[i] == 0: S = add(R, S), R = dbl(R)
|
||||
* k[i] == 1: R = add(S, R), S = dbl(S)
|
||||
*
|
||||
* Swapping R, S conditionally on k[i] leaves you with state
|
||||
*
|
||||
* k[i] == 0: T, U = R, S
|
||||
* k[i] == 1: T, U = S, R
|
||||
*
|
||||
* Then perform the ECC ops.
|
||||
*
|
||||
* U = add(T, U)
|
||||
* T = dbl(T)
|
||||
*
|
||||
* Which leaves you with state
|
||||
*
|
||||
* k[i] == 0: U = add(R, S), T = dbl(R)
|
||||
* k[i] == 1: U = add(S, R), T = dbl(S)
|
||||
*
|
||||
* Swapping T, U conditionally on k[i] leaves you with state
|
||||
*
|
||||
* k[i] == 0: R, S = T, U
|
||||
* k[i] == 1: R, S = U, T
|
||||
*
|
||||
* Which leaves you with state
|
||||
*
|
||||
* k[i] == 0: S = add(R, S), R = dbl(R)
|
||||
* k[i] == 1: R = add(S, R), S = dbl(S)
|
||||
*
|
||||
* So we get the same logic, but instead of a branch it's a
|
||||
* conditional swap, followed by ECC ops, then another conditional swap.
|
||||
*
|
||||
* Optimization: The end of iteration i and start of i-1 looks like
|
||||
*
|
||||
* ...
|
||||
* CSWAP(k[i], R, S)
|
||||
* ECC
|
||||
* CSWAP(k[i], R, S)
|
||||
* (next iteration)
|
||||
* CSWAP(k[i-1], R, S)
|
||||
* ECC
|
||||
* CSWAP(k[i-1], R, S)
|
||||
* ...
|
||||
*
|
||||
* So instead of two contiguous swaps, you can merge the condition
|
||||
* bits and do a single swap.
|
||||
*
|
||||
* k[i] k[i-1] Outcome
|
||||
* 0 0 No Swap
|
||||
* 0 1 Swap
|
||||
* 1 0 Swap
|
||||
* 1 1 No Swap
|
||||
*
|
||||
* This is XOR. pbit tracks the previous bit of k.
|
||||
*/
|
||||
|
||||
for (i = cardinality_bits - 1; i >= 0; i--) {
|
||||
kbit = BN_is_bit_set(k, i) ^ pbit;
|
||||
EC_POINT_CSWAP(kbit, r, s, group_top, Z_is_one);
|
||||
if (!EC_POINT_add(group, s, r, s, ctx))
|
||||
goto err;
|
||||
if (!EC_POINT_dbl(group, r, r, ctx))
|
||||
goto err;
|
||||
/*
|
||||
* pbit logic merges this cswap with that of the
|
||||
* next iteration
|
||||
*/
|
||||
pbit ^= kbit;
|
||||
}
|
||||
/* one final cswap to move the right value into r */
|
||||
EC_POINT_CSWAP(pbit, r, s, group_top, Z_is_one);
|
||||
#undef EC_POINT_CSWAP
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
EC_POINT_clear_free(s);
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(new_ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef EC_POINT_BN_set_flags
|
||||
|
||||
/*
|
||||
* TODO: table should be optimised for the wNAF-based implementation,
|
||||
* sometimes smaller windows will give better performance (thus the
|
||||
@@ -369,6 +587,34 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
|
||||
return EC_POINT_set_to_infinity(group, r);
|
||||
}
|
||||
|
||||
if (!BN_is_zero(&group->order) && !BN_is_zero(&group->cofactor)) {
|
||||
/*-
|
||||
* Handle the common cases where the scalar is secret, enforcing a constant
|
||||
* time scalar multiplication algorithm.
|
||||
*/
|
||||
if ((scalar != NULL) && (num == 0)) {
|
||||
/*-
|
||||
* In this case we want to compute scalar * GeneratorPoint: this
|
||||
* codepath is reached most prominently by (ephemeral) key generation
|
||||
* of EC cryptosystems (i.e. ECDSA keygen and sign setup, ECDH
|
||||
* keygen/first half), where the scalar is always secret. This is why
|
||||
* we ignore if BN_FLG_CONSTTIME is actually set and we always call the
|
||||
* constant time version.
|
||||
*/
|
||||
return ec_mul_consttime(group, r, scalar, NULL, ctx);
|
||||
}
|
||||
if ((scalar == NULL) && (num == 1)) {
|
||||
/*-
|
||||
* In this case we want to compute scalar * GenericPoint: this codepath
|
||||
* is reached most prominently by the second half of ECDH, where the
|
||||
* secret scalar is multiplied by the peer's public point. To protect
|
||||
* the secret scalar, we ignore if BN_FLG_CONSTTIME is actually set and
|
||||
* we always call the constant time version.
|
||||
*/
|
||||
return ec_mul_consttime(group, r, scalars[0], points[0], ctx);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
if (group->meth != points[i]->meth) {
|
||||
ECerr(EC_F_EC_WNAF_MUL, EC_R_INCOMPATIBLE_OBJECTS);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
# include <string.h>
|
||||
# include <openssl/err.h>
|
||||
# include "ec_lcl.h"
|
||||
# include "bn_int.h" /* bn_bn2lebinpad, bn_lebin2bn */
|
||||
|
||||
# if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
/* even with gcc, the typedef won't work for 32-bit platforms */
|
||||
@@ -334,34 +335,21 @@ static void felem_to_bin28(u8 out[28], const felem in)
|
||||
}
|
||||
}
|
||||
|
||||
/* To preserve endianness when using BN_bn2bin and BN_bin2bn */
|
||||
static void flip_endian(u8 *out, const u8 *in, unsigned len)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < len; ++i)
|
||||
out[i] = in[len - 1 - i];
|
||||
}
|
||||
|
||||
/* From OpenSSL BIGNUM to internal representation */
|
||||
static int BN_to_felem(felem out, const BIGNUM *bn)
|
||||
{
|
||||
felem_bytearray b_in;
|
||||
felem_bytearray b_out;
|
||||
unsigned num_bytes;
|
||||
int num_bytes;
|
||||
|
||||
/* BN_bn2bin eats leading zeroes */
|
||||
memset(b_out, 0, sizeof(b_out));
|
||||
num_bytes = BN_num_bytes(bn);
|
||||
if (num_bytes > sizeof(b_out)) {
|
||||
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
|
||||
return 0;
|
||||
}
|
||||
if (BN_is_negative(bn)) {
|
||||
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
|
||||
return 0;
|
||||
}
|
||||
num_bytes = BN_bn2bin(bn, b_in);
|
||||
flip_endian(b_out, b_in, num_bytes);
|
||||
num_bytes = bn_bn2lebinpad(bn, b_out, sizeof(b_out));
|
||||
if (num_bytes < 0) {
|
||||
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
|
||||
return 0;
|
||||
}
|
||||
bin28_to_felem(out, b_out);
|
||||
return 1;
|
||||
}
|
||||
@@ -369,10 +357,9 @@ static int BN_to_felem(felem out, const BIGNUM *bn)
|
||||
/* From internal representation to OpenSSL BIGNUM */
|
||||
static BIGNUM *felem_to_BN(BIGNUM *out, const felem in)
|
||||
{
|
||||
felem_bytearray b_in, b_out;
|
||||
felem_to_bin28(b_in, in);
|
||||
flip_endian(b_out, b_in, sizeof(b_out));
|
||||
return BN_bin2bn(b_out, sizeof(b_out), out);
|
||||
felem_bytearray b_out;
|
||||
felem_to_bin28(b_out, in);
|
||||
return bn_lebin2bn(b_out, sizeof(b_out), out);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
@@ -1426,8 +1413,7 @@ int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
felem_bytearray *secrets = NULL;
|
||||
felem(*pre_comp)[17][3] = NULL;
|
||||
felem *tmp_felems = NULL;
|
||||
felem_bytearray tmp;
|
||||
unsigned num_bytes;
|
||||
int num_bytes;
|
||||
int have_pre_comp = 0;
|
||||
size_t num_points = num;
|
||||
felem x_in, y_in, z_in, x_out, y_out, z_out;
|
||||
@@ -1509,14 +1495,12 @@ int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
memset(secrets, 0, num_points * sizeof(felem_bytearray));
|
||||
memset(pre_comp, 0, num_points * 17 * 3 * sizeof(felem));
|
||||
for (i = 0; i < num_points; ++i) {
|
||||
if (i == num)
|
||||
if (i == num) {
|
||||
/* the generator */
|
||||
{
|
||||
p = EC_GROUP_get0_generator(group);
|
||||
p_scalar = scalar;
|
||||
} else
|
||||
} else {
|
||||
/* the i^th point */
|
||||
{
|
||||
p = points[i];
|
||||
p_scalar = scalars[i];
|
||||
}
|
||||
@@ -1532,10 +1516,16 @@ int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
ECerr(EC_F_EC_GFP_NISTP224_POINTS_MUL, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
num_bytes = BN_bn2bin(tmp_scalar, tmp);
|
||||
} else
|
||||
num_bytes = BN_bn2bin(p_scalar, tmp);
|
||||
flip_endian(secrets[i], tmp, num_bytes);
|
||||
num_bytes = bn_bn2lebinpad(tmp_scalar,
|
||||
secrets[i], sizeof(secrets[i]));
|
||||
} else {
|
||||
num_bytes = bn_bn2lebinpad(p_scalar,
|
||||
secrets[i], sizeof(secrets[i]));
|
||||
}
|
||||
if (num_bytes < 0) {
|
||||
ECerr(EC_F_EC_GFP_NISTP224_POINTS_MUL, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
/* precompute multiples */
|
||||
if ((!BN_to_felem(x_out, &p->X)) ||
|
||||
(!BN_to_felem(y_out, &p->Y)) ||
|
||||
@@ -1578,20 +1568,21 @@ int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
ECerr(EC_F_EC_GFP_NISTP224_POINTS_MUL, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
num_bytes = BN_bn2bin(tmp_scalar, tmp);
|
||||
} else
|
||||
num_bytes = BN_bn2bin(scalar, tmp);
|
||||
flip_endian(g_secret, tmp, num_bytes);
|
||||
num_bytes = bn_bn2lebinpad(tmp_scalar, g_secret, sizeof(g_secret));
|
||||
} else {
|
||||
num_bytes = bn_bn2lebinpad(scalar, g_secret, sizeof(g_secret));
|
||||
}
|
||||
/* do the multiplication with generator precomputation */
|
||||
batch_mul(x_out, y_out, z_out,
|
||||
(const felem_bytearray(*))secrets, num_points,
|
||||
g_secret,
|
||||
mixed, (const felem(*)[17][3])pre_comp, g_pre_comp);
|
||||
} else
|
||||
} else {
|
||||
/* do the multiplication without generator precomputation */
|
||||
batch_mul(x_out, y_out, z_out,
|
||||
(const felem_bytearray(*))secrets, num_points,
|
||||
NULL, mixed, (const felem(*)[17][3])pre_comp, NULL);
|
||||
}
|
||||
/* reduce the output to its unique minimal representation */
|
||||
felem_contract(x_in, x_out);
|
||||
felem_contract(y_in, y_out);
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
# include <string.h>
|
||||
# include <openssl/err.h>
|
||||
# include "ec_lcl.h"
|
||||
# include "bn_int.h" /* bn_bn2lebinpad, bn_lebin2bn */
|
||||
|
||||
# if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
/* even with gcc, the typedef won't work for 32-bit platforms */
|
||||
@@ -144,34 +145,21 @@ static void smallfelem_to_bin32(u8 out[32], const smallfelem in)
|
||||
*((u64 *)&out[24]) = in[3];
|
||||
}
|
||||
|
||||
/* To preserve endianness when using BN_bn2bin and BN_bin2bn */
|
||||
static void flip_endian(u8 *out, const u8 *in, unsigned len)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < len; ++i)
|
||||
out[i] = in[len - 1 - i];
|
||||
}
|
||||
|
||||
/* BN_to_felem converts an OpenSSL BIGNUM into an felem */
|
||||
static int BN_to_felem(felem out, const BIGNUM *bn)
|
||||
{
|
||||
felem_bytearray b_in;
|
||||
felem_bytearray b_out;
|
||||
unsigned num_bytes;
|
||||
int num_bytes;
|
||||
|
||||
/* BN_bn2bin eats leading zeroes */
|
||||
memset(b_out, 0, sizeof(b_out));
|
||||
num_bytes = BN_num_bytes(bn);
|
||||
if (num_bytes > sizeof(b_out)) {
|
||||
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
|
||||
return 0;
|
||||
}
|
||||
if (BN_is_negative(bn)) {
|
||||
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
|
||||
return 0;
|
||||
}
|
||||
num_bytes = BN_bn2bin(bn, b_in);
|
||||
flip_endian(b_out, b_in, num_bytes);
|
||||
num_bytes = bn_bn2lebinpad(bn, b_out, sizeof(b_out));
|
||||
if (num_bytes < 0) {
|
||||
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
|
||||
return 0;
|
||||
}
|
||||
bin32_to_felem(out, b_out);
|
||||
return 1;
|
||||
}
|
||||
@@ -179,10 +167,9 @@ static int BN_to_felem(felem out, const BIGNUM *bn)
|
||||
/* felem_to_BN converts an felem into an OpenSSL BIGNUM */
|
||||
static BIGNUM *smallfelem_to_BN(BIGNUM *out, const smallfelem in)
|
||||
{
|
||||
felem_bytearray b_in, b_out;
|
||||
smallfelem_to_bin32(b_in, in);
|
||||
flip_endian(b_out, b_in, sizeof(b_out));
|
||||
return BN_bin2bn(b_out, sizeof(b_out), out);
|
||||
felem_bytearray b_out;
|
||||
smallfelem_to_bin32(b_out, in);
|
||||
return bn_lebin2bn(b_out, sizeof(b_out), out);
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -2014,8 +2001,8 @@ int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
felem_bytearray *secrets = NULL;
|
||||
smallfelem(*pre_comp)[17][3] = NULL;
|
||||
smallfelem *tmp_smallfelems = NULL;
|
||||
felem_bytearray tmp;
|
||||
unsigned i, num_bytes;
|
||||
unsigned i;
|
||||
int num_bytes;
|
||||
int have_pre_comp = 0;
|
||||
size_t num_points = num;
|
||||
smallfelem x_in, y_in, z_in;
|
||||
@@ -2097,17 +2084,15 @@ int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
memset(secrets, 0, num_points * sizeof(felem_bytearray));
|
||||
memset(pre_comp, 0, num_points * 17 * 3 * sizeof(smallfelem));
|
||||
for (i = 0; i < num_points; ++i) {
|
||||
if (i == num)
|
||||
if (i == num) {
|
||||
/*
|
||||
* we didn't have a valid precomputation, so we pick the
|
||||
* generator
|
||||
*/
|
||||
{
|
||||
p = EC_GROUP_get0_generator(group);
|
||||
p_scalar = scalar;
|
||||
} else
|
||||
} else {
|
||||
/* the i^th point */
|
||||
{
|
||||
p = points[i];
|
||||
p_scalar = scalars[i];
|
||||
}
|
||||
@@ -2123,10 +2108,16 @@ int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
ECerr(EC_F_EC_GFP_NISTP256_POINTS_MUL, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
num_bytes = BN_bn2bin(tmp_scalar, tmp);
|
||||
} else
|
||||
num_bytes = BN_bn2bin(p_scalar, tmp);
|
||||
flip_endian(secrets[i], tmp, num_bytes);
|
||||
num_bytes = bn_bn2lebinpad(tmp_scalar,
|
||||
secrets[i], sizeof(secrets[i]));
|
||||
} else {
|
||||
num_bytes = bn_bn2lebinpad(p_scalar,
|
||||
secrets[i], sizeof(secrets[i]));
|
||||
}
|
||||
if (num_bytes < 0) {
|
||||
ECerr(EC_F_EC_GFP_NISTP256_POINTS_MUL, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
/* precompute multiples */
|
||||
if ((!BN_to_felem(x_out, &p->X)) ||
|
||||
(!BN_to_felem(y_out, &p->Y)) ||
|
||||
@@ -2171,20 +2162,21 @@ int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
ECerr(EC_F_EC_GFP_NISTP256_POINTS_MUL, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
num_bytes = BN_bn2bin(tmp_scalar, tmp);
|
||||
} else
|
||||
num_bytes = BN_bn2bin(scalar, tmp);
|
||||
flip_endian(g_secret, tmp, num_bytes);
|
||||
num_bytes = bn_bn2lebinpad(tmp_scalar, g_secret, sizeof(g_secret));
|
||||
} else {
|
||||
num_bytes = bn_bn2lebinpad(scalar, g_secret, sizeof(g_secret));
|
||||
}
|
||||
/* do the multiplication with generator precomputation */
|
||||
batch_mul(x_out, y_out, z_out,
|
||||
(const felem_bytearray(*))secrets, num_points,
|
||||
g_secret,
|
||||
mixed, (const smallfelem(*)[17][3])pre_comp, g_pre_comp);
|
||||
} else
|
||||
} else {
|
||||
/* do the multiplication without generator precomputation */
|
||||
batch_mul(x_out, y_out, z_out,
|
||||
(const felem_bytearray(*))secrets, num_points,
|
||||
NULL, mixed, (const smallfelem(*)[17][3])pre_comp, NULL);
|
||||
}
|
||||
/* reduce the output to its unique minimal representation */
|
||||
felem_contract(x_in, x_out);
|
||||
felem_contract(y_in, y_out);
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
# include <string.h>
|
||||
# include <openssl/err.h>
|
||||
# include "ec_lcl.h"
|
||||
# include "bn_int.h" /* bn_bn2lebinpad, bn_lebin2bn */
|
||||
|
||||
# if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
/* even with gcc, the typedef won't work for 32-bit platforms */
|
||||
@@ -168,34 +169,21 @@ static void felem_to_bin66(u8 out[66], const felem in)
|
||||
(*((limb *) & out[58])) = in[8];
|
||||
}
|
||||
|
||||
/* To preserve endianness when using BN_bn2bin and BN_bin2bn */
|
||||
static void flip_endian(u8 *out, const u8 *in, unsigned len)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < len; ++i)
|
||||
out[i] = in[len - 1 - i];
|
||||
}
|
||||
|
||||
/* BN_to_felem converts an OpenSSL BIGNUM into an felem */
|
||||
static int BN_to_felem(felem out, const BIGNUM *bn)
|
||||
{
|
||||
felem_bytearray b_in;
|
||||
felem_bytearray b_out;
|
||||
unsigned num_bytes;
|
||||
int num_bytes;
|
||||
|
||||
/* BN_bn2bin eats leading zeroes */
|
||||
memset(b_out, 0, sizeof(b_out));
|
||||
num_bytes = BN_num_bytes(bn);
|
||||
if (num_bytes > sizeof(b_out)) {
|
||||
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
|
||||
return 0;
|
||||
}
|
||||
if (BN_is_negative(bn)) {
|
||||
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
|
||||
return 0;
|
||||
}
|
||||
num_bytes = BN_bn2bin(bn, b_in);
|
||||
flip_endian(b_out, b_in, num_bytes);
|
||||
num_bytes = bn_bn2lebinpad(bn, b_out, sizeof(b_out));
|
||||
if (num_bytes < 0) {
|
||||
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
|
||||
return 0;
|
||||
}
|
||||
bin66_to_felem(out, b_out);
|
||||
return 1;
|
||||
}
|
||||
@@ -203,10 +191,9 @@ static int BN_to_felem(felem out, const BIGNUM *bn)
|
||||
/* felem_to_BN converts an felem into an OpenSSL BIGNUM */
|
||||
static BIGNUM *felem_to_BN(BIGNUM *out, const felem in)
|
||||
{
|
||||
felem_bytearray b_in, b_out;
|
||||
felem_to_bin66(b_in, in);
|
||||
flip_endian(b_out, b_in, sizeof(b_out));
|
||||
return BN_bin2bn(b_out, sizeof(b_out), out);
|
||||
felem_bytearray b_out;
|
||||
felem_to_bin66(b_out, in);
|
||||
return bn_lebin2bn(b_out, sizeof(b_out), out);
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -356,10 +343,15 @@ static void felem_diff64(felem out, const felem in)
|
||||
static void felem_diff_128_64(largefelem out, const felem in)
|
||||
{
|
||||
/*
|
||||
* In order to prevent underflow, we add 0 mod p before subtracting.
|
||||
* In order to prevent underflow, we add 64p mod p (which is equivalent
|
||||
* to 0 mod p) before subtracting. p is 2^521 - 1, i.e. in binary a 521
|
||||
* digit number with all bits set to 1. See "The representation of field
|
||||
* elements" comment above for a description of how limbs are used to
|
||||
* represent a number. 64p is represented with 8 limbs containing a number
|
||||
* with 58 bits set and one limb with a number with 57 bits set.
|
||||
*/
|
||||
static const limb two63m6 = (((limb) 1) << 62) - (((limb) 1) << 5);
|
||||
static const limb two63m5 = (((limb) 1) << 62) - (((limb) 1) << 4);
|
||||
static const limb two63m6 = (((limb) 1) << 63) - (((limb) 1) << 6);
|
||||
static const limb two63m5 = (((limb) 1) << 63) - (((limb) 1) << 5);
|
||||
|
||||
out[0] += two63m6 - in[0];
|
||||
out[1] += two63m5 - in[1];
|
||||
@@ -1821,8 +1813,8 @@ int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
felem_bytearray *secrets = NULL;
|
||||
felem(*pre_comp)[17][3] = NULL;
|
||||
felem *tmp_felems = NULL;
|
||||
felem_bytearray tmp;
|
||||
unsigned i, num_bytes;
|
||||
unsigned i;
|
||||
int num_bytes;
|
||||
int have_pre_comp = 0;
|
||||
size_t num_points = num;
|
||||
felem x_in, y_in, z_in, x_out, y_out, z_out;
|
||||
@@ -1904,17 +1896,15 @@ int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
memset(secrets, 0, num_points * sizeof(felem_bytearray));
|
||||
memset(pre_comp, 0, num_points * 17 * 3 * sizeof(felem));
|
||||
for (i = 0; i < num_points; ++i) {
|
||||
if (i == num)
|
||||
if (i == num) {
|
||||
/*
|
||||
* we didn't have a valid precomputation, so we pick the
|
||||
* generator
|
||||
*/
|
||||
{
|
||||
p = EC_GROUP_get0_generator(group);
|
||||
p_scalar = scalar;
|
||||
} else
|
||||
} else {
|
||||
/* the i^th point */
|
||||
{
|
||||
p = points[i];
|
||||
p_scalar = scalars[i];
|
||||
}
|
||||
@@ -1930,10 +1920,16 @@ int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
num_bytes = BN_bn2bin(tmp_scalar, tmp);
|
||||
} else
|
||||
num_bytes = BN_bn2bin(p_scalar, tmp);
|
||||
flip_endian(secrets[i], tmp, num_bytes);
|
||||
num_bytes = bn_bn2lebinpad(tmp_scalar,
|
||||
secrets[i], sizeof(secrets[i]));
|
||||
} else {
|
||||
num_bytes = bn_bn2lebinpad(p_scalar,
|
||||
secrets[i], sizeof(secrets[i]));
|
||||
}
|
||||
if (num_bytes < 0) {
|
||||
ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
/* precompute multiples */
|
||||
if ((!BN_to_felem(x_out, &p->X)) ||
|
||||
(!BN_to_felem(y_out, &p->Y)) ||
|
||||
@@ -1976,21 +1972,22 @@ int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
|
||||
ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
num_bytes = BN_bn2bin(tmp_scalar, tmp);
|
||||
} else
|
||||
num_bytes = BN_bn2bin(scalar, tmp);
|
||||
flip_endian(g_secret, tmp, num_bytes);
|
||||
num_bytes = bn_bn2lebinpad(tmp_scalar, g_secret, sizeof(g_secret));
|
||||
} else {
|
||||
num_bytes = bn_bn2lebinpad(scalar, g_secret, sizeof(g_secret));
|
||||
}
|
||||
/* do the multiplication with generator precomputation */
|
||||
batch_mul(x_out, y_out, z_out,
|
||||
(const felem_bytearray(*))secrets, num_points,
|
||||
g_secret,
|
||||
mixed, (const felem(*)[17][3])pre_comp,
|
||||
(const felem(*)[3])g_pre_comp);
|
||||
} else
|
||||
} else {
|
||||
/* do the multiplication without generator precomputation */
|
||||
batch_mul(x_out, y_out, z_out,
|
||||
(const felem_bytearray(*))secrets, num_points,
|
||||
NULL, mixed, (const felem(*)[17][3])pre_comp, NULL);
|
||||
}
|
||||
/* reduce the output to its unique minimal representation */
|
||||
felem_contract(x_in, x_out);
|
||||
felem_contract(y_in, y_out);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* OpenSSL project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -408,16 +408,14 @@ int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* EC_POINT_set_affine_coordinates_GFp is responsible for checking that
|
||||
* the point is on the curve.
|
||||
*/
|
||||
if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* test required by X9.62 */
|
||||
if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
|
||||
ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_POINT_IS_NOT_ON_CURVE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Originally written by Bodo Moeller for the OpenSSL project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -325,7 +325,7 @@ static void prime_field_tests(void)
|
||||
EC_GROUP *P_160 = NULL, *P_192 = NULL, *P_224 = NULL, *P_256 =
|
||||
NULL, *P_384 = NULL, *P_521 = NULL;
|
||||
EC_POINT *P, *Q, *R;
|
||||
BIGNUM *x, *y, *z;
|
||||
BIGNUM *x, *y, *z, *yplusone;
|
||||
unsigned char buf[100];
|
||||
size_t i, len;
|
||||
int k;
|
||||
@@ -405,7 +405,8 @@ static void prime_field_tests(void)
|
||||
x = BN_new();
|
||||
y = BN_new();
|
||||
z = BN_new();
|
||||
if (!x || !y || !z)
|
||||
yplusone = BN_new();
|
||||
if (x == NULL || y == NULL || z == NULL || yplusone == NULL)
|
||||
ABORT;
|
||||
|
||||
if (!BN_hex2bn(&x, "D"))
|
||||
@@ -542,6 +543,14 @@ static void prime_field_tests(void)
|
||||
ABORT;
|
||||
if (!BN_hex2bn(&y, "23a628553168947d59dcc912042351377ac5fb32"))
|
||||
ABORT;
|
||||
if (!BN_add(yplusone, y, BN_value_one()))
|
||||
ABORT;
|
||||
/*
|
||||
* When (x, y) is on the curve, (x, y + 1) is, as it happens, not,
|
||||
* and therefore setting the coordinates should fail.
|
||||
*/
|
||||
if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))
|
||||
ABORT;
|
||||
if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx))
|
||||
ABORT;
|
||||
if (EC_POINT_is_on_curve(group, P, ctx) <= 0)
|
||||
@@ -613,6 +622,15 @@ static void prime_field_tests(void)
|
||||
if (0 != BN_cmp(y, z))
|
||||
ABORT;
|
||||
|
||||
if (!BN_add(yplusone, y, BN_value_one()))
|
||||
ABORT;
|
||||
/*
|
||||
* When (x, y) is on the curve, (x, y + 1) is, as it happens, not,
|
||||
* and therefore setting the coordinates should fail.
|
||||
*/
|
||||
if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))
|
||||
ABORT;
|
||||
|
||||
fprintf(stdout, "verify degree ...");
|
||||
if (EC_GROUP_get_degree(group) != 192)
|
||||
ABORT;
|
||||
@@ -668,6 +686,15 @@ static void prime_field_tests(void)
|
||||
if (0 != BN_cmp(y, z))
|
||||
ABORT;
|
||||
|
||||
if (!BN_add(yplusone, y, BN_value_one()))
|
||||
ABORT;
|
||||
/*
|
||||
* When (x, y) is on the curve, (x, y + 1) is, as it happens, not,
|
||||
* and therefore setting the coordinates should fail.
|
||||
*/
|
||||
if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))
|
||||
ABORT;
|
||||
|
||||
fprintf(stdout, "verify degree ...");
|
||||
if (EC_GROUP_get_degree(group) != 224)
|
||||
ABORT;
|
||||
@@ -728,6 +755,15 @@ static void prime_field_tests(void)
|
||||
if (0 != BN_cmp(y, z))
|
||||
ABORT;
|
||||
|
||||
if (!BN_add(yplusone, y, BN_value_one()))
|
||||
ABORT;
|
||||
/*
|
||||
* When (x, y) is on the curve, (x, y + 1) is, as it happens, not,
|
||||
* and therefore setting the coordinates should fail.
|
||||
*/
|
||||
if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))
|
||||
ABORT;
|
||||
|
||||
fprintf(stdout, "verify degree ...");
|
||||
if (EC_GROUP_get_degree(group) != 256)
|
||||
ABORT;
|
||||
@@ -783,6 +819,15 @@ static void prime_field_tests(void)
|
||||
if (0 != BN_cmp(y, z))
|
||||
ABORT;
|
||||
|
||||
if (!BN_add(yplusone, y, BN_value_one()))
|
||||
ABORT;
|
||||
/*
|
||||
* When (x, y) is on the curve, (x, y + 1) is, as it happens, not,
|
||||
* and therefore setting the coordinates should fail.
|
||||
*/
|
||||
if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))
|
||||
ABORT;
|
||||
|
||||
fprintf(stdout, "verify degree ...");
|
||||
if (EC_GROUP_get_degree(group) != 384)
|
||||
ABORT;
|
||||
@@ -844,6 +889,15 @@ static void prime_field_tests(void)
|
||||
if (0 != BN_cmp(y, z))
|
||||
ABORT;
|
||||
|
||||
if (!BN_add(yplusone, y, BN_value_one()))
|
||||
ABORT;
|
||||
/*
|
||||
* When (x, y) is on the curve, (x, y + 1) is, as it happens, not,
|
||||
* and therefore setting the coordinates should fail.
|
||||
*/
|
||||
if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))
|
||||
ABORT;
|
||||
|
||||
fprintf(stdout, "verify degree ...");
|
||||
if (EC_GROUP_get_degree(group) != 521)
|
||||
ABORT;
|
||||
@@ -858,6 +912,10 @@ static void prime_field_tests(void)
|
||||
|
||||
/* more tests using the last curve */
|
||||
|
||||
/* Restore the point that got mangled in the (x, y + 1) test. */
|
||||
if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx))
|
||||
ABORT;
|
||||
|
||||
if (!EC_POINT_copy(Q, P))
|
||||
ABORT;
|
||||
if (EC_POINT_is_at_infinity(group, Q))
|
||||
@@ -987,6 +1045,7 @@ static void prime_field_tests(void)
|
||||
BN_free(x);
|
||||
BN_free(y);
|
||||
BN_free(z);
|
||||
BN_free(yplusone);
|
||||
|
||||
if (P_160)
|
||||
EC_GROUP_free(P_160);
|
||||
@@ -1007,6 +1066,13 @@ static void prime_field_tests(void)
|
||||
# ifdef OPENSSL_EC_BIN_PT_COMP
|
||||
# define CHAR2_CURVE_TEST_INTERNAL(_name, _p, _a, _b, _x, _y, _y_bit, _order, _cof, _degree, _variable) \
|
||||
if (!BN_hex2bn(&x, _x)) ABORT; \
|
||||
if (!BN_hex2bn(&y, _y)) ABORT; \
|
||||
if (!BN_add(yplusone, y, BN_value_one())) ABORT; \
|
||||
/* \
|
||||
* When (x, y) is on the curve, (x, y + 1) is, as it happens, not, \
|
||||
* and therefore setting the coordinates should fail. \
|
||||
*/ \
|
||||
if (EC_POINT_set_affine_coordinates_GF2m(group, P, x, yplusone, ctx)) ABORT; \
|
||||
if (!EC_POINT_set_compressed_coordinates_GF2m(group, P, x, _y_bit, ctx)) ABORT; \
|
||||
if (EC_POINT_is_on_curve(group, P, ctx) <= 0) ABORT; \
|
||||
if (!BN_hex2bn(&z, _order)) ABORT; \
|
||||
@@ -1025,6 +1091,12 @@ static void prime_field_tests(void)
|
||||
# define CHAR2_CURVE_TEST_INTERNAL(_name, _p, _a, _b, _x, _y, _y_bit, _order, _cof, _degree, _variable) \
|
||||
if (!BN_hex2bn(&x, _x)) ABORT; \
|
||||
if (!BN_hex2bn(&y, _y)) ABORT; \
|
||||
if (!BN_add(yplusone, y, BN_value_one())) ABORT; \
|
||||
/* \
|
||||
* When (x, y) is on the curve, (x, y + 1) is, as it happens, not, \
|
||||
* and therefore setting the coordinates should fail. \
|
||||
*/ \
|
||||
if (EC_POINT_set_affine_coordinates_GF2m(group, P, x, yplusone, ctx)) ABORT; \
|
||||
if (!EC_POINT_set_affine_coordinates_GF2m(group, P, x, y, ctx)) ABORT; \
|
||||
if (EC_POINT_is_on_curve(group, P, ctx) <= 0) ABORT; \
|
||||
if (!BN_hex2bn(&z, _order)) ABORT; \
|
||||
@@ -1062,7 +1134,7 @@ static void char2_field_tests(void)
|
||||
EC_GROUP *C2_B163 = NULL, *C2_B233 = NULL, *C2_B283 = NULL, *C2_B409 =
|
||||
NULL, *C2_B571 = NULL;
|
||||
EC_POINT *P, *Q, *R;
|
||||
BIGNUM *x, *y, *z, *cof;
|
||||
BIGNUM *x, *y, *z, *cof, *yplusone;
|
||||
unsigned char buf[100];
|
||||
size_t i, len;
|
||||
int k;
|
||||
@@ -1076,7 +1148,7 @@ static void char2_field_tests(void)
|
||||
p = BN_new();
|
||||
a = BN_new();
|
||||
b = BN_new();
|
||||
if (!p || !a || !b)
|
||||
if (p == NULL || a == NULL || b == NULL)
|
||||
ABORT;
|
||||
|
||||
if (!BN_hex2bn(&p, "13"))
|
||||
@@ -1142,7 +1214,8 @@ static void char2_field_tests(void)
|
||||
y = BN_new();
|
||||
z = BN_new();
|
||||
cof = BN_new();
|
||||
if (!x || !y || !z || !cof)
|
||||
yplusone = BN_new();
|
||||
if (x == NULL || y == NULL || z == NULL || cof == NULL || yplusone == NULL)
|
||||
ABORT;
|
||||
|
||||
if (!BN_hex2bn(&x, "6"))
|
||||
@@ -1504,6 +1577,7 @@ static void char2_field_tests(void)
|
||||
BN_free(y);
|
||||
BN_free(z);
|
||||
BN_free(cof);
|
||||
BN_free(yplusone);
|
||||
|
||||
if (C2_K163)
|
||||
EC_GROUP_free(C2_K163);
|
||||
@@ -1672,7 +1746,7 @@ static const struct nistp_test_params nistp_tests_params[] = {
|
||||
static void nistp_single_test(const struct nistp_test_params *test)
|
||||
{
|
||||
BN_CTX *ctx;
|
||||
BIGNUM *p, *a, *b, *x, *y, *n, *m, *order;
|
||||
BIGNUM *p, *a, *b, *x, *y, *n, *m, *order, *yplusone;
|
||||
EC_GROUP *NISTP;
|
||||
EC_POINT *G, *P, *Q, *Q_CHECK;
|
||||
|
||||
@@ -1687,6 +1761,7 @@ static void nistp_single_test(const struct nistp_test_params *test)
|
||||
m = BN_new();
|
||||
n = BN_new();
|
||||
order = BN_new();
|
||||
yplusone = BN_new();
|
||||
|
||||
NISTP = EC_GROUP_new(test->meth());
|
||||
if (!NISTP)
|
||||
@@ -1709,6 +1784,14 @@ static void nistp_single_test(const struct nistp_test_params *test)
|
||||
ABORT;
|
||||
if (!BN_hex2bn(&y, test->Qy))
|
||||
ABORT;
|
||||
if (!BN_add(yplusone, y, BN_value_one()))
|
||||
ABORT;
|
||||
/*
|
||||
* When (x, y) is on the curve, (x, y + 1) is, as it happens, not,
|
||||
* and therefore setting the coordinates should fail.
|
||||
*/
|
||||
if (EC_POINT_set_affine_coordinates_GFp(NISTP, Q_CHECK, x, yplusone, ctx))
|
||||
ABORT;
|
||||
if (!EC_POINT_set_affine_coordinates_GFp(NISTP, Q_CHECK, x, y, ctx))
|
||||
ABORT;
|
||||
if (!BN_hex2bn(&x, test->Gx))
|
||||
@@ -1811,6 +1894,7 @@ static void nistp_single_test(const struct nistp_test_params *test)
|
||||
BN_free(x);
|
||||
BN_free(y);
|
||||
BN_free(order);
|
||||
BN_free(yplusone);
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -207,7 +207,7 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
|
||||
|
||||
err:
|
||||
if (tmp)
|
||||
EC_POINT_free(tmp);
|
||||
EC_POINT_clear_free(tmp);
|
||||
if (ctx)
|
||||
BN_CTX_end(ctx);
|
||||
if (ctx)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -62,6 +62,7 @@
|
||||
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
|
||||
*/
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include "eng_int.h"
|
||||
|
||||
/*
|
||||
@@ -369,10 +370,10 @@ ENGINE *ENGINE_by_id(const char *id)
|
||||
*/
|
||||
if (strcmp(id, "dynamic")) {
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
if ((load_dir = getenv("OPENSSL_ENGINES")) == 0)
|
||||
if ((load_dir = ossl_safe_getenv("OPENSSL_ENGINES")) == 0)
|
||||
load_dir = "SSLROOT:[ENGINES]";
|
||||
# else
|
||||
if ((load_dir = getenv("OPENSSL_ENGINES")) == 0)
|
||||
if ((load_dir = ossl_safe_getenv("OPENSSL_ENGINES")) == 0)
|
||||
load_dir = ENGINESDIR;
|
||||
# endif
|
||||
iterator = ENGINE_by_id("dynamic");
|
||||
|
||||
@@ -82,7 +82,7 @@ err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
|
||||
err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
err.o: ../cryptlib.h err.c
|
||||
err.o: ../constant_time_locl.h ../cryptlib.h err.c
|
||||
err_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
err_all.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
|
||||
err_all.o: ../../include/openssl/cms.h ../../include/openssl/comp.h
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -118,6 +118,7 @@
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include "constant_time_locl.h"
|
||||
|
||||
DECLARE_LHASH_OF(ERR_STRING_DATA);
|
||||
DECLARE_LHASH_OF(ERR_STATE);
|
||||
@@ -826,8 +827,24 @@ static unsigned long get_error_values(int inc, int top, const char **file,
|
||||
return ERR_R_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
while (es->bottom != es->top) {
|
||||
if (es->err_flags[es->top] & ERR_FLAG_CLEAR) {
|
||||
err_clear(es, es->top);
|
||||
es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1;
|
||||
continue;
|
||||
}
|
||||
i = (es->bottom + 1) % ERR_NUM_ERRORS;
|
||||
if (es->err_flags[i] & ERR_FLAG_CLEAR) {
|
||||
es->bottom = i;
|
||||
err_clear(es, es->bottom);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (es->bottom == es->top)
|
||||
return 0;
|
||||
|
||||
if (top)
|
||||
i = es->top; /* last error */
|
||||
else
|
||||
@@ -1156,3 +1173,23 @@ int ERR_pop_to_mark(void)
|
||||
es->err_flags[es->top] &= ~ERR_FLAG_MARK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void err_clear_last_constant_time(int clear)
|
||||
{
|
||||
ERR_STATE *es;
|
||||
int top;
|
||||
|
||||
es = ERR_get_state();
|
||||
if (es == NULL)
|
||||
return;
|
||||
|
||||
top = es->top;
|
||||
|
||||
/*
|
||||
* Flag error as cleared but remove it elsewhere to avoid two errors
|
||||
* accessing the same error stack location, revealing timing information.
|
||||
*/
|
||||
clear = constant_time_select_int(constant_time_eq_int(clear, 0),
|
||||
0, ERR_FLAG_CLEAR);
|
||||
es->err_flags[top] |= clear;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -143,6 +143,7 @@ extern "C" {
|
||||
# define ERR_TXT_STRING 0x02
|
||||
|
||||
# define ERR_FLAG_MARK 0x01
|
||||
# define ERR_FLAG_CLEAR 0x02
|
||||
|
||||
# define ERR_NUM_ERRORS 16
|
||||
typedef struct err_state_st {
|
||||
|
||||
@@ -1489,8 +1489,10 @@ void ERR_load_EVP_strings(void);
|
||||
# define EVP_F_EVP_CIPHER_CTX_CTRL 124
|
||||
# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
|
||||
# define EVP_F_EVP_DECRYPTFINAL_EX 101
|
||||
# define EVP_F_EVP_DECRYPTUPDATE 181
|
||||
# define EVP_F_EVP_DIGESTINIT_EX 128
|
||||
# define EVP_F_EVP_ENCRYPTFINAL_EX 127
|
||||
# define EVP_F_EVP_ENCRYPTUPDATE 180
|
||||
# define EVP_F_EVP_MD_CTX_COPY_EX 110
|
||||
# define EVP_F_EVP_MD_SIZE 162
|
||||
# define EVP_F_EVP_OPENINIT 102
|
||||
|
||||
@@ -317,7 +317,8 @@ int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0);
|
||||
}
|
||||
|
||||
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
||||
static int evp_EncryptDecryptUpdate(EVP_CIPHER_CTX *ctx,
|
||||
unsigned char *out, int *outl,
|
||||
const unsigned char *in, int inl)
|
||||
{
|
||||
int i, j, bl;
|
||||
@@ -380,6 +381,18 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
||||
const unsigned char *in, int inl)
|
||||
{
|
||||
/* Prevent accidental use of decryption context when encrypting */
|
||||
if (!ctx->encrypt) {
|
||||
EVPerr(EVP_F_EVP_ENCRYPTUPDATE, EVP_R_INVALID_OPERATION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return evp_EncryptDecryptUpdate(ctx, out, outl, in, inl);
|
||||
}
|
||||
|
||||
int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
||||
{
|
||||
int ret;
|
||||
@@ -392,6 +405,12 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
||||
int n, ret;
|
||||
unsigned int i, b, bl;
|
||||
|
||||
/* Prevent accidental use of decryption context when encrypting */
|
||||
if (!ctx->encrypt) {
|
||||
EVPerr(EVP_F_EVP_ENCRYPTFINAL_EX, EVP_R_INVALID_OPERATION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
|
||||
ret = M_do_cipher(ctx, out, NULL, 0);
|
||||
if (ret < 0)
|
||||
@@ -435,6 +454,12 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
||||
int fix_len;
|
||||
unsigned int b;
|
||||
|
||||
/* Prevent accidental use of encryption context when decrypting */
|
||||
if (ctx->encrypt) {
|
||||
EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_INVALID_OPERATION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
|
||||
fix_len = M_do_cipher(ctx, out, in, inl);
|
||||
if (fix_len < 0) {
|
||||
@@ -451,7 +476,7 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
||||
}
|
||||
|
||||
if (ctx->flags & EVP_CIPH_NO_PADDING)
|
||||
return EVP_EncryptUpdate(ctx, out, outl, in, inl);
|
||||
return evp_EncryptDecryptUpdate(ctx, out, outl, in, inl);
|
||||
|
||||
b = ctx->cipher->block_size;
|
||||
OPENSSL_assert(b <= sizeof(ctx->final));
|
||||
@@ -463,7 +488,7 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
||||
} else
|
||||
fix_len = 0;
|
||||
|
||||
if (!EVP_EncryptUpdate(ctx, out, outl, in, inl))
|
||||
if (!evp_EncryptDecryptUpdate(ctx, out, outl, in, inl))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
@@ -494,6 +519,13 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
||||
{
|
||||
int i, n;
|
||||
unsigned int b;
|
||||
|
||||
/* Prevent accidental use of encryption context when decrypting */
|
||||
if (ctx->encrypt) {
|
||||
EVPerr(EVP_F_EVP_DECRYPTFINAL_EX, EVP_R_INVALID_OPERATION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*outl = 0;
|
||||
|
||||
if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* crypto/evp/evp_err.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2016 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -92,8 +92,10 @@ static ERR_STRING_DATA EVP_str_functs[] = {
|
||||
{ERR_FUNC(EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH),
|
||||
"EVP_CIPHER_CTX_set_key_length"},
|
||||
{ERR_FUNC(EVP_F_EVP_DECRYPTFINAL_EX), "EVP_DecryptFinal_ex"},
|
||||
{ERR_FUNC(EVP_F_EVP_DECRYPTUPDATE), "EVP_DecryptUpdate"},
|
||||
{ERR_FUNC(EVP_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"},
|
||||
{ERR_FUNC(EVP_F_EVP_ENCRYPTFINAL_EX), "EVP_EncryptFinal_ex"},
|
||||
{ERR_FUNC(EVP_F_EVP_ENCRYPTUPDATE), "EVP_EncryptUpdate"},
|
||||
{ERR_FUNC(EVP_F_EVP_MD_CTX_COPY_EX), "EVP_MD_CTX_copy_ex"},
|
||||
{ERR_FUNC(EVP_F_EVP_MD_SIZE), "EVP_MD_size"},
|
||||
{ERR_FUNC(EVP_F_EVP_OPENINIT), "EVP_OpenInit"},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Written by Ben Laurie, 2001 */
|
||||
/*
|
||||
* Copyright (c) 2001 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2001-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -327,7 +327,7 @@ static void test1(const EVP_CIPHER *c, const unsigned char *key, int kn,
|
||||
ERR_print_errors_fp(stderr);
|
||||
test1_exit(12);
|
||||
}
|
||||
if (an && !EVP_EncryptUpdate(&ctx, NULL, &outl, aad, an)) {
|
||||
if (an && !EVP_DecryptUpdate(&ctx, NULL, &outl, aad, an)) {
|
||||
fprintf(stderr, "AAD set failed\n");
|
||||
ERR_print_errors_fp(stderr);
|
||||
test1_exit(13);
|
||||
|
||||
31
crypto/getenv.c
Normal file
31
crypto/getenv.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "cryptlib.h"
|
||||
|
||||
char *ossl_safe_getenv(const char *name)
|
||||
{
|
||||
#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
||||
# if __GLIBC_PREREQ(2, 17)
|
||||
# define SECURE_GETENV
|
||||
return secure_getenv(name);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SECURE_GETENV
|
||||
if (OPENSSL_issetugid())
|
||||
return NULL;
|
||||
return getenv(name);
|
||||
#endif
|
||||
}
|
||||
@@ -30,11 +30,11 @@ extern "C" {
|
||||
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
|
||||
* major minor fix final patch/beta)
|
||||
*/
|
||||
# define OPENSSL_VERSION_NUMBER 0x1000210fL
|
||||
# define OPENSSL_VERSION_NUMBER 0x1000214fL
|
||||
# ifdef OPENSSL_FIPS
|
||||
# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2p-fips 14 Aug 2018"
|
||||
# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2t-fips 10 Sep 2019"
|
||||
# else
|
||||
# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2p 14 Aug 2018"
|
||||
# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2t 10 Sep 2019"
|
||||
# endif
|
||||
# define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 2005.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2005-2018 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2005-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -327,6 +327,8 @@ static EVP_PKEY *b2i_dss(const unsigned char **in, unsigned int length,
|
||||
} else {
|
||||
if (!read_lebn(&p, 20, &dsa->priv_key))
|
||||
goto memerr;
|
||||
/* Set constant time flag before public key calculation */
|
||||
BN_set_flags(dsa->priv_key, BN_FLG_CONSTTIME);
|
||||
/* Calculate public key */
|
||||
if (!(dsa->pub_key = BN_new()))
|
||||
goto memerr;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 1999.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -70,7 +70,8 @@ PKCS12 *PKCS12_init(int mode)
|
||||
PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
ASN1_INTEGER_set(pkcs12->version, 3);
|
||||
if (!ASN1_INTEGER_set(pkcs12->version, 3))
|
||||
goto err;
|
||||
pkcs12->authsafes->type = OBJ_nid2obj(mode);
|
||||
switch (mode) {
|
||||
case NID_pkcs7_data:
|
||||
|
||||
@@ -191,7 +191,8 @@ static int pkcs7_encode_rinfo(PKCS7_RECIP_INFO *ri,
|
||||
}
|
||||
|
||||
static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen,
|
||||
PKCS7_RECIP_INFO *ri, EVP_PKEY *pkey)
|
||||
PKCS7_RECIP_INFO *ri, EVP_PKEY *pkey,
|
||||
size_t fixlen)
|
||||
{
|
||||
EVP_PKEY_CTX *pctx = NULL;
|
||||
unsigned char *ek = NULL;
|
||||
@@ -224,7 +225,9 @@ static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen,
|
||||
}
|
||||
|
||||
if (EVP_PKEY_decrypt(pctx, ek, &eklen,
|
||||
ri->enc_key->data, ri->enc_key->length) <= 0) {
|
||||
ri->enc_key->data, ri->enc_key->length) <= 0
|
||||
|| eklen == 0
|
||||
|| (fixlen != 0 && eklen != fixlen)) {
|
||||
ret = 0;
|
||||
PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
@@ -571,13 +574,14 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
for (i = 0; i < sk_PKCS7_RECIP_INFO_num(rsk); i++) {
|
||||
ri = sk_PKCS7_RECIP_INFO_value(rsk, i);
|
||||
|
||||
if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey) < 0)
|
||||
if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey,
|
||||
EVP_CIPHER_key_length(evp_cipher)) < 0)
|
||||
goto err;
|
||||
ERR_clear_error();
|
||||
}
|
||||
} else {
|
||||
/* Only exit on fatal errors, not decrypt failure */
|
||||
if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey) < 0)
|
||||
if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey, 0) < 0)
|
||||
goto err;
|
||||
ERR_clear_error();
|
||||
}
|
||||
|
||||
@@ -185,7 +185,6 @@ int PKCS7_set_type(PKCS7 *p7, int type)
|
||||
if ((p7->d.signed_and_enveloped = PKCS7_SIGN_ENVELOPE_new())
|
||||
== NULL)
|
||||
goto err;
|
||||
ASN1_INTEGER_set(p7->d.signed_and_enveloped->version, 1);
|
||||
if (!ASN1_INTEGER_set(p7->d.signed_and_enveloped->version, 1))
|
||||
goto err;
|
||||
p7->d.signed_and_enveloped->enc_data->content_type
|
||||
|
||||
@@ -157,10 +157,11 @@ rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
|
||||
rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
rand_win.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h
|
||||
rand_win.o: rand_win.c
|
||||
randfile.o: ../../e_os.h ../../include/openssl/buffer.h
|
||||
randfile.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
randfile.o: ../../include/openssl/opensslconf.h
|
||||
randfile.o: ../../e_os.h ../../include/openssl/bio.h
|
||||
randfile.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
randfile.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
randfile.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
randfile.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
randfile.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
|
||||
randfile.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
randfile.o: randfile.c
|
||||
randfile.o: ../cryptlib.h randfile.c
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -345,7 +345,6 @@ int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo, int lock)
|
||||
static volatile int stirred_pool = 0;
|
||||
int i, j, k;
|
||||
size_t num_ceil, st_idx, st_num;
|
||||
int ok;
|
||||
long md_c[2];
|
||||
unsigned char local_md[MD_DIGEST_LENGTH];
|
||||
EVP_MD_CTX m;
|
||||
@@ -400,14 +399,13 @@ int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo, int lock)
|
||||
|
||||
if (!initialized) {
|
||||
RAND_poll();
|
||||
initialized = 1;
|
||||
initialized = (entropy >= ENTROPY_NEEDED);
|
||||
}
|
||||
|
||||
if (!stirred_pool)
|
||||
do_stir_pool = 1;
|
||||
|
||||
ok = (entropy >= ENTROPY_NEEDED);
|
||||
if (!ok) {
|
||||
if (!initialized) {
|
||||
/*
|
||||
* If the PRNG state is not yet unpredictable, then seeing the PRNG
|
||||
* output may help attackers to determine the new state; thus we have
|
||||
@@ -446,7 +444,7 @@ int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo, int lock)
|
||||
ssleay_rand_add(DUMMY_SEED, MD_DIGEST_LENGTH, 0.0);
|
||||
n -= MD_DIGEST_LENGTH;
|
||||
}
|
||||
if (ok)
|
||||
if (initialized)
|
||||
stirred_pool = 1;
|
||||
}
|
||||
|
||||
@@ -539,7 +537,7 @@ int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo, int lock)
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
|
||||
|
||||
EVP_MD_CTX_cleanup(&m);
|
||||
if (ok)
|
||||
if (initialized)
|
||||
return (1);
|
||||
else if (pseudo)
|
||||
return 0;
|
||||
@@ -555,6 +553,18 @@ int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo, int lock)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns ssleay_rand_bytes(), enforcing a reseeding from the
|
||||
* system entropy sources using RAND_poll() before generating
|
||||
`* the random bytes.
|
||||
*/
|
||||
|
||||
int ssleay_rand_bytes_from_system(unsigned char *buf, int num)
|
||||
{
|
||||
initialized = 0;
|
||||
return ssleay_rand_bytes(buf, num, 0, 0);
|
||||
}
|
||||
|
||||
static int ssleay_rand_nopseudo_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
return ssleay_rand_bytes(buf, num, 0, 1);
|
||||
@@ -600,10 +610,10 @@ static int ssleay_rand_status(void)
|
||||
|
||||
if (!initialized) {
|
||||
RAND_poll();
|
||||
initialized = 1;
|
||||
initialized = (entropy >= ENTROPY_NEEDED);
|
||||
}
|
||||
|
||||
ret = entropy >= ENTROPY_NEEDED;
|
||||
ret = initialized;
|
||||
|
||||
if (!do_not_lock) {
|
||||
/* before unlocking, we must clear 'crypto_lock_rand' */
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -154,5 +154,5 @@
|
||||
# endif
|
||||
|
||||
int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo, int lock);
|
||||
|
||||
int ssleay_rand_bytes_from_system(unsigned char *buf, int num);
|
||||
#endif
|
||||
|
||||
@@ -185,11 +185,29 @@ int RAND_status(void)
|
||||
|
||||
/*
|
||||
* Entropy gatherer: use standard OpenSSL PRNG to seed (this will gather
|
||||
* entropy internally through RAND_poll().
|
||||
* entropy internally through RAND_poll()).
|
||||
*/
|
||||
|
||||
static size_t drbg_get_entropy(DRBG_CTX *ctx, unsigned char **pout,
|
||||
int entropy, size_t min_len, size_t max_len)
|
||||
{
|
||||
/* Round up request to multiple of block size */
|
||||
min_len = ((min_len + 19) / 20) * 20;
|
||||
*pout = OPENSSL_malloc(min_len);
|
||||
if (!*pout)
|
||||
return 0;
|
||||
|
||||
/* Enforces a reseed of the SSLEAY PRNG before generating random bytes */
|
||||
if (ssleay_rand_bytes_from_system(*pout, min_len) <= 0) {
|
||||
OPENSSL_free(*pout);
|
||||
*pout = NULL;
|
||||
return 0;
|
||||
}
|
||||
return min_len;
|
||||
}
|
||||
|
||||
static size_t drbg_get_nonce(DRBG_CTX *ctx, unsigned char **pout,
|
||||
int entropy, size_t min_len, size_t max_len)
|
||||
{
|
||||
/* Round up request to multiple of block size */
|
||||
min_len = ((min_len + 19) / 20) * 20;
|
||||
@@ -281,7 +299,7 @@ int RAND_init_fips(void)
|
||||
|
||||
FIPS_drbg_set_callbacks(dctx,
|
||||
drbg_get_entropy, drbg_free_entropy, 20,
|
||||
drbg_get_entropy, drbg_free_entropy);
|
||||
drbg_get_nonce, drbg_free_entropy);
|
||||
FIPS_drbg_set_rand_callbacks(dctx, drbg_get_adin, 0,
|
||||
drbg_rand_seed, drbg_rand_add);
|
||||
/* Personalisation string: a string followed by date time vector */
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include "e_os.h"
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/rand.h>
|
||||
@@ -327,14 +328,12 @@ const char *RAND_file_name(char *buf, size_t size)
|
||||
struct stat sb;
|
||||
#endif
|
||||
|
||||
if (OPENSSL_issetugid() == 0)
|
||||
s = getenv("RANDFILE");
|
||||
s = ossl_safe_getenv("RANDFILE");
|
||||
if (s != NULL && *s && strlen(s) + 1 < size) {
|
||||
if (BUF_strlcpy(buf, s, size) >= size)
|
||||
return NULL;
|
||||
} else {
|
||||
if (OPENSSL_issetugid() == 0)
|
||||
s = getenv("HOME");
|
||||
s = ossl_safe_getenv("HOME");
|
||||
#ifdef DEFAULT_HOME
|
||||
if (s == NULL) {
|
||||
s = DEFAULT_HOME;
|
||||
|
||||
@@ -153,7 +153,8 @@ rsa_eay.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
rsa_eay.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
rsa_eay.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
|
||||
rsa_eay.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
rsa_eay.o: ../../include/openssl/symhacks.h ../bn_int.h ../cryptlib.h rsa_eay.c
|
||||
rsa_eay.o: ../../include/openssl/symhacks.h ../bn_int.h ../constant_time_locl.h
|
||||
rsa_eay.o: ../cryptlib.h rsa_eay.c
|
||||
rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
rsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
rsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
@@ -299,7 +300,8 @@ rsa_ssl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
rsa_ssl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
rsa_ssl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
|
||||
rsa_ssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
rsa_ssl.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_ssl.c
|
||||
rsa_ssl.o: ../../include/openssl/symhacks.h ../constant_time_locl.h
|
||||
rsa_ssl.o: ../cryptlib.h rsa_ssl.c
|
||||
rsa_x931.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
rsa_x931.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
rsa_x931.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* crypto/rsa/rsa_chk.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -63,6 +63,10 @@ int RSA_check_key(const RSA *key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set consant-time flag on private parameters */
|
||||
BN_set_flags(key->p, BN_FLG_CONSTTIME);
|
||||
BN_set_flags(key->q, BN_FLG_CONSTTIME);
|
||||
BN_set_flags(key->d, BN_FLG_CONSTTIME);
|
||||
i = BN_new();
|
||||
j = BN_new();
|
||||
k = BN_new();
|
||||
@@ -141,6 +145,10 @@ int RSA_check_key(const RSA *key)
|
||||
}
|
||||
|
||||
if (key->dmp1 != NULL && key->dmq1 != NULL && key->iqmp != NULL) {
|
||||
/* Set consant-time flag on CRT parameters */
|
||||
BN_set_flags(key->dmp1, BN_FLG_CONSTTIME);
|
||||
BN_set_flags(key->dmq1, BN_FLG_CONSTTIME);
|
||||
BN_set_flags(key->iqmp, BN_FLG_CONSTTIME);
|
||||
/* dmp1 = d mod (p-1)? */
|
||||
if (!BN_sub(i, key->p, BN_value_one())) {
|
||||
ret = -1;
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2018 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -115,6 +115,7 @@
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/rand.h>
|
||||
#include "bn_int.h"
|
||||
#include "constant_time_locl.h"
|
||||
|
||||
#ifndef RSA_NULL
|
||||
|
||||
@@ -224,8 +225,8 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
|
||||
}
|
||||
|
||||
if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)
|
||||
if (!BN_MONT_CTX_set_locked
|
||||
(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx))
|
||||
if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA,
|
||||
rsa->n, ctx))
|
||||
goto err;
|
||||
|
||||
if (!rsa->meth->bn_mod_exp(ret, f, rsa->e, rsa->n, ctx,
|
||||
@@ -397,6 +398,11 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)
|
||||
if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA,
|
||||
rsa->n, ctx))
|
||||
goto err;
|
||||
|
||||
if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) {
|
||||
blinding = rsa_get_blinding(rsa, &local_blinding, ctx);
|
||||
if (blinding == NULL) {
|
||||
@@ -431,11 +437,6 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
|
||||
} else
|
||||
d = rsa->d;
|
||||
|
||||
if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)
|
||||
if (!BN_MONT_CTX_set_locked
|
||||
(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx))
|
||||
goto err;
|
||||
|
||||
if (!rsa->meth->bn_mod_exp(ret, f, d, rsa->n, ctx,
|
||||
rsa->_method_mod_n))
|
||||
goto err;
|
||||
@@ -554,8 +555,8 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
|
||||
d = rsa->d;
|
||||
|
||||
if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)
|
||||
if (!BN_MONT_CTX_set_locked
|
||||
(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx))
|
||||
if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA,
|
||||
rsa->n, ctx))
|
||||
goto err;
|
||||
if (!rsa->meth->bn_mod_exp(ret, f, d, rsa->n, ctx,
|
||||
rsa->_method_mod_n))
|
||||
@@ -587,8 +588,8 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, RSA_R_UNKNOWN_PADDING_TYPE);
|
||||
goto err;
|
||||
}
|
||||
if (r < 0)
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, RSA_R_PADDING_CHECK_FAILED);
|
||||
err_clear_last_constant_time(1 & ~constant_time_msb(r));
|
||||
|
||||
err:
|
||||
if (ctx != NULL) {
|
||||
@@ -660,8 +661,8 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
|
||||
}
|
||||
|
||||
if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)
|
||||
if (!BN_MONT_CTX_set_locked
|
||||
(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx))
|
||||
if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA,
|
||||
rsa->n, ctx))
|
||||
goto err;
|
||||
|
||||
if (!rsa->meth->bn_mod_exp(ret, f, rsa->e, rsa->n, ctx,
|
||||
@@ -708,7 +709,7 @@ static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
|
||||
BIGNUM *r1, *m1, *vrfy;
|
||||
BIGNUM local_dmp1, local_dmq1, local_c, local_r1;
|
||||
BIGNUM *dmp1, *dmq1, *c, *pr1;
|
||||
int ret = 0;
|
||||
int ret = 0, smooth = 0;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
r1 = BN_CTX_get(ctx);
|
||||
@@ -737,20 +738,64 @@ static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
|
||||
}
|
||||
|
||||
if (rsa->flags & RSA_FLAG_CACHE_PRIVATE) {
|
||||
if (!BN_MONT_CTX_set_locked
|
||||
(&rsa->_method_mod_p, CRYPTO_LOCK_RSA, p, ctx))
|
||||
if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_p, CRYPTO_LOCK_RSA,
|
||||
p, ctx))
|
||||
goto err;
|
||||
if (!BN_MONT_CTX_set_locked
|
||||
(&rsa->_method_mod_q, CRYPTO_LOCK_RSA, q, ctx))
|
||||
if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_q, CRYPTO_LOCK_RSA,
|
||||
q, ctx))
|
||||
goto err;
|
||||
|
||||
smooth = (rsa->meth->bn_mod_exp == BN_mod_exp_mont)
|
||||
&& (BN_num_bits(q) == BN_num_bits(p));
|
||||
}
|
||||
}
|
||||
|
||||
if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)
|
||||
if (!BN_MONT_CTX_set_locked
|
||||
(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx))
|
||||
if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA,
|
||||
rsa->n, ctx))
|
||||
goto err;
|
||||
|
||||
if (smooth) {
|
||||
/*
|
||||
* Conversion from Montgomery domain, a.k.a. Montgomery reduction,
|
||||
* accepts values in [0-m*2^w) range. w is m's bit width rounded up
|
||||
* to limb width. So that at the very least if |I| is fully reduced,
|
||||
* i.e. less than p*q, we can count on from-to round to perform
|
||||
* below modulo operations on |I|. Unlike BN_mod it's constant time.
|
||||
*/
|
||||
if (/* m1 = I moq q */
|
||||
!bn_from_mont_fixed_top(m1, I, rsa->_method_mod_q, ctx)
|
||||
|| !bn_to_mont_fixed_top(m1, m1, rsa->_method_mod_q, ctx)
|
||||
/* m1 = m1^dmq1 mod q */
|
||||
|| !BN_mod_exp_mont_consttime(m1, m1, rsa->dmq1, rsa->q, ctx,
|
||||
rsa->_method_mod_q)
|
||||
/* r1 = I mod p */
|
||||
|| !bn_from_mont_fixed_top(r1, I, rsa->_method_mod_p, ctx)
|
||||
|| !bn_to_mont_fixed_top(r1, r1, rsa->_method_mod_p, ctx)
|
||||
/* r1 = r1^dmp1 mod p */
|
||||
|| !BN_mod_exp_mont_consttime(r1, r1, rsa->dmp1, rsa->p, ctx,
|
||||
rsa->_method_mod_p)
|
||||
/* r1 = (r1 - m1) mod p */
|
||||
/*
|
||||
* bn_mod_sub_fixed_top is not regular modular subtraction,
|
||||
* it can tolerate subtrahend to be larger than modulus, but
|
||||
* not bit-wise wider. This makes up for uncommon q>p case,
|
||||
* when |m1| can be larger than |rsa->p|.
|
||||
*/
|
||||
|| !bn_mod_sub_fixed_top(r1, r1, m1, rsa->p)
|
||||
|
||||
/* r1 = r1 * iqmp mod p */
|
||||
|| !bn_to_mont_fixed_top(r1, r1, rsa->_method_mod_p, ctx)
|
||||
|| !bn_mul_mont_fixed_top(r1, r1, rsa->iqmp, rsa->_method_mod_p,
|
||||
ctx)
|
||||
/* r0 = r1 * q + m1 */
|
||||
|| !bn_mul_fixed_top(r0, r1, rsa->q, ctx)
|
||||
|| !bn_mod_add_fixed_top(r0, r0, m1, rsa->n))
|
||||
goto err;
|
||||
|
||||
goto tail;
|
||||
}
|
||||
|
||||
/* compute I mod q */
|
||||
if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) {
|
||||
c = &local_c;
|
||||
@@ -828,10 +873,18 @@ static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
|
||||
if (!BN_add(r0, r1, m1))
|
||||
goto err;
|
||||
|
||||
tail:
|
||||
if (rsa->e && rsa->n) {
|
||||
if (rsa->meth->bn_mod_exp == BN_mod_exp_mont) {
|
||||
if (!BN_mod_exp_mont(vrfy, r0, rsa->e, rsa->n, ctx,
|
||||
rsa->_method_mod_n))
|
||||
goto err;
|
||||
} else {
|
||||
bn_correct_top(r0);
|
||||
if (!rsa->meth->bn_mod_exp(vrfy, r0, rsa->e, rsa->n, ctx,
|
||||
rsa->_method_mod_n))
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
* If 'I' was greater than (or equal to) rsa->n, the operation will
|
||||
* be equivalent to using 'I mod n'. However, the result of the
|
||||
@@ -840,6 +893,11 @@ static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
|
||||
*/
|
||||
if (!BN_sub(vrfy, vrfy, I))
|
||||
goto err;
|
||||
if (BN_is_zero(vrfy)) {
|
||||
bn_correct_top(r0);
|
||||
ret = 1;
|
||||
goto err; /* not actually error */
|
||||
}
|
||||
if (!BN_mod(vrfy, vrfy, rsa->n, ctx))
|
||||
goto err;
|
||||
if (BN_is_negative(vrfy))
|
||||
@@ -865,6 +923,15 @@ static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* It's unfortunate that we have to bn_correct_top(r0). What hopefully
|
||||
* saves the day is that correction is highly unlike, and private key
|
||||
* operations are customarily performed on blinded message. Which means
|
||||
* that attacker won't observe correlation with chosen plaintext.
|
||||
* Secondly, remaining code would still handle it in same computational
|
||||
* time and even conceal memory access pattern around corrected top.
|
||||
*/
|
||||
bn_correct_top(r0);
|
||||
ret = 1;
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
|
||||
@@ -121,7 +121,7 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
|
||||
const EVP_MD *mgf1md)
|
||||
{
|
||||
int i, dblen = 0, mlen = -1, one_index = 0, msg_index;
|
||||
unsigned int good, found_one_byte;
|
||||
unsigned int good = 0, found_one_byte, mask;
|
||||
const unsigned char *maskedseed, *maskeddb;
|
||||
/*
|
||||
* |em| is the encoded message, zero-padded to exactly |num| bytes: em =
|
||||
@@ -144,12 +144,15 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
|
||||
* |num| is the length of the modulus; |flen| is the length of the
|
||||
* encoded message. Therefore, for any |from| that was obtained by
|
||||
* decrypting a ciphertext, we must have |flen| <= |num|. Similarly,
|
||||
* num < 2 * mdlen + 2 must hold for the modulus irrespective of
|
||||
* |num| >= 2 * |mdlen| + 2 must hold for the modulus irrespective of
|
||||
* the ciphertext, see PKCS #1 v2.2, section 7.1.2.
|
||||
* This does not leak any side-channel information.
|
||||
*/
|
||||
if (num < flen || num < 2 * mdlen + 2)
|
||||
goto decoding_err;
|
||||
if (num < flen || num < 2 * mdlen + 2) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1,
|
||||
RSA_R_OAEP_DECODING_ERROR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
dblen = num - mdlen - 1;
|
||||
db = OPENSSL_malloc(dblen);
|
||||
@@ -158,7 +161,6 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (flen != num) {
|
||||
em = OPENSSL_malloc(num);
|
||||
if (em == NULL) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1,
|
||||
@@ -168,15 +170,15 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
|
||||
|
||||
/*
|
||||
* Caller is encouraged to pass zero-padded message created with
|
||||
* BN_bn2binpad, but if it doesn't, we do this zero-padding copy
|
||||
* to avoid leaking that information. The copy still leaks some
|
||||
* side-channel information, but it's impossible to have a fixed
|
||||
* memory access pattern since we can't read out of the bounds of
|
||||
* |from|.
|
||||
* BN_bn2binpad. Trouble is that since we can't read out of |from|'s
|
||||
* bounds, it's impossible to have an invariant memory access pattern
|
||||
* in case |from| was not zero-padded in advance.
|
||||
*/
|
||||
memset(em, 0, num);
|
||||
memcpy(em + num - flen, from, flen);
|
||||
from = em;
|
||||
for (from += flen, em += num, i = 0; i < num; i++) {
|
||||
mask = ~constant_time_is_zero(flen);
|
||||
flen -= 1 & mask;
|
||||
from -= 1 & mask;
|
||||
*--em = *from & mask;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -184,10 +186,10 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
|
||||
* true. See James H. Manger, "A Chosen Ciphertext Attack on RSA
|
||||
* Optimal Asymmetric Encryption Padding (OAEP) [...]", CRYPTO 2001).
|
||||
*/
|
||||
good = constant_time_is_zero(from[0]);
|
||||
good = constant_time_is_zero(em[0]);
|
||||
|
||||
maskedseed = from + 1;
|
||||
maskeddb = from + 1 + mdlen;
|
||||
maskedseed = em + 1;
|
||||
maskeddb = em + 1 + mdlen;
|
||||
|
||||
if (PKCS1_MGF1(seed, mdlen, maskeddb, dblen, mgf1md))
|
||||
goto cleanup;
|
||||
@@ -224,37 +226,51 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
|
||||
* so plaintext-awareness ensures timing side-channels are no longer a
|
||||
* concern.
|
||||
*/
|
||||
if (!good)
|
||||
goto decoding_err;
|
||||
|
||||
msg_index = one_index + 1;
|
||||
mlen = dblen - msg_index;
|
||||
|
||||
if (tlen < mlen) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1, RSA_R_DATA_TOO_LARGE);
|
||||
mlen = -1;
|
||||
} else {
|
||||
memcpy(to, db + msg_index, mlen);
|
||||
goto cleanup;
|
||||
/*
|
||||
* For good measure, do this check in constant time as well.
|
||||
*/
|
||||
good &= constant_time_ge(tlen, mlen);
|
||||
|
||||
/*
|
||||
* Move the result in-place by |dblen|-|mdlen|-1-|mlen| bytes to the left.
|
||||
* Then if |good| move |mlen| bytes from |db|+|mdlen|+1 to |to|.
|
||||
* Otherwise leave |to| unchanged.
|
||||
* Copy the memory back in a way that does not reveal the size of
|
||||
* the data being copied via a timing side channel. This requires copying
|
||||
* parts of the buffer multiple times based on the bits set in the real
|
||||
* length. Clear bits do a non-copy with identical access pattern.
|
||||
* The loop below has overall complexity of O(N*log(N)).
|
||||
*/
|
||||
tlen = constant_time_select_int(constant_time_lt(dblen - mdlen - 1, tlen),
|
||||
dblen - mdlen - 1, tlen);
|
||||
for (msg_index = 1; msg_index < dblen - mdlen - 1; msg_index <<= 1) {
|
||||
mask = ~constant_time_eq(msg_index & (dblen - mdlen - 1 - mlen), 0);
|
||||
for (i = mdlen + 1; i < dblen - msg_index; i++)
|
||||
db[i] = constant_time_select_8(mask, db[i + msg_index], db[i]);
|
||||
}
|
||||
for (i = 0; i < tlen; i++) {
|
||||
mask = good & constant_time_lt(i, mlen);
|
||||
to[i] = constant_time_select_8(mask, db[i + mdlen + 1], to[i]);
|
||||
}
|
||||
|
||||
decoding_err:
|
||||
/*
|
||||
* To avoid chosen ciphertext attacks, the error message should not
|
||||
* reveal which kind of decoding error happened.
|
||||
*/
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1,
|
||||
RSA_R_OAEP_DECODING_ERROR);
|
||||
err_clear_last_constant_time(1 & good);
|
||||
cleanup:
|
||||
if (db != NULL) {
|
||||
OPENSSL_cleanse(seed, sizeof(seed));
|
||||
OPENSSL_cleanse(db, dblen);
|
||||
OPENSSL_free(db);
|
||||
}
|
||||
if (em != NULL) {
|
||||
OPENSSL_cleanse(em, num);
|
||||
OPENSSL_free(em);
|
||||
}
|
||||
return mlen;
|
||||
|
||||
return constant_time_select_int(good, mlen, -1);
|
||||
}
|
||||
|
||||
int PKCS1_MGF1(unsigned char *mask, long len,
|
||||
|
||||
@@ -207,7 +207,7 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
|
||||
int i;
|
||||
/* |em| is the encoded message, zero-padded to exactly |num| bytes */
|
||||
unsigned char *em = NULL;
|
||||
unsigned int good, found_zero_byte;
|
||||
unsigned int good, found_zero_byte, mask;
|
||||
int zero_index = 0, msg_index, mlen = -1;
|
||||
|
||||
if (tlen < 0 || flen < 0)
|
||||
@@ -218,13 +218,12 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
|
||||
* section 7.2.2.
|
||||
*/
|
||||
|
||||
if (flen > num)
|
||||
goto err;
|
||||
if (flen > num || num < 11) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,
|
||||
RSA_R_PKCS_DECODING_ERROR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (num < 11)
|
||||
goto err;
|
||||
|
||||
if (flen != num) {
|
||||
em = OPENSSL_malloc(num);
|
||||
if (em == NULL) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, ERR_R_MALLOC_FAILURE);
|
||||
@@ -232,35 +231,36 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
|
||||
}
|
||||
/*
|
||||
* Caller is encouraged to pass zero-padded message created with
|
||||
* BN_bn2binpad, but if it doesn't, we do this zero-padding copy
|
||||
* to avoid leaking that information. The copy still leaks some
|
||||
* side-channel information, but it's impossible to have a fixed
|
||||
* memory access pattern since we can't read out of the bounds of
|
||||
* |from|.
|
||||
* BN_bn2binpad. Trouble is that since we can't read out of |from|'s
|
||||
* bounds, it's impossible to have an invariant memory access pattern
|
||||
* in case |from| was not zero-padded in advance.
|
||||
*/
|
||||
memset(em, 0, num);
|
||||
memcpy(em + num - flen, from, flen);
|
||||
from = em;
|
||||
for (from += flen, em += num, i = 0; i < num; i++) {
|
||||
mask = ~constant_time_is_zero(flen);
|
||||
flen -= 1 & mask;
|
||||
from -= 1 & mask;
|
||||
*--em = *from & mask;
|
||||
}
|
||||
|
||||
good = constant_time_is_zero(from[0]);
|
||||
good &= constant_time_eq(from[1], 2);
|
||||
good = constant_time_is_zero(em[0]);
|
||||
good &= constant_time_eq(em[1], 2);
|
||||
|
||||
/* scan over padding data */
|
||||
found_zero_byte = 0;
|
||||
for (i = 2; i < num; i++) {
|
||||
unsigned int equals0 = constant_time_is_zero(from[i]);
|
||||
zero_index =
|
||||
constant_time_select_int(~found_zero_byte & equals0, i,
|
||||
zero_index);
|
||||
unsigned int equals0 = constant_time_is_zero(em[i]);
|
||||
|
||||
zero_index = constant_time_select_int(~found_zero_byte & equals0,
|
||||
i, zero_index);
|
||||
found_zero_byte |= equals0;
|
||||
}
|
||||
|
||||
/*
|
||||
* PS must be at least 8 bytes long, and it starts two bytes into |from|.
|
||||
* PS must be at least 8 bytes long, and it starts two bytes into |em|.
|
||||
* If we never found a 0-byte, then |zero_index| is 0 and the check
|
||||
* also fails.
|
||||
*/
|
||||
good &= constant_time_ge((unsigned int)(zero_index), 2 + 8);
|
||||
good &= constant_time_ge(zero_index, 2 + 8);
|
||||
|
||||
/*
|
||||
* Skip the zero byte. This is incorrect if we never found a zero-byte
|
||||
@@ -270,30 +270,36 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
|
||||
mlen = num - msg_index;
|
||||
|
||||
/*
|
||||
* For good measure, do this check in constant time as well; it could
|
||||
* leak something if |tlen| was assuming valid padding.
|
||||
* For good measure, do this check in constant time as well.
|
||||
*/
|
||||
good &= constant_time_ge((unsigned int)(tlen), (unsigned int)(mlen));
|
||||
good &= constant_time_ge(tlen, mlen);
|
||||
|
||||
/*
|
||||
* We can't continue in constant-time because we need to copy the result
|
||||
* and we cannot fake its length. This unavoidably leaks timing
|
||||
* information at the API boundary.
|
||||
* Move the result in-place by |num|-11-|mlen| bytes to the left.
|
||||
* Then if |good| move |mlen| bytes from |em|+11 to |to|.
|
||||
* Otherwise leave |to| unchanged.
|
||||
* Copy the memory back in a way that does not reveal the size of
|
||||
* the data being copied via a timing side channel. This requires copying
|
||||
* parts of the buffer multiple times based on the bits set in the real
|
||||
* length. Clear bits do a non-copy with identical access pattern.
|
||||
* The loop below has overall complexity of O(N*log(N)).
|
||||
*/
|
||||
if (!good) {
|
||||
mlen = -1;
|
||||
goto err;
|
||||
tlen = constant_time_select_int(constant_time_lt(num - 11, tlen),
|
||||
num - 11, tlen);
|
||||
for (msg_index = 1; msg_index < num - 11; msg_index <<= 1) {
|
||||
mask = ~constant_time_eq(msg_index & (num - 11 - mlen), 0);
|
||||
for (i = 11; i < num - msg_index; i++)
|
||||
em[i] = constant_time_select_8(mask, em[i + msg_index], em[i]);
|
||||
}
|
||||
for (i = 0; i < tlen; i++) {
|
||||
mask = good & constant_time_lt(i, mlen);
|
||||
to[i] = constant_time_select_8(mask, em[i + 11], to[i]);
|
||||
}
|
||||
|
||||
memcpy(to, from + msg_index, mlen);
|
||||
|
||||
err:
|
||||
if (em != NULL) {
|
||||
OPENSSL_cleanse(em, num);
|
||||
OPENSSL_free(em);
|
||||
}
|
||||
if (mlen == -1)
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,
|
||||
RSA_R_PKCS_DECODING_ERROR);
|
||||
return mlen;
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, RSA_R_PKCS_DECODING_ERROR);
|
||||
err_clear_last_constant_time(1 & good);
|
||||
|
||||
return constant_time_select_int(good, mlen, -1);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 2006.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2006-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -103,7 +103,7 @@ static int pkey_rsa_init(EVP_PKEY_CTX *ctx)
|
||||
rctx = OPENSSL_malloc(sizeof(RSA_PKEY_CTX));
|
||||
if (!rctx)
|
||||
return 0;
|
||||
rctx->nbits = 1024;
|
||||
rctx->nbits = 2048;
|
||||
rctx->pub_exp = NULL;
|
||||
rctx->pad_mode = RSA_PKCS1_PADDING;
|
||||
rctx->md = NULL;
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/rand.h>
|
||||
#include "constant_time_locl.h"
|
||||
|
||||
int RSA_padding_add_SSLv23(unsigned char *to, int tlen,
|
||||
const unsigned char *from, int flen)
|
||||
@@ -101,57 +102,119 @@ int RSA_padding_add_SSLv23(unsigned char *to, int tlen,
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy of RSA_padding_check_PKCS1_type_2 with a twist that rejects padding
|
||||
* if nul delimiter is not preceded by 8 consecutive 0x03 bytes. It also
|
||||
* preserves error code reporting for backward compatibility.
|
||||
*/
|
||||
int RSA_padding_check_SSLv23(unsigned char *to, int tlen,
|
||||
const unsigned char *from, int flen, int num)
|
||||
{
|
||||
int i, j, k;
|
||||
const unsigned char *p;
|
||||
int i;
|
||||
/* |em| is the encoded message, zero-padded to exactly |num| bytes */
|
||||
unsigned char *em = NULL;
|
||||
unsigned int good, found_zero_byte, mask, threes_in_row;
|
||||
int zero_index = 0, msg_index, mlen = -1, err;
|
||||
|
||||
p = from;
|
||||
if (flen < 10) {
|
||||
if (tlen <= 0 || flen <= 0)
|
||||
return -1;
|
||||
|
||||
if (flen > num || num < 11) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_DATA_TOO_SMALL);
|
||||
return (-1);
|
||||
}
|
||||
/* Accept even zero-padded input */
|
||||
if (flen == num) {
|
||||
if (*(p++) != 0) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_BLOCK_TYPE_IS_NOT_02);
|
||||
|
||||
em = OPENSSL_malloc(num);
|
||||
if (em == NULL) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, ERR_R_MALLOC_FAILURE);
|
||||
return -1;
|
||||
}
|
||||
flen--;
|
||||
}
|
||||
if ((num != (flen + 1)) || (*(p++) != 02)) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_BLOCK_TYPE_IS_NOT_02);
|
||||
return (-1);
|
||||
/*
|
||||
* Caller is encouraged to pass zero-padded message created with
|
||||
* BN_bn2binpad. Trouble is that since we can't read out of |from|'s
|
||||
* bounds, it's impossible to have an invariant memory access pattern
|
||||
* in case |from| was not zero-padded in advance.
|
||||
*/
|
||||
for (from += flen, em += num, i = 0; i < num; i++) {
|
||||
mask = ~constant_time_is_zero(flen);
|
||||
flen -= 1 & mask;
|
||||
from -= 1 & mask;
|
||||
*--em = *from & mask;
|
||||
}
|
||||
|
||||
good = constant_time_is_zero(em[0]);
|
||||
good &= constant_time_eq(em[1], 2);
|
||||
err = constant_time_select_int(good, 0, RSA_R_BLOCK_TYPE_IS_NOT_02);
|
||||
mask = ~good;
|
||||
|
||||
/* scan over padding data */
|
||||
j = flen - 1; /* one for type */
|
||||
for (i = 0; i < j; i++)
|
||||
if (*(p++) == 0)
|
||||
break;
|
||||
found_zero_byte = 0;
|
||||
threes_in_row = 0;
|
||||
for (i = 2; i < num; i++) {
|
||||
unsigned int equals0 = constant_time_is_zero(em[i]);
|
||||
|
||||
if ((i == j) || (i < 8)) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,
|
||||
zero_index = constant_time_select_int(~found_zero_byte & equals0,
|
||||
i, zero_index);
|
||||
found_zero_byte |= equals0;
|
||||
|
||||
threes_in_row += 1 & ~found_zero_byte;
|
||||
threes_in_row &= found_zero_byte | constant_time_eq(em[i], 3);
|
||||
}
|
||||
|
||||
/*
|
||||
* PS must be at least 8 bytes long, and it starts two bytes into |em|.
|
||||
* If we never found a 0-byte, then |zero_index| is 0 and the check
|
||||
* also fails.
|
||||
*/
|
||||
good &= constant_time_ge(zero_index, 2 + 8);
|
||||
err = constant_time_select_int(mask | good, err,
|
||||
RSA_R_NULL_BEFORE_BLOCK_MISSING);
|
||||
return (-1);
|
||||
mask = ~good;
|
||||
|
||||
good &= constant_time_ge(threes_in_row, 8);
|
||||
err = constant_time_select_int(mask | good, err,
|
||||
RSA_R_SSLV3_ROLLBACK_ATTACK);
|
||||
mask = ~good;
|
||||
|
||||
/*
|
||||
* Skip the zero byte. This is incorrect if we never found a zero-byte
|
||||
* but in this case we also do not copy the message out.
|
||||
*/
|
||||
msg_index = zero_index + 1;
|
||||
mlen = num - msg_index;
|
||||
|
||||
/*
|
||||
* For good measure, do this check in constant time as well.
|
||||
*/
|
||||
good &= constant_time_ge(tlen, mlen);
|
||||
err = constant_time_select_int(mask | good, err, RSA_R_DATA_TOO_LARGE);
|
||||
|
||||
/*
|
||||
* Move the result in-place by |num|-11-|mlen| bytes to the left.
|
||||
* Then if |good| move |mlen| bytes from |em|+11 to |to|.
|
||||
* Otherwise leave |to| unchanged.
|
||||
* Copy the memory back in a way that does not reveal the size of
|
||||
* the data being copied via a timing side channel. This requires copying
|
||||
* parts of the buffer multiple times based on the bits set in the real
|
||||
* length. Clear bits do a non-copy with identical access pattern.
|
||||
* The loop below has overall complexity of O(N*log(N)).
|
||||
*/
|
||||
tlen = constant_time_select_int(constant_time_lt(num - 11, tlen),
|
||||
num - 11, tlen);
|
||||
for (msg_index = 1; msg_index < num - 11; msg_index <<= 1) {
|
||||
mask = ~constant_time_eq(msg_index & (num - 11 - mlen), 0);
|
||||
for (i = 11; i < num - msg_index; i++)
|
||||
em[i] = constant_time_select_8(mask, em[i + msg_index], em[i]);
|
||||
}
|
||||
for (k = -9; k < -1; k++) {
|
||||
if (p[k] != 0x03)
|
||||
break;
|
||||
}
|
||||
if (k == -1) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_SSLV3_ROLLBACK_ATTACK);
|
||||
return (-1);
|
||||
for (i = 0; i < tlen; i++) {
|
||||
mask = good & constant_time_lt(i, mlen);
|
||||
to[i] = constant_time_select_8(mask, em[i + 11], to[i]);
|
||||
}
|
||||
|
||||
i++; /* Skip over the '\0' */
|
||||
j -= i;
|
||||
if (j > tlen) {
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_DATA_TOO_LARGE);
|
||||
return (-1);
|
||||
}
|
||||
memcpy(to, p, (unsigned int)j);
|
||||
OPENSSL_cleanse(em, num);
|
||||
OPENSSL_free(em);
|
||||
RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, err);
|
||||
err_clear_last_constant_time(1 & good);
|
||||
|
||||
return (j);
|
||||
return constant_time_select_int(good, mlen, -1);
|
||||
}
|
||||
|
||||
@@ -509,6 +509,24 @@ static int open_console(UI *ui)
|
||||
is_a_tty = 0;
|
||||
else
|
||||
# endif
|
||||
# ifdef ENXIO
|
||||
/*
|
||||
* Solaris can return ENXIO.
|
||||
* This should be ok
|
||||
*/
|
||||
if (errno == ENXIO)
|
||||
is_a_tty = 0;
|
||||
else
|
||||
# endif
|
||||
# ifdef EIO
|
||||
/*
|
||||
* Linux can return EIO.
|
||||
* This should be ok
|
||||
*/
|
||||
if (errno == EIO)
|
||||
is_a_tty = 0;
|
||||
else
|
||||
# endif
|
||||
# ifdef ENODEV
|
||||
/*
|
||||
* MacOS X returns ENODEV (Operation not supported by device),
|
||||
|
||||
@@ -128,7 +128,7 @@ static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
|
||||
switch (cmd) {
|
||||
case X509_L_ADD_DIR:
|
||||
if (argl == X509_FILETYPE_DEFAULT) {
|
||||
dir = (char *)getenv(X509_get_default_cert_dir_env());
|
||||
dir = (char *)ossl_safe_getenv(X509_get_default_cert_dir_env());
|
||||
if (dir)
|
||||
ret = add_cert_dir(ld, dir, X509_FILETYPE_PEM);
|
||||
else
|
||||
|
||||
@@ -97,7 +97,8 @@ static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp,
|
||||
switch (cmd) {
|
||||
case X509_L_FILE_LOAD:
|
||||
if (argl == X509_FILETYPE_DEFAULT) {
|
||||
file = getenv(X509_get_default_cert_file_env());
|
||||
file = ossl_safe_getenv(X509_get_default_cert_file_env());
|
||||
|
||||
if (file)
|
||||
ok = (X509_load_cert_crl_file(ctx, file,
|
||||
X509_FILETYPE_PEM) != 0);
|
||||
|
||||
@@ -490,6 +490,8 @@ STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain)
|
||||
STACK_OF(X509) *ret;
|
||||
int i;
|
||||
ret = sk_X509_dup(chain);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
for (i = 0; i < sk_X509_num(ret); i++) {
|
||||
X509 *x = sk_X509_value(ret, i);
|
||||
CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
|
||||
|
||||
@@ -621,7 +621,7 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
|
||||
* A hack to keep people who don't want to modify their software
|
||||
* happy
|
||||
*/
|
||||
if (getenv("OPENSSL_ALLOW_PROXY_CERTS"))
|
||||
if (ossl_safe_getenv("OPENSSL_ALLOW_PROXY_CERTS"))
|
||||
allow_proxy_certs = 1;
|
||||
purpose = ctx->param->purpose;
|
||||
}
|
||||
@@ -694,10 +694,9 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
/* Check pathlen if not self issued */
|
||||
if ((i > 1) && !(x->ex_flags & EXFLAG_SI)
|
||||
&& (x->ex_pathlen != -1)
|
||||
&& (plen > (x->ex_pathlen + proxy_path_length + 1))) {
|
||||
/* Check pathlen */
|
||||
if ((i > 1) && (x->ex_pathlen != -1)
|
||||
&& (plen > (x->ex_pathlen + proxy_path_length))) {
|
||||
ctx->error = X509_V_ERR_PATH_LENGTH_EXCEEDED;
|
||||
ctx->error_depth = i;
|
||||
ctx->current_cert = x;
|
||||
@@ -705,8 +704,8 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
|
||||
if (!ok)
|
||||
goto end;
|
||||
}
|
||||
/* Increment path length if not self issued */
|
||||
if (!(x->ex_flags & EXFLAG_SI))
|
||||
/* Increment path length if not a self issued intermediate CA */
|
||||
if (i > 0 && (x->ex_flags & EXFLAG_SI) == 0)
|
||||
plen++;
|
||||
/*
|
||||
* If this certificate is a proxy certificate, the next certificate
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2003 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -205,15 +205,18 @@ int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen)
|
||||
break;
|
||||
|
||||
case GEN_EMAIL:
|
||||
BIO_printf(out, "email:%s", gen->d.ia5->data);
|
||||
BIO_printf(out, "email:");
|
||||
ASN1_STRING_print(out, gen->d.ia5);
|
||||
break;
|
||||
|
||||
case GEN_DNS:
|
||||
BIO_printf(out, "DNS:%s", gen->d.ia5->data);
|
||||
BIO_printf(out, "DNS:");
|
||||
ASN1_STRING_print(out, gen->d.ia5);
|
||||
break;
|
||||
|
||||
case GEN_URI:
|
||||
BIO_printf(out, "URI:%s", gen->d.ia5->data);
|
||||
BIO_printf(out, "URI:");
|
||||
ASN1_STRING_print(out, gen->d.ia5);
|
||||
break;
|
||||
|
||||
case GEN_DIRNAME:
|
||||
|
||||
@@ -396,12 +396,8 @@ static void x509v3_cache_extensions(X509 *x)
|
||||
ASN1_BIT_STRING *ns;
|
||||
EXTENDED_KEY_USAGE *extusage;
|
||||
X509_EXTENSION *ex;
|
||||
|
||||
int i;
|
||||
|
||||
if (x->ex_flags & EXFLAG_SET)
|
||||
return;
|
||||
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_X509);
|
||||
if (x->ex_flags & EXFLAG_SET) {
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_X509);
|
||||
|
||||
@@ -214,7 +214,7 @@ the section of the configuration file containing certificate extensions
|
||||
to be added when a certificate is issued (defaults to B<x509_extensions>
|
||||
unless the B<-extfile> option is used). If no extension section is
|
||||
present then, a V1 certificate is created. If the extension section
|
||||
is present (even if it is empty), then a V3 certificate is created. See the:w
|
||||
is present (even if it is empty), then a V3 certificate is created. See the
|
||||
L<x509v3_config(5)|x509v3_config(5)> manual page for details of the
|
||||
extension section format.
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ Convert a CRL file from PEM to DER:
|
||||
|
||||
Output the text form of a DER encoded certificate:
|
||||
|
||||
openssl crl -in crl.der -text -noout
|
||||
openssl crl -in crl.der -inform DER -text -noout
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ below.
|
||||
|
||||
=item B<rsa_keygen_bits:numbits>
|
||||
|
||||
The number of bits in the generated key. If not specified 1024 is used.
|
||||
The number of bits in the generated key. If not specified 2048 is used.
|
||||
|
||||
=item B<rsa_keygen_pubexp:value>
|
||||
|
||||
@@ -149,12 +149,12 @@ below.
|
||||
|
||||
=item B<dsa_paramgen_bits:numbits>
|
||||
|
||||
The number of bits in the generated prime. If not specified 1024 is used.
|
||||
The number of bits in the generated prime. If not specified 2048 is used.
|
||||
|
||||
=item B<dsa_paramgen_q_bits:numbits>
|
||||
|
||||
The number of bits in the q parameter. Must be one of 160, 224 or 256. If not
|
||||
specified 160 is used.
|
||||
specified 224 is used.
|
||||
|
||||
=item B<dsa_paramgen_md:digest>
|
||||
|
||||
@@ -173,7 +173,7 @@ or B<sha256> if it is 256.
|
||||
|
||||
=item B<dh_paramgen_prime_len:numbits>
|
||||
|
||||
The number of bits in the prime parameter B<p>. The default is 1024.
|
||||
The number of bits in the prime parameter B<p>. The default is 2048.
|
||||
|
||||
=item B<dh_paramgen_subprime_len:numbits>
|
||||
|
||||
|
||||
@@ -393,8 +393,7 @@ option. For compatibility B<encrypt_rsa_key> is an equivalent option.
|
||||
=item B<default_md>
|
||||
|
||||
This option specifies the digest algorithm to use. Possible values
|
||||
include B<md5 sha1 mdc2>. If not present then MD5 is used. This
|
||||
option can be overridden on the command line.
|
||||
include B<md5 sha1 mdc2>. This option can be overridden on the command line.
|
||||
|
||||
=item B<string_mask>
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ B<openssl> B<s_server>
|
||||
[B<-no_ssl3>]
|
||||
[B<-no_tls1>]
|
||||
[B<-no_dhe>]
|
||||
[B<-no_ecdhe>]
|
||||
[B<-bugs>]
|
||||
[B<-hack>]
|
||||
[B<-www>]
|
||||
@@ -144,6 +145,11 @@ a static set of parameters hard coded into the s_server program will be used.
|
||||
if this option is set then no DH parameters will be loaded effectively
|
||||
disabling the ephemeral DH cipher suites.
|
||||
|
||||
=item B<-no_ecdhe>
|
||||
|
||||
if this option is set then no ECDH parameters will be selected, effectively
|
||||
disabling the ephemeral ECDH cipher suites.
|
||||
|
||||
=item B<-no_tmp_rsa>
|
||||
|
||||
certain export cipher suites sometimes use a temporary RSA key, this option
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user