writeonce/runtime/test/tls_record_vectors.h
shoney.arickathil 7e71c1a171 feat(tls): TLS 1.3 record layer (rv2 9 phase F1)
- new tls.c/tls.h on the crypto ladder: wo_tls_record_seal/open
  (RFC 8446 §5.2) — TLSInnerPlaintext (content||type, no padding),
  5-byte header as AEAD additional-data, per-record nonce = iv XOR
  seq big-endian (§5.3)
- suite dispatch: TLS_AES_128_GCM_SHA256 (mandatory) +
  TLS_CHACHA20_POLY1305_SHA256 (AES-NI-less fallback), over phase-A AEAD
- open() strips trailing zero padding to recover the inner content type;
  rejects a length-field lie before the AEAD, and auth failure after
- KAT vs python AEAD oracle (test/gen_tls_record.py): sealed record
  byte-for-byte both suites, open() recovers it, 5-seq round-trip,
  tamper + wrong-seq + bad-suite rejected. test_tls 51 pass, ASan/UBSan

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 5021a99f8359f78a642bb0cc2b28ab66f6b624e2)
2026-09-15 01:15:31 +02:00

12 lines
987 B
C

/* Generated by scratchpad/gen_tls_record.py (python cryptography). */
#define TLSREC_IV "\xca\xfe\xba\xbe\xca\xfe\xba\xbe\xca\xfe\xba\xbe"
#define TLSREC_AESKEY "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
#define TLSREC_CHAKEY "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
#define TLSREC_SEQ 0x0102030405060708ULL
#define TLSREC_CT 22
#define TLSREC_PT "\x68\x65\x6c\x6c\x6f\x20\x77\x72\x69\x74\x65\x6f\x6e\x63\x65\x20\x74\x6c\x73"
#define TLSREC_PTLEN 19
#define TLSREC_AES "\x17\x03\x03\x00\x24\x37\x16\x16\xb3\xfc\x57\x75\x92\xab\x49\xf1\x68\xcf\x12\x79\x81\x68\x15\x8e\xb3\x7d\x65\x87\x28\xeb\xa2\x58\x79\xac\x9c\x3a\x6f\x08\xa2\x3e\x3e"
#define TLSREC_AESLEN 41
#define TLSREC_CHA "\x17\x03\x03\x00\x24\xbb\xd8\xe8\x3a\x0b\x08\xf5\x65\x6d\xcc\x12\x4b\x39\x3b\x77\xe2\x2a\x56\xc9\x53\xff\x6d\x6c\x1f\x99\x4a\x86\xf4\xab\x5d\x5d\xaf\x59\x2b\x99\xfb"
#define TLSREC_CHALEN 41