Skip to content

Commit

Permalink
deps: upgrade openssl sources to 1.0.2f
Browse files Browse the repository at this point in the history
This replaces all sources of openssl-1.0.2f.tar.gz
into deps/openssl/openssl

Fix: #4857
PR-URL: #4961
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>

deps: copy openssl header files to include dir

All symlink files in deps/openssl/openssl/include/openssl/ are removed
and replaced with real header files to avoid issues on Windows.
Two files of opensslconf.h in crypto and include dir are replaced to
refer config/opensslconf.h.

Fix: #4857
PR-URL: #4961
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>

deps: fix openssl assembly error on ia32 win32

`x86masm.pl` was mistakenly using .486 instruction set, why `cpuid` (and
perhaps others) are requiring .686 .

Fixes: #589
PR-URL: #1389
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>

deps: fix asm build error of openssl in x86_win32

See
https://mta.openssl.org/pipermail/openssl-dev/2015-February/000651.html

iojs needs to stop using masm and move to nasm or yasm on Win32.

Fixes: #589
PR-URL: #1389
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

openssl: fix keypress requirement in apps on win32

Reapply b910613 .

Fixes: #589
PR-URL: #1389
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

docs: update openssl UPDATING guide

the guide is now current with the steps taken to update
openssl to v1.0.2f

PR-URL: #4961
Reviewed-By: Myles Borins <mborins@us.ibm.com>
  • Loading branch information
Myles Borins authored and Shigeki Ohtsu committed Jan 31, 2016
1 parent 6cbbfef commit 1f43478
Show file tree
Hide file tree
Showing 199 changed files with 1,216 additions and 564 deletions.
235 changes: 213 additions & 22 deletions deps/openssl/doc/UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## How to upgrade openssl library in Node.js

This document describes the procedure to upgrade openssl from 1.0.2a
to 1.0.2c in Node.js.

This document describes the procedure to upgrade openssl from 1.0.2e
to 1.0.2f in Node.js. This procedure might be applied to upgrading
any versions in 1.0.2.

### Build System and Upgrading Overview
The openssl build system is based on the `Configure` perl script in
Expand Down Expand Up @@ -31,6 +31,8 @@ The tested platform in CI are also listed.

| --dest-os | --dest-cpu | conf | asm | openssl target | CI |
|---------- |----------- |----- |----- |------------------- |--- |
| aix | ppc | o | x(*2)| aix-gcc | o |
| aix | ppc64 | o | x(*2)| aix64-gcc | o |
| linux | ia32 | o | o |linux-elf | o |
| linux | x32 | o | x(*2)|linux-x32 | x |
| linux | x64 | o | o |linux-x86_64 | o |
Expand Down Expand Up @@ -91,48 +93,197 @@ https://github.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/crypto/sha/asm/sha5
otherwise asm_obsolete are used.

The following is the detail instruction steps how to upgrade openssl
version from 1.0.2a to 1.0.2c in node.
version from 1.0.2e to 1.0.2f in node.

*This needs to run Linux
enviroment.*

### 1. Replace openssl source in `deps/openssl/openssl`
Remove old openssl sources in `deps/openssl/openssl` .
Get original openssl sources from
https://www.openssl.org/source/openssl-1.0.2c.tar.gz and extract all
https://www.openssl.org/source/openssl-1.0.2f.tar.gz and extract all
files into `deps/openssl/openssl` .

### 2. Apply private patches
There are three kinds of private patches to be applied in openssl-1.0.2c.

- The two fixes of assembly error on ia32 win32. masm is no longer
supported in openssl. We should move to use nasm or yasm in future
version of node.

