Skip to content

Commit 8bf2ce4

Browse files
committed
fixup! crypto: refactor WebCrypto AEAD algorithms auth tag handling
1 parent f26a933 commit 8bf2ce4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/internal/crypto/aes.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ function asyncAesKwCipher(mode, key, data) {
140140

141141
function asyncAesGcmCipher(mode, key, data, algorithm) {
142142
const { tagLength = 128 } = algorithm;
143+
const tagByteLength = tagLength / 8;
143144

144145
return jobPromise(() => new AESCipherJob(
145146
kCryptoJobAsync,
@@ -148,12 +149,13 @@ function asyncAesGcmCipher(mode, key, data, algorithm) {
148149
data,
149150
getVariant('AES-GCM', key[kAlgorithm].length),
150151
algorithm.iv,
151-
tagLength / 8,
152+
tagByteLength,
152153
algorithm.additionalData));
153154
}
154155

155156
function asyncAesOcbCipher(mode, key, data, algorithm) {
156157
const { tagLength = 128 } = algorithm;
158+
const tagByteLength = tagLength / 8;
157159

158160
return jobPromise(() => new AESCipherJob(
159161
kCryptoJobAsync,
@@ -162,7 +164,7 @@ function asyncAesOcbCipher(mode, key, data, algorithm) {
162164
data,
163165
getVariant('AES-OCB', key.algorithm.length),
164166
algorithm.iv,
165-
tagLength / 8,
167+
tagByteLength,
166168
algorithm.additionalData));
167169
}
168170

0 commit comments

Comments
 (0)