aes_gcm_backend library
Pluggable AES-256-GCM backend for Filen file-chunk crypto.
Filen's wire format is iv(12) | ciphertext | tag(16) (the tag is appended
to the ciphertext, GCM-style). That's the standard AES-GCM layout, so every
backend here is byte-interoperable — existing Filen-encrypted chunks decrypt
under the fast paths and vice versa.
Best-available, chosen at startup (each FFI backend self-tests on load and returns null on failure, so the chain degrades safely):
- OS OpenSSL libcrypto via FFI (Linux/desktop) — AES-NI, ~1280 MB/s
- Windows CNG bcrypt.dll via FFI — hardware AES-GCM
- package:cryptography — hardware via the app's Cryptography.instance (FlutterCryptography → CryptoKit/Keystore when the host app enabled it; WebCrypto on web), else pure-Dart (~10 MB/s)
- pointycastle GCMBlockCipher — the original software path
This replaces the ~1 MB/s pointycastle path that previously ran on every Filen chunk.
Classes
- AesGcmBackend
- CryptographyBackend
- package:cryptography — uses the host app's Cryptography.instance, so it picks up FlutterCryptography (hardware) when enabled, and BrowserCryptography (WebCrypto) on web; otherwise pure-Dart.
- PointycastleBackend
- The original pointycastle path (kept as the final fallback). Generates a random 12-byte IV; GCMBlockCipher.process appends the 16-byte tag.
Functions
-
chooseAesGcmBackend(
) → AesGcmBackend - Pick the fastest backend available on this platform.