GeezerVison is showing github.com — test: update WPT for WebCryptoAPI to a6a0a0292a by nodejs-github-bot · Pull Request #66142 · nodejs/node
test: update WPT for WebCryptoAPI to a6a0a0292a
#66142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.js
(4)
.json
(1)
All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
test: update WPT for WebCryptoAPI to a6a0a0292a
Loading branch information
Uh oh!
There was an error while loading. Please reload this page.
commit fc09f0651e5591f0170a99d8a48f1229f69d656d
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -51,7 +51,6 @@
emptyExpected: digestedData[alg].empty,
label: upCase + " with " + size + " source data",
mutations: true,
transferBeforeCall: true,
});
vectors.push({
algorithm: {name: downCase},
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -58,15 +58,10 @@ function runDigestTests(subtle, sourceData, getVectors) {
promise_test(function () {
var buffer = new Uint8Array(sourceData[size]);
var algorithm = vector.transferBeforeCall
? vector.algorithm
: withNameGetter(vector.algorithm, function () {
buffer.buffer.transfer();
return algorithmName(vector.algorithm);
});
if (vector.transferBeforeCall) {
var algorithm = withNameGetter(vector.algorithm, function () {
buffer.buffer.transfer();
}
return algorithmName(vector.algorithm);
});
return subtle.digest(algorithm, buffer).then(function (result) {
assert_true(
equalBuffers(result, vector.emptyExpected),
Expand Down
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,53 @@
// META: title=WebCryptoAPI: exportKey() and wrapKey() check export support first
// HKDF and PBKDF2 are not registered for the export key operation, and their
// keys can only be imported as non-extractable. Both error conditions are
// therefore always true at once, which makes the order observable.
//
// exportKey: step 6 (NotSupportedError) precedes step 7 (InvalidAccessError).
// https://w3c.github.io/webcrypto/#SubtleCrypto-method-exportKey
//
// wrapKey: step 11 (NotSupportedError) precedes step 12 (InvalidAccessError).
// https://w3c.github.io/webcrypto/#SubtleCrypto-method-wrapKey
function importDeriveKey(name) {
return crypto.subtle.importKey('raw', new Uint8Array([]), name, false,
['deriveBits']);
}
function importAesKey(name, usages) {
return crypto.subtle.importKey('raw', new Uint8Array(16), name, false,
usages);
}
for (const name of ['HKDF', 'PBKDF2']) {
promise_test(async (t) => {
const key = await importDeriveKey(name);
return promise_rejects_dom(t, 'NotSupportedError',
crypto.subtle.exportKey('raw', key));
}, `exportKey() with a ${name} key throws NotSupportedError`);
promise_test(async (t) => {
const key = await importDeriveKey(name);
const wrappingKey = await importAesKey('AES-KW', ['wrapKey']);
return promise_rejects_dom(
t, 'NotSupportedError',
crypto.subtle.wrapKey('raw', key, wrappingKey, 'AES-KW'));
}, `wrapKey() with a ${name} key throws NotSupportedError`);
}
// An algorithm that does support the export key operation must still report
// the extractable check.
promise_test(async (t) => {
const key = await importAesKey('AES-CBC', ['encrypt']);
return promise_rejects_dom(t, 'InvalidAccessError',
crypto.subtle.exportKey('raw', key));
}, 'exportKey() with a non-extractable AES-CBC key throws InvalidAccessError');
promise_test(async (t) => {
const key = await importAesKey('AES-CBC', ['encrypt']);
const wrappingKey = await importAesKey('AES-KW', ['wrapKey']);
return promise_rejects_dom(
t, 'InvalidAccessError',
crypto.subtle.wrapKey('raw', key, wrappingKey, 'AES-KW'));
}, 'wrapKey() with a non-extractable AES-CBC key throws InvalidAccessError');
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,38 @@
// META: title=WebCryptoAPI: BufferSource arguments and members reject shared buffers
// None of the BufferSource arguments of SubtleCrypto, or of the dictionaries it
// takes, are [AllowShared], so a SharedArrayBuffer, or a view onto one, has to
// throw a TypeError.
//
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`.
const sharedBuffer = new WebAssembly.Memory({ shared: true, initial: 1, maximum: 1 }).buffer;
function generateAesGcmKey() {
return crypto.subtle.generateKey({ name: "AES-GCM", length: 128 }, false, ["encrypt"]);
}
for (const [kind, buffer] of [["SharedArrayBuffer", sharedBuffer],
["Uint8Array(SharedArrayBuffer)", new Uint8Array(sharedBuffer)]]) {
promise_test(t => {
return promise_rejects_js(t, TypeError, crypto.subtle.digest("SHA-256", buffer));
}, `digest() data is a ${kind}`);
promise_test(async t => {
const key = await generateAesGcmKey();
await promise_rejects_js(t, TypeError,
crypto.subtle.encrypt({ name: "AES-GCM", iv: new Uint8Array(12) }, key, buffer));
}, `encrypt() data is a ${kind}`);
promise_test(async t => {
const key = await generateAesGcmKey();
await promise_rejects_js(t, TypeError,
crypto.subtle.encrypt({ name: "AES-GCM", iv: buffer }, key, new Uint8Array(1)));
}, `encrypt() AesGcmParams.iv is a ${kind}`);
promise_test(async t => {
const key = await generateAesGcmKey();
await promise_rejects_js(t, TypeError,
crypto.subtle.encrypt({ name: "AES-GCM", iv: new Uint8Array(12), additionalData: buffer },
key, new Uint8Array(1)));
}, `encrypt() AesGcmParams.additionalData is a ${kind}`);
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -100,7 +100,7 @@
"path": "web-locks"
},
"WebCryptoAPI": {
"commit": "55ce71bb9deaf4b8a30fe80f95558a10699fb433 ",
"commit": "a6a0a0292a4706866328488ffaaace00400edcc6 ",
"path": "WebCryptoAPI"
},
"webidl": {
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.