From 212961726c73914a94f4d73a24c7fbcc20501989 Mon Sep 17 00:00:00 2001
From: marco-ippolito <marcoippolito54@gmail.com>
Date: Wed, 13 Mar 2024 12:02:44 +0100
Subject: [PATCH] crypto: runtime deprecate hmac constructor

---
 doc/api/deprecations.md           |  5 ++++-
 lib/crypto.js                     |  2 +-
 test/parallel/test-crypto-hmac.js | 10 ++++++++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md
index 2f3f420d0d36a4..dfb9648d364939 100644
--- a/doc/api/deprecations.md
+++ b/doc/api/deprecations.md
@@ -3595,12 +3595,15 @@ deprecated due to being internals, not intended for public use.
 
 <!-- YAML
 changes:
+  - version: REPLACEME
+    pr-url: https://github.com/nodejs/node/pull/52071
+    description: Runtime deprecation.
   - version: REPLACEME
     pr-url: https://github.com/nodejs/node/pull/51881
     description: Documentation-only deprecation.
 -->
 
-Type: Documentation-only
+Type: Runtime
 
 Calling `Hmac` class directly with `Hmac()` or `new Hmac()` is
 deprecated due to being internals, not intended for public use.
diff --git a/lib/crypto.js b/lib/crypto.js
index c7cfdc841be2dc..a954a2736e7b82 100644
--- a/lib/crypto.js
+++ b/lib/crypto.js
@@ -232,7 +232,7 @@ module.exports = {
   DiffieHellmanGroup,
   ECDH,
   Hash: deprecate(Hash, 'crypto.Hash constructor is deprecated.', 'DEP0179'),
-  Hmac,
+  Hmac: deprecate(Hmac, 'crypto.Hmac constructor is deprecated.', 'DEP0181'),
   KeyObject,
   Sign,
   Verify,
diff --git a/test/parallel/test-crypto-hmac.js b/test/parallel/test-crypto-hmac.js
index 0edea0dfb0fdcc..8128dea658bda5 100644
--- a/test/parallel/test-crypto-hmac.js
+++ b/test/parallel/test-crypto-hmac.js
@@ -459,3 +459,13 @@ assert.strictEqual(
     crypto.createHmac('sha256', keyObject).update('foo').digest(),
   );
 }
+
+{
+  crypto.Hmac('sha256', 'Node');
+  common.expectWarning({
+    DeprecationWarning: [
+      ['crypto.Hmac constructor is deprecated.',
+       'DEP0181'],
+    ]
+  });
+}