crypto library
Pure Dart cryptographic primitives for the archive formats that need
them (Phase 3, doc/encryption-scope.md): AES with CBC/CTR modes,
SHA-1, SHA-256, HMAC, and PBKDF2.
A separate entrypoint from the compression codecs
(package:koni_codecs/koni_codecs.dart); import it only where
decryption is actually wired in. Everything here is standards-defined
(FIPS-197, SP 800-38A, FIPS 180-4, RFC 2104, RFC 8018), vector-tested,
zero-dependency, and dart2js/dart2wasm-exact.
Scope honesty: these primitives exist to read and write encrypted archives. They are not constant-time and make no key-zeroization promises; do not build interactive security systems on them.
Classes
- Aes
- AES block cipher (FIPS-197), key sizes 128/192/256.
- AesCbcDecryptor
- AES-CBC decryption (SP 800-38A) as an incremental whole-block transform.
- AesCbcEncryptor
-
AES-CBC encryption. Used by the 7z write-side encryption (Phase 4,
doc/encryption-scope.md), and by the primitives' round-trip tests and the RAR4 fixture builder (P3-5). - AesCtrLeStream
- The WinZip AES variant of CTR mode: the 16-byte counter block is a little-endian integer starting at 1, with no nonce, not the big-endian layout of SP 800-38A. XORing the keystream is its own inverse, so one class serves encrypt and decrypt.
- BlockHash
- Shared Merkle–Damgård framing for the SHA family (P3-1).
- Hmac
- HMAC (RFC 2104) over a SHA-family hash.
- Sha1
- SHA-1 (FIPS 180-4) as an incremental hash.
- Sha256
- SHA-256 (FIPS 180-4) as an incremental hash.