summaryrefslogtreecommitdiff
path: root/lib/internal/crypto/hash.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/crypto/hash.js')
-rw-r--r--lib/internal/crypto/hash.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/internal/crypto/hash.js b/lib/internal/crypto/hash.js
index f289d11cf8..713ded3d18 100644
--- a/lib/internal/crypto/hash.js
+++ b/lib/internal/crypto/hash.js
@@ -12,6 +12,10 @@ const {
toBuf
} = require('internal/crypto/util');
+const {
+ prepareSecretKey
+} = require('internal/crypto/keys');
+
const { Buffer } = require('buffer');
const {
@@ -88,10 +92,7 @@ function Hmac(hmac, key, options) {
if (!(this instanceof Hmac))
return new Hmac(hmac, key, options);
validateString(hmac, 'hmac');
- if (typeof key !== 'string' && !isArrayBufferView(key)) {
- throw new ERR_INVALID_ARG_TYPE('key',
- ['string', 'TypedArray', 'DataView'], key);
- }
+ key = prepareSecretKey(key);
this[kHandle] = new _Hmac();
this[kHandle].init(hmac, toBuf(key));
this[kState] = {