From ec20d7d79d702ab7bb49772cadbd3f2c6d1b5ec3 Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 9 Jun 2026 05:20:38 +0000 Subject: [PATCH] ssl_kex: exercise an invalid point as well --- regress/lib/libssl/unit/ssl_kex.c | 35 ++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/regress/lib/libssl/unit/ssl_kex.c b/regress/lib/libssl/unit/ssl_kex.c index 8b4f644a412..4050d04bd5f 100644 --- a/regress/lib/libssl/unit/ssl_kex.c +++ b/regress/lib/libssl/unit/ssl_kex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_kex.c,v 1.3 2026/06/09 05:17:24 tb Exp $ */ +/* $OpenBSD: ssl_kex.c,v 1.4 2026/06/09 05:20:38 tb Exp $ */ /* * Copyright (c) 2026 Theo Buehler @@ -77,6 +77,23 @@ static const uint8_t secp384r1_hybrid_point[] = { }; static const size_t secp384r1_hybrid_point_len = sizeof(secp384r1_hybrid_point); +static const uint8_t secp384r1_invalid_point[] = { + 0x04, 0xca, 0x0e, 0xc0, 0x60, 0xce, 0x24, 0x25, + 0xa7, 0x6e, 0xd1, 0x96, 0x69, 0x33, 0x36, 0x04, + 0x87, 0x69, 0x36, 0xfd, 0x2a, 0x83, 0x7a, 0x99, + 0xad, 0xb7, 0x35, 0xe9, 0x4c, 0x2f, 0x56, 0xfc, + 0xee, 0x7e, 0x68, 0x43, 0x90, 0x41, 0xb7, 0x3c, + 0x64, 0xd4, 0xec, 0x82, 0xc1, 0xc6, 0xd9, 0x4b, + 0x7d, 0xfa, 0xaa, 0x43, 0x46, 0x19, 0x94, 0x7f, + 0xb4, 0xe2, 0xa7, 0xbd, 0x75, 0xaf, 0x4d, 0x8f, + 0x45, 0xed, 0x3a, 0x8f, 0xef, 0x93, 0x57, 0x50, + 0x3f, 0x24, 0xf4, 0xa8, 0x68, 0x22, 0xf8, 0xa3, + 0x8c, 0xa9, 0x8b, 0xe8, 0xb9, 0x28, 0xff, 0x9f, + 0xcf, 0xcd, 0xac, 0xc1, 0x20, 0x5f, 0x23, 0x07, + 0x41, +}; +static const size_t secp384r1_invalid_point_len = sizeof(secp384r1_invalid_point); + static int ssl_key_share_ecdhe_test(void) { @@ -161,6 +178,22 @@ ssl_key_share_ecdhe_test(void) EC_KEY_free(ecdh_peer); ecdh_peer = NULL; + decode_error = 0; + CBS_init(&cbs, secp384r1_invalid_point, secp384r1_invalid_point_len); + if ((ecdh_peer = EC_KEY_new()) == NULL) + err(1, NULL); + if (ssl_kex_peer_public_ecdhe_ecp(ecdh_peer, nid, &cbs, &decode_error)) { + fprintf(stderr, "FAIL: parsed invalid P-384 point\n"); + failed |= 1; + } + if (!decode_error) { + fprintf(stderr, "FAIL: no decode_error for invalid P-384 point\n"); + failed |= 1; + } + + EC_KEY_free(ecdh_peer); + ecdh_peer = NULL; + EC_KEY_free(ecdh); freezero(shared_key, shared_key_len);