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 <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 74c415d commit fd3fb0c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎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-
functioncreateCipherBase(cipher,credential,options,decipher,iv){
115+
functioncreateCipherBase(cipher,credential,options,isEncrypt,iv){
116116
constauthTagLength=getUIntOption(options,'authTagLength');
117-
this[kHandle]=newCipherBase(decipher);
117+
this[kHandle]=newCipherBase(isEncrypt);
118118
this[kHandle].initiv(cipher,credential,iv,authTagLength);
119119
this._decoder=null;
120120

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

124-
functioncreateCipherWithIV(cipher,key,options,decipher,iv){
124+
functioncreateCipherWithIV(cipher,key,options,isEncrypt,iv){
125125
validateString(cipher,'cipher');
126126
constencoding=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)