Files
sousa-gecko/testing/web-platform/tests/WebCryptoAPI/normalize-algorithm-name.https.any.js
T
Fredrik Söderquist 8051ff677f Bug 2021163 [wpt PR 58271] - Use EqualIgnoringAsciiCase() in LookupAlgorithmIdByName(), a=testonly
Automatic update from web-platform-tests
Use EqualIgnoringAsciiCase() in LookupAlgorithmIdByName()

The "Normalizing an algorithm" algorithm[1] says that names should be
matched ASCII case-insensitive [2]. Currently the lookup sort of does
that, but the verifying comparison still uses a full Unicode
case-folding comparison. Because of how the lookup is structured the
lookup for some algorithm names could still accept non-ASCII.

Replace the final DeprecatedEqualIgnoringCase() comparison with
EqualIgnoringAsciiCase().

[1] https://w3c.github.io/webcrypto/#algorithm-normalization-normalize-an-algorithm
[2] https://w3c.github.io/webcrypto/#case-insensitive

Bug: 40476285
Change-Id: If1ee6a3c1e75f271c171b44f8de31fe688546b0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7633022
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/main@{#1594550}

--

wpt-commits: 9d18397b6447964d44605e0b5e411b6fb87d8cfe
wpt-pr: 58271
2026-03-12 15:56:27 +00:00

53 lines
1.7 KiB
JavaScript

// META: title=WebCryptoAPI: Algorithm normalization matches names ASCII case-insensitively
// U+212A is the Kelvin Sign
function makeSalt() {
return crypto.getRandomValues(new Uint8Array(32));
}
async function makeKey(algorithm) {
const keyData = new Uint8Array([]);
return crypto.subtle.importKey("raw", keyData, algorithm, false, ["deriveBits"]);
}
promise_test(async (t) => {
const algorithm = {
name: "H\u212ADF",
hash: "SHA-256",
salt: makeSalt(),
info: new TextEncoder().encode(''),
};
const key = await makeKey("HKDF");
const p = crypto.subtle.deriveBits(algorithm, key, 256);
return promise_rejects_dom(t, "NotSupportedError", p, algorithm.name);
}, `"H<U+212A>DF" does not match "HKDF"`);
promise_test(async (t) => {
const algorithm = {
name: "PB\u212ADF2",
hash: "SHA-256",
iterations: 1,
salt: makeSalt(),
};
const key = await makeKey("PBKDF2");
const p = crypto.subtle.deriveBits(algorithm, key, 256);
return promise_rejects_dom(t, "NotSupportedError", p, algorithm.name);
}, `"PB<U+212A>DF2" does not match "PBKDF2"`);
promise_test(async (t) => {
const algorithm = {name: "AES-\u212AW", length: 256};
const p = crypto.subtle.generateKey(algorithm, false, ["wrapKey"]);
return promise_rejects_dom(t, "NotSupportedError", p, algorithm.name);
}, `"AES-<U+212A>W" does not match "AES-KW"`);
promise_test(async (t) => {
const algorithm = {
name: "RSASSA-P\u212ACS1-V1_5",
modulusLength: 2048,
publicExponent: new Uint8Array([3]),
hash: "SHA-256",
};
const p = crypto.subtle.generateKey(algorithm, false, ["sign"]);
return promise_rejects_dom(t, "NotSupportedError", p, algorithm.name);
}, `"RSASSA-P<U+212A>CS1-V1_5" does not match "RSASSA-PKCS1-V1_5"`);