Skip to content

Commit ff44998

Browse files
committed
crypto: fix webcrypto operation errors to be OperationError
1 parent c3ff198 commit ff44998

File tree

4 files changed

+9
-26
lines changed

4 files changed

+9
-26
lines changed

lib/internal/crypto/util.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,11 @@ const validateByteSource = hideStackFrames((val, name) => {
278278
});
279279

280280
function onDone(resolve, reject, err, result) {
281-
if (err) return reject(err);
281+
if (err) {
282+
return reject(lazyDOMException(
283+
'The operation failed for an operation-specific reason',
284+
'OperationError'));
285+
}
282286
resolve(result);
283287
}
284288

test/parallel/test-webcrypto-encrypt-decrypt-aes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ async function testDecrypt({ keyBuffer, algorithm, result }) {
119119

120120
decryptionFailing.forEach((vector) => {
121121
variations.push(assert.rejects(testDecrypt(vector), {
122-
message: /bad decrypt/
122+
name: 'OperationError'
123123
}));
124124
});
125125

@@ -158,7 +158,7 @@ async function testDecrypt({ keyBuffer, algorithm, result }) {
158158

159159
decryptionFailing.forEach((vector) => {
160160
variations.push(assert.rejects(testDecrypt(vector), {
161-
message: /bad decrypt/
161+
name: 'OperationError'
162162
}));
163163
});
164164

@@ -195,7 +195,7 @@ async function testDecrypt({ keyBuffer, algorithm, result }) {
195195

196196
decryptionFailing.forEach((vector) => {
197197
variations.push(assert.rejects(testDecrypt(vector), {
198-
message: /bad decrypt/
198+
name: 'OperationError'
199199
}));
200200
});
201201

test/parallel/test-webcrypto-encrypt-decrypt-rsa.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async function testEncryptionLongPlaintext({ algorithm,
127127

128128
return assert.rejects(
129129
subtle.encrypt(algorithm, publicKey, newplaintext), {
130-
message: /data too large/
130+
name: 'OperationError'
131131
});
132132
}
133133

test/wpt/status/WebCryptoAPI.json

-21
Original file line numberDiff line numberDiff line change
@@ -2654,33 +2654,12 @@
26542654
"encrypt_decrypt/aes_cbc.https.any.js": {
26552655
"fail": {
26562656
"expected": [
2657-
"AES-CBC 128-bit key, zeroPadChar",
2658-
"AES-CBC 128-bit key, bigPadChar",
2659-
"AES-CBC 128-bit key, inconsistentPadChars",
2660-
"AES-CBC 192-bit key, zeroPadChar",
2661-
"AES-CBC 192-bit key, bigPadChar",
2662-
"AES-CBC 192-bit key, inconsistentPadChars",
2663-
"AES-CBC 256-bit key, zeroPadChar",
2664-
"AES-CBC 256-bit key, bigPadChar",
2665-
"AES-CBC 256-bit key, inconsistentPadChars"
26662657
]
26672658
}
26682659
},
26692660
"encrypt_decrypt/rsa_oaep.https.any.js": {
26702661
"fail": {
26712662
"expected": [
2672-
"RSA-OAEP with SHA-1 and no label too long plaintext",
2673-
"RSA-OAEP with SHA-256 and no label too long plaintext",
2674-
"RSA-OAEP with SHA-384 and no label too long plaintext",
2675-
"RSA-OAEP with SHA-512 and no label too long plaintext",
2676-
"RSA-OAEP with SHA-1 and empty label too long plaintext",
2677-
"RSA-OAEP with SHA-256 and empty label too long plaintext",
2678-
"RSA-OAEP with SHA-384 and empty label too long plaintext",
2679-
"RSA-OAEP with SHA-512 and empty label too long plaintext",
2680-
"RSA-OAEP with SHA-1 and a label too long plaintext",
2681-
"RSA-OAEP with SHA-256 and a label too long plaintext",
2682-
"RSA-OAEP with SHA-384 and a label too long plaintext",
2683-
"RSA-OAEP with SHA-512 and a label too long plaintext"
26842663
]
26852664
}
26862665
},

0 commit comments

Comments
 (0)