- The fix of openssl-cli built on win. Key press requirement of
openssl-cli in win causes timeout failures of several tests.
```sh
ohtsu@ubuntu:~/github/node$ cd deps/openssl/
ohtsu@ubuntu:~/github/node/deps/openssl$ rm -rf openssl
ohtsu@ubuntu:~/github/node/deps/openssl$ tar zxf ~/tmp/openssl-1.0.2f.tar.gz
ohtsu@ubuntu:~/github/node/deps/openssl$ mv openssl-1.0.2f openssl
ohtsu@ubuntu:~/github/node/deps/openssl$ git add --all openssl
ohtsu@ubuntu:~/github/node/deps/openssl$ git commit openssl
````
The commit message can be

- A new `-no_rand_screen` option to openssl s_client. This makes test
time of test-tls-server-verify be much faster.
>deps: upgrade openssl sources to 1.0.2f
>
>This replaces all sources of openssl-1.0.2f.tar.gz into
>deps/openssl/openssl

### 3. Replace openssl header files in `deps/openssl/openssl/include/openssl`
### 2. Replace openssl header files in `deps/openssl/openssl/include/openssl`
all header files in `deps/openssl/openssl/include/openssl/*.h` are
symbolic links in the distributed release tar.gz. They cause issues in
Windows. They are copied from the real files of symlink origin into
the include directory. During installation, they also copied into
`PREFIX/node/include` by tools/install.py.
`deps/openssl/openssl/include/openssl/opensslconf.h` and
`deps/openssl/openssl/crypto/opensslconf.h` needs to be changed so as
to refer the platform independent file of `deps/openssl/config/opensslconf.h`

The following shell script (copy_symlink.sh) is my tool for working
this procedures to invoke it in the `deps/openssl/openssl/include/openssl/`.

```sh
#!/bin/bash
for var in "$@"
do
if [ -L $var ]; then
origin=`readlink $var`
rm $var
cp $origin $var
fi
done
rm opensslconf.h
echo '#include "../../crypto/opensslconf.h"' > opensslconf.h
rm ../../crypto/opensslconf.h
echo '#include "../../config/opensslconf.h"' > ../../crypto/opensslconf.h
````
This step somehow gets troublesome since openssl-1.0.2f because
symlink headers are removed in tar.gz file and we have to execute
./config script to generate them. The config script also generate
unnecessary platform dependent files in the repository so that we have
to clean up them after committing header files.
```sh
ohtsu@ubuntu:~/github/node/deps/openssl$ cd openssl/
ohtsu@ubuntu:~/github/node/deps/openssl/openssl$ ./config

make[1]: Leaving directory `/home/ohtsu/github/node/deps/openssl/openssl/test'
Configured for linux-x86_64.
ohtsu@ubuntu:~/github/node/deps/openssl/openssl$ cd include/openssl/
ohtsu@ubuntu:~/github/node/deps/openssl/openssl/include/openssl$ ~/copy_symlink.sh *.h
ohtsu@ubuntu:~/github/node/deps/openssl/openssl/include/openssl$ cd ../..
ohtsu@ubuntu:~/github/node/deps/openssl/openssl$ git add include
ohtsu@ubuntu:~/github/node/deps/openssl/openssl$ git commit include/ crypto/opensslconf.h
ohtsu@ubuntu:~/github/node/deps/openssl/openssl$ git clean -f
ohtsu@ubuntu:~/github/node/deps/openssl/openssl$ git checkout Makefile Makefile.bak
````
The commit message can be
>deps: copy all openssl header files to include dir
>
>All symlink files in `deps/openssl/openssl/include/openssl/`
>are removed and replaced with real header files to avoid
>issues on Windows. Two files of opensslconf.h in crypto and
>include dir are replaced to refer config/opensslconf.h.
### 3. Apply floating patches
At the time of writing, there are four floating patches to be applied
to openssl.
- Two fixes for assembly errors on ia32 win32.
- One fix for openssl-cli built on win. Key press requirement of
openssl-cli in win causes timeout failures of several tests.
- Adding a new `-no_rand_screen` option to openssl s_client. This
makes test time of test-tls-server-verify be much faster.
These fixes can be applied via cherry-pick. The first three will merge without conflict.
The last commit can be landed using a recursive strategy that prefers newer changes.
```sh
git cherry-pick c66c3d9fa3f5bab0bdfe363dd947136cf8a3907f
git cherry-pick 42a8de2ac66b6953cbc731fdb0b128b8019643b2
git cherry-pick 2eb170874aa5e84e71b62caab7ac9792fd59c10f
git cherry-pick --strategy=recursive -X theirs 664a659
```
If you attempted to cherry-pick the last commit you would have the following conflict
```
# do not do this
git cherry-pick 664a6596960655e214fef25e74d3285097703e95
error: could not apply 664a659... deps: add -no_rand_screen to openssl s_client
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
git cherry-pi
```
the conflict is in `deps/openssl/openssl/apps/app_rand.c` as below.
```sh
ohtsu@omb:openssl$ git diff
diff --cc deps/openssl/openssl/apps/app_rand.c
index 7f40bba,b6fe294..0000000
--- a/deps/openssl/openssl/apps/app_rand.c
+++ b/deps/openssl/openssl/apps/app_rand.c
@@@ -124,7 -124,16 +124,20 @@@ int app_RAND_load_file(const char *file
char buffer[200];
#ifdef OPENSSL_SYS_WINDOWS
++<<<<<<< HEAD
+ RAND_screen();
++=======
+ /*
+ * allocate 2 to dont_warn not to use RAND_screen() via
+ * -no_rand_screen option in s_client
+ */
+ if (dont_warn != 2) {
+ BIO_printf(bio_e, "Loading 'screen' into random state -");
+ BIO_flush(bio_e);
+ RAND_screen();
+ BIO_printf(bio_e, " done\n");
+ }
++>>>>>>> 664a659... deps: add -no_rand_screen to openssl s_client
#endif
if (file == NULL)
````
We want to opt for the changes from 664a659 instead of the changes present on HEAD.
`git cherry-pick --strategy=recursive -X theirs` will do just that!
### 4. Change `opensslconf.h` so as to fit each platform.
No change.
opensslconf.h includes defines and macros which are platform
dependent. Each files can be generated via `deps/openssl/config/Makefile`
We can regenerate them and commit them if any diffs exist.
```sh
ohtsu@ubuntu:~/github/node/deps/openssl$ cd config
ohtsu@ubuntu:~/github/node/deps/openssl/config$ make clean
find archs -name opensslconf.h -exec rm "{}" \;
ohtsu@ubuntu:~/github/node/deps/openssl/config$ make
cd ../openssl; perl ./Configure no-shared no-symlinks aix-gcc > /dev/null
ohtsu@ubuntu:~/github/node/deps/openssl/config$ git diff
ohtsu@ubuntu:~/github/node/deps/openssl/config$ git commit .
````
The commit message can be
>deps: update openssl config files
>
>Regenerate config files for supported platforms with Makefile.
### 5. Update openssl.gyp and openssl.gypi
No change.
This process is needed when source files are removed, renamed and added.
It seldom happen in the minor bug fix release. Build errors would be
thrown if it happens. In case of build errors, we need to check source
files in Makefiles of its platform and change openssl.gyp or
openssl.gypi according to the changes of source files. Please contact
@shigeki if it is needed.
### 6. ASM files for openssl
We provide two sets of asm files. One is for the latest assembler
and the other is the older one.
and the other is the older one. sections 6.1 and 6.2 describe the two
types of files. Section 6.3 explains the steps to update the files.
In the case of upgrading 1.0.2f there were no changes to the asm files.
### 6.1. asm files for the latest compiler
This was made in `deps/openssl/asm/Makefile`
- Updated asm files for each platforms which are required in
openssl-1.0.2c.
openssl-1.0.2f.
- Some perl files need CC and ASM envs. Added a check if these envs
exist. Followed asm files are to be generated with CC=gcc and
ASM=nasm on Linux. See
Expand All @@ -148,8 +299,9 @@ This was made in `deps/openssl/asm/Makefile`
With export environments of CC=gcc and ASM=nasm, then type make
command and check if new asm files are generated.
If you don't have nasm please install it such as `apt-get install nasm`.
### 6.2.asm files for the older compiler
### 6.2. asm files for the older compiler
For older assembler, the version check of CC and ASM should be
skipped in generating asm file with perl scripts.
Copy files from `deps/openssl/asm` into
Expand All @@ -158,3 +310,42 @@ into this directories and remove the check of CC and ASM envs.
Without environments of CC and ASM, then type make command and check
if new asm files for older compilers are generated.
The following steps includes version check of gcc and nasm.
### 6.3 steps
```sh
ohtsu@ubuntu:~/github/node/deps/openssl/config$ cd ../asm
ohtsu@ubuntu:~/github/node/deps/openssl/asm$ gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ohtsu@ubuntu:~/github/node/deps/openssl/asm$ nasm -v
NASM version 2.10.09 compiled on Dec 29 2013
ohtsu@ubuntu:~/github/node/deps/openssl/asm$ export CC=gcc
ohtsu@ubuntu:~/github/node/deps/openssl/asm$ export ASM=nasm
ohtsu@ubuntu:~/github/node/deps/openssl/asm$ make clean
find . -iname '*.asm' -exec rm "{}" \;
find . -iname '*.s' -exec rm "{}" \;
find . -iname '*.S' -exec rm "{}" \;
ohtsu@ubuntu:~/github/node/deps/openssl/asm$ make
ohtsu@ubuntu:~/github/node/deps/openssl/asm$ cd ../asm_obsolete/
ohtsu@ubuntu:~/github/node/deps/openssl/asm_obsolete$ unset CC
ohtsu@ubuntu:~/github/node/deps/openssl/asm_obsolete$ unset ASM
ohtsu@ubuntu:~/github/node/deps/openssl/asm_obsolete$ make clean
find . -iname '*.asm' -exec rm "{}" \;
find . -iname '*.s' -exec rm "{}" \;
find . -iname '*.S' -exec rm "{}" \;
ohtsu@ubuntu:~/github/node/deps/openssl$ git status
ohtsu@ubuntu:~/github/node/deps/openssl$ git commit asm asm_obsolete
````
The commit message can be
>deps: update openssl asm and asm_obsolete files
>
>Regenerate asm files with Makefile and CC=gcc and ASM=gcc where
>gcc-4.8.4. Also asm files in asm_obsolete dir to support old compiler
>and assembler are regenerated without CC and ASM envs.
32 changes: 2 additions & 30 deletions deps/openssl/openssl/ACKNOWLEDGMENTS
Original file line number Diff line number Diff line change
@@ -1,30 +1,2 @@
The OpenSSL project depends on volunteer efforts and financial support from
the end user community. That support comes in the form of donations and paid
sponsorships, software support contracts, paid consulting services
and commissioned software development.

