impl/ns_crypto library

Classes

NSEncryptionLease
Keeps NativeCallable instances alive while an encrypted database is open.

Constants

kDefaultArgon2Iterations → const int
kDefaultArgon2MemoryKib → const int
Default Argon2id costs for passphrase → AES-key stretching. Stored in the database KDF slab so they can be raised later without a format break. 8 MiB / 2 iterations is intentional for embedded open latency.
kDefaultArgon2Parallelism → const int
kDefaultArgon2SaltLen → const int

Functions

aesGcmDecrypt(Uint8List key, Uint8List input, Uint8List aad) → Uint8List?
AES-256-GCM decrypt for aesGcmEncrypt output. aad must match the bytes used at encryption time or decryption fails (returns null).
aesGcmEncrypt(Uint8List key, Uint8List plaintext, Uint8List aad) → Uint8List?
AES-256-GCM encrypt. Output layout: ciphertext + 16-byte tag.
allocDefaultArgon2Params() → Pointer<ns_kdf_params_t>
Allocate default Argon2id params with a fresh random salt for a new database. Caller must calloc.free the returned pointer.
deriveAesKeyArgon2id(List<int> passphrase, Pointer<ns_kdf_params_t> params) → Uint8List
Derive a 32-byte AES-256 key from a passphrase using Argon2id.
secureRandomBytes(int length) → Uint8List
Generate length cryptographically-strong random bytes.
secureZero(Uint8List bytes) → void
Overwrite bytes with zeros before releasing sensitive material.