Skip to content

Commit 08af7db

Browse files
committed
build: add OpenSSL-1.1.0 support
- For Windows, nasm is new build requirements and openssl_no_asm is set to 1 with warning if it is not installed. - For use of openssl assemble codes, either gas_version >= 2.23, xcode_version >= 5.0 ,llvm_version >= 3.3 or nasm_version >= 2.10 is needed. Otherwise, openssl_no_asm is set to 1 with warning. - FIPS is not supported in OpenSSL-1.1.0 so that it leads an error when openssl_fips options is enabled in configure. Fixes: #4270 PR-URL: #19794 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 7812ec7 commit 08af7db

File tree

4 files changed

+68
-61
lines changed

4 files changed

+68
-61
lines changed

BUILDING.md

+18-38
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ Depending on host platform, the selection of toolchains may vary.
8888

8989
* Visual Studio 2017 or the Build Tools thereof
9090

91+
#### OpenSSL asm support
92+
93+
OpenSSL-1.1.0 requires the following asssembler version for use of asm
94+
support.
95+
96+
* gas (GNU assembler) version 2.23 or higher
97+
* xcode version 5.0 or higher
98+
* llvm version 3.3 or higher
99+
* nasm version 2.10 or higher in Windows
100+
101+
Otherwise, `--openssl-no-asm` is added with warning in configure.
102+
103+
*Note:* The forthcoming OpenSSL-1.1.1 will require higher
104+
version. Please refer
105+
https://www.openssl.org/docs/man1.1.1/man3/OPENSSL_ia32cap.html for
106+
details.
107+
91108
## Building Node.js on supported platforms
92109

