From 2f22cc549d9b6756ceae4f0ba80938b231c0931b Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Tue, 4 Apr 2023 23:22:43 +0200 Subject: [PATCH] fix(api): accept empty decrypted plaintext --- packages/native_crypto/lib/src/ciphers/aes/aes.dart | 7 ------- .../native_crypto/lib/src/core/constants/constants.dart | 5 +++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/native_crypto/lib/src/ciphers/aes/aes.dart b/packages/native_crypto/lib/src/ciphers/aes/aes.dart index 8eda12e..9d995fe 100644 --- a/packages/native_crypto/lib/src/ciphers/aes/aes.dart +++ b/packages/native_crypto/lib/src/ciphers/aes/aes.dart @@ -288,13 +288,6 @@ class AES implements Cipher { ); } - if (bytes.isEmpty) { - throw NativeCryptoException( - code: NativeCryptoExceptionCode.invalidData, - message: 'Platform returned no data on chunk #$count', - ); - } - return bytes; } } diff --git a/packages/native_crypto/lib/src/core/constants/constants.dart b/packages/native_crypto/lib/src/core/constants/constants.dart index c9b13ae..97b111c 100644 --- a/packages/native_crypto/lib/src/core/constants/constants.dart +++ b/packages/native_crypto/lib/src/core/constants/constants.dart @@ -6,8 +6,13 @@ abstract class Constants { /// The default chunk size in bytes used for encryption and decryption. + /// + /// ~32MB static const int defaultChunkSize = 33554432; + /// The length of the initialization vector in bytes used for AES GCM. static const int aesGcmNonceLength = 12; + + /// The length of the tag in bytes used for AES GCM. static const int aesGcmTagLength = 16; }