Skip to content

Commit 773bdd1

Browse files
authored
crypto: remove select Web Crypto warnings
Remove ExperimentalWarning from algorithms and methods that are on their way to an unflagged browser implementation. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #66312 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 28194a3 commit 773bdd1

3 files changed

Lines changed: 14 additions & 20 deletions

File tree

‎lib/internal/crypto/util.js‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -575,26 +575,19 @@ function getConditionalAlgorithms() {
575575
};
576576
}
577577

578-
// Experimental algorithms
579-
const experimentalAlgorithms = [
578+
// Experimental algorithms that emit warnings.
579+
const experimentalAlgorithmsWithWarnings = [
580580
'AES-OCB',
581581
'Argon2d',
582582
'Argon2i',
583583
'Argon2id',
584-
'ChaCha20-Poly1305',
585584
'cSHAKE128',
586585
'cSHAKE256',
587586
'Ed448',
588587
'KMAC128',
589588
'KMAC256',
590-
'ML-DSA-44',
591-
'ML-DSA-65',
592-
'ML-DSA-87',
593589
'ML-KEM-512',
594-
'ML-KEM-768',
595-
'ML-KEM-1024',
596590
'MLKEM768-P256',
597-
'MLKEM768-X25519',
598591
'MLKEM1024-P384',
599592
'SHA3-256',
600593
'SHA3-384',
@@ -604,6 +597,14 @@ const experimentalAlgorithms = [
604597
'KT128',
605598
'KT256',
606599
'X448',
600+
// Ships unflagged in Chromium >= 155
601+
// 'ChaCha20-Poly1305'
602+
// 'ML-DSA-44'
603+
// 'ML-DSA-65'
604+
// 'ML-DSA-87'
605+
// 'ML-KEM-768'
606+
// 'ML-KEM-1024'
607+
// 'MLKEM768-X25519'
607608
];
608609

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

635-
// Add experimental warnings for experimental algorithms
636-
if (ArrayPrototypeIncludes(experimentalAlgorithms, algorithmName)) {
636+
// Add warnings for select experimental algorithms
637+
if (ArrayPrototypeIncludes(experimentalAlgorithmsWithWarnings, algorithmName)) {
637638
ObjectDefineProperty(result[operation], algorithmName, {
638639
get() {
639640
emitExperimentalWarning(`The ${algorithmName} Web Crypto API algorithm`);

‎lib/internal/crypto/webcrypto.js‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ const {
7474
} = require('internal/crypto/util');
7575

7676
const {
77-
emitExperimentalWarning,
7877
kEnumerableProperty,
7978
lazyDOMException,
8079
setOwnProperty,
@@ -1473,7 +1472,6 @@ function getPublicKey(key, keyUsages) {
14731472
}
14741473

14751474
function getPublicKeyImpl(key, keyUsages) {
1476-
emitExperimentalWarning('The getPublicKey Web Crypto API method');
14771475
const prefix = prepareSubtleMethod(this, 'getPublicKey', arguments.length, 2);
14781476
let i = 0;
14791477
key = convertSubtleArgument(prefix, 'CryptoKey', key, i++);
@@ -1501,7 +1499,6 @@ function encapsulateBits(encapsulationAlgorithm, encapsulationKey) {
15011499
}
15021500

15031501
function encapsulateBitsImpl(encapsulationAlgorithm, encapsulationKey) {
1504-
emitExperimentalWarning('The encapsulateBits Web Crypto API method');
15051502
const prefix = prepareSubtleMethod(
15061503
this, 'encapsulateBits', arguments.length, 2);
15071504
let i = 0;
@@ -1563,7 +1560,6 @@ function encapsulateKeyImpl(
15631560
sharedKeyAlgorithm,
15641561
extractable,
15651562
keyUsages) {
1566-
emitExperimentalWarning('The encapsulateKey Web Crypto API method');
15671563
const prefix = prepareSubtleMethod(
15681564
this, 'encapsulateKey', arguments.length, 5);
15691565
let i = 0;
@@ -1642,7 +1638,6 @@ function decapsulateBits(decapsulationAlgorithm, decapsulationKey, ciphertext) {
16421638
}
16431639

16441640
function decapsulateBitsImpl(decapsulationAlgorithm, decapsulationKey, ciphertext) {
1645-
emitExperimentalWarning('The decapsulateBits Web Crypto API method');
16461641
const prefix = prepareSubtleMethod(
16471642
this, 'decapsulateBits', arguments.length, 3);
16481643
let i = 0;
@@ -1707,7 +1702,6 @@ function decapsulateKeyImpl(
17071702
sharedKeyAlgorithm,
17081703
extractable,
17091704
keyUsages) {
1710-
emitExperimentalWarning('The decapsulateKey Web Crypto API method');
17111705
const prefix = prepareSubtleMethod(
17121706
this, 'decapsulateKey', arguments.length, 6);
17131707
let i = 0;
@@ -1785,7 +1779,6 @@ class SubtleCrypto {
17851779

17861780
// Implements https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-supports
17871781
static supports(operation, algorithm, lengthOrAdditionalAlgorithm = null) {
1788-
emitExperimentalWarning('The supports Web Crypto API method');
17891782
webidl ??= require('internal/crypto/webidl');
17901783
const prefix = "Failed to execute 'supports' on 'SubtleCrypto'";
17911784
webidl.requiredArguments(arguments.length, 2, { prefix });

‎test/parallel/test-webcrypto-prototype-pollution.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const TypedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
2020
const data = new TextEncoder().encode('prototype pollution');
2121
const modulusLength = getFips() === 1 ? 2048 : 1024;
2222

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

0 commit comments

Comments
 (0)