bcgit / pc-dart

Pointy Castle - Dart Derived Bouncy Castle APIs
MIT License
230 stars 120 forks source link

12 byte MAC throwing ArgumentError exception when using AES-GCM #229

Open jingramwright opened 3 months ago

jingramwright commented 3 months ago

I'm currently rewriting an existing Kotlin encryption/decryption implementation in Dart for a project uplift and I'm running into an issue with the following code:

final aesGcmCipher = GCMBlockCipher(AESEngine())..init(false, AEADParameters(KeyParameter(kmAndIv.km), (tagSize * bitsInAByte), kmAndIv.iv, Uint8List.fromList([])));

Where tagSize is 12, throws the exception:

ArgumentError (Invalid argument(s): macSize should be equal to 16 for GCM)

I've found this article, and I'm assuming this library also only supports 16-byte MAC's due to Apple's CryptoKit on macOS.

Is this the case? If so, is there anyway the MAC size can be enforced only on macOS?

Thanks.