aesAuthDecrypt function

Uint8List aesAuthDecrypt(
  1. Uint8List encrypted,
  2. Uint8List aesKey,
  3. Uint8List iv,
  4. Uint8List tag,
)

Implementation

Uint8List aesAuthDecrypt(
    Uint8List encrypted, Uint8List aesKey, Uint8List iv, Uint8List tag) {
  final cryptoKeys.KeyPair keyPair =
      cryptoKeys.KeyPair.symmetric(cryptoKeys.SymmetricKey(keyValue: aesKey));

  final cryptoKeys.Encrypter encrypter = keyPair.publicKey!
      .createEncrypter(cryptoKeys.algorithms.encryption.aes.gcm);

  final Uint8List decrypted = encrypter.decrypt(cryptoKeys.EncryptionResult(
      encrypted,
      initializationVector: iv,
      authenticationTag: tag));

  return decrypted;
}