Skip to content

Commit fd3fb0c

Browse files
tniessenRafaelGSS
authored andcommitted
crypto: fix misleading positional argument
The fourth positional argument of `createCipherBase` is `true` when called from within the `Cipheriv` constructor and `false`when called from within the `Decipheriv` constructor. This value is then passed to the `CipherBase::New()` method, which treats it as follows: args[0]->IsTrue() ? kCipher : kDecipher However, the current name of said positional argument is `decipher` and thus indicates the exact opposite: when the argument is set to true, the instance is *not* a `Decipheriv` object. Therefore, this commit renames the argument to `isEncrypt`, which matches the actual semantics. PR-URL: #57843 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Edy Silva <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 74c415d commit fd3fb0c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/internal/crypto/cipher.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,21 @@ function getUIntOption(options, key) {
112112
return -1;
113113
}
114114

115-
function createCipherBase(cipher, credential, options, decipher, iv) {
115+
function createCipherBase(cipher, credential, options, isEncrypt, iv) {
116116
const authTagLength = getUIntOption(options, 'authTagLength');
117-
this[kHandle] = new CipherBase(decipher);
117+
this[kHandle] = new CipherBase(isEncrypt);
118118
this[kHandle].initiv(cipher, credential, iv, authTagLength);
119119
this._decoder = null;
120120

121121
ReflectApply(LazyTransform, this, [options]);
122122
}
123123

124-
function createCipherWithIV(cipher, key, options, decipher, iv) {
124+
function createCipherWithIV(cipher, key, options, isEncrypt, iv) {
125125
validateString(cipher, 'cipher');
126126
const encoding = getStringOption(options, 'encoding');
127127
key = prepareSecretKey(key, encoding);
128128
iv = iv === null ? null : getArrayBufferOrView(iv, 'iv');
129-
ReflectApply(createCipherBase, this, [cipher, key, options, decipher, iv]);
129+
ReflectApply(createCipherBase, this, [cipher, key, options, isEncrypt, iv]);
130130
}
131131

132132
// The Cipher class is part of the legacy Node.js crypto API. It exposes

0 commit comments

Comments
 (0)