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 crypto_keys.KeyPair keyPair =
      crypto_keys.KeyPair.symmetric(crypto_keys.SymmetricKey(keyValue: aesKey));

  final crypto_keys.Encrypter<crypto_keys.Key> encrypter = keyPair.publicKey!
      .createEncrypter(crypto_keys.algorithms.encryption.aes.gcm);

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

  return decrypted;
}