| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3839ff0 commit bef02ab
2 files 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 | |
|---|---|---|---|
@@ -2926,6 +2926,8 @@ void CipherBase::SetAuthTag(const FunctionCallbackInfo<Value>& args) { | |||
| 2926 | 2926 | ||
| 2927 | 2927 | memset(cipher->auth_tag_, 0, sizeof(cipher->auth_tag_)); | |
| 2928 | 2928 | memcpy(cipher->auth_tag_, Buffer::Data(args[0]), cipher->auth_tag_len_); | |
| 2929 | + | ||
| 2930 | + args.GetReturnValue().Set(true); | ||
| 2929 | 2931 | } | |
| 2930 | 2932 | ||
| 2931 | 2933 | ||
@@ -2980,9 +2982,9 @@ void CipherBase::SetAAD(const FunctionCallbackInfo<Value>& args) { | |||
| 2980 | 2982 | CHECK(args[1]->IsInt32()); | |
| 2981 | 2983 | int plaintext_len = args[1].As<Int32>()->Value(); | |
| 2982 | 2984 | ||
| 2983 | - if (!cipher->SetAAD(Buffer::Data(args[0]), Buffer::Length(args[0]), | ||
| 2984 | - plaintext_len)) | ||
| 2985 | - args.GetReturnValue().Set(false); // Report invalid state failure | ||
| 2985 | + bool b = cipher->SetAAD(Buffer::Data(args[0]), Buffer::Length(args[0]), | ||
| 2986 | + plaintext_len); | ||
| 2987 | + args.GetReturnValue().Set(b); // Possibly report invalid state failure | ||
| 2986 | 2988 | } | |
| 2987 | 2989 | ||
| 2988 | 2990 | ||
@@ -3094,8 +3096,8 @@ void CipherBase::SetAutoPadding(const FunctionCallbackInfo<Value>& args) { | |||
| 3094 | 3096 | CipherBase* cipher; | |
| 3095 | 3097 | ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder()); | |
| 3096 | 3098 | ||
| 3097 | - if (!cipher->SetAutoPadding(args.Length() < 1 || args[0]->BooleanValue())) | ||
| 3098 | - args.GetReturnValue().Set(false); // Report invalid state failure | ||
| 3099 | + bool b = cipher->SetAutoPadding(args.Length() < 1 || args[0]->BooleanValue()); | ||
| 3100 | + args.GetReturnValue().Set(b); // Possibly report invalid state failure | ||
| 3099 | 3101 | } | |
| 3100 | 3102 | ||
| 3101 | 3103 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments