decrypt method

List<int> decrypt(
  1. EncryptedPayload payload
)

Decifra payload e retorna o plaintext original.

Lança CryptException se a tag de autenticação não for válida.

Implementation

List<int> decrypt(EncryptedPayload payload) {
  _validate();
  final ek = aesExpandKey(key);
  final h = aesEncryptBlock(Uint8List(16), ek);
  final j0 = _makeJ0();

  final expectedTag = _computeTag(ek, h, j0, payload.ciphertext);
  if (!_ctEqual(payload.tag, expectedTag)) {
    throw const CryptException(
        'Tag GCM inválida. Dados corrompidos ou chave incorreta.');
  }
  return _gctr(ek, _inc32(j0), payload.ciphertext);
}