Since all these activities support the continued development and improvement
of OpenSSL we consider all these clients and customers as sponsors of the
OpenSSL project.

We would like to identify and thank the following such sponsors for their past
or current significant support of the OpenSSL project:

Major support:

Qualys http://www.qualys.com/

Very significant support:

OpenGear: http://www.opengear.com/

Significant support:

PSW Group: http://www.psw.net/
Acano Ltd. http://acano.com/

Please note that we ask permission to identify sponsors and that some sponsors
we consider eligible for inclusion here have requested to remain anonymous.

Additional sponsorship or financial support is always welcome: for more
information please contact the OpenSSL Software Foundation.
Please https://www.openssl.org/community/thanks.html for the current
acknowledgements.
48 changes: 48 additions & 0 deletions deps/openssl/openssl/CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,54 @@
OpenSSL CHANGES
_______________

Changes between 1.0.2e and 1.0.2f [28 Jan 2016]

*) DH small subgroups

Historically OpenSSL only ever generated DH parameters based on "safe"
primes. More recently (in version 1.0.2) support was provided for
generating X9.42 style parameter files such as those required for RFC 5114
support. The primes used in such files may not be "safe". Where an
application is using DH configured with parameters based on primes that are
not "safe" then an attacker could use this fact to find a peer's private
DH exponent. This attack requires that the attacker complete multiple
handshakes in which the peer uses the same private DH exponent. For example
this could be used to discover a TLS server's private DH exponent if it's
reusing the private DH exponent or it's using a static DH ciphersuite.

