/** * AES-128/192/256 in CTR mode. * * **WARNING: CTR mode is unauthenticated.** An attacker can flip ciphertext * bits without detection. Always pair with HMAC-SHA256 (Encrypt-then-MAC) * or use an authenticated cipher (`AESGCM`, `AESGCMSIV`, or `Seal` with * `AESGCMSIVCipher` / `SerpentCipher` / `XChaCha20Cipher`) instead. * * The constructor requires `{ dangerUnauthenticated: true }` so callers * cannot reach the unauthenticated path by accident, same gate as * `AESCbc` and `SerpentCtr`. * * The counter is 128-bit big-endian (SP 800-38A Appendix B.1 / §F.5). * * Stateful, the counter advances across `encrypt`/`decrypt` calls. Reset * with `setNonce()` before each new message. Holds exclusive access to the * `aes` WASM module from construction until `dispose()`. */ export declare class AESCtr { private readonly x; private _tok; constructor(opts?: { dangerUnauthenticated: true; }); /** * Expand `key` into the WASM key schedule. Must be called before * `setNonce` / `encrypt` / `decrypt`. * @param key 16, 24, or 32 bytes (AES-128 / 192 / 256) */ loadKey(key: Uint8Array): void; /** * Set the 128-bit initial counter block (the full IC, not a separate * nonce/counter split). Resets the working counter so subsequent * encrypt/decrypt calls start at this value. * @param nonce 16 bytes, must be unique per (key, message) */ setNonce(nonce: Uint8Array): void; /** * XOR `plaintext` with AES CTR keystream. The counter advances by * ceil(plaintext.length / 16) blocks; counter state persists across * calls until `setNonce()` resets it. * @param plaintext any length; internally chunked to WASM CHUNK_SIZE * @returns ciphertext of the same length */ encrypt(plaintext: Uint8Array): Uint8Array; /** Alias for `encrypt`, CTR mode is symmetric. */ decrypt(ciphertext: Uint8Array): Uint8Array; /** Wipe WASM state and release exclusive module access. Idempotent. */ dispose(): void; }