@@ -67,23 +67,23 @@ testHelper(
6767 'stdout' ,
6868 [ ] ,
6969 FIPS_DISABLED ,
70- 'require("crypto").fips ' ,
70+ 'require("crypto").getFips() ' ,
7171 Object . assign ( { } , process . env , { 'OPENSSL_CONF' : '' } ) ) ;
7272
7373// --enable-fips should turn FIPS mode on
7474testHelper (
7575 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
7676 [ '--enable-fips' ] ,
7777 compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
78- 'require("crypto").fips ' ,
78+ 'require("crypto").getFips() ' ,
7979 process . env ) ;
8080
8181//--force-fips should turn FIPS mode on
8282testHelper (
8383 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
8484 [ '--force-fips' ] ,
8585 compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
86- 'require("crypto").fips ' ,
86+ 'require("crypto").getFips() ' ,
8787 process . env ) ;
8888
8989// If Node was configured using --shared-openssl fips support might be
@@ -104,140 +104,140 @@ if (!sharedOpenSSL()) {
104104 'stdout' ,
105105 [ `--openssl-config=${ CNF_FIPS_ON } ` ] ,
106106 compiledWithFips ( ) ? FIPS_ENABLED : FIPS_DISABLED ,
107- 'require("crypto").fips ' ,
107+ 'require("crypto").getFips() ' ,
108108 process . env ) ;
109109
110110 // OPENSSL_CONF should be able to turn on FIPS mode
111111 testHelper (
112112 'stdout' ,
113113 [ ] ,
114114 compiledWithFips ( ) ? FIPS_ENABLED : FIPS_DISABLED ,
115- 'require("crypto").fips ' ,
115+ 'require("crypto").getFips() ' ,
116116 Object . assign ( { } , process . env , { 'OPENSSL_CONF' : CNF_FIPS_ON } ) ) ;
117117
118118 // --openssl-config option should override OPENSSL_CONF
119119 testHelper (
120120 'stdout' ,
121121 [ `--openssl-config=${ CNF_FIPS_ON } ` ] ,
122122 compiledWithFips ( ) ? FIPS_ENABLED : FIPS_DISABLED ,
123- 'require("crypto").fips ' ,
123+ 'require("crypto").getFips() ' ,
124124 Object . assign ( { } , process . env , { 'OPENSSL_CONF' : CNF_FIPS_OFF } ) ) ;
125125}
126126
127127testHelper (
128128 'stdout' ,
129129 [ `--openssl-config=${ CNF_FIPS_OFF } ` ] ,
130130 FIPS_DISABLED ,
131- 'require("crypto").fips ' ,
131+ 'require("crypto").getFips() ' ,
132132 Object . assign ( { } , process . env , { 'OPENSSL_CONF' : CNF_FIPS_ON } ) ) ;
133133
134134// --enable-fips should take precedence over OpenSSL config file
135135testHelper (
136136 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
137137 [ '--enable-fips' , `--openssl-config=${ CNF_FIPS_OFF } ` ] ,
138138 compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
139- 'require("crypto").fips ' ,
139+ 'require("crypto").getFips() ' ,
140140 process . env ) ;
141141
142142// OPENSSL_CONF should _not_ make a difference to --enable-fips
143143testHelper (
144144 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
145145 [ '--enable-fips' ] ,
146146 compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
147- 'require("crypto").fips ' ,
147+ 'require("crypto").getFips() ' ,
148148 Object . assign ( { } , process . env , { 'OPENSSL_CONF' : CNF_FIPS_OFF } ) ) ;
149149
150150// --force-fips should take precedence over OpenSSL config file
151151testHelper (
152152 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
153153 [ '--force-fips' , `--openssl-config=${ CNF_FIPS_OFF } ` ] ,
154154 compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
155- 'require("crypto").fips ' ,
155+ 'require("crypto").getFips() ' ,
156156 process . env ) ;
157157
158158// Using OPENSSL_CONF should not make a difference to --force-fips
159159testHelper (
160160 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
161161 [ '--force-fips' ] ,
162162 compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
163- 'require("crypto").fips ' ,
163+ 'require("crypto").getFips() ' ,
164164 Object . assign ( { } , process . env , { 'OPENSSL_CONF' : CNF_FIPS_OFF } ) ) ;
165165
166166// setFipsCrypto should be able to turn FIPS mode on
167167testHelper (
168168 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
169169 [ ] ,
170170 compiledWithFips ( ) ? FIPS_ENABLED : FIPS_ERROR_STRING ,
171- '(require("crypto").fips = true,' +
172- 'require("crypto").fips )' ,
171+ '(require("crypto").setFips( true) ,' +
172+ 'require("crypto").getFips() )' ,
173173 process . env ) ;
174174
175175// setFipsCrypto should be able to turn FIPS mode on and off
176176testHelper (
177177 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
178178 [ ] ,
179179 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() )' ,
183183 process . env ) ;
184184
185185// setFipsCrypto takes precedence over OpenSSL config file, FIPS on
186186testHelper (
187187 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
188188 [ `--openssl-config=${ CNF_FIPS_OFF } ` ] ,
189189 compiledWithFips ( ) ? FIPS_ENABLED : FIPS_ERROR_STRING ,
190- '(require("crypto").fips = true,' +
191- 'require("crypto").fips )' ,
190+ '(require("crypto").setFips( true) ,' +
191+ 'require("crypto").getFips() )' ,
192192 process . env ) ;
193193
194194// setFipsCrypto takes precedence over OpenSSL config file, FIPS off
195195testHelper (
196196 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
197197 [ `--openssl-config=${ CNF_FIPS_ON } ` ] ,
198198 compiledWithFips ( ) ? FIPS_DISABLED : FIPS_ERROR_STRING ,
199- '(require("crypto").fips = false,' +
200- 'require("crypto").fips )' ,
199+ '(require("crypto").setFips( false) ,' +
200+ 'require("crypto").getFips() )' ,
201201 process . env ) ;
202202
203203// --enable-fips does not prevent use of setFipsCrypto API
204204testHelper (
205205 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
206206 [ '--enable-fips' ] ,
207207 compiledWithFips ( ) ? FIPS_DISABLED : OPTION_ERROR_STRING ,
208- '(require("crypto").fips = false,' +
209- 'require("crypto").fips )' ,
208+ '(require("crypto").setFips( false) ,' +
209+ 'require("crypto").getFips() )' ,
210210 process . env ) ;
211211
212212// --force-fips prevents use of setFipsCrypto API
213213testHelper (
214214 'stderr' ,
215215 [ '--force-fips' ] ,
216216 compiledWithFips ( ) ? FIPS_ERROR_STRING2 : OPTION_ERROR_STRING ,
217- 'require("crypto").fips = false' ,
217+ 'require("crypto").setFips( false) ' ,
218218 process . env ) ;
219219
220220// --force-fips makes setFipsCrypto enable a no-op (FIPS stays on)
221221testHelper (
222222 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
223223 [ '--force-fips' ] ,
224224 compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
225- '(require("crypto").fips = true,' +
226- 'require("crypto").fips )' ,
225+ '(require("crypto").setFips( true) ,' +
226+ 'require("crypto").getFips() )' ,
227227 process . env ) ;
228228
229229// --force-fips and --enable-fips order does not matter
230230testHelper (
231231 'stderr' ,
232232 [ '--force-fips' , '--enable-fips' ] ,
233233 compiledWithFips ( ) ? FIPS_ERROR_STRING2 : OPTION_ERROR_STRING ,
234- 'require("crypto").fips = false' ,
234+ 'require("crypto").setFips( false) ' ,
235235 process . env ) ;
236236
237237//--enable-fips and --force-fips order does not matter
238238testHelper (
239239 'stderr' ,
240240 [ '--enable-fips' , '--force-fips' ] ,
241241 compiledWithFips ( ) ? FIPS_ERROR_STRING2 : OPTION_ERROR_STRING ,
242- 'require("crypto").fips = false' ,
242+ 'require("crypto").setFips( false) ' ,
243243 process . env ) ;
0 commit comments