File tree 2 files changed +10
-11
lines changed
2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ Cipher.prototype.final = function final(outputEncoding) {
181
181
182
182
183
183
Cipher . prototype . setAutoPadding = function setAutoPadding ( ap ) {
184
- if ( this . _handle . setAutoPadding ( ap ) === false )
184
+ if ( ! this . _handle . setAutoPadding ( ap ) )
185
185
throw new ERR_CRYPTO_INVALID_STATE ( 'setAutoPadding' ) ;
186
186
return this ;
187
187
} ;
@@ -200,10 +200,7 @@ Cipher.prototype.setAuthTag = function setAuthTag(tagbuf) {
200
200
[ 'Buffer' , 'TypedArray' , 'DataView' ] ,
201
201
tagbuf ) ;
202
202
}
203
- // Do not do a normal falsy check because the method returns
204
- // undefined if it succeeds. Returns false specifically if it
205
- // errored
206
- if ( this . _handle . setAuthTag ( tagbuf ) === false )
203
+ if ( ! this . _handle . setAuthTag ( tagbuf ) )
207
204
throw new ERR_CRYPTO_INVALID_STATE ( 'setAuthTag' ) ;
208
205
return this ;
209
206
} ;
@@ -216,7 +213,7 @@ Cipher.prototype.setAAD = function setAAD(aadbuf, options) {
216
213
}
217
214
218
215
const plaintextLength = getUIntOption ( options , 'plaintextLength' ) ;
219
- if ( this . _handle . setAAD ( aadbuf , plaintextLength ) === false )
216
+ if ( ! this . _handle . setAAD ( aadbuf , plaintextLength ) )
220
217
throw new ERR_CRYPTO_INVALID_STATE ( 'setAAD' ) ;
221
218
return this ;
222
219
} ;
Original file line number Diff line number Diff line change @@ -2939,6 +2939,8 @@ void CipherBase::SetAuthTag(const FunctionCallbackInfo<Value>& args) {
2939
2939
2940
2940
memset (cipher->auth_tag_ , 0 , sizeof (cipher->auth_tag_ ));
2941
2941
memcpy (cipher->auth_tag_ , Buffer::Data (args[0 ]), cipher->auth_tag_len_ );
2942
+
2943
+ args.GetReturnValue ().Set (true );
2942
2944
}
2943
2945
2944
2946
@@ -2993,9 +2995,9 @@ void CipherBase::SetAAD(const FunctionCallbackInfo<Value>& args) {
2993
2995
CHECK (args[1 ]->IsInt32 ());
2994
2996
int plaintext_len = args[1 ].As <Int32>()->Value ();
2995
2997
2996
- if (! cipher->SetAAD (Buffer::Data (args[0 ]), Buffer::Length (args[0 ]),
2997
- plaintext_len))
2998
- args.GetReturnValue ().Set (false ); // Report invalid state failure
2998
+ bool b = cipher->SetAAD (Buffer::Data (args[0 ]), Buffer::Length (args[0 ]),
2999
+ plaintext_len);
3000
+ args.GetReturnValue ().Set (b ); // Possibly report invalid state failure
2999
3001
}
3000
3002
3001
3003
@@ -3107,8 +3109,8 @@ void CipherBase::SetAutoPadding(const FunctionCallbackInfo<Value>& args) {
3107
3109
CipherBase* cipher;
3108
3110
ASSIGN_OR_RETURN_UNWRAP (&cipher, args.Holder ());
3109
3111
3110
- if (! cipher->SetAutoPadding (args.Length () < 1 || args[0 ]->BooleanValue ()))
3111
- args.GetReturnValue ().Set (false ); // Report invalid state failure
3112
+ bool b = cipher->SetAutoPadding (args.Length () < 1 || args[0 ]->BooleanValue ());
3113
+ args.GetReturnValue ().Set (b ); // Possibly report invalid state failure
3112
3114
}
3113
3115
3114
3116
You can’t perform that action at this time.
0 commit comments