From e6dda65cb34e6afbb3864ddb245d6fa8f3fa16fa Mon Sep 17 00:00:00 2001 From: terrier989 Date: Fri, 21 Nov 2025 15:59:17 +0000 Subject: [PATCH] Allow empty HMAC key --- cryptography/lib/src/browser/hmac.dart | 7 ------- cryptography/lib/src/dart/hmac.dart | 7 ------- 2 files changed, 14 deletions(-) diff --git a/cryptography/lib/src/browser/hmac.dart b/cryptography/lib/src/browser/hmac.dart index ef7cce35..ccc8278c 100644 --- a/cryptography/lib/src/browser/hmac.dart +++ b/cryptography/lib/src/browser/hmac.dart @@ -66,13 +66,6 @@ class BrowserHmac extends Hmac { Future _jsCryptoKey(SecretKey secretKey) async { final secretKeyBytes = await secretKey.extractBytes(); - if (secretKeyBytes.isEmpty) { - throw ArgumentError.value( - secretKey, - 'secretKey', - 'SecretKey bytes must be non-empty', - ); - } return await web_crypto.importKeyWhenRaw( web_crypto.jsUint8ListFrom(secretKeyBytes), web_crypto.HmacImportParams( diff --git a/cryptography/lib/src/dart/hmac.dart b/cryptography/lib/src/dart/hmac.dart index 06e41baf..07a1991e 100644 --- a/cryptography/lib/src/dart/hmac.dart +++ b/cryptography/lib/src/dart/hmac.dart @@ -120,13 +120,6 @@ class _DartHmacSink extends MacSink with DartMacSinkMixin { 'AAD is not supported by HMAC', ); } - if (secretKey.bytes.isEmpty) { - throw ArgumentError.value( - secretKey, - 'secretKey', - 'Secret key must be non-empty', - ); - } _isClosed = false; var hmacKey = secretKey.bytes; var eraseKey = false;