fortis 0.3.0
fortis: ^0.3.0 copied to clipboard
High-level cryptography for Dart. Fluent builder API with compile-time safety, sane defaults, and seamless cross-platform interoperability.
Changelog #
0.3.0 - 2026-04-24 #
Added #
- Flutter web support:
Fortis.aes().generateKey(),Fortis.ecdh().generateKeyPair(), andFortis.rsa().generateKeyPair()now work on web. Implementation uses conditional imports —dart:isolateon VM/AOT, synchronous execution wrapped inFuture.syncon web (sincedart:isolateis unavailable there). FortisLog.warnnow fires on web when generating RSA keys ≥ 2048 bits to flag that the main thread will be blocked.
Changed #
- Internal: key-generation call sites now route through
lib/src/core/platform.dartinstead of importingdart:isolatedirectly. - Docstrings of
generateKey/generateKeyPairnow describe the web behaviour alongside the VM/Isolate path.
0.2.0 - 2026-04-16 #
Added #
- ECDH key agreement with NIST curves P-256, P-384, and P-521
- HKDF-SHA256 key derivation:
deriveSharedSecret,deriveKey, andderiveAesKey - Static HKDF utilities (
EcdhKeyDerivation.hkdf,EcdhKeyDerivation.hkdfDeriveAesKey) for pre-shared secrets - ECDH key serialization (PEM X.509 / PKCS#8 / SEC1, DER, Base64, raw uncompressed point)
- Typed AES builder shortcuts (
.ecb(),.cbc(),.ctr(),.cfb(),.ofb(),.gcm(),.ccm()) returning statically-typed cipher variants - Sealed
AesCipherhierarchy (AesEcbCipher,AesStandardCipher,AesAuthCipher) —encryptToPayloadis now statically typed per variant (no casts) - Multilingual cryptography guides (
doc/) for AES, RSA, and ECDH in English, Spanish, and Portuguese - Comprehensive edge-case and validation tests across all three algorithms
Changed #
- Split
AesAuthModeBuilderintoAesGcmModeBuilder(exposesaadandivSize; tag fixed at 128 bits) andAesCcmModeBuilder(exposesaad,ivSize, andtagSizevalidated against NIST SP 800-38C: {32, 48, 64, 80, 96, 112, 128}). CallingtagSizeon GCM is now a compile-time error instead of a runtimeArgumentError. The sealedAesAuthModeBuilderremains as a common base type. - Renamed
AesAuthModeBuilder.nonceSizetoivSizefor consistency with theencrypt(iv: ...)parameter. - Bumped
lintsto^6.1.0andtestto^1.31.0
Fixed #
AesCipher.decrypt(String|Map)andRsaDecrypter.decrypt(String)now wrapFormatExceptionfrombase64DecodeasFortisConfigExceptioninstead of letting it escape the public API.AesAuthCipherconstructor now fails fast on invalidtagSizeBits(GCM ≠ 128, or CCM outside{32, 48, 64, 80, 96, 112, 128}) viaFortisConfigException, instead of surfacing a runtimeArgumentErrorfrom PointyCastle.AesStandardCipherconstructor now rejects CBC without padding and stream modes (CTR/CFB/OFB) with padding, instead of crashing later or silently ignoring the value.RsaEncrypterandRsaDecrypterconstructors now rejectlabelcombined with any padding other thanRsaPadding.oaep_v2_1(previously the label was silently ignored at encrypt/decrypt time).FortisAesKey.fromTrustedBytesnow validates the byte length (16/24/32). Although named "trusted", the symbol is exported publicly, so an invalid size would surface as a cryptic PointyCastle error on the firstencryptcall.FortisEcdhPublicKeyandFortisEcdhPrivateKeyconstructors now rejectkey/curvemismatches (e.g., a P-256 key declared as P-384). Previously the combination was accepted silently and surfaced as inconsistent shared secrets or cryptic errors downstream.
0.1.0 - 2026-04-12 #
Added #
- RSA encryption/decryption with PKCS#1 v1.5 and OAEP padding support
- AES encryption/decryption with ECB, CBC, CTR, GCM, CFB, OFB, and CCM modes
- Fluent builder API with compile-time safety via phantom types
- Async key generation via Dart Isolate
- Key serialization (PEM, DER, Base64)
- AAD support for GCM and CCM
- Automatic IV/nonce management
FortisExceptionhierarchy for structured error handling