11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif (!common.hasCrypto) 51cb0ef41Sopenharmony_ci common.skip('missing crypto'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciif (!common.hasOpenSSL3) 81cb0ef41Sopenharmony_ci common.skip('this test requires OpenSSL 3.x'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst assert = require('node:assert/strict'); 111cb0ef41Sopenharmony_ciconst crypto = require('node:crypto'); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciif (common.isMainThread) { 141cb0ef41Sopenharmony_ci // TODO(richardlau): Decide if `crypto.setFips` should error if the 151cb0ef41Sopenharmony_ci // provider named "fips" is not available. 161cb0ef41Sopenharmony_ci crypto.setFips(1); 171cb0ef41Sopenharmony_ci crypto.randomBytes(20, common.mustCall((err) => { 181cb0ef41Sopenharmony_ci // crypto.randomBytes should either succeed or fail but not hang. 191cb0ef41Sopenharmony_ci if (err) { 201cb0ef41Sopenharmony_ci assert.match(err.message, /digital envelope routines::unsupported/); 211cb0ef41Sopenharmony_ci const expected = /random number generator::unable to fetch drbg/; 221cb0ef41Sopenharmony_ci assert(err.opensslErrorStack.some((msg) => expected.test(msg)), 231cb0ef41Sopenharmony_ci `did not find ${expected} in ${err.opensslErrorStack}`); 241cb0ef41Sopenharmony_ci } 251cb0ef41Sopenharmony_ci })); 261cb0ef41Sopenharmony_ci} 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci{ 291cb0ef41Sopenharmony_ci // Startup test. Should not hang. 301cb0ef41Sopenharmony_ci const { path } = require('../common/fixtures'); 311cb0ef41Sopenharmony_ci const { spawnSync } = require('node:child_process'); 321cb0ef41Sopenharmony_ci const baseConf = path('openssl3-conf', 'base_only.cnf'); 331cb0ef41Sopenharmony_ci const cp = spawnSync(process.execPath, 341cb0ef41Sopenharmony_ci [ `--openssl-config=${baseConf}`, '-p', '"hello"' ], 351cb0ef41Sopenharmony_ci { encoding: 'utf8' }); 361cb0ef41Sopenharmony_ci assert(common.nodeProcessAborted(cp.status, cp.signal), 371cb0ef41Sopenharmony_ci `process did not abort, code:${cp.status} signal:${cp.signal}`); 381cb0ef41Sopenharmony_ci} 39