A cipher for AES authenticated modes: AesMode.gcm, AesMode.ccm.
Authenticated Encryption with Associated Data (AEAD) provides both confidentiality and integrity. On decrypt, Fortis verifies the auth tag automatically and throws FortisEncryptionException if the ciphertext or AAD has been tampered with.
Built via the matching mode builder:
final key = await Fortis.aes().generateKey();
final cipher = Fortis.aes().gcm().cipher(key); // AesAuthCipher
final payload = cipher.encryptToPayload('hello'); // AesAuthPayload
print(payload.tag); // ✓ typed, no cast
Use AesGcmModeBuilder for GCM (aad, ivSize; tag fixed at 128 bits) or AesCcmModeBuilder for CCM (aad, ivSize, tagSize) to customize before building.
See also:
- AesAuthModeBuilder, the sealed base of the two builders that produce this cipher.
- AesAuthPayload, the iv/data/tag output of encryptToPayload.
- AesStandardCipher, the non-authenticated counterpart.
Constructors
- AesAuthCipher({required AesMode mode, required FortisAesKey key, Uint8List? aad, int tagSizeBits = 128, int? ivSize})
-
Creates an authenticated AES cipher for GCM or CCM. Prefer the
builder:
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
decrypt(
Object input) → Uint8List -
Decrypts
inputand returns the plaintext as raw bytes.inherited -
decryptToString(
Object input) → String -
Decrypts
inputand returns the plaintext as a UTF-8 decoded String.inherited -
encrypt(
Object plaintext, {Uint8List? iv}) → Uint8List -
Encrypts
plaintextand returns the combined buffer as raw bytes.inherited -
encryptToPayload(
Object plaintext, {Uint8List? iv}) → AesAuthPayload -
Encrypts
plaintextand returns a structured AesAuthPayload. -
encryptToString(
Object plaintext, {Uint8List? iv}) → String -
Encrypts
plaintextand returns the result as a Base64-encoded string.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited