@@ -67,23 +67,23 @@ testHelper(
67
67
'stdout' ,
68
68
[ ] ,
69
69
FIPS_DISABLED ,
70
- 'require("crypto").fips ' ,
70
+ 'require("crypto").getFips() ' ,
71
71
Object . assign ( { } , process . env , { 'OPENSSL_CONF' : '' } ) ) ;
72
72
73
73
// --enable-fips should turn FIPS mode on
74
74
testHelper (
75
75
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
76
76
[ '--enable-fips' ] ,
77
77
compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
78
- 'require("crypto").fips ' ,
78
+ 'require("crypto").getFips() ' ,
79
79
process . env ) ;
80
80
81
81
//--force-fips should turn FIPS mode on
82
82
testHelper (
83
83
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
84
84
[ '--force-fips' ] ,
85
85
compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
86
- 'require("crypto").fips ' ,
86
+ 'require("crypto").getFips() ' ,
87
87
process . env ) ;
88
88
89
89
// If Node was configured using --shared-openssl fips support might be
@@ -104,140 +104,140 @@ if (!sharedOpenSSL()) {
104
104
'stdout' ,
105
105
[ `--openssl-config=${ CNF_FIPS_ON } ` ] ,
106
106
compiledWithFips ( ) ? FIPS_ENABLED : FIPS_DISABLED ,
107
- 'require("crypto").fips ' ,
107
+ 'require("crypto").getFips() ' ,
108
108
process . env ) ;
109
109
110
110
// OPENSSL_CONF should be able to turn on FIPS mode
111
111
testHelper (
112
112
'stdout' ,
113
113
[ ] ,
114
114
compiledWithFips ( ) ? FIPS_ENABLED : FIPS_DISABLED ,
115
- 'require("crypto").fips ' ,
115
+ 'require("crypto").getFips() ' ,
116
116
Object . assign ( { } , process . env , { 'OPENSSL_CONF' : CNF_FIPS_ON } ) ) ;
117
117
118
118
// --openssl-config option should override OPENSSL_CONF
119
119
testHelper (
120
120
'stdout' ,
121
121
[ `--openssl-config=${ CNF_FIPS_ON } ` ] ,
122
122
compiledWithFips ( ) ? FIPS_ENABLED : FIPS_DISABLED ,
123
- 'require("crypto").fips ' ,
123
+ 'require("crypto").getFips() ' ,
124
124
Object . assign ( { } , process . env , { 'OPENSSL_CONF' : CNF_FIPS_OFF } ) ) ;
125
125
}
126
126
127
127
testHelper (
128
128
'stdout' ,
129
129
[ `--openssl-config=${ CNF_FIPS_OFF } ` ] ,
130
130
FIPS_DISABLED ,
131
- 'require("crypto").fips ' ,
131
+ 'require("crypto").getFips() ' ,
132
132
Object . assign ( { } , process . env , { 'OPENSSL_CONF' : CNF_FIPS_ON } ) ) ;
133
133
134
134
// --enable-fips should take precedence over OpenSSL config file
135
135
testHelper (
136
136
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
137
137
[ '--enable-fips' , `--openssl-config=${ CNF_FIPS_OFF } ` ] ,
138
138
compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
139
- 'require("crypto").fips ' ,
139
+ 'require("crypto").getFips() ' ,
140
140
process . env ) ;
141
141
142
142
// OPENSSL_CONF should _not_ make a difference to --enable-fips
143
143
testHelper (
144
144
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
145
145
[ '--enable-fips' ] ,
146
146
compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
147
- 'require("crypto").fips ' ,
147
+ 'require("crypto").getFips() ' ,
148
148
Object . assign ( { } , process . env , { 'OPENSSL_CONF' : CNF_FIPS_OFF } ) ) ;
149
149
150
150
// --force-fips should take precedence over OpenSSL config file
151
151
testHelper (
152
152
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
153
153
[ '--force-fips' , `--openssl-config=${ CNF_FIPS_OFF } ` ] ,
154
154
compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
155
- 'require("crypto").fips ' ,
155
+ 'require("crypto").getFips() ' ,
156
156
process . env ) ;
157
157
158
158
// Using OPENSSL_CONF should not make a difference to --force-fips
159
159
testHelper (
160
160
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
161
161
[ '--force-fips' ] ,
162
162
compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
163
- 'require("crypto").fips ' ,
163
+ 'require("crypto").getFips() ' ,
164
164
Object . assign ( { } , process . env , { 'OPENSSL_CONF' : CNF_FIPS_OFF } ) ) ;
165
165
166
166
// setFipsCrypto should be able to turn FIPS mode on
167
167
testHelper (
168
168
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
169
169
[ ] ,
170
170
compiledWithFips ( ) ? FIPS_ENABLED : FIPS_ERROR_STRING ,
171
- '(require("crypto").fips = true,' +
172
- 'require("crypto").fips )' ,
171
+ '(require("crypto").setFips( true) ,' +
172
+ 'require("crypto").getFips() )' ,
173
173
process . env ) ;
174
174
175
175
// setFipsCrypto should be able to turn FIPS mode on and off
176
176
testHelper (
177
177
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
178
178
[ ] ,
179
179
compiledWithFips ( ) ? FIPS_DISABLED : FIPS_ERROR_STRING ,
180
- '(require("crypto").fips = true,' +
181
- 'require("crypto").fips = false,' +
182
- 'require("crypto").fips )' ,
180
+ '(require("crypto").setFips( true) ,' +
181
+ 'require("crypto").setFips( false) ,' +
182
+ 'require("crypto").getFips() )' ,
183
183
process . env ) ;
184
184
185
185
// setFipsCrypto takes precedence over OpenSSL config file, FIPS on
186
186
testHelper (
187
187
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
188
188
[ `--openssl-config=${ CNF_FIPS_OFF } ` ] ,
189
189
compiledWithFips ( ) ? FIPS_ENABLED : FIPS_ERROR_STRING ,
190
- '(require("crypto").fips = true,' +
191
- 'require("crypto").fips )' ,
190
+ '(require("crypto").setFips( true) ,' +
191
+ 'require("crypto").getFips() )' ,
192
192
process . env ) ;
193
193
194
194
// setFipsCrypto takes precedence over OpenSSL config file, FIPS off
195
195
testHelper (
196
196
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
197
197
[ `--openssl-config=${ CNF_FIPS_ON } ` ] ,
198
198
compiledWithFips ( ) ? FIPS_DISABLED : FIPS_ERROR_STRING ,
199
- '(require("crypto").fips = false,' +
200
- 'require("crypto").fips )' ,
199
+ '(require("crypto").setFips( false) ,' +
200
+ 'require("crypto").getFips() )' ,
201
201
process . env ) ;
202
202
203
203
// --enable-fips does not prevent use of setFipsCrypto API
204
204
testHelper (
205
205
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
206
206
[ '--enable-fips' ] ,
207
207
compiledWithFips ( ) ? FIPS_DISABLED : OPTION_ERROR_STRING ,
208
- '(require("crypto").fips = false,' +
209
- 'require("crypto").fips )' ,
208
+ '(require("crypto").setFips( false) ,' +
209
+ 'require("crypto").getFips() )' ,
210
210
process . env ) ;
211
211
212
212
// --force-fips prevents use of setFipsCrypto API
213
213
testHelper (
214
214
'stderr' ,
215
215
[ '--force-fips' ] ,
216
216
compiledWithFips ( ) ? FIPS_ERROR_STRING2 : OPTION_ERROR_STRING ,
217
- 'require("crypto").fips = false' ,
217
+ 'require("crypto").setFips( false) ' ,
218
218
process . env ) ;
219
219
220
220
// --force-fips makes setFipsCrypto enable a no-op (FIPS stays on)
221
221
testHelper (
222
222
compiledWithFips ( ) ? 'stdout' : 'stderr' ,
223
223
[ '--force-fips' ] ,
224
224
compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
225
- '(require("crypto").fips = true,' +
226
- 'require("crypto").fips )' ,
225
+ '(require("crypto").setFips( true) ,' +
226
+ 'require("crypto").getFips() )' ,
227
227
process . env ) ;
228
228
229
229
// --force-fips and --enable-fips order does not matter
230
230
testHelper (
231
231
'stderr' ,
232
232
[ '--force-fips' , '--enable-fips' ] ,
233
233
compiledWithFips ( ) ? FIPS_ERROR_STRING2 : OPTION_ERROR_STRING ,
234
- 'require("crypto").fips = false' ,
234
+ 'require("crypto").setFips( false) ' ,
235
235
process . env ) ;
236
236
237
237
//--enable-fips and --force-fips order does not matter
238
238
testHelper (
239
239
'stderr' ,
240
240
[ '--enable-fips' , '--force-fips' ] ,
241
241
compiledWithFips ( ) ? FIPS_ERROR_STRING2 : OPTION_ERROR_STRING ,
242
- 'require("crypto").fips = false' ,
242
+ 'require("crypto").setFips( false) ' ,
243
243
process . env ) ;
0 commit comments