- wo_tls_server: the mirror of the client driver. parse ClientHello (pick
suite, extract x25519 share, echo session id; reject no-x25519/no-1.3),
build ServerHello, derive the role-symmetric keys, emit the encrypted
flight (EncryptedExtensions + Certificate + a signed CertificateVerify +
Finished), verify the client Finished, switch to application keys
- server_sign_cv signs the CertificateVerify with the phase-G1 primitives
(RSA-PSS or ECDSA-P256 + a minimal DER SEQ{r,s} encoder); parse_client_hello
+ build helpers reuse the file's wire reader/writer
- wo_tls_server_start builds the Certificate message from a cert chain +
private key (RSA n/d or EC scalar) + ephemeral; encrypt/decrypt over the
application keys
- KAT: loopback — our client driver against our server driver, EC then RSA
server identity, reaching ESTABLISHED with an app round-trip both ways.
test_tls 123, ASan/UBSan clean
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 34d2b8f87cebe536cd2b1b33e6948251ec11684f)
186 lines
10 KiB
C
186 lines
10 KiB
C
/* Loopback server identities (self-signed EC + RSA leaves, SAN loopback.test). */
|
|
static const unsigned char srv_ec_leaf[] = {
|
|
0x30,0x82,0x01,0x63,0x30,0x82,0x01,0x09,0xa0,0x03,0x02,0x01,
|
|
0x02,0x02,0x14,0x20,0x63,0x6f,0xa1,0x21,0xec,0xc4,0x0b,0xb9,
|
|
0xca,0xf8,0x16,0x51,0x40,0x20,0x7a,0x79,0x42,0x1c,0x98,0x30,
|
|
0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02,0x30,
|
|
0x18,0x31,0x16,0x30,0x14,0x06,0x03,0x55,0x04,0x03,0x0c,0x0d,
|
|
0x6c,0x6f,0x6f,0x70,0x62,0x61,0x63,0x6b,0x2e,0x74,0x65,0x73,
|
|
0x74,0x30,0x1e,0x17,0x0d,0x32,0x30,0x30,0x31,0x30,0x31,0x30,
|
|
0x30,0x30,0x30,0x30,0x30,0x5a,0x17,0x0d,0x33,0x35,0x30,0x31,
|
|
0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x18,0x31,
|
|
0x16,0x30,0x14,0x06,0x03,0x55,0x04,0x03,0x0c,0x0d,0x6c,0x6f,
|
|
0x6f,0x70,0x62,0x61,0x63,0x6b,0x2e,0x74,0x65,0x73,0x74,0x30,
|
|
0x59,0x30,0x13,0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,0x02,0x01,
|
|
0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01,0x07,0x03,0x42,
|
|
0x00,0x04,0x21,0x28,0x55,0x43,0x81,0x8c,0x5b,0xec,0xfe,0x7a,
|
|
0xed,0x27,0xec,0x51,0x83,0x1b,0x3e,0x08,0x5a,0x97,0x5b,0xea,
|
|
0x66,0xe1,0xac,0x53,0x32,0x42,0x3b,0xf0,0x49,0x6a,0x38,0xe4,
|
|
0x8f,0xd7,0x44,0x5f,0x53,0x3e,0x58,0x7a,0x9f,0xd6,0x31,0xeb,
|
|
0xcd,0x16,0xa1,0x13,0x43,0xdb,0x50,0xe7,0x1a,0x8e,0x09,0xb0,
|
|
0x26,0xc1,0x2b,0x42,0xeb,0xde,0xa3,0x31,0x30,0x2f,0x30,0x18,
|
|
0x06,0x03,0x55,0x1d,0x11,0x04,0x11,0x30,0x0f,0x82,0x0d,0x6c,
|
|
0x6f,0x6f,0x70,0x62,0x61,0x63,0x6b,0x2e,0x74,0x65,0x73,0x74,
|
|
0x30,0x13,0x06,0x03,0x55,0x1d,0x25,0x04,0x0c,0x30,0x0a,0x06,
|
|
0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x03,0x01,0x30,0x0a,0x06,
|
|
0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02,0x03,0x48,0x00,
|
|
0x30,0x45,0x02,0x20,0x5a,0x2e,0x70,0x99,0x96,0x06,0xcd,0xf9,
|
|
0x1a,0x07,0xcc,0x84,0x03,0x25,0x36,0x16,0xcb,0x15,0x9b,0x25,
|
|
0xe2,0xd3,0xf6,0xd8,0x5c,0xd4,0x80,0x7d,0xf5,0xe8,0xde,0x34,
|
|
0x02,0x21,0x00,0x90,0x13,0x3e,0x9a,0x70,0x5f,0xab,0x01,0x24,
|
|
0xaf,0xe6,0xb9,0x83,0x07,0xd7,0x8e,0x77,0xe2,0xac,0xda,0xad,
|
|
0x19,0xc8,0xdf,0xb6,0x7e,0xd2,0x95,0x09,0x9e,0xfb,0x99,
|
|
};
|
|
|
|
static const unsigned char srv_ec_d[] = {
|
|
0x76,0xcb,0x44,0x4f,0x28,0x7c,0x32,0xa5,0xae,0xda,0xd5,0xab,
|
|
0x34,0x59,0x9f,0xa3,0x5b,0xc5,0x8a,0x21,0x74,0xb1,0x7e,0xf4,
|
|
0x2b,0x1a,0xcc,0xa9,0x56,0xf2,0xec,0xf3,
|
|
};
|
|
|
|
static const unsigned char srv_rsa_leaf[] = {
|
|
0x30,0x82,0x02,0xef,0x30,0x82,0x01,0xd7,0xa0,0x03,0x02,0x01,
|
|
0x02,0x02,0x14,0x49,0xc2,0x91,0xde,0x51,0xd3,0xe7,0x6a,0x18,
|
|
0xa5,0x58,0x6f,0x45,0xf5,0x44,0x8c,0xf3,0x4a,0x4b,0xcf,0x30,
|
|
0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0b,
|
|
0x05,0x00,0x30,0x18,0x31,0x16,0x30,0x14,0x06,0x03,0x55,0x04,
|
|
0x03,0x0c,0x0d,0x6c,0x6f,0x6f,0x70,0x62,0x61,0x63,0x6b,0x2e,
|
|
0x74,0x65,0x73,0x74,0x30,0x1e,0x17,0x0d,0x32,0x30,0x30,0x31,
|
|
0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x17,0x0d,0x33,
|
|
0x35,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
|
|
0x30,0x18,0x31,0x16,0x30,0x14,0x06,0x03,0x55,0x04,0x03,0x0c,
|
|
0x0d,0x6c,0x6f,0x6f,0x70,0x62,0x61,0x63,0x6b,0x2e,0x74,0x65,
|
|
0x73,0x74,0x30,0x82,0x01,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,
|
|
0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,
|
|
0x0f,0x00,0x30,0x82,0x01,0x0a,0x02,0x82,0x01,0x01,0x00,0xa8,
|
|
0x53,0xad,0x6a,0x9b,0xe1,0xbd,0x6e,0xbf,0xd1,0xfa,0xa4,0x19,
|
|
0xda,0xf8,0x25,0x4d,0x22,0x9f,0xe0,0x28,0xfc,0xc8,0x04,0x25,
|
|
0x3d,0x9f,0x81,0xfd,0x86,0x74,0x62,0x4d,0xa0,0xf9,0xfb,0x8e,
|
|
0xb1,0x46,0x65,0xa6,0x2b,0x77,0x27,0xd6,0xdf,0x2d,0xfe,0x83,
|
|
0x2b,0xed,0x43,0x74,0x8d,0x57,0xd0,0x00,0xdf,0x1f,0x85,0x68,
|
|
0x68,0xbd,0x02,0xf6,0x20,0x2e,0x06,0x96,0x0d,0xd3,0x2d,0x44,
|
|
0x89,0x95,0x6f,0xa8,0xf4,0xf2,0xdf,0x0b,0x86,0xa1,0x4a,0x20,
|
|
0x3c,0x52,0x64,0xe6,0x2f,0x44,0x5c,0x7c,0xd2,0x97,0xbe,0xcb,
|
|
0x2a,0x5b,0xa1,0x5f,0xd6,0x13,0xe1,0x43,0x45,0x33,0xe7,0x96,
|
|
0x0a,0x10,0x67,0xac,0xb9,0xd4,0x39,0x35,0x07,0x04,0x4c,0xaf,
|
|
0x05,0x6c,0x5d,0xca,0x38,0x14,0x3c,0xd9,0x49,0x72,0x9b,0x26,
|
|
0x7d,0x17,0x77,0xba,0x87,0x50,0xde,0x66,0x7d,0xcf,0x7d,0xec,
|
|
0x25,0x86,0xcc,0x59,0xa4,0xdb,0x56,0x71,0xd3,0xe0,0xa3,0x26,
|
|
0xae,0xb1,0xe5,0x16,0x5d,0x0c,0x82,0xbd,0x8e,0x20,0x3f,0x37,
|
|
0xfb,0x55,0x64,0x62,0x34,0xee,0x85,0x4f,0x99,0x61,0x1e,0x5d,
|
|
0x20,0x4b,0xdc,0x5e,0xcd,0x87,0x8d,0x4c,0x95,0x85,0x6e,0x43,
|
|
0x28,0x2b,0x3a,0x93,0xf0,0x36,0x41,0xd5,0xdc,0xcc,0x5f,0x30,
|
|
0x07,0x01,0xe1,0x37,0x03,0xd9,0x17,0x9f,0x17,0xb7,0xfb,0x03,
|
|
0x9a,0x32,0xdd,0x47,0xed,0x9e,0x1f,0x23,0x13,0xd4,0xd3,0x34,
|
|
0x68,0x81,0xc8,0x94,0xc7,0xad,0x27,0x7f,0x01,0xb4,0xb9,0x19,
|
|
0x79,0xfa,0x9f,0xeb,0xc7,0x60,0x8d,0x35,0x32,0xa5,0x79,0xda,
|
|
0x7d,0xaa,0x51,0x02,0x03,0x01,0x00,0x01,0xa3,0x31,0x30,0x2f,
|
|
0x30,0x18,0x06,0x03,0x55,0x1d,0x11,0x04,0x11,0x30,0x0f,0x82,
|
|
0x0d,0x6c,0x6f,0x6f,0x70,0x62,0x61,0x63,0x6b,0x2e,0x74,0x65,
|
|
0x73,0x74,0x30,0x13,0x06,0x03,0x55,0x1d,0x25,0x04,0x0c,0x30,
|
|
0x0a,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x03,0x01,0x30,
|
|
0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0b,
|
|
0x05,0x00,0x03,0x82,0x01,0x01,0x00,0xa2,0x02,0x25,0x4b,0x52,
|
|
0x42,0x2f,0x40,0x11,0xb3,0x34,0xdf,0x1b,0x91,0xce,0x2c,0x50,
|
|
0xc3,0x8a,0x28,0x34,0x59,0xa1,0x66,0xac,0x95,0x06,0xe4,0x03,
|
|
0x4e,0xba,0xc4,0x5d,0x75,0xea,0x4b,0xc6,0x5b,0x88,0xb2,0xa3,
|
|
0xa3,0xa5,0x3c,0x92,0x7c,0x93,0xca,0x05,0x99,0xa1,0xd8,0xc1,
|
|
0x6b,0xae,0x70,0xae,0x12,0x49,0x40,0x93,0x2f,0xc4,0xa5,0x3c,
|
|
0xf8,0xf5,0x7a,0x9f,0x19,0x39,0xc0,0xfa,0xa0,0x97,0x89,0x65,
|
|
0x6c,0x48,0x87,0xec,0x25,0xe1,0x05,0x7d,0xc6,0x8b,0xee,0x79,
|
|
0xd3,0xa3,0x4a,0x25,0xa5,0x89,0xa0,0x89,0x3a,0x94,0xa7,0x76,
|
|
0xfb,0xee,0x0f,0xb3,0xe2,0x65,0xde,0x00,0x92,0xa6,0x45,0x28,
|
|
0x11,0x42,0xe8,0xe0,0xe1,0xff,0x02,0x7a,0xe0,0x55,0x65,0xaa,
|
|
0xb8,0xea,0xb2,0x7a,0x50,0x42,0x5e,0x99,0xb5,0xbb,0xc7,0x72,
|
|
0x33,0x18,0xe0,0x7d,0x04,0x12,0xd7,0xb1,0x63,0x9f,0xde,0x2a,
|
|
0x55,0x23,0x37,0x06,0x70,0xf7,0xb8,0x06,0x4c,0xa6,0x0c,0x9b,
|
|
0x99,0x44,0x78,0xdf,0xc3,0x76,0x8e,0x2f,0xc5,0x92,0x28,0xae,
|
|
0xe1,0x10,0xb1,0x28,0x57,0x3d,0x5a,0x80,0x82,0x87,0xab,0x68,
|
|
0x13,0xa4,0x4d,0x0b,0xd1,0xfd,0x19,0xa2,0x6a,0x83,0x90,0xe3,
|
|
0x7b,0xac,0xc9,0xab,0x95,0x67,0xa8,0xf4,0x5f,0x4a,0x0f,0xec,
|
|
0x78,0x0b,0xb7,0x5a,0x58,0x50,0xc3,0xd6,0x23,0xd3,0xeb,0x52,
|
|
0x56,0xf7,0xb5,0x66,0x6c,0xc7,0x4f,0xe0,0x62,0xae,0x4f,0xa2,
|
|
0x41,0xb8,0xb2,0xe1,0x93,0xff,0xaa,0xc9,0xf2,0xdc,0xe7,0x69,
|
|
0x30,0x1b,0x08,0x18,0x32,0x1a,0xd4,0xa0,0x8c,0x47,0xed,
|
|
};
|
|
|
|
static const unsigned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
|
|
0x30,0x07,0x01,0xe1,0x37,0x03,0xd9,0x17,0x9f,0x17,0xb7,0xfb,
|
|
0x03,0x9a,0x32,0xdd,0x47,0xed,0x9e,0x1f,0x23,0x13,0xd4,0xd3,
|
|
0x34,0x68,0x81,0xc8,0x94,0xc7,0xad,0x27,0x7f,0x01,0xb4,0xb9,
|
|
0x19,0x79,0xfa,0x9f,0xeb,0xc7,0x60,0x8d,0x35,0x32,0xa5,0x79,
|
|
0xda,0x7d,0xaa,0x51,
|
|
};
|
|
|
|
static const unsigned char srv_rsa_d[] = {
|
|
0x0a,0xa3,0x99,0x51,0x24,0xef,0xa0,0x6f,0xc4,0xcf,0x82,0x8a,
|
|
0x47,0x39,0x14,0x18,0x95,0x76,0xc4,0x08,0xa0,0xc6,0x93,0x64,
|
|
0xd1,0xae,0xc2,0xab,0x6e,0x69,0x06,0x67,0xa5,0x34,0xf0,0xbf,
|
|
0xf1,0xdd,0xaa,0x0f,0xa8,0x30,0x54,0x9c,0x6f,0xc4,0x14,0xed,
|
|
0xe2,0x80,0x0f,0x03,0xc5,0xb4,0xde,0x51,0x3f,0x10,0xdb,0x36,
|
|
0xed,0x29,0xbb,0x92,0x99,0x98,0x60,0x98,0x59,0x79,0x1f,0xb9,
|
|
0x1b,0x7d,0x1f,0xb5,0x1a,0x46,0x7b,0x28,0x56,0x5b,0xe8,0xcb,
|
|
0x5c,0xdc,0xbb,0x2f,0x75,0xee,0x14,0x61,0xcd,0x20,0xe9,0x66,
|
|
0xed,0x83,0xec,0x9d,0x37,0x47,0xba,0x63,0x71,0x43,0x49,0x3b,
|
|
0xd0,0xbb,0xab,0x9c,0x45,0xea,0x4b,0xeb,0xde,0xba,0x66,0x0e,
|
|
0xeb,0xbc,0x09,0xc4,0xa6,0xd0,0xa3,0x14,0xb8,0x35,0x97,0xbc,
|
|
0x1a,0x42,0xe8,0x43,0x9b,0xdd,0x1a,0x39,0x0b,0x71,0xf7,0xea,
|
|
0x7a,0x82,0x87,0xb9,0xbf,0xed,0x4d,0x8e,0xd5,0xdd,0x3a,0x8f,
|
|
0xa0,0xff,0xc8,0x36,0x72,0xf2,0x4e,0x22,0x28,0x10,0x6a,0x8e,
|
|
0xdd,0xcd,0x29,0xfc,0xc2,0x8b,0xdf,0x75,0x4d,0x45,0x33,0x60,
|
|
0x0e,0x20,0xa5,0xd5,0x81,0x53,0xe7,0x2f,0xba,0x91,0xb3,0x0f,
|
|
0x23,0xaf,0xeb,0x8a,0xe9,0xad,0x5e,0xe4,0xa2,0xed,0xc8,0x18,
|
|
0xe3,0xd5,0xd4,0xe6,0x62,0x4e,0xf9,0x4d,0x99,0x9b,0x02,0xa2,
|
|
0x89,0x2c,0xa0,0x2b,0xf5,0x64,0x6b,0x9f,0xda,0x93,0x39,0xaf,
|
|
0x42,0x92,0xca,0xc6,0x1b,0x4b,0x73,0xc1,0xc5,0x38,0x39,0x26,
|
|
0x82,0x1a,0xc6,0x15,0x9d,0x61,0xfe,0x6b,0x41,0x7a,0x28,0xb0,
|
|
0xd2,0xe2,0x16,0xbd,
|
|
};
|
|
|
|
static const unsigned char srv_eph[] = {
|
|
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
|
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
|
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
|
|
};
|
|
|
|
static const unsigned char cli_eph[] = {
|
|
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
|
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
|
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
|
|
};
|
|
|
|
static const unsigned char cli_rand[] = {
|
|
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
|
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
|
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
|
|
};
|
|
|
|
static const unsigned char cli_sid[] = {
|
|
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
|
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
|
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
|
|
};
|
|
|
|
static const unsigned char srv_pss_salt[] = {
|
|
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
|
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
|
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
|
|
};
|
|
|