import { describe, expect, it } from "@suaveplan/testing/runner"; import { CryptoCipherError } from "../../errors/crypto-cipher-error/crypto-cipher-error.js"; import { aesGcmStreamingEngine } from "./streaming-aead-aes-gcm.js"; describe("aesGcmStreamingEngine — conformance", () => { it("rejects wrong-length base nonce with STREAM_INVALID_NONCE_BASE", { timeout: 5000, }, () => { let caught: unknown; try { aesGcmStreamingEngine.deriveNonce(new Uint8Array(12), 0, 0); } catch (e) { caught = e; } expect(caught).toBeInstanceOf(CryptoCipherError); expect((caught as CryptoCipherError).code).toBe( "CRYPTO.CIPHER.STREAM_INVALID_NONCE_BASE" ); expect((caught as CryptoCipherError).context?.expectedLength).toBe(8); expect((caught as CryptoCipherError).context?.actualLength).toBe(12); }); it("declares stable wire identity", { timeout: 5000 }, () => { expect(aesGcmStreamingEngine.id).toBe("aes-256-gcm"); expect(aesGcmStreamingEngine.wireId).toBe(0x02); expect(aesGcmStreamingEngine.keyLength).toBe(32); expect(aesGcmStreamingEngine.nonceLength).toBe(12); expect(aesGcmStreamingEngine.nonceBaseLength).toBe(8); expect(aesGcmStreamingEngine.tagLength).toBe(16); }); });