summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_tlsext.c
diff options
context:
space:
mode:
authorjsing <>2022-01-11 18:28:41 +0000
committerjsing <>2022-01-11 18:28:41 +0000
commit7af437db632fa247609a08c8b60d48ae34bf3d68 (patch)
treeb1b5872add715360561434ded72edd4aac2d3950 /src/lib/libssl/ssl_tlsext.c
parentc48aae5cc38995b3b04baaf61334783d01a7772e (diff)
downloadopenbsd-7af437db632fa247609a08c8b60d48ae34bf3d68.tar.gz
openbsd-7af437db632fa247609a08c8b60d48ae34bf3d68.tar.bz2
openbsd-7af437db632fa247609a08c8b60d48ae34bf3d68.zip
Plumb decode errors through key share parsing code.
Distinguish between decode errors and other errors, so that we can send a SSL_AD_DECODE_ERROR alert when appropriate. Fixes a tlsfuzzer failure, due to it expecting a decode error alert and not receiving one. Prompted by anton@ ok tb@
Diffstat (limited to 'src/lib/libssl/ssl_tlsext.c')
-rw-r--r--src/lib/libssl/ssl_tlsext.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/libssl/ssl_tlsext.c b/src/lib/libssl/ssl_tlsext.c
index 7538efdc8c..69f8ddbc40 100644
--- a/src/lib/libssl/ssl_tlsext.c
+++ b/src/lib/libssl/ssl_tlsext.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_tlsext.c,v 1.107 2022/01/11 18:24:03 jsing Exp $ */ 1/* $OpenBSD: ssl_tlsext.c,v 1.108 2022/01/11 18:28:41 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2016, 2017, 2019 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> 4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org>
@@ -1478,6 +1478,7 @@ int
1478tlsext_keyshare_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) 1478tlsext_keyshare_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert)
1479{ 1479{
1480 CBS client_shares, key_exchange; 1480 CBS client_shares, key_exchange;
1481 int decode_error;
1481 uint16_t group; 1482 uint16_t group;
1482 1483
1483 if (!CBS_get_u16_length_prefixed(cbs, &client_shares)) 1484 if (!CBS_get_u16_length_prefixed(cbs, &client_shares))
@@ -1515,8 +1516,11 @@ tlsext_keyshare_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert)
1515 return 0; 1516 return 0;
1516 } 1517 }
1517 if (!tls_key_share_peer_public(S3I(s)->hs.key_share, 1518 if (!tls_key_share_peer_public(S3I(s)->hs.key_share,
1518 &key_exchange, NULL)) 1519 &key_exchange, &decode_error, NULL)) {
1520 if (!decode_error)
1521 *alert = SSL_AD_INTERNAL_ERROR;
1519 return 0; 1522 return 0;
1523 }
1520 } 1524 }
1521 1525
1522 return 1; 1526 return 1;
@@ -1561,6 +1565,7 @@ int
1561tlsext_keyshare_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) 1565tlsext_keyshare_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert)
1562{ 1566{
1563 CBS key_exchange; 1567 CBS key_exchange;
1568 int decode_error;
1564 uint16_t group; 1569 uint16_t group;
1565 1570
1566 /* Unpack server share. */ 1571 /* Unpack server share. */
@@ -1588,8 +1593,11 @@ tlsext_keyshare_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert)
1588 return 0; 1593 return 0;
1589 } 1594 }
1590 if (!tls_key_share_peer_public(S3I(s)->hs.key_share, 1595 if (!tls_key_share_peer_public(S3I(s)->hs.key_share,
1591 &key_exchange, NULL)) 1596 &key_exchange, &decode_error, NULL)) {
1597 if (!decode_error)
1598 *alert = SSL_AD_INTERNAL_ERROR;
1592 return 0; 1599 return 0;
1600 }
1593 1601
1594 return 1; 1602 return 1;
1595} 1603}