Skip to content

Commit 64233d2

Browse files
committed
crypto: runtime-deprecate calling hmac.digest() multiple times
1 parent 1b4e0fd commit 64233d2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/internal/crypto/hash.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ const maybeEmitDeprecationWarning = getDeprecationWarningEmitter(
8787
},
8888
);
8989

90+
const maybeEmitHMACMultipleDigestDeprecationWarning =
91+
getDeprecationWarningEmitter(
92+
'DEP0208',
93+
'Calling hmac.digest() multiple times without re-initialization is ' +
94+
'deprecated and will throw an error in a future version.',
95+
);
96+
9097
function Hash(algorithm, options) {
9198
if (!new.target)
9299
return new Hash(algorithm, options);
@@ -186,6 +193,7 @@ Hmac.prototype.digest = function digest(outputEncoding) {
186193
const state = this[kState];
187194

188195
if (state[kFinalized]) {
196+
maybeEmitHMACMultipleDigestDeprecationWarning();
189197
const buf = Buffer.from('');
190198
if (outputEncoding && outputEncoding !== 'buffer')
191199
return buf.toString(outputEncoding);

0 commit comments

Comments
 (0)