Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f488b2f

Browse filesBrowse files
Renegade334aduh95
authored andcommitted
crypto: use async functions for non-stub Promise-returning functions
These were intended to mimic simple async functions, but exceptions thrown in the function body would be returned synchronously, not wrapped in a rejected Promise. PR-URL: #59841 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent aed9fd5 commit f488b2f
Copy full SHA for f488b2f

File tree

Expand file treeCollapse file tree

5 files changed

+8
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+8
-9
lines changed
Open diff view settings
Collapse file

‎lib/internal/crypto/aes.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/aes.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const {
55
ArrayBufferPrototypeSlice,
66
ArrayFrom,
77
ArrayPrototypePush,
8-
PromiseReject,
98
SafeSet,
109
TypedArrayPrototypeSlice,
1110
} = primordials;
@@ -132,7 +131,7 @@ function asyncAesKwCipher(mode, key, data) {
132131
getVariant('AES-KW', key.algorithm.length)));
133132
}
134133

135-
function asyncAesGcmCipher(mode, key, data, algorithm) {
134+
async function asyncAesGcmCipher(mode, key, data, algorithm) {
136135
const { tagLength = 128 } = algorithm;
137136

138137
const tagByteLength = tagLength / 8;
@@ -148,9 +147,9 @@ function asyncAesGcmCipher(mode, key, data, algorithm) {
148147
// > If *plaintext* has a length less than *tagLength* bits, then `throw`
149148
// > an `OperationError`.
150149
if (tagByteLength > tag.byteLength) {
151-
return PromiseReject(lazyDOMException(
150+
throw lazyDOMException(
152151
'The provided data is too small.',
153-
'OperationError'));
152+
'OperationError');
154153
}
155154

156155
data = slice(data, 0, -tagByteLength);
Collapse file

‎lib/internal/crypto/cfrg.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/cfrg.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ function cfrgImportKey(
342342
extractable);
343343
}
344344

345-
function eddsaSignVerify(key, data, algorithm, signature) {
345+
async function eddsaSignVerify(key, data, algorithm, signature) {
346346
const mode = signature === undefined ? kSignJobModeSign : kSignJobModeVerify;
347347
const type = mode === kSignJobModeSign ? 'private' : 'public';
348348

Collapse file

‎lib/internal/crypto/ec.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/ec.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function ecImportKey(
283283
extractable);
284284
}
285285

286-
function ecdsaSignVerify(key, data, { name, hash }, signature) {
286+
async function ecdsaSignVerify(key, data, { name, hash }, signature) {
287287
const mode = signature === undefined ? kSignJobModeSign : kSignJobModeVerify;
288288
const type = mode === kSignJobModeSign ? 'private' : 'public';
289289

Collapse file

‎lib/internal/crypto/rsa.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/rsa.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function validateRsaOaepAlgorithm(algorithm) {
9191
}
9292
}
9393

94-
function rsaOaepCipher(mode, key, data, algorithm) {
94+
async function rsaOaepCipher(mode, key, data, algorithm) {
9595
validateRsaOaepAlgorithm(algorithm);
9696

9797
const type = mode === kWebCryptoCipherEncrypt ? 'public' : 'private';
@@ -328,7 +328,7 @@ function rsaImportKey(
328328
}, keyUsages, extractable);
329329
}
330330

331-
function rsaSignVerify(key, data, { saltLength }, signature) {
331+
async function rsaSignVerify(key, data, { saltLength }, signature) {
332332
const mode = signature === undefined ? kSignJobModeSign : kSignJobModeVerify;
333333
const type = mode === kSignJobModeSign ? 'private' : 'public';
334334

Collapse file

‎lib/internal/crypto/webcrypto.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/webcrypto.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ async function unwrapKey(
769769
);
770770
}
771771

772-
function signVerify(algorithm, key, data, signature) {
772+
async function signVerify(algorithm, key, data, signature) {
773773
let usage = 'sign';
774774
if (signature !== undefined) {
775775
usage = 'verify';

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.