Browse Source

src: remove duplicate HMAC_Init calls

PR-URL: https://github.com/nodejs/node/pull/7374
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
v4.x
Ben Noordhuis 9 years ago
committed by Myles Borins
parent
commit
7305e7b9d2
  1. 7
      src/node_crypto.cc

7
src/node_crypto.cc

@ -3326,13 +3326,10 @@ void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) {
return env()->ThrowError("Unknown message digest"); return env()->ThrowError("Unknown message digest");
} }
HMAC_CTX_init(&ctx_); HMAC_CTX_init(&ctx_);
int result = 0;
if (key_len == 0) { if (key_len == 0) {
result = HMAC_Init(&ctx_, "", 0, md); key = "";
} else {
result = HMAC_Init(&ctx_, key, key_len, md);
} }
if (!result) { if (!HMAC_Init(&ctx_, key, key_len, md)) {
return ThrowCryptoError(env(), ERR_get_error()); return ThrowCryptoError(env(), ERR_get_error());
} }
initialised_ = true; initialised_ = true;

Loading…
Cancel
Save