blob: b3ca5f9905c0416c60ca6d8d953629cb348c2e0e [file]
/*
* Copyright (C) 2026 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* TLS key schedule tests
*
* TLS version 1.3 example handshake traces are provided in RFC 8448.
* We include the "Simple 1-RTT Handshake" and "Resumed 0-RTT
* Handshake" test cases, to exercise all successful code paths for
* the HKDF-based key schedule (including session resumption).
*
* For TLS version 1.2 and earlier, there are no good reference
* example handshake traces available. We choose to run through a
* non-functional minimal handshake that allows us to exercise the
* relevant code paths and so at least prevent regressions.
*
*/
/* Forcibly enable assertions */
#undef NDEBUG
#include <string.h>
#include <ipxe/malloc.h>
#include <ipxe/sha256.h>
#include <ipxe/md5_sha1.h>
#include <ipxe/x25519.h>
#include <ipxe/tlskey.h>
#include <ipxe/test.h>
/** RFC 8448 simple 1-RTT test: client random bytes */
static const struct tls_random rfc8448_simple_client_nonce = {
.bytes = {
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
},
};
/** RFC 8448 simple 1-RTT test: client X25519 private key */
static const uint8_t rfc8448_simple_x25519_private[] = {
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
};
/** RFC 8448 simple 1-RTT test: server X25519 public key */
static const uint8_t rfc8448_simple_x25519_partner[] = {
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
};
/** RFC 8448 simple 1-RTT test: ticket nonce */
static const uint8_t rfc8448_simple_ticket_nonce[] = { 0x00, 0x00 };
/** RFC 8448 simple 1-RTT test: ClientHello */
static const uint8_t rfc8448_simple_clienthello[] = {
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
};
/** RFC 8448 simple 1-RTT test: ServerHello */
static const uint8_t rfc8448_simple_serverhello[] = {
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
};
/** RFC 8448 simple 1-RTT test: EncryptedExtensions */
static const uint8_t rfc8448_simple_encryptedextensions[] = {
0x08, 0x00, 0x00, 0x24, 0x00, 0x22, 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, 0x1c, 0x00,
0x02, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00
};
/** RFC 8448 simple 1-RTT test: Certificate */
static const uint8_t rfc8448_simple_certificate[] = {
0x0b, 0x00, 0x01, 0xb9, 0x00, 0x00, 0x01, 0xb5, 0x00, 0x01, 0xb0,
0x30, 0x82, 0x01, 0xac, 0x30, 0x82, 0x01, 0x15, 0xa0, 0x03, 0x02,
0x01, 0x02, 0x02, 0x01, 0x02, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86,
0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x0e,
0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x03,
0x72, 0x73, 0x61, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x36, 0x30, 0x37,
0x33, 0x30, 0x30, 0x31, 0x32, 0x33, 0x35, 0x39, 0x5a, 0x17, 0x0d,
0x32, 0x36, 0x30, 0x37, 0x33, 0x30, 0x30, 0x31, 0x32, 0x33, 0x35,
0x39, 0x5a, 0x30, 0x0e, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55,
0x04, 0x03, 0x13, 0x03, 0x72, 0x73, 0x61, 0x30, 0x81, 0x9f, 0x30,
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02,
0x81, 0x81, 0x00, 0xb4, 0xbb, 0x49, 0x8f, 0x82, 0x79, 0x30, 0x3d,
0x98, 0x08, 0x36, 0x39, 0x9b, 0x36, 0xc6, 0x98, 0x8c, 0x0c, 0x68,
0xde, 0x55, 0xe1, 0xbd, 0xb8, 0x26, 0xd3, 0x90, 0x1a, 0x24, 0x61,
0xea, 0xfd, 0x2d, 0xe4, 0x9a, 0x91, 0xd0, 0x15, 0xab, 0xbc, 0x9a,
0x95, 0x13, 0x7a, 0xce, 0x6c, 0x1a, 0xf1, 0x9e, 0xaa, 0x6a, 0xf9,
0x8c, 0x7c, 0xed, 0x43, 0x12, 0x09, 0x98, 0xe1, 0x87, 0xa8, 0x0e,
0xe0, 0xcc, 0xb0, 0x52, 0x4b, 0x1b, 0x01, 0x8c, 0x3e, 0x0b, 0x63,
0x26, 0x4d, 0x44, 0x9a, 0x6d, 0x38, 0xe2, 0x2a, 0x5f, 0xda, 0x43,
0x08, 0x46, 0x74, 0x80, 0x30, 0x53, 0x0e, 0xf0, 0x46, 0x1c, 0x8c,
0xa9, 0xd9, 0xef, 0xbf, 0xae, 0x8e, 0xa6, 0xd1, 0xd0, 0x3e, 0x2b,
0xd1, 0x93, 0xef, 0xf0, 0xab, 0x9a, 0x80, 0x02, 0xc4, 0x74, 0x28,
0xa6, 0xd3, 0x5a, 0x8d, 0x88, 0xd7, 0x9f, 0x7f, 0x1e, 0x3f, 0x02,
0x03, 0x01, 0x00, 0x01, 0xa3, 0x1a, 0x30, 0x18, 0x30, 0x09, 0x06,
0x03, 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x0b, 0x06,
0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03, 0x02, 0x05, 0xa0, 0x30,
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
0x0b, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x85, 0xaa, 0xd2, 0xa0,
0xe5, 0xb9, 0x27, 0x6b, 0x90, 0x8c, 0x65, 0xf7, 0x3a, 0x72, 0x67,
0x17, 0x06, 0x18, 0xa5, 0x4c, 0x5f, 0x8a, 0x7b, 0x33, 0x7d, 0x2d,
0xf7, 0xa5, 0x94, 0x36, 0x54, 0x17, 0xf2, 0xea, 0xe8, 0xf8, 0xa5,
0x8c, 0x8f, 0x81, 0x72, 0xf9, 0x31, 0x9c, 0xf3, 0x6b, 0x7f, 0xd6,
0xc5, 0x5b, 0x80, 0xf2, 0x1a, 0x03, 0x01, 0x51, 0x56, 0x72, 0x60,
0x96, 0xfd, 0x33, 0x5e, 0x5e, 0x67, 0xf2, 0xdb, 0xf1, 0x02, 0x70,
0x2e, 0x60, 0x8c, 0xca, 0xe6, 0xbe, 0xc1, 0xfc, 0x63, 0xa4, 0x2a,
0x99, 0xbe, 0x5c, 0x3e, 0xb7, 0x10, 0x7c, 0x3c, 0x54, 0xe9, 0xb9,
0xeb, 0x2b, 0xd5, 0x20, 0x3b, 0x1c, 0x3b, 0x84, 0xe0, 0xa8, 0xb2,
0xf7, 0x59, 0x40, 0x9b, 0xa3, 0xea, 0xc9, 0xd9, 0x1d, 0x40, 0x2d,
0xcc, 0x0c, 0xc8, 0xf8, 0x96, 0x12, 0x29, 0xac, 0x91, 0x87, 0xb4,
0x2b, 0x4d, 0xe1, 0x00, 0x00
};
/** RFC 8448 simple 1-RTT test: CertificateVerify */
static const uint8_t rfc8448_simple_certificateverify[] = {
0x0f, 0x00, 0x00, 0x84, 0x08, 0x04, 0x00, 0x80, 0x5a, 0x74, 0x7c,
0x5d, 0x88, 0xfa, 0x9b, 0xd2, 0xe5, 0x5a, 0xb0, 0x85, 0xa6, 0x10,
0x15, 0xb7, 0x21, 0x1f, 0x82, 0x4c, 0xd4, 0x84, 0x14, 0x5a, 0xb3,
0xff, 0x52, 0xf1, 0xfd, 0xa8, 0x47, 0x7b, 0x0b, 0x7a, 0xbc, 0x90,
0xdb, 0x78, 0xe2, 0xd3, 0x3a, 0x5c, 0x14, 0x1a, 0x07, 0x86, 0x53,
0xfa, 0x6b, 0xef, 0x78, 0x0c, 0x5e, 0xa2, 0x48, 0xee, 0xaa, 0xa7,
0x85, 0xc4, 0xf3, 0x94, 0xca, 0xb6, 0xd3, 0x0b, 0xbe, 0x8d, 0x48,
0x59, 0xee, 0x51, 0x1f, 0x60, 0x29, 0x57, 0xb1, 0x54, 0x11, 0xac,
0x02, 0x76, 0x71, 0x45, 0x9e, 0x46, 0x44, 0x5c, 0x9e, 0xa5, 0x8c,
0x18, 0x1e, 0x81, 0x8e, 0x95, 0xb8, 0xc3, 0xfb, 0x0b, 0xf3, 0x27,
0x84, 0x09, 0xd3, 0xbe, 0x15, 0x2a, 0x3d, 0xa5, 0x04, 0x3e, 0x06,
0x3d, 0xda, 0x65, 0xcd, 0xf5, 0xae, 0xa2, 0x0d, 0x53, 0xdf, 0xac,
0xd4, 0x2f, 0x74, 0xf3
};
/** RFC 8448 simple 1-RTT test: server Finished */
static const uint8_t rfc8448_simple_server_finished[] = {
0x14, 0x00, 0x00, 0x20, 0x9b, 0x9b, 0x14, 0x1d, 0x90, 0x63, 0x37,
0xfb, 0xd2, 0xcb, 0xdc, 0xe7, 0x1d, 0xf4, 0xde, 0xda, 0x4a, 0xb4,
0x2c, 0x30, 0x95, 0x72, 0xcb, 0x7f, 0xff, 0xee, 0x54, 0x54, 0xb7,
0x8f, 0x07, 0x18
};
/** RFC 8448 simple 1-RTT test: client Finished */
static const uint8_t rfc8448_simple_client_finished[] = {
0x14, 0x00, 0x00, 0x20, 0xa8, 0xec, 0x43, 0x6d, 0x67, 0x76, 0x34,
0xae, 0x52, 0x5a, 0xc1, 0xfc, 0xeb, 0xe1, 0x1a, 0x03, 0x9e, 0xc1,
0x76, 0x94, 0xfa, 0xc6, 0xe9, 0x85, 0x27, 0xb6, 0x42, 0xf2, 0xed,
0xd5, 0xce, 0x61
};
/** RFC 8448 simple 1-RTT test: NewSessionTicket */
static const uint8_t rfc8448_simple_newsessionticket[] = {
0x04, 0x00, 0x00, 0xc9, 0x00, 0x00, 0x00, 0x1e, 0xfa, 0xd6, 0xaa,
0xc5, 0x02, 0x00, 0x00, 0x00, 0xb2, 0x2c, 0x03, 0x5d, 0x82, 0x93,
0x59, 0xee, 0x5f, 0xf7, 0xaf, 0x4e, 0xc9, 0x00, 0x00, 0x00, 0x00,
0x26, 0x2a, 0x64, 0x94, 0xdc, 0x48, 0x6d, 0x2c, 0x8a, 0x34, 0xcb,
0x33, 0xfa, 0x90, 0xbf, 0x1b, 0x00, 0x70, 0xad, 0x3c, 0x49, 0x88,
0x83, 0xc9, 0x36, 0x7c, 0x09, 0xa2, 0xbe, 0x78, 0x5a, 0xbc, 0x55,
0xcd, 0x22, 0x60, 0x97, 0xa3, 0xa9, 0x82, 0x11, 0x72, 0x83, 0xf8,
0x2a, 0x03, 0xa1, 0x43, 0xef, 0xd3, 0xff, 0x5d, 0xd3, 0x6d, 0x64,
0xe8, 0x61, 0xbe, 0x7f, 0xd6, 0x1d, 0x28, 0x27, 0xdb, 0x27, 0x9c,
0xce, 0x14, 0x50, 0x77, 0xd4, 0x54, 0xa3, 0x66, 0x4d, 0x4e, 0x6d,
0xa4, 0xd2, 0x9e, 0xe0, 0x37, 0x25, 0xa6, 0xa4, 0xda, 0xfc, 0xd0,
0xfc, 0x67, 0xd2, 0xae, 0xa7, 0x05, 0x29, 0x51, 0x3e, 0x3d, 0xa2,
0x67, 0x7f, 0xa5, 0x90, 0x6c, 0x5b, 0x3f, 0x7d, 0x8f, 0x92, 0xf2,
0x28, 0xbd, 0xa4, 0x0d, 0xda, 0x72, 0x14, 0x70, 0xf9, 0xfb, 0xf2,
0x97, 0xb5, 0xae, 0xa6, 0x17, 0x64, 0x6f, 0xac, 0x5c, 0x03, 0x27,
0x2e, 0x97, 0x07, 0x27, 0xc6, 0x21, 0xa7, 0x91, 0x41, 0xef, 0x5f,
0x7d, 0xe6, 0x50, 0x5e, 0x5b, 0xfb, 0xc3, 0x88, 0xe9, 0x33, 0x43,
0x69, 0x40, 0x93, 0x93, 0x4a, 0xe4, 0xd3, 0x57, 0x00, 0x08, 0x00,
0x2a, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00
};
/** RFC 8448 simple 1-RTT test: early secret */
static const uint8_t rfc8448_simple_early_secret[] = {
0x33, 0xad, 0x0a, 0x1c, 0x60, 0x7e, 0xc0, 0x3b, 0x09, 0xe6, 0xcd,
0x98, 0x93, 0x68, 0x0c, 0xe2, 0x10, 0xad, 0xf3, 0x00, 0xaa, 0x1f,
0x26, 0x60, 0xe1, 0xb2, 0x2e, 0x10, 0xf1, 0x70, 0xf9, 0x2a
};
/** RFC 8448 simple 1-RTT test: handshake secret */
static const uint8_t rfc8448_simple_handshake_secret[] = {
0x1d, 0xc8, 0x26, 0xe9, 0x36, 0x06, 0xaa, 0x6f, 0xdc, 0x0a, 0xad,
0xc1, 0x2f, 0x74, 0x1b, 0x01, 0x04, 0x6a, 0xa6, 0xb9, 0x9f, 0x69,
0x1e, 0xd2, 0x21, 0xa9, 0xf0, 0xca, 0x04, 0x3f, 0xbe, 0xac
};
/** RFC 8448 simple 1-RTT test: client handshake traffic secret */
static const uint8_t rfc8448_simple_client_handshake_traffic_secret[] = {
0xb3, 0xed, 0xdb, 0x12, 0x6e, 0x06, 0x7f, 0x35, 0xa7, 0x80, 0xb3,
0xab, 0xf4, 0x5e, 0x2d, 0x8f, 0x3b, 0x1a, 0x95, 0x07, 0x38, 0xf5,
0x2e, 0x96, 0x00, 0x74, 0x6a, 0x0e, 0x27, 0xa5, 0x5a, 0x21
};
/** RFC 8448 simple 1-RTT test: client handshake traffic key */
static const uint8_t rfc8448_simple_client_handshake_traffic_key[] = {
0xdb, 0xfa, 0xa6, 0x93, 0xd1, 0x76, 0x2c, 0x5b, 0x66, 0x6a, 0xf5,
0xd9, 0x50, 0x25, 0x8d, 0x01
};
/** RFC 8448 simple 1-RTT test: client handshake traffic IV */
static const uint8_t rfc8448_simple_client_handshake_traffic_iv[] = {
0x5b, 0xd3, 0xc7, 0x1b, 0x83, 0x6e, 0x0b, 0x76, 0xbb, 0x73, 0x26,
0x5f
};
/** RFC 8448 simple 1-RTT test: server handshake traffic secret */
static const uint8_t rfc8448_simple_server_handshake_traffic_secret[] = {
0xb6, 0x7b, 0x7d, 0x69, 0x0c, 0xc1, 0x6c, 0x4e, 0x75, 0xe5, 0x42,
0x13, 0xcb, 0x2d, 0x37, 0xb4, 0xe9, 0xc9, 0x12, 0xbc, 0xde, 0xd9,
0x10, 0x5d, 0x42, 0xbe, 0xfd, 0x59, 0xd3, 0x91, 0xad, 0x38
};
/** RFC 8448 simple 1-RTT test: server handshake traffic key */
static const uint8_t rfc8448_simple_server_handshake_traffic_key[] = {
0x3f, 0xce, 0x51, 0x60, 0x09, 0xc2, 0x17, 0x27, 0xd0, 0xf2, 0xe4,
0xe8, 0x6e, 0xe4, 0x03, 0xbc
};
/** RFC 8448 simple 1-RTT test: server handshake traffic IV */
static const uint8_t rfc8448_simple_server_handshake_traffic_iv[] = {
0x5d, 0x31, 0x3e, 0xb2, 0x67, 0x12, 0x76, 0xee, 0x13, 0x00, 0x0b,
0x30
};
/** RFC 8448 simple 1-RTT test: client verification */
static const uint8_t rfc8448_simple_client_verify[] = {
0xa8, 0xec, 0x43, 0x6d, 0x67, 0x76, 0x34, 0xae, 0x52, 0x5a, 0xc1,
0xfc, 0xeb, 0xe1, 0x1a, 0x03, 0x9e, 0xc1, 0x76, 0x94, 0xfa, 0xc6,
0xe9, 0x85, 0x27, 0xb6, 0x42, 0xf2, 0xed, 0xd5, 0xce, 0x61
};
/** RFC 8448 simple 1-RTT test: server verification */
static const uint8_t rfc8448_simple_server_verify[] = {
0x9b, 0x9b, 0x14, 0x1d, 0x90, 0x63, 0x37, 0xfb, 0xd2, 0xcb, 0xdc,
0xe7, 0x1d, 0xf4, 0xde, 0xda, 0x4a, 0xb4, 0x2c, 0x30, 0x95, 0x72,
0xcb, 0x7f, 0xff, 0xee, 0x54, 0x54, 0xb7, 0x8f, 0x07, 0x18
};
/** RFC 8448 simple 1-RTT test: master secret */
static const uint8_t rfc8448_simple_master_secret[] = {
0x18, 0xdf, 0x06, 0x84, 0x3d, 0x13, 0xa0, 0x8b, 0xf2, 0xa4, 0x49,
0x84, 0x4c, 0x5f, 0x8a, 0x47, 0x80, 0x01, 0xbc, 0x4d, 0x4c, 0x62,
0x79, 0x84, 0xd5, 0xa4, 0x1d, 0xa8, 0xd0, 0x40, 0x29, 0x19
};
/** RFC 8448 simple 1-RTT test: client application traffic secret */
static const uint8_t rfc8448_simple_client_application_traffic_secret[] = {
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
};
/** RFC 8448 simple 1-RTT test: client application traffic key */
static const uint8_t rfc8448_simple_client_application_traffic_key[] = {
0x17, 0x42, 0x2d, 0xda, 0x59, 0x6e, 0xd5, 0xd9, 0xac, 0xd8, 0x90,
0xe3, 0xc6, 0x3f, 0x50, 0x51
};
/** RFC 8448 simple 1-RTT test: client application traffic IV */
static const uint8_t rfc8448_simple_client_application_traffic_iv[] = {
0x5b, 0x78, 0x92, 0x3d, 0xee, 0x08, 0x57, 0x90, 0x33, 0xe5, 0x23,
0xd9
};
/** RFC 8448 simple 1-RTT test: server application traffic secret */
static const uint8_t rfc8448_simple_server_application_traffic_secret[] = {
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
};
/** RFC 8448 simple 1-RTT test: server application traffic key */
static const uint8_t rfc8448_simple_server_application_traffic_key[] = {
0x9f, 0x02, 0x28, 0x3b, 0x6c, 0x9c, 0x07, 0xef, 0xc2, 0x6b, 0xb9,
0xf2, 0xac, 0x92, 0xe3, 0x56
};
/** RFC 8448 simple 1-RTT test: server application traffic IV */
static const uint8_t rfc8448_simple_server_application_traffic_iv[] = {
0xcf, 0x78, 0x2b, 0x88, 0xdd, 0x83, 0x54, 0x9a, 0xad, 0xf1, 0xe9,
0x84
};
/** RFC 8448 simple 1-RTT test: resumption secret */
static const uint8_t rfc8448_simple_resumption[] = {
0x4e, 0xcd, 0x0e, 0xb6, 0xec, 0x3b, 0x4d, 0x87, 0xf5, 0xd6, 0x02,
0x8f, 0x92, 0x2c, 0xa4, 0xc5, 0x85, 0x1a, 0x27, 0x7f, 0xd4, 0x13,
0x11, 0xc9, 0xe6, 0x2d, 0x2c, 0x94, 0x92, 0xe1, 0xc4, 0xf3
};
/** RFC 8448 simple 1-RTT test: server CertificateVerify signable digest
*
* This value is not provided directly within RFC 8448, but may be
* calculated from the provided values.
*/
static const uint8_t rfc8448_simple_server_tbshash[] = {
0xbe, 0xed, 0x95, 0xaf, 0x40, 0x4e, 0x23, 0xdd, 0x55, 0x3e, 0xbc,
0xfb, 0x4a, 0x00, 0xb8, 0xdb, 0xbf, 0x22, 0x44, 0xdb, 0x2a, 0x9a,
0xa3, 0x9a, 0x37, 0x92, 0x56, 0x51, 0x26, 0x7c, 0x14, 0x1f
};
/** RFC 8448 resumed 0-RTT test: server random bytes */
static const struct tls_random rfc8448_resumed_server_nonce = {
.bytes = {
0x3c, 0xcf, 0xd2, 0xde, 0xc8, 0x90, 0x22, 0x27, 0x63, 0x47,
0x2a, 0xe8, 0x13, 0x67, 0x77, 0xc9, 0xd7, 0x35, 0x87, 0x77,
0xbb, 0x66, 0xe9, 0x1e, 0xa5, 0x12, 0x24, 0x95, 0xf5, 0x59,
0xea, 0x2d
},
};
/** RFC 8448 resumed 0-RTT test: client X25519 private key */
static const uint8_t rfc8448_resumed_x25519_private[] = {
0xbf, 0xf9, 0x11, 0x88, 0x28, 0x38, 0x46, 0xdd, 0x6a, 0x21, 0x34,
0xef, 0x71, 0x80, 0xca, 0x2b, 0x0b, 0x14, 0xfb, 0x10, 0xdc, 0xe7,
0x07, 0xb5, 0x09, 0x8c, 0x0d, 0xdd, 0xc8, 0x13, 0xb2, 0xdf
};
/** RFC 8448 resumed 0-RTT test: server X25519 public key */
static const uint8_t rfc8448_resumed_x25519_partner[] = {
0x12, 0x17, 0x61, 0xee, 0x42, 0xc3, 0x33, 0xe1, 0xb9, 0xe7, 0x7b,
0x60, 0xdd, 0x57, 0xc2, 0x05, 0x3c, 0xd9, 0x45, 0x12, 0xab, 0x47,
0xf1, 0x15, 0xe8, 0x6e, 0xff, 0x50, 0x94, 0x2c, 0xea, 0x31
};
/** RFC 8448 resumed 0-RTT test: ClientHello */
static const uint8_t rfc8448_resumed_clienthello[] = {
0x01, 0x00, 0x01, 0xfc, 0x03, 0x03, 0x1b, 0xc3, 0xce, 0xb6, 0xbb,
0xe3, 0x9c, 0xff, 0x93, 0x83, 0x55, 0xb5, 0xa5, 0x0a, 0xdb, 0x6d,
0xb2, 0x1b, 0x7a, 0x6a, 0xf6, 0x49, 0xd7, 0xb4, 0xbc, 0x41, 0x9d,
0x78, 0x76, 0x48, 0x7d, 0x95, 0x00, 0x00, 0x06, 0x13, 0x01, 0x13,
0x03, 0x13, 0x02, 0x01, 0x00, 0x01, 0xcd, 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, 0x33, 0x00, 0x26,
0x00, 0x24, 0x00, 0x1d, 0x00, 0x20, 0xe4, 0xff, 0xb6, 0x8a, 0xc0,
0x5f, 0x8d, 0x96, 0xc9, 0x9d, 0xa2, 0x66, 0x98, 0x34, 0x6c, 0x6b,
0xe1, 0x64, 0x82, 0xba, 0xdd, 0xda, 0xfe, 0x05, 0x1a, 0x66, 0xb4,
0xf1, 0x8d, 0x66, 0x8f, 0x0b, 0x00, 0x2a, 0x00, 0x00, 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, 0x00, 0x15,
0x00, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x29, 0x00, 0xdd, 0x00, 0xb8, 0x00, 0xb2, 0x2c, 0x03,
0x5d, 0x82, 0x93, 0x59, 0xee, 0x5f, 0xf7, 0xaf, 0x4e, 0xc9, 0x00,
0x00, 0x00, 0x00, 0x26, 0x2a, 0x64, 0x94, 0xdc, 0x48, 0x6d, 0x2c,
0x8a, 0x34, 0xcb, 0x33, 0xfa, 0x90, 0xbf, 0x1b, 0x00, 0x70, 0xad,
0x3c, 0x49, 0x88, 0x83, 0xc9, 0x36, 0x7c, 0x09, 0xa2, 0xbe, 0x78,
0x5a, 0xbc, 0x55, 0xcd, 0x22, 0x60, 0x97, 0xa3, 0xa9, 0x82, 0x11,
0x72, 0x83, 0xf8, 0x2a, 0x03, 0xa1, 0x43, 0xef, 0xd3, 0xff, 0x5d,
0xd3, 0x6d, 0x64, 0xe8, 0x61, 0xbe, 0x7f, 0xd6, 0x1d, 0x28, 0x27,
0xdb, 0x27, 0x9c, 0xce, 0x14, 0x50, 0x77, 0xd4, 0x54, 0xa3, 0x66,
0x4d, 0x4e, 0x6d, 0xa4, 0xd2, 0x9e, 0xe0, 0x37, 0x25, 0xa6, 0xa4,
0xda, 0xfc, 0xd0, 0xfc, 0x67, 0xd2, 0xae, 0xa7, 0x05, 0x29, 0x51,
0x3e, 0x3d, 0xa2, 0x67, 0x7f, 0xa5, 0x90, 0x6c, 0x5b, 0x3f, 0x7d,
0x8f, 0x92, 0xf2, 0x28, 0xbd, 0xa4, 0x0d, 0xda, 0x72, 0x14, 0x70,
0xf9, 0xfb, 0xf2, 0x97, 0xb5, 0xae, 0xa6, 0x17, 0x64, 0x6f, 0xac,
0x5c, 0x03, 0x27, 0x2e, 0x97, 0x07, 0x27, 0xc6, 0x21, 0xa7, 0x91,
0x41, 0xef, 0x5f, 0x7d, 0xe6, 0x50, 0x5e, 0x5b, 0xfb, 0xc3, 0x88,
0xe9, 0x33, 0x43, 0x69, 0x40, 0x93, 0x93, 0x4a, 0xe4, 0xd3, 0x57,
0xfa, 0xd6, 0xaa, 0xcb, 0x00, 0x21, 0x20, 0x3a, 0xdd, 0x4f, 0xb2,
0xd8, 0xfd, 0xf8, 0x22, 0xa0, 0xca, 0x3c, 0xf7, 0x67, 0x8e, 0xf5,
0xe8, 0x8d, 0xae, 0x99, 0x01, 0x41, 0xc5, 0x92, 0x4d, 0x57, 0xbb,
0x6f, 0xa3, 0x1b, 0x9e, 0x5f, 0x9d
};
/** RFC 8448 resumed 0-RTT test: ServerHello */
static const uint8_t rfc8448_resumed_serverhello[] = {
0x02, 0x00, 0x00, 0x5c, 0x03, 0x03, 0x3c, 0xcf, 0xd2, 0xde, 0xc8,
0x90, 0x22, 0x27, 0x63, 0x47, 0x2a, 0xe8, 0x13, 0x67, 0x77, 0xc9,
0xd7, 0x35, 0x87, 0x77, 0xbb, 0x66, 0xe9, 0x1e, 0xa5, 0x12, 0x24,
0x95, 0xf5, 0x59, 0xea, 0x2d, 0x00, 0x13, 0x01, 0x00, 0x00, 0x34,
0x00, 0x29, 0x00, 0x02, 0x00, 0x00, 0x00, 0x33, 0x00, 0x24, 0x00,
0x1d, 0x00, 0x20, 0x12, 0x17, 0x61, 0xee, 0x42, 0xc3, 0x33, 0xe1,
0xb9, 0xe7, 0x7b, 0x60, 0xdd, 0x57, 0xc2, 0x05, 0x3c, 0xd9, 0x45,
0x12, 0xab, 0x47, 0xf1, 0x15, 0xe8, 0x6e, 0xff, 0x50, 0x94, 0x2c,
0xea, 0x31, 0x00, 0x2b, 0x00, 0x02, 0x03, 0x04
};
/** RFC 8448 resumed 0-RTT test: ClientHello prefix length */
static const size_t rfc8448_resumed_clienthello_prefix_len =
( sizeof ( rfc8448_resumed_clienthello ) - 35 );
/** RFC 8448 resumed 0-RTT test: EncryptedExtensions */
static const uint8_t rfc8448_resumed_encryptedextensions[] = {
0x08, 0x00, 0x00, 0x28, 0x00, 0x26, 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, 0x1c, 0x00,
0x02, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00
};
/** RFC 8448 resumed 0-RTT test: server Finished */
static const uint8_t rfc8448_resumed_server_finished[] = {
0x14, 0x00, 0x00, 0x20, 0x48, 0xd3, 0xe0, 0xe1, 0xb3, 0xd9, 0x07,
0xc6, 0xac, 0xff, 0x14, 0x5e, 0x16, 0x09, 0x03, 0x88, 0xc7, 0x7b,
0x05, 0xc0, 0x50, 0xb6, 0x34, 0xab, 0x1a, 0x88, 0xbb, 0xd0, 0xdd,
0x1a, 0x34, 0xb2
};
/** RFC 8448 resumed 0-RTT test: EndOfEarlyData */
static const uint8_t rfc8448_resumed_endofearlydata[] = {
0x05, 0x00, 0x00, 0x00
};
/** RFC 8448 resumed 0-RTT test: client Finished */
static const uint8_t rfc8448_resumed_client_finished[] = {
0x14, 0x00, 0x00, 0x20, 0x72, 0x30, 0xa9, 0xc9, 0x52, 0xc2, 0x5c,
0xd6, 0x13, 0x8f, 0xc5, 0xe6, 0x62, 0x83, 0x08, 0xc4, 0x1c, 0x53,
0x35, 0xdd, 0x81, 0xb9, 0xf9, 0x6b, 0xce, 0xa5, 0x0f, 0xd3, 0x2b,
0xda, 0x41, 0x6d
};
/** RFC 8448 resumed 0-RTT test: PSK binder */
static const uint8_t rfc8448_resumed_psk_binder[] = {
0x3a, 0xdd, 0x4f, 0xb2, 0xd8, 0xfd, 0xf8, 0x22, 0xa0, 0xca, 0x3c,
0xf7, 0x67, 0x8e, 0xf5, 0xe8, 0x8d, 0xae, 0x99, 0x01, 0x41, 0xc5,
0x92, 0x4d, 0x57, 0xbb, 0x6f, 0xa3, 0x1b, 0x9e, 0x5f, 0x9d
};
/** RFC 8448 resumed 0-RTT test: early secret */
static const uint8_t rfc8448_resumed_early_secret[] = {
0x9b, 0x21, 0x88, 0xe9, 0xb2, 0xfc, 0x6d, 0x64, 0xd7, 0x1d, 0xc3,
0x29, 0x90, 0x0e, 0x20, 0xbb, 0x41, 0x91, 0x50, 0x00, 0xf6, 0x78,
0xaa, 0x83, 0x9c, 0xbb, 0x79, 0x7c, 0xb7, 0xd8, 0x33, 0x2c
};
/** RFC 8448 resumed 0-RTT test: client early traffic secret */
static const uint8_t rfc8448_resumed_client_early_traffic_secret[] = {
0x3f, 0xbb, 0xe6, 0xa6, 0x0d, 0xeb, 0x66, 0xc3, 0x0a, 0x32, 0x79,
0x5a, 0xba, 0x0e, 0xff, 0x7e, 0xaa, 0x10, 0x10, 0x55, 0x86, 0xe7,
0xbe, 0x5c, 0x09, 0x67, 0x8d, 0x63, 0xb6, 0xca, 0xab, 0x62
};
/** RFC 8448 resumed 0-RTT test: client early traffic key */
static const uint8_t rfc8448_resumed_client_early_traffic_key[] = {
0x92, 0x02, 0x05, 0xa5, 0xb7, 0xbf, 0x21, 0x15, 0xe6, 0xfc, 0x5c,
0x29, 0x42, 0x83, 0x4f, 0x54
};
/** RFC 8448 resumed 0-RTT test: client early traffic IV */
static const uint8_t rfc8448_resumed_client_early_traffic_iv[] = {
0x6d, 0x47, 0x5f, 0x09, 0x93, 0xc8, 0xe5, 0x64, 0x61, 0x0d, 0xb2,
0xb9
};
/** RFC 8448 resumed 0-RTT test: handshake secret */
static const uint8_t rfc8448_resumed_handshake_secret[] = {
0x00, 0x5c, 0xb1, 0x12, 0xfd, 0x8e, 0xb4, 0xcc, 0xc6, 0x23, 0xbb,
0x88, 0xa0, 0x7c, 0x64, 0xb3, 0xed, 0xe1, 0x60, 0x53, 0x63, 0xfc,
0x7d, 0x0d, 0xf8, 0xc7, 0xce, 0x4f, 0xf0, 0xfb, 0x4a, 0xe6
};
/** RFC 8448 resumed 0-RTT test: client handshake traffic secret */
static const uint8_t rfc8448_resumed_client_handshake_traffic_secret[] = {
0x2f, 0xaa, 0xc0, 0x8f, 0x85, 0x1d, 0x35, 0xfe, 0xa3, 0x60, 0x4f,
0xcb, 0x4d, 0xe8, 0x2d, 0xc6, 0x2c, 0x9b, 0x16, 0x4a, 0x70, 0x97,
0x4d, 0x04, 0x62, 0xe2, 0x7f, 0x1a, 0xb2, 0x78, 0x70, 0x0f
};
/** RFC 8448 resumed 0-RTT test: client handshake traffic key */
static const uint8_t rfc8448_resumed_client_handshake_traffic_key[] = {
0xb1, 0x53, 0x08, 0x06, 0xf4, 0xad, 0xfe, 0xac, 0x83, 0xf1, 0x41,
0x30, 0x32, 0xbb, 0xfa, 0x82
};
/** RFC 8448 resumed 0-RTT test: client handshake traffic IV */
static const uint8_t rfc8448_resumed_client_handshake_traffic_iv[] = {
0xeb, 0x50, 0xc1, 0x6b, 0xe7, 0x65, 0x4a, 0xbf, 0x99, 0xdd, 0x06,
0xd9
};
/** RFC 8448 resumed 0-RTT test: server handshake traffic secret */
static const uint8_t rfc8448_resumed_server_handshake_traffic_secret[] = {
0xfe, 0x92, 0x7a, 0xe2, 0x71, 0x31, 0x2e, 0x8b, 0xf0, 0x27, 0x5b,
0x58, 0x1c, 0x54, 0xee, 0xf0, 0x20, 0x45, 0x0d, 0xc4, 0xec, 0xff,
0xaa, 0x05, 0xa1, 0xa3, 0x5d, 0x27, 0x51, 0x8e, 0x78, 0x03
};
/** RFC 8448 resumed 0-RTT test: server handshake traffic key */
static const uint8_t rfc8448_resumed_server_handshake_traffic_key[] = {
0x27, 0xc6, 0xbd, 0xc0, 0xa3, 0xdc, 0xea, 0x39, 0xa4, 0x73, 0x26,
0xd7, 0x9b, 0xc9, 0xe4, 0xee
};
/** RFC 8448 resumed 0-RTT test: server handshake traffic IV */
static const uint8_t rfc8448_resumed_server_handshake_traffic_iv[] = {
0x95, 0x69, 0xec, 0xdd, 0x4d, 0x05, 0x36, 0x70, 0x5e, 0x9e, 0xf7,
0x25
};
/** RFC 8448 resumed 0-RTT test: client verification */
static const uint8_t rfc8448_resumed_client_verify[] = {
0x72, 0x30, 0xa9, 0xc9, 0x52, 0xc2, 0x5c, 0xd6, 0x13, 0x8f, 0xc5,
0xe6, 0x62, 0x83, 0x08, 0xc4, 0x1c, 0x53, 0x35, 0xdd, 0x81, 0xb9,
0xf9, 0x6b, 0xce, 0xa5, 0x0f, 0xd3, 0x2b, 0xda, 0x41, 0x6d
};
/** RFC 8448 resumed 0-RTT test: server verification */
static const uint8_t rfc8448_resumed_server_verify[] = {
0x48, 0xd3, 0xe0, 0xe1, 0xb3, 0xd9, 0x07, 0xc6, 0xac, 0xff, 0x14,
0x5e, 0x16, 0x09, 0x03, 0x88, 0xc7, 0x7b, 0x05, 0xc0, 0x50, 0xb6,
0x34, 0xab, 0x1a, 0x88, 0xbb, 0xd0, 0xdd, 0x1a, 0x34, 0xb2
};
/** RFC 8448 resumed 0-RTT test: master secret */
static const uint8_t rfc8448_resumed_master_secret[] = {
0xe2, 0xd3, 0x2d, 0x4e, 0xd6, 0x6d, 0xd3, 0x78, 0x97, 0xa0, 0xe8,
0x0c, 0x84, 0x10, 0x75, 0x03, 0xce, 0x58, 0xbf, 0x8a, 0xad, 0x4c,
0xb5, 0x5a, 0x50, 0x02, 0xd7, 0x7e, 0xcb, 0x89, 0x0e, 0xce
};
/** RFC 8448 resumed 0-RTT test: client application traffic secret */
static const uint8_t rfc8448_resumed_client_application_traffic_secret[] = {
0x2a, 0xbb, 0xf2, 0xb8, 0xe3, 0x81, 0xd2, 0x3d, 0xbe, 0xbe, 0x1d,
0xd2, 0xa7, 0xd1, 0x6a, 0x8b, 0xf4, 0x84, 0xcb, 0x49, 0x50, 0xd2,
0x3f, 0xb7, 0xfb, 0x7f, 0xa8, 0x54, 0x70, 0x62, 0xd9, 0xa1
};
/** RFC 8448 resumed 0-RTT test: client application traffic key */
static const uint8_t rfc8448_resumed_client_application_traffic_key[] = {
0x3c, 0xf1, 0x22, 0xf3, 0x01, 0xc6, 0x35, 0x8c, 0xa7, 0x98, 0x95,
0x53, 0x25, 0x0e, 0xfd, 0x72
};
/** RFC 8448 resumed 0-RTT test: client application traffic IV */
static const uint8_t rfc8448_resumed_client_application_traffic_iv[] = {
0xab, 0x1a, 0xec, 0x26, 0xaa, 0x78, 0xb8, 0xfc, 0x11, 0x76, 0xb9,
0xac
};
/** RFC 8448 resumed 0-RTT test: server application traffic secret */
static const uint8_t rfc8448_resumed_server_application_traffic_secret[] = {
0xcc, 0x21, 0xf1, 0xbf, 0x8f, 0xeb, 0x7d, 0xd5, 0xfa, 0x50, 0x5b,
0xd9, 0xc4, 0xb4, 0x68, 0xa9, 0x98, 0x4d, 0x55, 0x4a, 0x99, 0x3d,
0xc4, 0x9e, 0x6d, 0x28, 0x55, 0x98, 0xfb, 0x67, 0x26, 0x91
};
/** RFC 8448 resumed 0-RTT test: server application traffic key */
static const uint8_t rfc8448_resumed_server_application_traffic_key[] = {
0xe8, 0x57, 0xc6, 0x90, 0xa3, 0x4c, 0x5a, 0x91, 0x29, 0xd8, 0x33,
0x61, 0x96, 0x84, 0xf9, 0x5e
};
/** RFC 8448 resumed 0-RTT test: server application traffic IV */
static const uint8_t rfc8448_resumed_server_application_traffic_iv[] = {
0x06, 0x85, 0xd6, 0xb5, 0x61, 0xaa, 0xb9, 0xef, 0x10, 0x13, 0xfa,
0xf9
};
/** Dummy minimal tests: client random bytes */
static const struct tls_random dummy_client_nonce = {
.bytes = {
0x86, 0x75, 0xa3, 0x00, 0x0c, 0x3d, 0x73, 0x79, 0xa3, 0x78,
0x04, 0xfc, 0x5d, 0x7f, 0x99, 0xef, 0xf1, 0x9e, 0xda, 0x74,
0x80, 0x3c, 0x60, 0x83, 0xac, 0xbe, 0x15, 0xae, 0x11, 0x3f,
0xbe, 0xba
},
};
/** Dummy minimal tests: ClientHello */
static const uint8_t dummy_clienthello[] = {
0x01, 0x00, 0x00, 0x22, 0x03, 0x02, 0x86, 0x75, 0xa3, 0x00, 0x0c,
0x3d, 0x73, 0x79, 0xa3, 0x78, 0x04, 0xfc, 0x5d, 0x7f, 0x99, 0xef,
0xf1, 0x9e, 0xda, 0x74, 0x80, 0x3c, 0x60, 0x83, 0xac, 0xbe, 0x15,
0xae, 0x11, 0x3f, 0xbe, 0xba
};
/** Dummy minimal tests: ServerHello */
static const uint8_t dummy_serverhello[] = {
0x02, 0x00, 0x00, 0x22, 0x03, 0x02, 0xa3, 0xdd, 0xe4, 0x56, 0xda,
0xc8, 0x65, 0xd8, 0x2c, 0xc3, 0xb0, 0x47, 0x49, 0x2f, 0xdb, 0xfd,
0xc3, 0xaf, 0x6b, 0x60, 0x98, 0xe1, 0x99, 0xb3, 0xd4, 0x9b, 0x55,
0x15, 0x43, 0x8d, 0xec, 0x3e
};
/** Dummy minimal tests: pre-master secret */
static const uint8_t dummy_premaster[] = {
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64,
0x21, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61,
0x20, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x20, 0x70, 0x72, 0x65, 0x2d,
0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x20, 0x73, 0x65, 0x63, 0x72,
0x65, 0x74, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x65, 0x6e, 0x6f,
0x75, 0x67, 0x68, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x65, 0x71, 0x75,
0x69, 0x72, 0x65, 0x20, 0x48, 0x4d, 0x41, 0x43, 0x20, 0x6b, 0x65,
0x79, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69,
0x6f, 0x6e, 0x2e
};
/** Dummy minimal tests: ServerKeyExchange DH parameters */
static const uint8_t dummy_dh_param[] = {
0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c
};
/** Dummy minimal TLSv1.2 test: master secret */
static const uint8_t dummy_hash_master_secret[] = {
0x6f, 0x57, 0xe7, 0xab, 0xd9, 0x0c, 0xcc, 0x99, 0xe0, 0x18, 0xa6,
0x2b, 0x7c, 0x7d, 0x04, 0x84, 0x18, 0x37, 0xee, 0x9e, 0xad, 0x47,
0x54, 0x6e, 0xd4, 0xd0, 0x84, 0x99, 0x91, 0x5d, 0x8f, 0xee, 0xfa,
0xec, 0x08, 0x21, 0x35, 0x2d, 0x1e, 0xe3, 0x4b, 0xe5, 0xbf, 0x81,
0xc2, 0x23, 0x47, 0x10
};
/** Dummy minimal TLSv1.2 test: client verification */
static const uint8_t dummy_hash_client_verify[] = {
0xd6, 0x5d, 0xbb, 0xff, 0x72, 0xc5, 0x51, 0xa5, 0xa9, 0x53, 0x85,
0xab
};
/** Dummy minimal TLSv1.2 test: server verification */
static const uint8_t dummy_hash_server_verify[] = {
0x6c, 0xe4, 0x95, 0x70, 0xc3, 0x8d, 0x2a, 0xcd, 0x2d, 0x8b, 0x0b,
0x33
};
/** Dummy minimal TLSv1.2 test: client traffic key */
static const uint8_t dummy_hash_client_traffic_key[] = {
0xda, 0x2a, 0x4b, 0xbd, 0x5b, 0x0a, 0xa5, 0xd3, 0x30, 0x54, 0x9a,
0xcc, 0x99, 0x28, 0x93, 0xfa
};
/** Dummy minimal TLSv1.2 test: client traffic IV */
static const uint8_t dummy_hash_client_traffic_iv[] = {
0xcd, 0xa5, 0x5a, 0x1d
};
/** Dummy minimal TLSv1.2 test: client traffic MAC */
static const uint8_t dummy_hash_client_traffic_mac[] = {
0xe8, 0x4e, 0x9b, 0x7a, 0xb9, 0x97, 0x7d, 0x47, 0xfb, 0x4a, 0xe8,
0x1e, 0xb6, 0x6e, 0xfc, 0x2b, 0x94, 0x8a, 0xd4, 0x75, 0xde, 0xd9,
0xb9, 0x73, 0x23, 0x16, 0x06, 0x2f, 0x96, 0xb0, 0xb6, 0xcb
};
/** Dummy minimal TLSv1.2 test: server traffic key */
static const uint8_t dummy_hash_server_traffic_key[] = {
0x0b, 0x58, 0x8a, 0xbc, 0x5a, 0x6a, 0x44, 0x33, 0xdc, 0x60, 0xd4,
0xd1, 0xf1, 0x9b, 0xba, 0xd7
};
/** Dummy minimal TLSv1.2 test: server traffic IV */
static const uint8_t dummy_hash_server_traffic_iv[] = {
0xa2, 0x35, 0xf7, 0x40
};
/** Dummy minimal TLSv1.2 test: server traffic MAC */
static const uint8_t dummy_hash_server_traffic_mac[] = {
0x16, 0x7c, 0x12, 0x5d, 0x85, 0x84, 0xfd, 0x5e, 0xf1, 0x3d, 0x0f,
0x5a, 0xbf, 0xf6, 0x44, 0x22, 0x93, 0xf8, 0xea, 0x17, 0x3c, 0x0b,
0x4e, 0xdf, 0x82, 0x5e, 0x26, 0xd0, 0xcb, 0xe5, 0xac, 0xa4
};
/** Dummy minimal TLSv1.2 test: client signable digest */
static const uint8_t dummy_hash_client_tbshash[] = {
0x14, 0x3b, 0xc1, 0x0c, 0x25, 0xf3, 0x6a, 0x4d, 0x4a, 0x7a, 0xd9,
0xb2, 0xee, 0x7e, 0x48, 0xc8, 0xf4, 0x71, 0x53, 0xb0, 0x69, 0x29,
0xe5, 0x2c, 0x0d, 0xeb, 0xa3, 0xf9, 0xe1, 0xcd, 0x02, 0x3d
};
/** Dummy minimal TLSv1.2 test: server signable digest */
static const uint8_t dummy_hash_server_tbshash[] = {
0xd4, 0x11, 0x45, 0x52, 0xa6, 0xf0, 0xe5, 0xe0, 0x5e, 0x20, 0x99,
0x77, 0x5e, 0x0c, 0xbe, 0xce, 0x3e, 0xd9, 0x81, 0xf7, 0x73, 0x49,
0xc1, 0xab, 0xf2, 0xd3, 0x1e, 0xf7, 0xf3, 0x72, 0xc4, 0x15
};
/** Dummy minimal TLSv1.0 test: master secret (MD5 portion) */
static const uint8_t dummy_md5_sha1_master_secret_md5[] = {
0xed, 0x60, 0x7e, 0x6b, 0xce, 0xcb, 0x2c, 0xaf, 0x04, 0x19, 0xeb,
0xee, 0xbd, 0x35, 0xfa, 0x85, 0xc2, 0xcf, 0x5b, 0x5d, 0xea, 0x62,
0xae, 0xe2,
};
/** Dummy minimal TLSv1.0 test: master secret (SHA-1 portion) */
static const uint8_t dummy_md5_sha1_master_secret_sha1[] = {
0xa2, 0x81, 0x2c, 0x2f, 0xbd, 0x69, 0x59, 0x19, 0xb8, 0xe5, 0x41,
0xfc, 0xb0, 0x63, 0x21, 0xbd, 0xd6, 0xca, 0x15, 0xab, 0xb1, 0x18,
0xea, 0x14
};
/** Dummy minimal TLSv1.0 test: client verification */
static const uint8_t dummy_md5_sha1_client_verify[] = {
0xc3, 0x50, 0x18, 0xee, 0x24, 0x70, 0x27, 0x6a, 0x98, 0xe0, 0xd0,
0x73
};
/** Dummy minimal TLSv1.0 test: server verification */
static const uint8_t dummy_md5_sha1_server_verify[] = {
0xcb, 0xa0, 0xc8, 0x13, 0x10, 0xc4, 0xba, 0xe1, 0x4c, 0xe3, 0x99,
0xeb
};
/** Dummy minimal TLSv1.0 test: client traffic key */
static const uint8_t dummy_md5_sha1_client_traffic_key[] = {
0x0e, 0xa5, 0x90, 0xb8, 0x12, 0xa2, 0xf0, 0xe1, 0xaa, 0x0a, 0xba,
0x85, 0x8d, 0x73, 0xcd, 0x99
};
/** Dummy minimal TLSv1.0 test: client traffic IV */
static const uint8_t dummy_md5_sha1_client_traffic_iv[] = {
0xac, 0x25, 0xe7, 0x78
};
/** Dummy minimal TLSv1.0 test: client traffic MAC */
static const uint8_t dummy_md5_sha1_client_traffic_mac[] = {
0x84, 0xe9, 0x05, 0xb6, 0xb0, 0x21, 0x71, 0x10, 0x93, 0xdd, 0xc7,
0x0b, 0xb8, 0x03, 0x3e, 0x14, 0x25, 0x69, 0xfe, 0xd6, 0xb3, 0x90,
0xf0, 0x0b, 0xa0, 0x9a, 0xff, 0x9b, 0x02, 0xc4, 0x3a, 0x49
};
/** Dummy minimal TLSv1.0 test: server traffic key */
static const uint8_t dummy_md5_sha1_server_traffic_key[] = {
0x7a, 0xea, 0x6d, 0xb8, 0x9d, 0xa8, 0xc5, 0x64, 0x7c, 0xd7, 0x0d,
0xc4, 0x1a, 0xfa, 0x92, 0x26
};
/** Dummy minimal TLSv1.0 test: server traffic IV */
static const uint8_t dummy_md5_sha1_server_traffic_iv[] = {
0xa0, 0xa9, 0x81, 0x33
};
/** Dummy minimal TLSv1.0 test: server traffic MAC */
static const uint8_t dummy_md5_sha1_server_traffic_mac[] = {
0x39, 0x7b, 0x90, 0xd7, 0xc8, 0xe3, 0x11, 0x4b, 0x39, 0x47, 0x56,
0x6a, 0xe5, 0xb8, 0x40, 0x4e, 0x58, 0xad, 0x8a, 0x1a, 0xbf, 0x9a,
0x91, 0x40, 0x44, 0x7d, 0xa3, 0xd0, 0x0b, 0x42, 0xa8, 0x09
};
/**
* Perform RFC 8448 simple 1-RTT test
*
* @v tlskey Key schedule
* @v psk Pre-shared key from which to resume
*/
static void rfc8448_simple_test ( struct tls_key_schedule *tlskey,
struct tls_preshared_key *psk ) {
struct exchange_algorithm *exchange = &x25519_algorithm;
struct digest_algorithm *digest = &sha256_algorithm;
size_t sharedsize = exchange->sharedsize;
size_t digestsize = digest->digestsize;
uint8_t shared[sharedsize];
uint8_t tbshash[digestsize];
uint8_t verify[digestsize];
uint8_t key[16];
uint8_t iv[12];
/* Start key schedule */
ok ( tlskey_start ( tlskey, &tlskey_hkdf, digest,
&rfc8448_simple_client_nonce ) == 0 );
/* Early secret */
ok ( memcmp ( rfc8448_simple_early_secret,
tlskey->kdf.secret, digestsize ) == 0 );
/* ClientHello */
tlskey_digest ( tlskey, rfc8448_simple_clienthello,
sizeof ( rfc8448_simple_clienthello ) );
/* ServerHello */
tlskey_digest ( tlskey, rfc8448_simple_serverhello,
sizeof ( rfc8448_simple_serverhello ) );
ok ( exchange_agree ( exchange, rfc8448_simple_x25519_private,
rfc8448_simple_x25519_partner, shared ) == 0 );
ok ( tlskey_apply ( tlskey, shared, sizeof ( shared ) ) == 0 );
/* Handshake secret */
ok ( memcmp ( rfc8448_simple_handshake_secret,
tlskey->kdf.secret, digestsize ) == 0 );
/* Client handshake traffic secret */
ok ( tlskey_traffic ( tlskey, &tls_client, &tls_handshake ) == 0 );
ok ( memcmp ( rfc8448_simple_client_handshake_traffic_secret,
tlskey->traffic[TLS_CLIENT].secret, digestsize ) == 0 );
/* Server handshake traffic secret */
ok ( tlskey_traffic ( tlskey, &tls_server, &tls_handshake ) == 0 );
ok ( memcmp ( rfc8448_simple_server_handshake_traffic_secret,
tlskey->traffic[TLS_SERVER].secret, digestsize ) == 0 );
/* Master secret */
ok ( tlskey_master ( tlskey, 1 ) == 0 );
ok ( memcmp ( rfc8448_simple_master_secret,
tlskey->kdf.secret, digestsize ) == 0 );
/* Server handshake traffic keys */
ok ( tlskey_cipher ( tlskey, &tls_server, key, sizeof ( key ),
iv, sizeof ( iv ), NULL, 0 ) == 0 );
ok ( memcmp ( rfc8448_simple_server_handshake_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( rfc8448_simple_server_handshake_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
/* EncryptedExtensions */
tlskey_digest ( tlskey, rfc8448_simple_encryptedextensions,
sizeof ( rfc8448_simple_encryptedextensions ) );
/* Certificate */
tlskey_digest ( tlskey, rfc8448_simple_certificate,
sizeof ( rfc8448_simple_certificate ) );
/* CertificateVerify signable digest */
ok ( tlskey_tbshash ( tlskey, &tls_server, digest, NULL, 0,
tbshash ) == 0 );
ok ( memcmp ( rfc8448_simple_server_tbshash,
tbshash, sizeof ( tbshash ) ) == 0 );
/* CertificateVerify */
tlskey_digest ( tlskey, rfc8448_simple_certificateverify,
sizeof ( rfc8448_simple_certificateverify ) );
/* Server verification */
ok ( tlskey_verify ( tlskey, &tls_server, verify,
sizeof ( verify ) ) == 0 );
ok ( memcmp ( rfc8448_simple_server_verify,
verify, sizeof ( verify ) ) == 0 );
/* Server Finished */
tlskey_digest ( tlskey, rfc8448_simple_server_finished,
sizeof ( rfc8448_simple_server_finished ) );
/* Server application traffic secret */
ok ( tlskey_traffic ( tlskey, &tls_server, &tls_application ) == 0 );
ok ( memcmp ( rfc8448_simple_server_application_traffic_secret,
tlskey->traffic[TLS_SERVER].secret, digestsize ) == 0 );
/* Server application traffic keys */
ok ( tlskey_cipher ( tlskey, &tls_server, key, sizeof ( key ),
iv, sizeof ( iv ), NULL, 0 ) == 0 );
ok ( memcmp ( rfc8448_simple_server_application_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( rfc8448_simple_server_application_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
/* Client handshake traffic keys */
ok ( tlskey_cipher ( tlskey, &tls_client, key, sizeof ( key ),
iv, sizeof ( iv ), NULL, 0 ) == 0 );
ok ( memcmp ( rfc8448_simple_client_handshake_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( rfc8448_simple_client_handshake_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
/* Client verification */
ok ( tlskey_verify ( tlskey, &tls_client, verify,
sizeof ( verify ) ) == 0 );
ok ( memcmp ( rfc8448_simple_client_verify,
verify, sizeof ( verify ) ) == 0 );
/* Client application traffic secret */
ok ( tlskey_traffic ( tlskey, &tls_client, &tls_application ) == 0 );
ok ( memcmp ( rfc8448_simple_client_application_traffic_secret,
tlskey->traffic[TLS_CLIENT].secret, digestsize ) == 0 );
/* Client Finished */
tlskey_digest ( tlskey, rfc8448_simple_client_finished,
sizeof ( rfc8448_simple_client_finished ) );
/* Client application traffic keys */
ok ( tlskey_cipher ( tlskey, &tls_client, key, sizeof ( key ),
iv, sizeof ( iv ), NULL, 0 ) == 0 );
ok ( memcmp ( rfc8448_simple_client_application_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( rfc8448_simple_client_application_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
/* NewSessionTicket */
tlskey_digest ( tlskey, rfc8448_simple_newsessionticket,
sizeof ( rfc8448_simple_newsessionticket ) );
/* Resumption secret */
ok ( tlskey_save ( tlskey, rfc8448_simple_ticket_nonce,
sizeof ( rfc8448_simple_ticket_nonce ),
psk ) == 0 );
ok ( memcmp ( rfc8448_simple_resumption,
psk->key.resumption, digestsize ) == 0 );
/* Stop key schedule */
tlskey_stop ( tlskey );
}
/**
* Perform RFC 8448 resumed 0-RTT test
*
* @v tlskey Key schedule
* @v psk Pre-shared key from which to resume
*/
static void rfc8448_resumed_test ( struct tls_key_schedule *tlskey,
struct tls_preshared_key *psk ) {
struct exchange_algorithm *exchange = &x25519_algorithm;
struct digest_algorithm *digest = &sha256_algorithm;
size_t sharedsize = exchange->sharedsize;
size_t digestsize = digest->digestsize;
uint8_t shared[sharedsize];
uint8_t binder[digestsize];
uint8_t verify[digestsize];
uint8_t key[16];
int8_t iv[12];
/* Start key schedule */
ok ( tlskey_start ( tlskey, &tlskey_hkdf, digest,
&rfc8448_resumed_server_nonce ) == 0 );
/* ClientHello */
ok ( tlskey_bind ( psk, rfc8448_resumed_clienthello,
rfc8448_resumed_clienthello_prefix_len,
binder, sizeof ( binder ) ) == 0 );
ok ( memcmp ( rfc8448_resumed_psk_binder,
binder, sizeof ( binder ) ) == 0 );
tlskey_digest ( tlskey, rfc8448_resumed_clienthello,
sizeof ( rfc8448_resumed_clienthello ) );
/* Early secret */
ok ( tlskey_load ( tlskey, 1, psk ) == 0 );
ok ( memcmp ( rfc8448_resumed_early_secret,
tlskey->kdf.secret, digestsize ) == 0 );
/* Client early traffic secret */
ok ( tlskey_traffic ( tlskey, &tls_client, &tls_early ) == 0 );
ok ( memcmp ( rfc8448_resumed_client_early_traffic_secret,
tlskey->traffic[TLS_CLIENT].secret, digestsize ) == 0 );
/* Client early traffic keys */
ok ( tlskey_cipher ( tlskey, &tls_client, key, sizeof ( key ),
iv, sizeof ( iv ), NULL, 0 ) == 0 );
ok ( memcmp ( rfc8448_resumed_client_early_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( rfc8448_resumed_client_early_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
/* ServerHello */
tlskey_digest ( tlskey, rfc8448_resumed_serverhello,
sizeof ( rfc8448_resumed_serverhello ) );
ok ( exchange_agree ( exchange, rfc8448_resumed_x25519_private,
rfc8448_resumed_x25519_partner, shared ) == 0 );
ok ( tlskey_apply ( tlskey, shared, sizeof ( shared ) ) == 0 );
/* Handshake secret */
ok ( memcmp ( rfc8448_resumed_handshake_secret,
tlskey->kdf.secret, digestsize ) == 0 );
/* Client handshake traffic secret */
ok ( tlskey_traffic ( tlskey, &tls_client, &tls_handshake ) == 0 );
ok ( memcmp ( rfc8448_resumed_client_handshake_traffic_secret,
tlskey->traffic[TLS_CLIENT].secret, digestsize ) == 0 );
/* Server handshake traffic secret */
ok ( tlskey_traffic ( tlskey, &tls_server, &tls_handshake ) == 0 );
ok ( memcmp ( rfc8448_resumed_server_handshake_traffic_secret,
tlskey->traffic[TLS_SERVER].secret, digestsize ) == 0 );
/* Master secret */
ok ( tlskey_master ( tlskey, 1 ) == 0 );
ok ( memcmp ( rfc8448_resumed_master_secret,
tlskey->kdf.secret, digestsize ) == 0 );
/* Server handshake traffic keys */
ok ( tlskey_cipher ( tlskey, &tls_server, key, sizeof ( key ),
iv, sizeof ( iv ), NULL, 0 ) == 0 );
ok ( memcmp ( rfc8448_resumed_server_handshake_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( rfc8448_resumed_server_handshake_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
/* EncryptedExtensions */
tlskey_digest ( tlskey, rfc8448_resumed_encryptedextensions,
sizeof ( rfc8448_resumed_encryptedextensions ) );
/* Server verification */
ok ( tlskey_verify ( tlskey, &tls_server, verify,
sizeof ( verify ) ) == 0 );
ok ( memcmp ( rfc8448_resumed_server_verify,
verify, sizeof ( verify ) ) == 0 );
/* Server Finished */
tlskey_digest ( tlskey, rfc8448_resumed_server_finished,
sizeof ( rfc8448_resumed_server_finished ) );
/* Server application traffic secret */
ok ( tlskey_traffic ( tlskey, &tls_server, &tls_application ) == 0 );
ok ( memcmp ( rfc8448_resumed_server_application_traffic_secret,
tlskey->traffic[TLS_SERVER].secret, digestsize ) == 0 );
/* Server application traffic keys */
ok ( tlskey_cipher ( tlskey, &tls_server, key, sizeof ( key ),
iv, sizeof ( iv ), NULL, 0 ) == 0 );
ok ( memcmp ( rfc8448_resumed_server_application_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( rfc8448_resumed_server_application_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
/* Client handshake traffic keys */
ok ( tlskey_cipher ( tlskey, &tls_client, key, sizeof ( key ),
iv, sizeof ( iv ), NULL, 0 ) == 0 );
ok ( memcmp ( rfc8448_resumed_client_handshake_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( rfc8448_resumed_client_handshake_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
/* EndOfEarlyData */
tlskey_digest ( tlskey, rfc8448_resumed_endofearlydata,
sizeof ( rfc8448_resumed_endofearlydata ) );
/* Client verification */
ok ( tlskey_verify ( tlskey, &tls_client, verify,
sizeof ( verify ) ) == 0 );
ok ( memcmp ( rfc8448_resumed_client_verify,
verify, sizeof ( verify ) ) == 0 );
/* Client application traffic secret */
ok ( tlskey_traffic ( tlskey, &tls_client, &tls_application ) == 0 );
ok ( memcmp ( rfc8448_resumed_client_application_traffic_secret,
tlskey->traffic[TLS_CLIENT].secret, digestsize ) == 0 );
/* Client Finished */
tlskey_digest ( tlskey, rfc8448_resumed_client_finished,
sizeof ( rfc8448_resumed_client_finished ) );
/* Client application traffic keys */
ok ( tlskey_cipher ( tlskey, &tls_client, key, sizeof ( key ),
iv, sizeof ( iv ), NULL, 0 ) == 0 );
ok ( memcmp ( rfc8448_resumed_client_application_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( rfc8448_resumed_client_application_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
/* Stop key schedule */
tlskey_stop ( tlskey );
}
/**
* Perform dummy TLS version 1.2 test
*
* @v tlskey Key schedule
* @v psk Pre-shared key
*/
static void dummy_hash ( struct tls_key_schedule *tlskey,
struct tls_preshared_key *psk ) {
struct digest_algorithm *digest = &sha256_algorithm;
size_t digestsize = digest->digestsize;
const int extended = 1;
uint8_t tbshash[digestsize];
uint8_t verify[12];
uint8_t key[16];
uint8_t iv[4];
uint8_t mac[32];
/* Start key schedule */
ok ( tlskey_start ( tlskey, &tlskey_hash, digest,
&dummy_client_nonce ) == 0 );
/* ClientHello */
tlskey_digest ( tlskey, dummy_clienthello,
sizeof ( dummy_clienthello ) );
/* ServerHello */
tlskey_digest ( tlskey, dummy_serverhello,
sizeof ( dummy_serverhello ) );
/* Pre-master secret */
ok ( tlskey_apply ( tlskey, dummy_premaster,
sizeof ( dummy_premaster ) ) == 0 );
/* Master secret */
ok ( tlskey_master ( tlskey, extended ) == 0 );
ok ( memcmp ( dummy_hash_master_secret, tlskey->kdf.secret,
sizeof ( dummy_hash_master_secret ) ) == 0 );
/* Client verification */
ok ( tlskey_verify ( tlskey, &tls_client, verify,
sizeof ( verify ) ) == 0 );
ok ( memcmp ( dummy_hash_client_verify, verify,
sizeof ( verify ) ) == 0 );
/* Server verification */
ok ( tlskey_verify ( tlskey, &tls_server, verify,
sizeof ( verify ) ) == 0 );
ok ( memcmp ( dummy_hash_server_verify, verify,
sizeof ( verify ) ) == 0 );
/* Client traffic keys */
ok ( tlskey_traffic ( tlskey, &tls_client, &tls_application ) == 0 );
ok ( tlskey_cipher ( tlskey, &tls_client, key, sizeof ( key ),
iv, sizeof ( iv ), mac, sizeof ( mac ) ) == 0 );
ok ( memcmp ( dummy_hash_client_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( dummy_hash_client_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
ok ( memcmp ( dummy_hash_client_traffic_mac,
mac, sizeof ( mac ) ) == 0 );
/* Server traffic keys */
ok ( tlskey_traffic ( tlskey, &tls_server, &tls_application ) == 0 );
ok ( tlskey_cipher ( tlskey, &tls_server, key, sizeof ( key ),
iv, sizeof ( iv ), mac, sizeof ( mac ) ) == 0 );
ok ( memcmp ( dummy_hash_server_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( dummy_hash_server_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
ok ( memcmp ( dummy_hash_server_traffic_mac,
mac, sizeof ( mac ) ) == 0 );
/* Client signable digest */
ok ( tlskey_tbshash ( tlskey, &tls_client, digest, NULL, 0,
tbshash ) == 0 );
ok ( memcmp ( dummy_hash_client_tbshash,
tbshash, sizeof ( tbshash ) ) == 0 );
/* Server signable digest */
ok ( tlskey_tbshash ( tlskey, &tls_server, digest, dummy_dh_param,
sizeof ( dummy_dh_param ), tbshash ) == 0 );
ok ( memcmp ( dummy_hash_server_tbshash,
tbshash, sizeof ( tbshash ) ) == 0 );
/* Save resumption secret */
ok ( tlskey_save ( tlskey, NULL, 0, psk ) == 0 );
/* Stop key schedule */
tlskey_stop ( tlskey );
/* Start key schedule */
ok ( tlskey_start ( tlskey, &tlskey_hash, digest,
&dummy_client_nonce ) == 0 );
/* ClientHello */
tlskey_digest ( tlskey, dummy_clienthello,
sizeof ( dummy_clienthello ) );
/* ServerHello */
tlskey_digest ( tlskey, dummy_serverhello,
sizeof ( dummy_serverhello ) );
/* Load resumption secret */
ok ( memcmp ( dummy_hash_master_secret, tlskey->kdf.secret,
sizeof ( dummy_hash_master_secret ) ) != 0 );
ok ( tlskey_load ( tlskey, extended, psk ) == 0 );
ok ( memcmp ( dummy_hash_master_secret, tlskey->kdf.secret,
sizeof ( dummy_hash_master_secret ) ) == 0 );
/* Stop key schedule */
tlskey_stop ( tlskey );
}
/**
* Perform dummy TLS version 1.0 test
*
* @v tlskey Key schedule
* @v psk Pre-shared key
*/
static void dummy_md5_sha1 ( struct tls_key_schedule *tlskey,
struct tls_preshared_key *psk ) {
struct digest_algorithm *digest = &md5_sha1_algorithm;
const struct md5_sha1_hmac_keys *hkeys;
const int extended = 0;
uint8_t verify[12];
uint8_t key[16];
uint8_t iv[4];
uint8_t mac[32];
/* Start key schedule */
ok ( tlskey_start ( tlskey, &tlskey_md5_sha1, digest,
&dummy_client_nonce ) == 0 );
hkeys = tlskey->kdf.secret;
/* ClientHello */
tlskey_digest ( tlskey, dummy_clienthello,
sizeof ( dummy_clienthello ) );
/* ServerHello */
tlskey_digest ( tlskey, dummy_serverhello,
sizeof ( dummy_serverhello ) );
/* Pre-master secret */
ok ( tlskey_apply ( tlskey, dummy_premaster,
sizeof ( dummy_premaster ) ) == 0 );
/* Master secret */
ok ( tlskey_master ( tlskey, extended ) == 0 );
ok ( memcmp ( dummy_md5_sha1_master_secret_md5, hkeys->md5,
sizeof ( dummy_md5_sha1_master_secret_md5 ) ) == 0 );
ok ( memcmp ( dummy_md5_sha1_master_secret_sha1, hkeys->sha1,
sizeof ( dummy_md5_sha1_master_secret_sha1 ) ) == 0 );
/* Client verification */
ok ( tlskey_verify ( tlskey, &tls_client, verify,
sizeof ( verify ) ) == 0 );
ok ( memcmp ( dummy_md5_sha1_client_verify, verify,
sizeof ( verify ) ) == 0 );
/* Server verification */
ok ( tlskey_verify ( tlskey, &tls_server, verify,
sizeof ( verify ) ) == 0 );
ok ( memcmp ( dummy_md5_sha1_server_verify, verify,
sizeof ( verify ) ) == 0 );
/* Client traffic keys */
ok ( tlskey_traffic ( tlskey, &tls_client, &tls_application ) == 0 );
ok ( tlskey_cipher ( tlskey, &tls_client, key, sizeof ( key ),
iv, sizeof ( iv ), mac, sizeof ( mac ) ) == 0 );
ok ( memcmp ( dummy_md5_sha1_client_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( dummy_md5_sha1_client_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
ok ( memcmp ( dummy_md5_sha1_client_traffic_mac,
mac, sizeof ( mac ) ) == 0 );
/* Server traffic keys */
ok ( tlskey_traffic ( tlskey, &tls_server, &tls_application ) == 0 );
ok ( tlskey_cipher ( tlskey, &tls_server, key, sizeof ( key ),
iv, sizeof ( iv ), mac, sizeof ( mac ) ) == 0 );
ok ( memcmp ( dummy_md5_sha1_server_traffic_key,
key, sizeof ( key ) ) == 0 );
ok ( memcmp ( dummy_md5_sha1_server_traffic_iv,
iv, sizeof ( iv ) ) == 0 );
ok ( memcmp ( dummy_md5_sha1_server_traffic_mac,
mac, sizeof ( mac ) ) == 0 );
/* Save resumption secret */
ok ( tlskey_save ( tlskey, NULL, 0, psk ) == 0 );
/* Stop key schedule */
tlskey_stop ( tlskey );
/* Start key schedule */
ok ( tlskey_start ( tlskey, &tlskey_md5_sha1, digest,
&dummy_client_nonce ) == 0 );
hkeys = tlskey->kdf.secret;
/* ClientHello */
tlskey_digest ( tlskey, dummy_clienthello,
sizeof ( dummy_clienthello ) );
/* ServerHello */
tlskey_digest ( tlskey, dummy_serverhello,
sizeof ( dummy_serverhello ) );
/* Load resumption secret */
ok ( memcmp ( dummy_md5_sha1_master_secret_md5, hkeys->md5,
sizeof ( dummy_md5_sha1_master_secret_md5 ) ) != 0 );
ok ( memcmp ( dummy_md5_sha1_master_secret_sha1, hkeys->sha1,
sizeof ( dummy_md5_sha1_master_secret_sha1 ) ) != 0 );
ok ( tlskey_load ( tlskey, extended, psk ) == 0 );
ok ( memcmp ( dummy_md5_sha1_master_secret_md5, hkeys->md5,
sizeof ( dummy_md5_sha1_master_secret_md5 ) ) == 0 );
ok ( memcmp ( dummy_md5_sha1_master_secret_sha1, hkeys->sha1,
sizeof ( dummy_md5_sha1_master_secret_sha1 ) ) == 0 );
/* Stop key schedule */
tlskey_stop ( tlskey );
}
/**
* Perform TLS key schedule self-test
*
*/
static void tlskey_test_exec ( void ) {
struct tls_key_schedule tlskey;
struct tls_preshared_key psk;
/* Initialise data structures */
memset ( &tlskey, 0, sizeof ( tlskey ) );
memset ( &psk, 0, sizeof ( psk ) );
/* RFC 8448 simple 1-RTT test */
rfc8448_simple_test ( &tlskey, &psk );
/* RFC 8448 resumed 0-RTT test */
rfc8448_resumed_test ( &tlskey, &psk );
/* Dummy TLS version 1.2 test */
dummy_hash ( &tlskey, &psk );
/* Dummy TLS version 1.0 test */
dummy_md5_sha1 ( &tlskey, &psk );
}
/** TLS key schedule self-test */
struct self_test tlskey_test __self_test = {
.name = "tlskey",
.exec = tlskey_test_exec,
};