OpenSSL provides the option SSL_OP_SINGLE_DH_USE for ephemeral DH (DHE) in
TLS. It is not on by default. If the option is not set then the server
reuses the same private DH exponent for the life of the server process and
would be vulnerable to this attack. It is believed that many popular
applications do set this option and would therefore not be at risk.

The fix for this issue adds an additional check where a "q" parameter is
available (as is the case in X9.42 based parameters). This detects the
only known attack, and is the only possible defense for static DH
ciphersuites. This could have some performance impact.

Additionally the SSL_OP_SINGLE_DH_USE option has been switched on by
default and cannot be disabled. This could have some performance impact.

This issue was reported to OpenSSL by Antonio Sanso (Adobe).
(CVE-2016-0701)
[Matt Caswell]

*) SSLv2 doesn't block disabled ciphers

A malicious client can negotiate SSLv2 ciphers that have been disabled on
the server and complete SSLv2 handshakes even if all SSLv2 ciphers have
been disabled, provided that the SSLv2 protocol was not also disabled via
SSL_OP_NO_SSLv2.

This issue was reported to OpenSSL on 26th December 2015 by Nimrod Aviram
and Sebastian Schinzel.
(CVE-2015-3197)
[Viktor Dukhovni]

*) Reject DH handshakes with parameters shorter than 1024 bits.
[Kurt Roeckx]

Changes between 1.0.2d and 1.0.2e [3 Dec 2015]

*) BN_mod_exp may produce incorrect results on x86_64
Expand Down
Loading

0 comments on commit 1f43478

Please sign in to comment.