GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: support FIPS mode of OpenSSL · nodejs/node@9338069

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • common.gypi
  • configure
  • deps/openssl
    • doc
      • FIPS.md
    • fips
      • fipscc
      • fipsld
    • openssl.gyp
  • node.gyp
  • src
    • node_crypto.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
'OBJ_DIR': '<(PRODUCT_DIR)/obj.target',
3939
'V8_BASE': '<(PRODUCT_DIR)/obj.target/deps/v8/tools/gyp/libv8_base.a',
4040
}],
41+
['openssl_fips != ""', {
42+
'OPENSSL_PRODUCT': 'libcrypto.a',
43+
}, {
44+
'OPENSSL_PRODUCT': 'libopenssl.a',
45+
}],
4146
['OS=="mac"', {
4247
'clang%': 1,
4348
}, {
Collapse file

‎configure‎

Copy file name to clipboardExpand all lines: configure
+27-1Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ parser.add_option("--openssl-no-asm",
8888
dest="openssl_no_asm",
8989
help="Do not build optimized assembly for OpenSSL")
9090

91+
parser.add_option("--openssl-fips",
92+
action="store",
93+
dest="openssl_fips",
94+
help="Build OpenSSL using FIPS canister .o file in supplied folder")
95+
9196
shared_optgroup.add_option('--shared-http-parser',
9297
action='store_true',
9398
dest='shared_http_parser',
@@ -720,6 +725,16 @@ def configure_openssl(o):
720725
o['variables']['node_use_openssl'] = b(not options.without_ssl)
721726
o['variables']['node_shared_openssl'] = b(options.shared_openssl)
722727
o['variables']['openssl_no_asm'] = 1 if options.openssl_no_asm else 0
728+
if options.openssl_fips:
729+
o['variables']['openssl_fips'] = options.openssl_fips
730+
fips_dir = os.path.join(root_dir, 'deps', 'openssl', 'fips')
731+
fips_ld = os.path.abspath(os.path.join(fips_dir, 'fipsld'))
732+
o['make_global_settings'] = [
733+
['LINK', fips_ld + ' <(openssl_fips)/bin/fipsld'],
734+
]
735+
else:
736+
o['variables']['openssl_fips'] = ''
737+
723738

724739
if options.without_ssl:
725740
return
@@ -1025,10 +1040,21 @@ configure_fullystatic(output)
10251040
# move everything else to target_defaults
10261041
variables = output['variables']
10271042
del output['variables']
1043+
1044+
# make_global_settings should be a root level element too
1045+
if 'make_global_settings' in output:
1046+
make_global_settings = output['make_global_settings']
1047+
del output['make_global_settings']
1048+
else:
1049+
make_global_settings = False
1050+
10281051
output = {
10291052
'variables': variables,
1030-
'target_defaults': output
1053+
'target_defaults': output,
10311054
}
1055+
if make_global_settings:
1056+
output['make_global_settings'] = make_global_settings
1057+
10321058
pprint.pprint(output, indent=2)
10331059

10341060
write('config.gypi', do_not_edit +
Collapse file

‎deps/openssl/doc/FIPS.md‎

Copy file name to clipboard
+19Lines changed: 19 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Building io.js with FIPS-compliant OpenSSL
2+
3+
It is possible to build io.js with [OpenSSL FIPS module][0].
4+
5+
Instructions:
6+
7+
1. Download and verify `openssl-fips-x.x.x.tar.gz` from
8+
https://www.openssl.org/source/
9+
2. Extract source to `openssl-fips` folder
10+
3. `cd openssl-fips && ./config fipscanisterbuild --prefix=\`pwd\`/out`
11+
(NOTE: On OS X, you may want to run
12+
`./Configure darwin64-x86_64-cc --prefix=\`pwd\`/out` if you are going to
13+
build x64-mode io.js)
14+
4. `make -j && make install`
15+
5. Get into io.js checkout folder
16+
6. `./configure --openssl-fips=/path/to/openssl-fips/out`
17+
7. Build io.js with `make -j`
18+
19+
[0]: https://www.openssl.org/docs/fips/fipsnotes.html
Collapse file

‎deps/openssl/fips/fipscc‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
ARGS=
3+
4+
while [ "x$1" != "x" ]; do
5+
ARG=$1
6+
shift
7+
case $ARG in
8+
*fips_premain.c) ARGS="$ARGS -x c $ARG -x none";;
9+
*) ARGS="$ARGS $ARG";;
10+
esac
11+
done
12+
13+
echo $CXX $ARGS
14+
${CXX} $ARGS
Collapse file

‎deps/openssl/fips/fipsld‎

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
# NOTE: Just a wrapper around normal fipsld
4+
FIPSLD=$1
5+
shift
6+
7+
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
8+
FIPSLD_CC=$DIR/fipscc $FIPSLD $@
Collapse file

‎deps/openssl/openssl.gyp‎

Copy file name to clipboardExpand all lines: deps/openssl/openssl.gyp
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'openssl_no_asm%': 0,
1010
'llvm_version%': 0,
1111
'gas_version%': 0,
12+
'openssl_fips%': 'false',
1213
},
1314
'targets': [
1415
{
@@ -21,6 +22,28 @@
2122
['exclude', 'store/.*$']
2223
],
2324
'conditions': [
25+
# FIPS
26+
['openssl_fips != ""', {
27+
'defines': [
28+
'OPENSSL_FIPS',
29+
],
30+
'include_dirs': [
31+
'<(openssl_fips)/include',
32+
],
33+
34+
# Trick fipsld, it expects to see libcrypto.a
35+
'product_name': 'crypto',
36+
37+
'direct_dependent_settings': {
38+
'defines': [
39+
'OPENSSL_FIPS',
40+
],
41+
'include_dirs': [
42+
'<(openssl_fips)/include',
43+
],
44+
},
45+
}],
46+
2447
['openssl_no_asm!=0', {
2548
# Disable asm
2649
'defines': [
Collapse file

‎node.gyp‎

Copy file name to clipboardExpand all lines: node.gyp
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,13 @@
233233
[ 'node_target_type!="static_library"', {
234234
'xcode_settings': {
235235
'OTHER_LDFLAGS': [
236-
'-Wl,-force_load,<(PRODUCT_DIR)/libopenssl.a',
236+
'-Wl,-force_load,<(PRODUCT_DIR)/<(OPENSSL_PRODUCT)',
237237
],
238238
},
239239
'conditions': [
240240
['OS in "linux freebsd"', {
241241
'ldflags': [
242-
'-Wl,--whole-archive <(PRODUCT_DIR)/libopenssl.a',
242+
'-Wl,--whole-archive <(PRODUCT_DIR)/<(OPENSSL_PRODUCT)',
243243
'-Wl,--no-whole-archive',
244244
],
245245
}],
Collapse file

‎src/node_crypto.cc‎

Copy file name to clipboardExpand all lines: src/node_crypto.cc
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5071,6 +5071,16 @@ void InitCryptoOnce() {
50715071
CRYPTO_set_locking_callback(crypto_lock_cb);
50725072
CRYPTO_THREADID_set_callback(crypto_threadid_cb);
50735073

5074+
#ifdef OPENSSL_FIPS
5075+
if (!FIPS_mode_set(1)) {
5076+
int r;
5077+
r = ERR_get_error();
5078+
fprintf(stderr, "openssl fips failed: %s\n", ERR_error_string(r, NULL));
5079+
UNREACHABLE();
5080+
}
5081+
#endif /* BUD_FIPS_ENABLED */
5082+
5083+
50745084
// Turn off compression. Saves memory and protects against CRIME attacks.
50755085
#if !defined(OPENSSL_NO_COMP)
50765086
#if OPENSSL_VERSION_NUMBER < 0x00908000L

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.