/** * AES-128/192/256 in GCM mode (SP 800-38D §7). Authenticated AEAD with * 128-bit tag. Tag length is fixed; shorter tags (32/64/96/104/112/120) * are out of scope for this version. * * `seal(key, iv, aad, pt)` returns `ciphertext || tag` (length pt.length + 16). * `open(key, iv, aad, sealed)` verifies the tag and returns the plaintext; * throws `RangeError('authentication failed')` on any verification failure * (the same generic error as a tag mismatch, no detail leak). * * Holds exclusive access to the `aes` WASM module from construction until * `dispose()`. Constructing a second AES-using class while this instance is * live throws. Always dispose when done so key material is wiped. */ export declare class AESGCM { private readonly x; private _tok; constructor(); /** * Authenticated encryption. * * @param key 16, 24, or 32 bytes (AES-128 / 192 / 256) * @param iv 1+ bytes; 12-byte (96-bit) IV is the recommended fast path * @param aad any length up to 64 KiB; may be empty * @param pt any length up to 2^36 - 32 bytes; may be empty * @returns ciphertext concatenated with the 128-bit tag * (length = pt.length + 16) * * @throws RangeError if key/iv/aad/pt lengths violate the spec or the * buffer-bounded API. */ seal(key: Uint8Array, iv: Uint8Array, aad: Uint8Array, pt: Uint8Array): Uint8Array; /** * Authenticated decryption. * * Performs verify-before-decrypt (SP 800-38D §7.2 permits the tag check * to precede plaintext computation): the entire ciphertext is absorbed * into GHASH, the tag is computed and constant-time-compared with the * received tag, and only then is the ciphertext decrypted to plaintext. * This avoids leaking decrypted bytes to higher layers when the tag * fails to verify. * * @param key same constraints as `seal` * @param iv same iv used during the matching `seal` call * @param aad same aad used during the matching `seal` call * @param sealed output of a previous `seal` call (ciphertext || tag) * @returns plaintext (length = sealed.length - 16) * * @throws RangeError('authentication failed') if the tag fails to * verify, or if the sealed input is too short, or any input * length violates the spec. The same generic error covers all * failure modes, no detail is leaked about which check failed. */ open(key: Uint8Array, iv: Uint8Array, aad: Uint8Array, sealed: Uint8Array): Uint8Array; /** Wipe WASM state and release exclusive module access. Idempotent. */ dispose(): void; private _validateInputs; private _loadKey; private _writeIv; private _writeAad; }