@@ -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
0 commit comments