@@ -88,12 +88,26 @@ testHelper(
88
88
// OpenSSL config file should be able to turn on FIPS mode
89
89
testHelper (
90
90
'stdout' ,
91
- [ ] ,
91
+ [ `--openssl-config= ${ CNF_FIPS_ON } ` ] ,
92
92
compiledWithFips ( ) ? FIPS_ENABLED : FIPS_DISABLED ,
93
93
'require("crypto").fips' ,
94
+ process . env ) ;
95
+ // OPENSSL_CONF should _not_ be able to turn on FIPS mode
96
+ testHelper (
97
+ 'stdout' ,
98
+ [ ] ,
99
+ FIPS_DISABLED ,
100
+ 'require("crypto").fips' ,
94
101
addToEnv ( 'OPENSSL_CONF' , CNF_FIPS_ON ) ) ;
95
102
96
103
// --enable-fips should take precedence over OpenSSL config file
104
+ testHelper (
105
+ compiledWithFips ( ) ? 'stdout' : 'stderr' ,
106
+ [ '--enable-fips' , `--openssl-config=${ CNF_FIPS_OFF } ` ] ,
107
+ compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
108
+ 'require("crypto").fips' ,
109
+ process . env ) ;
110
+ // OPENSSL_CONF should _not_ make a difference to --enable-fips
97
111
testHelper (
98
112
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
99
113
[ '--enable-fips' ] ,
@@ -102,6 +116,13 @@ testHelper(
102
116
addToEnv ( 'OPENSSL_CONF' , CNF_FIPS_OFF ) ) ;
103
117
104
118
// --force-fips should take precedence over OpenSSL config file
119
+ testHelper (
120
+ compiledWithFips ( ) ? 'stdout' : 'stderr' ,
121
+ [ '--force-fips' , `--openssl-config=${ CNF_FIPS_OFF } ` ] ,
122
+ compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
123
+ 'require("crypto").fips' ,
124
+ process . env ) ;
125
+ // Using OPENSSL_CONF should not make a difference to --force-fips
105
126
testHelper (
106
127
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
107
128
[ '--force-fips' ] ,
@@ -116,7 +137,7 @@ testHelper(
116
137
compiledWithFips ( ) ? FIPS_ENABLED : FIPS_ERROR_STRING ,
117
138
'(require("crypto").fips = true,' +
118
139
'require("crypto").fips)' ,
119
- addToEnv ( 'OPENSSL_CONF' , '' ) ) ;
140
+ process . env ) ;
120
141
121
142
// setFipsCrypto should be able to turn FIPS mode on and off
122
143
testHelper (
@@ -126,25 +147,25 @@ testHelper(
126
147
'(require("crypto").fips = true,' +
127
148
'require("crypto").fips = false,' +
128
149
'require("crypto").fips)' ,
129
- addToEnv ( 'OPENSSL_CONF' , '' ) ) ;
150
+ process . env ) ;
130
151
131
152
// setFipsCrypto takes precedence over OpenSSL config file, FIPS on
132
153
testHelper (
133
154
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
134
- [ ] ,
155
+ [ `--openssl-config= ${ CNF_FIPS_OFF } ` ] ,
135
156
compiledWithFips ( ) ? FIPS_ENABLED : FIPS_ERROR_STRING ,
136
157
'(require("crypto").fips = true,' +
137
158
'require("crypto").fips)' ,
138
- addToEnv ( 'OPENSSL_CONF' , CNF_FIPS_OFF ) ) ;
159
+ process . env ) ;
139
160
140
161
// setFipsCrypto takes precedence over OpenSSL config file, FIPS off
141
162
testHelper (
142
163
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
143
- [ ] ,
164
+ [ `--openssl-config= ${ CNF_FIPS_ON } ` ] ,
144
165
compiledWithFips ( ) ? FIPS_DISABLED : FIPS_ERROR_STRING ,
145
166
'(require("crypto").fips = false,' +
146
167
'require("crypto").fips)' ,
147
- addToEnv ( 'OPENSSL_CONF' , CNF_FIPS_ON ) ) ;
168
+ process . env ) ;
148
169
149
170
// --enable-fips does not prevent use of setFipsCrypto API
150
171
testHelper (
0 commit comments