| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e103044 commit 38baf6a
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3320,17 +3320,17 @@ void Hmac::New(const FunctionCallbackInfo<Value>& args) { | |||
| 3320 | 3320 | void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) { | |
| 3321 | 3321 | HandleScope scope(env()->isolate()); | |
| 3322 | 3322 | ||
| 3323 | - CHECK_EQ(md_, nullptr); | ||
| 3324 | - md_ = EVP_get_digestbyname(hash_type); | ||
| 3325 | - if (md_ == nullptr) { | ||
| 3323 | + CHECK_EQ(initialised_, false); | ||
| 3324 | + const EVP_MD* md = EVP_get_digestbyname(hash_type); | ||
| 3325 | + if (md == nullptr) { | ||
| 3326 | 3326 | return env()->ThrowError("Unknown message digest"); | |
| 3327 | 3327 | } | |
| 3328 | 3328 | HMAC_CTX_init(&ctx_); | |
| 3329 | 3329 | int result = 0; | |
| 3330 | 3330 | if (key_len == 0) { | |
| 3331 | - result = HMAC_Init(&ctx_, "", 0, md_); | ||
| 3331 | + result = HMAC_Init(&ctx_, "", 0, md); | ||
| 3332 | 3332 | } else { | |
| 3333 | - result = HMAC_Init(&ctx_, key, key_len, md_); | ||
| 3333 | + result = HMAC_Init(&ctx_, key, key_len, md); | ||
| 3334 | 3334 | } | |
| 3335 | 3335 | if (!result) { | |
| 3336 | 3336 | return ThrowCryptoError(env(), ERR_get_error()); | |
@@ -3461,12 +3461,12 @@ void Hash::New(const FunctionCallbackInfo<Value>& args) { | |||
| 3461 | 3461 | ||
| 3462 | 3462 | ||
| 3463 | 3463 | bool Hash::HashInit(const char* hash_type) { | |
| 3464 | - CHECK_EQ(md_, nullptr); | ||
| 3465 | - md_ = EVP_get_digestbyname(hash_type); | ||
| 3466 | - if (md_ == nullptr) | ||
| 3464 | + CHECK_EQ(initialised_, false); | ||
| 3465 | + const EVP_MD* md = EVP_get_digestbyname(hash_type); | ||
| 3466 | + if (md == nullptr) | ||
| 3467 | 3467 | return false; | |
| 3468 | 3468 | EVP_MD_CTX_init(&mdctx_); | |
| 3469 | - if (EVP_DigestInit_ex(&mdctx_, md_, nullptr) <= 0) { | ||
| 3469 | + if (EVP_DigestInit_ex(&mdctx_, md, nullptr) <= 0) { | ||
| 3470 | 3470 | return false; | |
| 3471 | 3471 | } | |
| 3472 | 3472 | initialised_ = true; | |
@@ -3599,13 +3599,13 @@ void Sign::New(const FunctionCallbackInfo<Value>& args) { | |||
| 3599 | 3599 | ||
| 3600 | 3600 | ||
| 3601 | 3601 | SignBase::Error Sign::SignInit(const char* sign_type) { | |
| 3602 | - CHECK_EQ(md_, nullptr); | ||
| 3603 | - md_ = EVP_get_digestbyname(sign_type); | ||
| 3604 | - if (!md_) | ||
| 3602 | + CHECK_EQ(initialised_, false); | ||
| 3603 | + const EVP_MD* md = EVP_get_digestbyname(sign_type); | ||
| 3604 | + if (md == nullptr) | ||
| 3605 | 3605 | return kSignUnknownDigest; | |
| 3606 | 3606 | ||
| 3607 | 3607 | EVP_MD_CTX_init(&mdctx_); | |
| 3608 | - if (!EVP_SignInit_ex(&mdctx_, md_, nullptr)) | ||
| 3608 | + if (!EVP_SignInit_ex(&mdctx_, md, nullptr)) | ||
| 3609 | 3609 | return kSignInit; | |
| 3610 | 3610 | initialised_ = true; | |
| 3611 | 3611 | ||
@@ -3799,13 +3799,13 @@ void Verify::New(const FunctionCallbackInfo<Value>& args) { | |||
| 3799 | 3799 | ||
| 3800 | 3800 | ||
| 3801 | 3801 | SignBase::Error Verify::VerifyInit(const char* verify_type) { | |
| 3802 | - CHECK_EQ(md_, nullptr); | ||
| 3803 | - md_ = EVP_get_digestbyname(verify_type); | ||
| 3804 | - if (md_ == nullptr) | ||
| 3802 | + CHECK_EQ(initialised_, false); | ||
| 3803 | + const EVP_MD* md = EVP_get_digestbyname(verify_type); | ||
| 3804 | + if (md == nullptr) | ||
| 3805 | 3805 | return kSignUnknownDigest; | |
| 3806 | 3806 | ||
| 3807 | 3807 | EVP_MD_CTX_init(&mdctx_); | |
| 3808 | - if (!EVP_VerifyInit_ex(&mdctx_, md_, nullptr)) | ||
| 3808 | + if (!EVP_VerifyInit_ex(&mdctx_, md, nullptr)) | ||
| 3809 | 3809 | return kSignInit; | |
| 3810 | 3810 | initialised_ = true; | |
| 3811 | 3811 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -495,14 +495,12 @@ class Hmac : public BaseObject { | |||
| 495 | 495 | ||
| 496 | 496 | Hmac(Environment* env, v8::Local<v8::Object> wrap) | |
| 497 | 497 | : BaseObject(env, wrap), | |
| 498 | - md_(nullptr), | ||
| 499 | 498 | initialised_(false) { | |
| 500 | 499 | MakeWeak<Hmac>(this); | |
| 501 | 500 | } | |
| 502 | 501 | ||
| 503 | 502 | private: | |
| 504 | 503 | HMAC_CTX ctx_; /* coverity[member_decl] */ | |
| 505 | - const EVP_MD* md_; /* coverity[member_decl] */ | ||
| 506 | 504 | bool initialised_; | |
| 507 | 505 | }; | |
| 508 | 506 | ||
@@ -526,14 +524,12 @@ class Hash : public BaseObject { | |||
| 526 | 524 | ||
| 527 | 525 | Hash(Environment* env, v8::Local<v8::Object> wrap) | |
| 528 | 526 | : BaseObject(env, wrap), | |
| 529 | - md_(nullptr), | ||
| 530 | 527 | initialised_(false) { | |
| 531 | 528 | MakeWeak<Hash>(this); | |
| 532 | 529 | } | |
| 533 | 530 | ||
| 534 | 531 | private: | |
| 535 | 532 | EVP_MD_CTX mdctx_; /* coverity[member_decl] */ | |
| 536 | - const EVP_MD* md_; /* coverity[member_decl] */ | ||
| 537 | 533 | bool initialised_; | |
| 538 | 534 | }; | |
| 539 | 535 | ||
@@ -551,7 +547,6 @@ class SignBase : public BaseObject { | |||
| 551 | 547 | ||
| 552 | 548 | SignBase(Environment* env, v8::Local<v8::Object> wrap) | |
| 553 | 549 | : BaseObject(env, wrap), | |
| 554 | - md_(nullptr), | ||
| 555 | 550 | initialised_(false) { | |
| 556 | 551 | } | |
| 557 | 552 | ||
@@ -565,7 +560,6 @@ class SignBase : public BaseObject { | |||
| 565 | 560 | void CheckThrow(Error error); | |
| 566 | 561 | ||
| 567 | 562 | EVP_MD_CTX mdctx_; /* coverity[member_decl] */ | |
| 568 | - const EVP_MD* md_; /* coverity[member_decl] */ | ||
| 569 | 563 | bool initialised_; | |
| 570 | 564 | }; | |
| 571 | 565 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments