summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2026-06-09 05:20:38 +0000
committertb <>2026-06-09 05:20:38 +0000
commitbb7c8a3975e9e76bf209ebf13cd598a0fda24e9b (patch)
treeb4f04dcfa0ba34cbfb3f3f26c77edc991fbfeeab /src
parentf14a542246cdcc303df2664106c4252e1c938396 (diff)
downloadopenbsd-bb7c8a3975e9e76bf209ebf13cd598a0fda24e9b.tar.gz
openbsd-bb7c8a3975e9e76bf209ebf13cd598a0fda24e9b.tar.bz2
openbsd-bb7c8a3975e9e76bf209ebf13cd598a0fda24e9b.zip
ssl_kex: exercise an invalid point as well
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libssl/unit/ssl_kex.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/regress/lib/libssl/unit/ssl_kex.c b/src/regress/lib/libssl/unit/ssl_kex.c
index 8b4f644a41..4050d04bd5 100644
--- a/src/regress/lib/libssl/unit/ssl_kex.c
+++ b/src/regress/lib/libssl/unit/ssl_kex.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_kex.c,v 1.3 2026/06/09 05:17:24 tb Exp $ */ 1/* $OpenBSD: ssl_kex.c,v 1.4 2026/06/09 05:20:38 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2026 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2026 Theo Buehler <tb@openbsd.org>
@@ -77,6 +77,23 @@ static const uint8_t secp384r1_hybrid_point[] = {
77}; 77};
78static const size_t secp384r1_hybrid_point_len = sizeof(secp384r1_hybrid_point); 78static const size_t secp384r1_hybrid_point_len = sizeof(secp384r1_hybrid_point);
79 79
80static const uint8_t secp384r1_invalid_point[] = {
81 0x04, 0xca, 0x0e, 0xc0, 0x60, 0xce, 0x24, 0x25,
82 0xa7, 0x6e, 0xd1, 0x96, 0x69, 0x33, 0x36, 0x04,
83 0x87, 0x69, 0x36, 0xfd, 0x2a, 0x83, 0x7a, 0x99,
84 0xad, 0xb7, 0x35, 0xe9, 0x4c, 0x2f, 0x56, 0xfc,
85 0xee, 0x7e, 0x68, 0x43, 0x90, 0x41, 0xb7, 0x3c,
86 0x64, 0xd4, 0xec, 0x82, 0xc1, 0xc6, 0xd9, 0x4b,
87 0x7d, 0xfa, 0xaa, 0x43, 0x46, 0x19, 0x94, 0x7f,
88 0xb4, 0xe2, 0xa7, 0xbd, 0x75, 0xaf, 0x4d, 0x8f,
89 0x45, 0xed, 0x3a, 0x8f, 0xef, 0x93, 0x57, 0x50,
90 0x3f, 0x24, 0xf4, 0xa8, 0x68, 0x22, 0xf8, 0xa3,
91 0x8c, 0xa9, 0x8b, 0xe8, 0xb9, 0x28, 0xff, 0x9f,
92 0xcf, 0xcd, 0xac, 0xc1, 0x20, 0x5f, 0x23, 0x07,
93 0x41,
94};
95static const size_t secp384r1_invalid_point_len = sizeof(secp384r1_invalid_point);
96
80static int 97static int
81ssl_key_share_ecdhe_test(void) 98ssl_key_share_ecdhe_test(void)
82{ 99{
@@ -161,6 +178,22 @@ ssl_key_share_ecdhe_test(void)
161 EC_KEY_free(ecdh_peer); 178 EC_KEY_free(ecdh_peer);
162 ecdh_peer = NULL; 179 ecdh_peer = NULL;
163 180
181 decode_error = 0;
182 CBS_init(&cbs, secp384r1_invalid_point, secp384r1_invalid_point_len);
183 if ((ecdh_peer = EC_KEY_new()) == NULL)
184 err(1, NULL);
185 if (ssl_kex_peer_public_ecdhe_ecp(ecdh_peer, nid, &cbs, &decode_error)) {
186 fprintf(stderr, "FAIL: parsed invalid P-384 point\n");
187 failed |= 1;
188 }
189 if (!decode_error) {
190 fprintf(stderr, "FAIL: no decode_error for invalid P-384 point\n");
191 failed |= 1;
192 }
193
194 EC_KEY_free(ecdh_peer);
195 ecdh_peer = NULL;
196
164 EC_KEY_free(ecdh); 197 EC_KEY_free(ecdh);
165 freezero(shared_key, shared_key_len); 198 freezero(shared_key, shared_key_len);
166 199