@@ -88,12 +88,26 @@ testHelper(
8888// OpenSSL config file should be able to turn on FIPS mode
8989testHelper (
9090 'stdout' ,
91- [ ] ,
91+ [ `--openssl-config= ${ CNF_FIPS_ON } ` ] ,
9292 compiledWithFips ( ) ? FIPS_ENABLED : FIPS_DISABLED ,
9393 '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' ,
94101 addToEnv ( 'OPENSSL_CONF' , CNF_FIPS_ON ) ) ;
95102
96103// --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
97111testHelper (
98112 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
99113 [ '--enable-fips' ] ,
@@ -102,6 +116,13 @@ testHelper(
102116 addToEnv ( 'OPENSSL_CONF' , CNF_FIPS_OFF ) ) ;
103117
104118// --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
105126testHelper (
106127 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
107128 [ '--force-fips' ] ,
@@ -116,7 +137,7 @@ testHelper(
116137 compiledWithFips ( ) ? FIPS_ENABLED : FIPS_ERROR_STRING ,
117138 '(require("crypto").fips = true,' +
118139 'require("crypto").fips)' ,
119- addToEnv ( 'OPENSSL_CONF' , '' ) ) ;
140+ process . env ) ;
120141
121142// setFipsCrypto should be able to turn FIPS mode on and off
122143testHelper (
@@ -126,25 +147,25 @@ testHelper(
126147 '(require("crypto").fips = true,' +
127148 'require("crypto").fips = false,' +
128149 'require("crypto").fips)' ,
129- addToEnv ( 'OPENSSL_CONF' , '' ) ) ;
150+ process . env ) ;
130151
131152// setFipsCrypto takes precedence over OpenSSL config file, FIPS on
132153testHelper (
133154 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
134- [ ] ,
155+ [ `--openssl-config= ${ CNF_FIPS_OFF } ` ] ,
135156 compiledWithFips ( ) ? FIPS_ENABLED : FIPS_ERROR_STRING ,
136157 '(require("crypto").fips = true,' +
137158 'require("crypto").fips)' ,
138- addToEnv ( 'OPENSSL_CONF' , CNF_FIPS_OFF ) ) ;
159+ process . env ) ;
139160
140161// setFipsCrypto takes precedence over OpenSSL config file, FIPS off
141162testHelper (
142163 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
143- [ ] ,
164+ [ `--openssl-config= ${ CNF_FIPS_ON } ` ] ,
144165 compiledWithFips ( ) ? FIPS_DISABLED : FIPS_ERROR_STRING ,
145166 '(require("crypto").fips = false,' +
146167 'require("crypto").fips)' ,
147- addToEnv ( 'OPENSSL_CONF' , CNF_FIPS_ON ) ) ;
168+ process . env ) ;
148169
149170// --enable-fips does not prevent use of setFipsCrypto API
150171testHelper (
0 commit comments