93110
*Note:* All prerequisites can be easily installed by following
@@ -377,44 +394,7 @@ as `deps/icu` (You'll have: `deps/icu/source/...`)
377394

378395
## Building Node.js with FIPS-compliant OpenSSL
379396

380-
It is possible to build Node.js with the
381-
[OpenSSL FIPS module](https://www.openssl.org/docs/fipsnotes.html) on POSIX
382-
systems. Windows is not supported.
383-
384-
Building in this way does not mean the runtime is FIPS 140-2 validated, but
385-
rather that the runtime uses a validated module. In addition, the validation for
386-
the underlying module is only valid if it is deployed in accordance with its
387-
[security policy](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf).
388-
If you need FIPS validated cryptography it is recommended that you read both
389-
the [security policy](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf)
390-
and [user guide](https://openssl.org/docs/fips/UserGuide-2.0.pdf).
391-
392-
### Instructions
393-
394-
1. Obtain a copy of openssl-fips-x.x.x.tar.gz.
395-
To comply with the security policy you must ensure the path
396-
through which you get the file complies with the requirements
397-
for a "secure installation" as described in section 6.6 in
398-
the [user guide](https://openssl.org/docs/fips/UserGuide-2.0.pdf).
399-
For evaluation/experimentation, you can simply download and verify
400-
`openssl-fips-x.x.x.tar.gz` from https://www.openssl.org/source/
401-
2. Extract source to `openssl-fips` folder and `cd openssl-fips`
402-
3. `./config`
403-
4. `make`
404-
5. `make install`
405-
(NOTE: to comply with the security policy you must use the exact
406-
commands in steps 3-5 without any additional options as per
407-
Appendix A in the [security policy](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf).
408-
The only exception is that `./config no-asm` can be
409-
used in place of `./config`, and the FIPSDIR environment variable
410-
may be used to specify a non-standard install folder for the
411-
validated module, as per User Guide sections 4.2.1, 4.2.2, and 4.2.3.
412-
6. Get into Node.js checkout folder
413-
7. `./configure --openssl-fips=/path/to/openssl-fips/installdir`
414-
For example on ubuntu 12 the installation directory was
415-
`/usr/local/ssl/fips-2.0`
416-
8. Build Node.js with `make -j`
417-
9. Verify with `node -p "process.versions.openssl"` (for example `1.0.2a-fips`)
397+
This version of Node.js does not support FIPS.
418398

419399
## Building Node.js with external core modules
420400

configure

+47-20
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,25 @@ def get_version_helper(cc, regexp):
639639
else:
640640
return 0
641641

642+
def get_nasm_version(asm):
643+
try:
644+
proc = subprocess.Popen(shlex.split(asm) + ['-v'],
645+
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
646+
stdout=subprocess.PIPE)
647+
except OSError:
648+
warn('''No acceptable ASM compiler found!
649+
Please make sure you have installed nasm from http://www.nasm.us
650+
and refer BUILDING.md.''')
651+
return 0
652+
653+
match = re.match(r"NASM version ([2-9]\.[0-9][0-9]+)",
654+
proc.communicate()[0])
655+
656+
if match:
657+
return match.group(1)
658+
else:
659+
return 0
660+
642661
def get_llvm_version(cc):
643662
return get_version_helper(
644663
cc, r"(^(?:FreeBSD )?clang version|based on LLVM) ([3-9]\.[0-9]+)")
@@ -677,6 +696,11 @@ def get_gas_version(cc):
677696
# quite prepared to go that far yet.
678697
def check_compiler(o):
679698
if sys.platform == 'win32':
699+
if not options.openssl_no_asm:
700+
nasm_version = get_nasm_version('nasm')
701+
o['variables']['nasm_version'] = nasm_version
702+
if nasm_version == 0:
703+
o['variables']['openssl_no_asm'] = 1
680704
return
681705

682706
ok, is_clang, clang_version, gcc_version = try_check_compiler(CXX, 'c++')
@@ -1039,32 +1063,35 @@ def configure_v8(o):
10391063

10401064

10411065
def configure_openssl(o):
1042-
o['variables']['node_use_openssl'] = b(not options.without_ssl)
1043-
o['variables']['node_shared_openssl'] = b(options.shared_openssl)
1044-
o['variables']['openssl_no_asm'] = 1 if options.openssl_no_asm else 0
1066+
variables = o['variables']
1067+
variables['node_use_openssl'] = b(not options.without_ssl)
1068+
variables['node_shared_openssl'] = b(options.shared_openssl)
1069+
variables['openssl_no_asm'] = 1 if options.openssl_no_asm else 0
10451070
if options.use_openssl_ca_store:
10461071
o['defines'] += ['NODE_OPENSSL_CERT_STORE']
10471072
if options.openssl_system_ca_path:
1048-
o['variables']['openssl_system_ca_path'] = options.openssl_system_ca_path
1049-
o['variables']['node_without_node_options'] = b(options.without_node_options)
1073+
variables['openssl_system_ca_path'] = options.openssl_system_ca_path
1074+
variables['node_without_node_options'] = b(options.without_node_options)
10501075
if options.without_node_options:
10511076
o['defines'] += ['NODE_WITHOUT_NODE_OPTIONS']
1077+
1078+
# supported asm compiler for AVX2. See https://github.com/openssl/openssl/
1079+
# blob/OpenSSL_1_1_0-stable/crypto/modes/asm/aesni-gcm-x86_64.pl#L52-L69
1080+
openssl110_asm_supported = \
1081+
('gas_version' in variables and variables['gas_version'] >= '2.23') or \
1082+
('xcode_version' in variables and variables['xcode_version'] >= '5.0') or \
1083+
('llvm_version' in variables and variables['llvm_version'] >= '3.3') or \
1084+
('nasm_version' in variables and variables['nasm_version'] >= '2.10')
1085+
1086+
if not openssl110_asm_supported and variables['openssl_no_asm'] == 0:
1087+
warn('''openssl_no_asm is enabled due to missed or old assembler.
1088+
Please refer BUILDING.md''')
1089+
variables['openssl_no_asm'] = 1
1090+
10521091
if options.openssl_fips:
1053-
o['variables']['openssl_fips'] = options.openssl_fips
1054-
fips_dir = os.path.join('deps', 'openssl', 'fips')
1055-
fips_ld = os.path.abspath(os.path.join(fips_dir, 'fipsld'))
1056-
# LINK is for Makefiles, LD/LDXX is for ninja
1057-
o['make_fips_settings'] = [
1058-
['LINK', fips_ld + ' <(openssl_fips)/bin/fipsld'],
1059-
['LD', fips_ld + ' <(openssl_fips)/bin/fipsld'],
1060-
['LDXX', fips_ld + ' <(openssl_fips)/bin/fipsld'],
1061-
]
1062-
else:
1063-
o['variables']['openssl_fips'] = ''
1064-
try:
1065-
os.remove('config_fips.gypi')
1066-
except OSError:
1067-
pass
1092+
print('Error: FIPS is not supported yet in this version')
1093+
exit(1)
1094+
variables['openssl_fips'] = ''
10681095

10691096
if options.without_ssl:
10701097
def without_ssl_error(option):

node.gyp

+2-2
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,8 @@
609609
{
610610
'action_name': 'mkssldef',
611611
'inputs': [
612-
'deps/openssl/openssl/util/libeay.num',
613-
'deps/openssl/openssl/util/ssleay.num',
612+
'deps/openssl/openssl/util/libcrypto.num',
613+
'deps/openssl/openssl/util/libssl.num',
614614
],
615615
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/openssl.def'],
616616
'action': [

tools/mkssldef.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
for filename in filenames:
2828
for line in open(filename).readlines():
29-
name, _, meta, _ = re.split('\s+', line)
29+
name, _, _, meta, _ = re.split('\s+', line)
3030
if any(map(lambda p: p.match(name), excludes)): continue
3131
meta = meta.split(':')
3232
assert meta[0] in ('EXIST', 'NOEXIST')

0 commit comments

Comments
 (0)