- wo_tls_client: a pure state machine (no sockets). Caller frames records; driver runs ClientHello->ServerHello->flight->Finished and hands back bytes to send. Keeps all I/O out of the security-critical FSM - start_with (inject CH + ephemeral priv), push_record, take_output, encrypt/decrypt (application traffic keys). Handshake-message reassembly across records; per-message transcript timing (CertVerify signs CH..Cert, Finished MACs CH..CertVerify); constant-time Finished compare; every failure lands in FAILED (no warn-and-continue) - verifies server CertificateVerify (phase E+D) + server Finished, emits the client Finished, switches to application keys - KAT: whole handshake driven offline against the RFC 8448 record trace — client Finished record byte-for-byte, first client app record byte-for-byte, NewSessionTicket + server app data decrypt to plaintext, tampered flight -> FAILED. test_tls 90 pass, ASan/UBSan clean - SECURITY TODO before live use (documented in tls.h + story): chain walk to a trust anchor + SAN/hostname match; random ephemeral for production start; the net.connect_tls socket glue Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> (cherry picked from commit 74c332d7efdb8bbfdbe90bd2fcc3defa2fe8da00)
175 lines
9.2 KiB
C
175 lines
9.2 KiB
C
/* Generated from RFC 8448 §3 'Simple 1-RTT Handshake'. Wire records +
|
|
* ephemeral key + app-data plaintext for the phase-F3c sans-io driver KAT. */
|
|
static const unsigned char drv_client_priv[] = {
|
|
0x49,0xaf,0x42,0xba,0x7f,0x79,0x94,0x85,0x2d,0x71,0x3e,0xf2,
|
|
0x78,0x4b,0xcb,0xca,0xa7,0x91,0x1d,0xe2,0x6a,0xdc,0x56,0x42,
|
|
0xcb,0x63,0x45,0x40,0xe7,0xea,0x50,0x05,
|
|
};
|
|
|
|
static const unsigned char drv_ch_msg[] = {
|
|
0x01,0x00,0x00,0xc0,0x03,0x03,0xcb,0x34,0xec,0xb1,0xe7,0x81,
|
|
0x63,0xba,0x1c,0x38,0xc6,0xda,0xcb,0x19,0x6a,0x6d,0xff,0xa2,
|
|
0x1a,0x8d,0x99,0x12,0xec,0x18,0xa2,0xef,0x62,0x83,0x02,0x4d,
|
|
0xec,0xe7,0x00,0x00,0x06,0x13,0x01,0x13,0x03,0x13,0x02,0x01,
|
|
0x00,0x00,0x91,0x00,0x00,0x00,0x0b,0x00,0x09,0x00,0x00,0x06,
|
|
0x73,0x65,0x72,0x76,0x65,0x72,0xff,0x01,0x00,0x01,0x00,0x00,
|
|
0x0a,0x00,0x14,0x00,0x12,0x00,0x1d,0x00,0x17,0x00,0x18,0x00,
|
|
0x19,0x01,0x00,0x01,0x01,0x01,0x02,0x01,0x03,0x01,0x04,0x00,
|
|
0x23,0x00,0x00,0x00,0x33,0x00,0x26,0x00,0x24,0x00,0x1d,0x00,
|
|
0x20,0x99,0x38,0x1d,0xe5,0x60,0xe4,0xbd,0x43,0xd2,0x3d,0x8e,
|
|
0x43,0x5a,0x7d,0xba,0xfe,0xb3,0xc0,0x6e,0x51,0xc1,0x3c,0xae,
|
|
0x4d,0x54,0x13,0x69,0x1e,0x52,0x9a,0xaf,0x2c,0x00,0x2b,0x00,
|
|
0x03,0x02,0x03,0x04,0x00,0x0d,0x00,0x20,0x00,0x1e,0x04,0x03,
|
|
0x05,0x03,0x06,0x03,0x02,0x03,0x08,0x04,0x08,0x05,0x08,0x06,
|
|
0x04,0x01,0x05,0x01,0x06,0x01,0x02,0x01,0x04,0x02,0x05,0x02,
|
|
0x06,0x02,0x02,0x02,0x00,0x2d,0x00,0x02,0x01,0x01,0x00,0x1c,
|
|
0x00,0x02,0x40,0x01,
|
|
};
|
|
|
|
static const unsigned char drv_rec_sh[] = {
|
|
0x16,0x03,0x03,0x00,0x5a,0x02,0x00,0x00,0x56,0x03,0x03,0xa6,
|
|
0xaf,0x06,0xa4,0x12,0x18,0x60,0xdc,0x5e,0x6e,0x60,0x24,0x9c,
|
|
0xd3,0x4c,0x95,0x93,0x0c,0x8a,0xc5,0xcb,0x14,0x34,0xda,0xc1,
|
|
0x55,0x77,0x2e,0xd3,0xe2,0x69,0x28,0x00,0x13,0x01,0x00,0x00,
|
|
0x2e,0x00,0x33,0x00,0x24,0x00,0x1d,0x00,0x20,0xc9,0x82,0x88,
|
|
0x76,0x11,0x20,0x95,0xfe,0x66,0x76,0x2b,0xdb,0xf7,0xc6,0x72,
|
|
0xe1,0x56,0xd6,0xcc,0x25,0x3b,0x83,0x3d,0xf1,0xdd,0x69,0xb1,
|
|
0xb0,0x4e,0x75,0x1f,0x0f,0x00,0x2b,0x00,0x02,0x03,0x04,
|
|
};
|
|
|
|
static const unsigned char drv_rec_flight[] = {
|
|
0x17,0x03,0x03,0x02,0xa2,0xd1,0xff,0x33,0x4a,0x56,0xf5,0xbf,
|
|
0xf6,0x59,0x4a,0x07,0xcc,0x87,0xb5,0x80,0x23,0x3f,0x50,0x0f,
|
|
0x45,0xe4,0x89,0xe7,0xf3,0x3a,0xf3,0x5e,0xdf,0x78,0x69,0xfc,
|
|
0xf4,0x0a,0xa4,0x0a,0xa2,0xb8,0xea,0x73,0xf8,0x48,0xa7,0xca,
|
|
0x07,0x61,0x2e,0xf9,0xf9,0x45,0xcb,0x96,0x0b,0x40,0x68,0x90,
|
|
0x51,0x23,0xea,0x78,0xb1,0x11,0xb4,0x29,0xba,0x91,0x91,0xcd,
|
|
0x05,0xd2,0xa3,0x89,0x28,0x0f,0x52,0x61,0x34,0xaa,0xdc,0x7f,
|
|
0xc7,0x8c,0x4b,0x72,0x9d,0xf8,0x28,0xb5,0xec,0xf7,0xb1,0x3b,
|
|
0xd9,0xae,0xfb,0x0e,0x57,0xf2,0x71,0x58,0x5b,0x8e,0xa9,0xbb,
|
|
0x35,0x5c,0x7c,0x79,0x02,0x07,0x16,0xcf,0xb9,0xb1,0x18,0x3e,
|
|
0xf3,0xab,0x20,0xe3,0x7d,0x57,0xa6,0xb9,0xd7,0x47,0x76,0x09,
|
|
0xae,0xe6,0xe1,0x22,0xa4,0xcf,0x51,0x42,0x73,0x25,0x25,0x0c,
|
|
0x7d,0x0e,0x50,0x92,0x89,0x44,0x4c,0x9b,0x3a,0x64,0x8f,0x1d,
|
|
0x71,0x03,0x5d,0x2e,0xd6,0x5b,0x0e,0x3c,0xdd,0x0c,0xba,0xe8,
|
|
0xbf,0x2d,0x0b,0x22,0x78,0x12,0xcb,0xb3,0x60,0x98,0x72,0x55,
|
|
0xcc,0x74,0x41,0x10,0xc4,0x53,0xba,0xa4,0xfc,0xd6,0x10,0x92,
|
|
0x8d,0x80,0x98,0x10,0xe4,0xb7,0xed,0x1a,0x8f,0xd9,0x91,0xf0,
|
|
0x6a,0xa6,0x24,0x82,0x04,0x79,0x7e,0x36,0xa6,0xa7,0x3b,0x70,
|
|
0xa2,0x55,0x9c,0x09,0xea,0xd6,0x86,0x94,0x5b,0xa2,0x46,0xab,
|
|
0x66,0xe5,0xed,0xd8,0x04,0x4b,0x4c,0x6d,0xe3,0xfc,0xf2,0xa8,
|
|
0x94,0x41,0xac,0x66,0x27,0x2f,0xd8,0xfb,0x33,0x0e,0xf8,0x19,
|
|
0x05,0x79,0xb3,0x68,0x45,0x96,0xc9,0x60,0xbd,0x59,0x6e,0xea,
|
|
0x52,0x0a,0x56,0xa8,0xd6,0x50,0xf5,0x63,0xaa,0xd2,0x74,0x09,
|
|
0x96,0x0d,0xca,0x63,0xd3,0xe6,0x88,0x61,0x1e,0xa5,0xe2,0x2f,
|
|
0x44,0x15,0xcf,0x95,0x38,0xd5,0x1a,0x20,0x0c,0x27,0x03,0x42,
|
|
0x72,0x96,0x8a,0x26,0x4e,0xd6,0x54,0x0c,0x84,0x83,0x8d,0x89,
|
|
0xf7,0x2c,0x24,0x46,0x1a,0xad,0x6d,0x26,0xf5,0x9e,0xca,0xba,
|
|
0x9a,0xcb,0xbb,0x31,0x7b,0x66,0xd9,0x02,0xf4,0xf2,0x92,0xa3,
|
|
0x6a,0xc1,0xb6,0x39,0xc6,0x37,0xce,0x34,0x31,0x17,0xb6,0x59,
|
|
0x62,0x22,0x45,0x31,0x7b,0x49,0xee,0xda,0x0c,0x62,0x58,0xf1,
|
|
0x00,0xd7,0xd9,0x61,0xff,0xb1,0x38,0x64,0x7e,0x92,0xea,0x33,
|
|
0x0f,0xae,0xea,0x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,0x8e,0xdc,0x03,0x99,0xf3,0xa9,0xf2,
|
|
0x3f,0xaa,0x63,0x97,0x8c,0x31,0x7f,0xc9,0xfa,0x66,0xa7,0x3f,
|
|
0x60,0xf0,0x50,0x4d,0xe9,0x3b,0x5b,0x84,0x5e,0x27,0x55,0x92,
|
|
0xc1,0x23,0x35,0xee,0x34,0x0b,0xbc,0x4f,0xdd,0xd5,0x02,0x78,
|
|
0x40,0x16,0xe4,0xb3,0xbe,0x7e,0xf0,0x4d,0xda,0x49,0xf4,0xb4,
|
|
0x40,0xa3,0x0c,0xb5,0xd2,0xaf,0x93,0x98,0x28,0xfd,0x4a,0xe3,
|
|
0x79,0x4e,0x44,0xf9,0x4d,0xf5,0xa6,0x31,0xed,0xe4,0x2c,0x17,
|
|
0x19,0xbf,0xda,0xbf,0x02,0x53,0xfe,0x51,0x75,0xbe,0x89,0x8e,
|
|
0x75,0x0e,0xdc,0x53,0x37,0x0d,0x2b,
|
|
};
|
|
|
|
static const unsigned char drv_rec_cfin[] = {
|
|
0x17,0x03,0x03,0x00,0x35,0x75,0xec,0x4d,0xc2,0x38,0xcc,0xe6,
|
|
0x0b,0x29,0x80,0x44,0xa7,0x1e,0x21,0x9c,0x56,0xcc,0x77,0xb0,
|
|
0x51,0x7f,0xe9,0xb9,0x3c,0x7a,0x4b,0xfc,0x44,0xd8,0x7f,0x38,
|
|
0xf8,0x03,0x38,0xac,0x98,0xfc,0x46,0xde,0xb3,0x84,0xbd,0x1c,
|
|
0xae,0xac,0xab,0x68,0x67,0xd7,0x26,0xc4,0x05,0x46,
|
|
};
|
|
|
|
static const unsigned char drv_rec_nst[] = {
|
|
0x17,0x03,0x03,0x00,0xde,0x3a,0x6b,0x8f,0x90,0x41,0x4a,0x97,
|
|
0xd6,0x95,0x9c,0x34,0x87,0x68,0x0d,0xe5,0x13,0x4a,0x2b,0x24,
|
|
0x0e,0x6c,0xff,0xac,0x11,0x6e,0x95,0xd4,0x1d,0x6a,0xf8,0xf6,
|
|
0xb5,0x80,0xdc,0xf3,0xd1,0x1d,0x63,0xc7,0x58,0xdb,0x28,0x9a,
|
|
0x01,0x59,0x40,0x25,0x2f,0x55,0x71,0x3e,0x06,0x1d,0xc1,0x3e,
|
|
0x07,0x88,0x91,0xa3,0x8e,0xfb,0xcf,0x57,0x53,0xad,0x8e,0xf1,
|
|
0x70,0xad,0x3c,0x73,0x53,0xd1,0x6d,0x9d,0xa7,0x73,0xb9,0xca,
|
|
0x7f,0x2b,0x9f,0xa1,0xb6,0xc0,0xd4,0xa3,0xd0,0x3f,0x75,0xe0,
|
|
0x9c,0x30,0xba,0x1e,0x62,0x97,0x2a,0xc4,0x6f,0x75,0xf7,0xb9,
|
|
0x81,0xbe,0x63,0x43,0x9b,0x29,0x99,0xce,0x13,0x06,0x46,0x15,
|
|
0x13,0x98,0x91,0xd5,0xe4,0xc5,0xb4,0x06,0xf1,0x6e,0x3f,0xc1,
|
|
0x81,0xa7,0x7c,0xa4,0x75,0x84,0x00,0x25,0xdb,0x2f,0x0a,0x77,
|
|
0xf8,0x1b,0x5a,0xb0,0x5b,0x94,0xc0,0x13,0x46,0x75,0x5f,0x69,
|
|
0x23,0x2c,0x86,0x51,0x9d,0x86,0xcb,0xee,0xac,0x87,0xaa,0xc3,
|
|
0x47,0xd1,0x43,0xf9,0x60,0x5d,0x64,0xf6,0x50,0xdb,0x4d,0x02,
|
|
0x3e,0x70,0xe9,0x52,0xca,0x49,0xfe,0x51,0x37,0x12,0x1c,0x74,
|
|
0xbc,0x26,0x97,0x68,0x7e,0x24,0x87,0x46,0xd6,0xdf,0x35,0x30,
|
|
0x05,0xf3,0xbc,0xe1,0x86,0x96,0x12,0x9c,0x81,0x53,0x55,0x6b,
|
|
0x3b,0x6c,0x67,0x79,0xb3,0x7b,0xf1,0x59,0x85,0x68,0x4f,
|
|
};
|
|
|
|
static const unsigned char drv_rec_capp[] = {
|
|
0x17,0x03,0x03,0x00,0x43,0xa2,0x3f,0x70,0x54,0xb6,0x2c,0x94,
|
|
0xd0,0xaf,0xfa,0xfe,0x82,0x28,0xba,0x55,0xcb,0xef,0xac,0xea,
|
|
0x42,0xf9,0x14,0xaa,0x66,0xbc,0xab,0x3f,0x2b,0x98,0x19,0xa8,
|
|
0xa5,0xb4,0x6b,0x39,0x5b,0xd5,0x4a,0x9a,0x20,0x44,0x1e,0x2b,
|
|
0x62,0x97,0x4e,0x1f,0x5a,0x62,0x92,0xa2,0x97,0x70,0x14,0xbd,
|
|
0x1e,0x3d,0xea,0xe6,0x3a,0xee,0xbb,0x21,0x69,0x49,0x15,0xe4,
|
|
};
|
|
|
|
static const unsigned char drv_capp_pt[] = {
|
|
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,
|
|
0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
|
|
0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,
|
|
0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
|
|
0x30,0x31,
|
|
};
|
|
|
|
static const unsigned char drv_rec_sapp[] = {
|
|
0x17,0x03,0x03,0x00,0x43,0x2e,0x93,0x7e,0x11,0xef,0x4a,0xc7,
|
|
0x40,0xe5,0x38,0xad,0x36,0x00,0x5f,0xc4,0xa4,0x69,0x32,0xfc,
|
|
0x32,0x25,0xd0,0x5f,0x82,0xaa,0x1b,0x36,0xe3,0x0e,0xfa,0xf9,
|
|
0x7d,0x90,0xe6,0xdf,0xfc,0x60,0x2d,0xcb,0x50,0x1a,0x59,0xa8,
|
|
0xfc,0xc4,0x9c,0x4b,0xf2,0xe5,0xf0,0xa2,0x1c,0x00,0x47,0xc2,
|
|
0xab,0xf3,0x32,0x54,0x0d,0xd0,0x32,0xe1,0x67,0xc2,0x95,0x5d,
|
|
};
|
|
|
|
static const unsigned char drv_sapp_pt[] = {
|
|
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,
|
|
0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
|
|
0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,
|
|
0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
|
|
0x30,0x31,
|
|
};
|
|
|
|
static const unsigned char drv_c_ap[] = {
|
|
0x9e,0x40,0x64,0x6c,0xe7,0x9a,0x7f,0x9d,0xc0,0x5a,0xf8,0x88,
|
|
0x9b,0xce,0x65,0x52,0x87,0x5a,0xfa,0x0b,0x06,0xdf,0x00,0x87,
|
|
0xf7,0x92,0xeb,0xb7,0xc1,0x75,0x04,0xa5,
|
|
};
|
|
|
|
static const unsigned char drv_s_ap[] = {
|
|
0xa1,0x1a,0xf9,0xf0,0x55,0x31,0xf8,0x56,0xad,0x47,0x11,0x6b,
|
|
0x45,0xa9,0x50,0x32,0x82,0x04,0xb4,0xf4,0x4b,0xfb,0x6b,0x3a,
|
|
0x4b,0x4f,0x1f,0x3f,0xcb,0x63,0x16,0x43,
|
|
};
|
|
|