Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions lib/internal/crypto/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,26 +575,19 @@ function getConditionalAlgorithms() {
};
}

// Experimental algorithms
const experimentalAlgorithms = [
// Experimental algorithms that emit warnings.
const experimentalAlgorithmsWithWarnings = [
'AES-OCB',
'Argon2d',
'Argon2i',
'Argon2id',
'ChaCha20-Poly1305',
'cSHAKE128',
'cSHAKE256',
'Ed448',
'KMAC128',
'KMAC256',
'ML-DSA-44',
'ML-DSA-65',
'ML-DSA-87',
'ML-KEM-512',
'ML-KEM-768',
'ML-KEM-1024',
'MLKEM768-P256',
'MLKEM768-X25519',
'MLKEM1024-P384',
'SHA3-256',
'SHA3-384',
Expand All @@ -604,6 +597,14 @@ const experimentalAlgorithms = [
'KT128',
'KT256',
'X448',
// Ships unflagged in Chromium >= 155
// 'ChaCha20-Poly1305'
// 'ML-DSA-44'
// 'ML-DSA-65'
// 'ML-DSA-87'
// 'ML-KEM-768'
// 'ML-KEM-1024'
// 'MLKEM768-X25519'
];

// Transform the algorithm definitions into the operation-keyed structure
Expand Down Expand Up @@ -632,8 +633,8 @@ function createSupportedAlgorithms(algorithmDefs) {
nameMap[operation] ||= new SafeMap();
nameMap[operation].set(StringPrototypeToUpperCase(algorithmName), algorithmName);

// Add experimental warnings for experimental algorithms
if (ArrayPrototypeIncludes(experimentalAlgorithms, algorithmName)) {
// Add warnings for select experimental algorithms
if (ArrayPrototypeIncludes(experimentalAlgorithmsWithWarnings, algorithmName)) {
ObjectDefineProperty(result[operation], algorithmName, {
get() {
emitExperimentalWarning(`The ${algorithmName} Web Crypto API algorithm`);
Expand Down
7 changes: 0 additions & 7 deletions lib/internal/crypto/webcrypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ const {
} = require('internal/crypto/util');

const {
emitExperimentalWarning,
kEnumerableProperty,
lazyDOMException,
setOwnProperty,
Expand Down Expand Up @@ -1464,7 +1463,6 @@ function getPublicKey(key, keyUsages) {
}

function getPublicKeyImpl(key, keyUsages) {
emitExperimentalWarning('The getPublicKey Web Crypto API method');
const prefix = prepareSubtleMethod(this, 'getPublicKey', arguments.length, 2);
let i = 0;
key = convertSubtleArgument(prefix, 'CryptoKey', key, i++);
Expand Down Expand Up @@ -1492,7 +1490,6 @@ function encapsulateBits(encapsulationAlgorithm, encapsulationKey) {
}

function encapsulateBitsImpl(encapsulationAlgorithm, encapsulationKey) {
emitExperimentalWarning('The encapsulateBits Web Crypto API method');
const prefix = prepareSubtleMethod(
this, 'encapsulateBits', arguments.length, 2);
let i = 0;
Expand Down Expand Up @@ -1554,7 +1551,6 @@ function encapsulateKeyImpl(
sharedKeyAlgorithm,
extractable,
keyUsages) {
emitExperimentalWarning('The encapsulateKey Web Crypto API method');
const prefix = prepareSubtleMethod(
this, 'encapsulateKey', arguments.length, 5);
let i = 0;
Expand Down Expand Up @@ -1633,7 +1629,6 @@ function decapsulateBits(decapsulationAlgorithm, decapsulationKey, ciphertext) {
}

function decapsulateBitsImpl(decapsulationAlgorithm, decapsulationKey, ciphertext) {
emitExperimentalWarning('The decapsulateBits Web Crypto API method');
const prefix = prepareSubtleMethod(
this, 'decapsulateBits', arguments.length, 3);
let i = 0;
Expand Down Expand Up @@ -1698,7 +1693,6 @@ function decapsulateKeyImpl(
sharedKeyAlgorithm,
extractable,
keyUsages) {
emitExperimentalWarning('The decapsulateKey Web Crypto API method');
const prefix = prepareSubtleMethod(
this, 'decapsulateKey', arguments.length, 6);
let i = 0;
Expand Down Expand Up @@ -1776,7 +1770,6 @@ class SubtleCrypto {

// Implements https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-supports
static supports(operation, algorithm, lengthOrAdditionalAlgorithm = null) {
emitExperimentalWarning('The supports Web Crypto API method');
webidl ??= require('internal/crypto/webidl');
const prefix = "Failed to execute 'supports' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 2, { prefix });
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-webcrypto-prototype-pollution.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const TypedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
const data = new TextEncoder().encode('prototype pollution');
const modulusLength = getFips() === 1 ? 2048 : 1024;

// Avoids SubtleCrypto.supports(), which warns and invokes the registry's
// experimental-algorithm getters.
// Avoids SubtleCrypto.supports(), which can invoke the registry's
// experimental-algorithm warning getters.
function supports(operation, name) {
return Object.hasOwn(kSupportedAlgorithms[operation] ?? {}, name);
}
Expand Down
Loading