Repository: denoland/deno
Pull request: fix(ext/node): internal getOpenSSLSecLevel() for tests

Enables `parallel/test-crypto-sec-level.js`

Ref https://github.com/denoland/deno/issues/29637

Changed files:
filename: ext/node/polyfills/internal/crypto/util.ts
patch: @@ -228,6 +228,10 @@ export function setEngine(_engine: string, _flags: typeof constants) {
   notImplemented("crypto.setEngine");
 }
 
+export function getOpenSSLSecLevel(): number {
+  return 5; // highest sec level, used in tests.
+}
+
 const kAesKeyLengths = [128, 192, 256];
 
 export { kAesKeyLengths, kHandle, kKeyObject };
@@ -238,6 +242,7 @@ export default {
   getCiphers,
   getCipherInfo,
   getCurves,
+  getOpenSSLSecLevel,
   secureHeapUsed,
   setEngine,
   validateByteSource,

filename: tests/node_compat/config.jsonc
patch: @@ -415,6 +415,7 @@
       "test-crypto-randomfillsync-regression.js",
       "test-crypto-randomuuid.js",
       "test-crypto-scrypt.js",
+      "test-crypto-sec-level.js",
       "test-crypto-secret-keygen.js",
       "test-crypto-stream.js",
       "test-crypto-subtle-zero-length.js",

filename: tests/node_compat/runner/TODO.md
patch: @@ -546,7 +546,6 @@ NOTE: This file should not be manually edited. Please edit `tests/node_compat/co
 - [parallel/test-crypto-private-decrypt-gh32240.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-crypto-private-decrypt-gh32240.js)
 - [parallel/test-crypto-random.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-crypto-random.js)
 - [parallel/test-crypto-rsa-dsa.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-crypto-rsa-dsa.js)
-- [parallel/test-crypto-sec-level.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-crypto-sec-level.js)
 - [parallel/test-crypto-secure-heap.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-crypto-secure-heap.js)
 - [parallel/test-crypto-sign-verify.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-crypto-sign-verify.js)
 - [parallel/test-crypto-verify-failure.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-crypto-verify-failure.js)

filename: tests/node_compat/test/parallel/test-crypto-sec-level.js
patch: @@ -0,0 +1,25 @@
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+
+// Copyright Joyent and Node contributors. All rights reserved. MIT license.
+// Taken from Node 23.9.0
+// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
+
+// Flags: --expose-internals
+'use strict';
+
+const common = require('../common');
+if (!common.hasCrypto)
+  common.skip('missing crypto');
+
+const assert = require('assert');
+
+// OpenSSL has a set of security levels which affect what algorithms
+// are available by default. Different OpenSSL veresions have different
+// default security levels and we use this value to adjust what a test
+// expects based on the security level. You can read more in
+// https://docs.openssl.org/1.1.1/man3/SSL_CTX_set_security_level/#default-callback-behaviour
+// This test simply validates that we can get some value for the secLevel
+// when needed by tests.
+const secLevel = require('internal/crypto/util').getOpenSSLSecLevel();
+assert.ok(secLevel >= 0 && secLevel <= 5);