@@ -187,7 +187,6 @@ const kSupportedAlgorithms = {
187187 'AES-CTR': 'AesKeyGenParams',
188188 'AES-CBC': 'AesKeyGenParams',
189189 'AES-GCM': 'AesKeyGenParams',
190- 'AES-KW': 'AesKeyGenParams',
191190 'HMAC': 'HmacKeyGenParams',
192191 'Ed25519': null,
193192 'X25519': null,
@@ -202,7 +201,6 @@ const kSupportedAlgorithms = {
202201 'AES-CTR': null,
203202 'AES-CBC': null,
204203 'AES-GCM': null,
205- 'AES-KW': null,
206204 'Ed25519': null,
207205 'X25519': null,
208206 },
@@ -232,7 +230,6 @@ const kSupportedAlgorithms = {
232230 'AES-CTR': null,
233231 'AES-CBC': null,
234232 'AES-GCM': null,
235- 'AES-KW': null,
236233 'Ed25519': null,
237234 'X25519': null,
238235 },
@@ -258,48 +255,69 @@ const kSupportedAlgorithms = {
258255 'AES-CBC': 'AesDerivedKeyParams',
259256 'AES-CTR': 'AesDerivedKeyParams',
260257 'AES-GCM': 'AesDerivedKeyParams',
261- 'AES-KW': 'AesDerivedKeyParams',
262258 'HMAC': 'HmacImportParams',
263259 'HKDF': null,
264260 'PBKDF2': null,
265261 },
266- 'wrapKey': {
267- 'AES-KW': null,
268- },
269- 'unwrapKey': {
270- 'AES-KW': null,
271- },
262+ 'wrapKey': {},
263+ 'unwrapKey': {},
272264};
273265
274- const experimentalAlgorithms = ObjectEntries({
275- 'X448': {
276- generateKey: null,
277- importKey: null,
278- deriveBits: 'EcdhKeyDeriveParams',
279- exportKey: null,
280- },
281- 'Ed448': {
282- generateKey: null,
283- sign: 'Ed448Params',
284- verify: 'Ed448Params',
285- importKey: null,
286- exportKey: null,
287- },
288- 'cSHAKE128': { digest: 'CShakeParams' },
289- 'cSHAKE256': { digest: 'CShakeParams' },
290- 'SHA3-256': { digest: null },
291- 'SHA3-384': { digest: null },
292- 'SHA3-512': { digest: null },
293- 'ChaCha20-Poly1305': {
294- 'encrypt': 'AeadParams',
295- 'decrypt': 'AeadParams',
296- 'generateKey': null,
297- 'importKey': null,
266+ const conditionalAlgorithms = ObjectEntries({
267+ 'AES-KW': [{
268+ 'generateKey': 'AesKeyGenParams',
298269 'exportKey': null,
299- 'get key length': null,
300- },
270+ 'importKey': null,
271+ 'get key length': 'AesDerivedKeyParams',
272+ 'wrapKey': null,
273+ 'unwrapKey': null,
274+ }, !process.features.openssl_is_boringssl],
301275});
302276
277+ for (let i = 0; i < conditionalAlgorithms.length; i++) {
278+ if (conditionalAlgorithms[i][1][1]) {
279+ const name = conditionalAlgorithms[i][0];
280+ const ops = ObjectEntries(conditionalAlgorithms[i][1][0]);
281+ for (let j = 0; j < ops.length; j++) {
282+ const { 0: op, 1: dict } = ops[j];
283+ kSupportedAlgorithms[op][name] = dict;
284+ }
285+ }
286+ }
287+
288+ const experimentalAlgorithms = ObjectEntries({});
289+
290+ if (!process.features.openssl_is_boringssl) {
291+ ArrayPrototypePush(experimentalAlgorithms,
292+ ['Ed448', {
293+ generateKey: null,
294+ sign: 'Ed448Params',
295+ verify: 'Ed448Params',
296+ importKey: null,
297+ exportKey: null,
298+ }],
299+ ['X448', {
300+ generateKey: null,
301+ importKey: null,
302+ deriveBits: 'EcdhKeyDeriveParams',
303+ exportKey: null,
304+ }],
305+ ['cSHAKE128', { digest: 'CShakeParams' }],
306+ ['cSHAKE256', { digest: 'CShakeParams' }],
307+ ['ChaCha20-Poly1305', {
308+ 'encrypt': 'AeadParams',
309+ 'decrypt': 'AeadParams',
310+ 'generateKey': null,
311+ 'importKey': null,
312+ 'exportKey': null,
313+ 'get key length': null,
314+ }],
315+ ['SHA3-256', { digest: null }],
316+ ['SHA3-384', { digest: null }],
317+ ['SHA3-512', { digest: null }],
318+ );
319+ }
320+
303321for (const { 0: algorithm, 1: nid } of [
304322 ['ML-DSA-44', EVP_PKEY_ML_DSA_44],
305323 ['ML-DSA-65', EVP_PKEY_ML_DSA_65],
0 commit comments