summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_clnt.c
diff options
context:
space:
mode:
authorjsing <>2026-05-31 14:34:44 +0000
committerjsing <>2026-05-31 14:34:44 +0000
commit220b0356be08906dac6ccaa9ba6cf9e0289b3435 (patch)
tree89953440f661f3c880d44b48db9a1e891f88879e /src/lib/libssl/ssl_clnt.c
parente10fcd3d372e2b1cc95379aa034431113c0aa7b4 (diff)
downloadopenbsd-220b0356be08906dac6ccaa9ba6cf9e0289b3435.tar.gz
openbsd-220b0356be08906dac6ccaa9ba6cf9e0289b3435.tar.bz2
openbsd-220b0356be08906dac6ccaa9ba6cf9e0289b3435.zip
Clean up signature algorithm handling.
Now that we no longer support TLSv1.0 and TLSv1.1, SSL_USE_SIGALGS() is always true - remove all of the code that handles the non-sigalgs path, along with SSL_USE_SIGALGS() and the related flags. Also remove SIGALG_RSA_PKCS1_MD5_SHA1 and references to it, since this is also now unused. ok kenjiro@ tb@
Diffstat (limited to 'src/lib/libssl/ssl_clnt.c')
-rw-r--r--src/lib/libssl/ssl_clnt.c140
1 files changed, 23 insertions, 117 deletions
diff --git a/src/lib/libssl/ssl_clnt.c b/src/lib/libssl/ssl_clnt.c
index 6ef81a1706..b59ffa0eff 100644
--- a/src/lib/libssl/ssl_clnt.c
+++ b/src/lib/libssl/ssl_clnt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_clnt.c,v 1.171 2026/04/03 12:58:19 jsing Exp $ */ 1/* $OpenBSD: ssl_clnt.c,v 1.172 2026/05/31 14:34:44 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1034,13 +1034,6 @@ ssl3_get_server_hello(SSL *s)
1034 if (!tls1_transcript_hash_init(s)) 1034 if (!tls1_transcript_hash_init(s))
1035 goto err; 1035 goto err;
1036 1036
1037 /*
1038 * Don't digest cached records if no sigalgs: we may need them for
1039 * client authentication.
1040 */
1041 if (!SSL_USE_SIGALGS(s))
1042 tls1_transcript_free(s);
1043
1044 if (!CBS_get_u8(&cbs, &compression_method)) 1037 if (!CBS_get_u8(&cbs, &compression_method))
1045 goto decode_err; 1038 goto decode_err;
1046 1039
@@ -1384,10 +1377,9 @@ ssl3_get_server_key_exchange(SSL *s)
1384 goto fatal_err; 1377 goto fatal_err;
1385 } 1378 }
1386 1379
1387 if (SSL_USE_SIGALGS(s)) { 1380 if (!CBS_get_u16(&cbs, &sigalg_value))
1388 if (!CBS_get_u16(&cbs, &sigalg_value)) 1381 goto decode_err;
1389 goto decode_err; 1382
1390 }
1391 if (!CBS_get_u16_length_prefixed(&cbs, &signature)) 1383 if (!CBS_get_u16_length_prefixed(&cbs, &signature))
1392 goto decode_err; 1384 goto decode_err;
1393 if (CBS_len(&signature) > EVP_PKEY_size(pkey)) { 1385 if (CBS_len(&signature) > EVP_PKEY_size(pkey)) {
@@ -1448,7 +1440,7 @@ ssl3_get_server_key_exchange(SSL *s)
1448static int 1440static int
1449ssl3_get_certificate_request(SSL *s) 1441ssl3_get_certificate_request(SSL *s)
1450{ 1442{
1451 CBS cert_request, cert_types, rdn_list; 1443 CBS cert_request, cert_types, rdn_list, sigalgs;
1452 X509_NAME *xn = NULL; 1444 X509_NAME *xn = NULL;
1453 const unsigned char *q; 1445 const unsigned char *q;
1454 STACK_OF(X509_NAME) *ca_sk = NULL; 1446 STACK_OF(X509_NAME) *ca_sk = NULL;
@@ -1497,27 +1489,23 @@ ssl3_get_certificate_request(SSL *s)
1497 if (!CBS_get_u8_length_prefixed(&cert_request, &cert_types)) 1489 if (!CBS_get_u8_length_prefixed(&cert_request, &cert_types))
1498 goto decode_err; 1490 goto decode_err;
1499 1491
1500 if (SSL_USE_SIGALGS(s)) { 1492 if (CBS_len(&cert_request) < 2) {
1501 CBS sigalgs; 1493 SSLerror(s, SSL_R_DATA_LENGTH_TOO_LONG);
1502 1494 goto err;
1503 if (CBS_len(&cert_request) < 2) { 1495 }
1504 SSLerror(s, SSL_R_DATA_LENGTH_TOO_LONG); 1496 if (!CBS_get_u16_length_prefixed(&cert_request, &sigalgs)) {
1505 goto err; 1497 ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
1506 } 1498 SSLerror(s, SSL_R_DATA_LENGTH_TOO_LONG);
1507 if (!CBS_get_u16_length_prefixed(&cert_request, &sigalgs)) { 1499 goto err;
1508 ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
1509 SSLerror(s, SSL_R_DATA_LENGTH_TOO_LONG);
1510 goto err;
1511 }
1512 if (CBS_len(&sigalgs) % 2 != 0 || CBS_len(&sigalgs) > 64) {
1513 ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
1514 SSLerror(s, SSL_R_SIGNATURE_ALGORITHMS_ERROR);
1515 goto err;
1516 }
1517 if (!CBS_stow(&sigalgs, &s->s3->hs.sigalgs,
1518 &s->s3->hs.sigalgs_len))
1519 goto err;
1520 } 1500 }
1501 if (CBS_len(&sigalgs) % 2 != 0 || CBS_len(&sigalgs) > 64) {
1502 ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
1503 SSLerror(s, SSL_R_SIGNATURE_ALGORITHMS_ERROR);
1504 goto err;
1505 }
1506 if (!CBS_stow(&sigalgs, &s->s3->hs.sigalgs,
1507 &s->s3->hs.sigalgs_len))
1508 goto err;
1521 1509
1522 /* get the CA RDNs */ 1510 /* get the CA RDNs */
1523 if (CBS_len(&cert_request) < 2) { 1511 if (CBS_len(&cert_request) < 2) {
@@ -2035,77 +2023,6 @@ ssl3_send_client_verify_sigalgs(SSL *s, EVP_PKEY *pkey,
2035} 2023}
2036 2024
2037static int 2025static int
2038ssl3_send_client_verify_rsa(SSL *s, EVP_PKEY *pkey, CBB *cert_verify)
2039{
2040 CBB cbb_signature;
2041 RSA *rsa;
2042 unsigned char data[EVP_MAX_MD_SIZE];
2043 unsigned char *signature = NULL;
2044 unsigned int signature_len;
2045 size_t data_len;
2046 int ret = 0;
2047
2048 if (!tls1_transcript_hash_value(s, data, sizeof(data), &data_len))
2049 goto err;
2050 if ((signature = calloc(1, EVP_PKEY_size(pkey))) == NULL)
2051 goto err;
2052 if ((rsa = EVP_PKEY_get0_RSA(pkey)) == NULL)
2053 goto err;
2054 if (RSA_sign(NID_md5_sha1, data, data_len, signature, &signature_len,
2055 rsa) <= 0 ) {
2056 SSLerror(s, ERR_R_RSA_LIB);
2057 goto err;
2058 }
2059
2060 if (!CBB_add_u16_length_prefixed(cert_verify, &cbb_signature))
2061 goto err;
2062 if (!CBB_add_bytes(&cbb_signature, signature, signature_len))
2063 goto err;
2064 if (!CBB_flush(cert_verify))
2065 goto err;
2066
2067 ret = 1;
2068 err:
2069 free(signature);
2070 return ret;
2071}
2072
2073static int
2074ssl3_send_client_verify_ec(SSL *s, EVP_PKEY *pkey, CBB *cert_verify)
2075{
2076 CBB cbb_signature;
2077 EC_KEY *eckey;
2078 unsigned char data[EVP_MAX_MD_SIZE];
2079 unsigned char *signature = NULL;
2080 unsigned int signature_len;
2081 int ret = 0;
2082
2083 if (!tls1_transcript_hash_value(s, data, sizeof(data), NULL))
2084 goto err;
2085 if ((signature = calloc(1, EVP_PKEY_size(pkey))) == NULL)
2086 goto err;
2087 if ((eckey = EVP_PKEY_get0_EC_KEY(pkey)) == NULL)
2088 goto err;
2089 if (!ECDSA_sign(0, &data[MD5_DIGEST_LENGTH], SHA_DIGEST_LENGTH,
2090 signature, &signature_len, eckey)) {
2091 SSLerror(s, ERR_R_ECDSA_LIB);
2092 goto err;
2093 }
2094
2095 if (!CBB_add_u16_length_prefixed(cert_verify, &cbb_signature))
2096 goto err;
2097 if (!CBB_add_bytes(&cbb_signature, signature, signature_len))
2098 goto err;
2099 if (!CBB_flush(cert_verify))
2100 goto err;
2101
2102 ret = 1;
2103 err:
2104 free(signature);
2105 return ret;
2106}
2107
2108static int
2109ssl3_send_client_verify(SSL *s) 2026ssl3_send_client_verify(SSL *s)
2110{ 2027{
2111 const struct ssl_sigalg *sigalg; 2028 const struct ssl_sigalg *sigalg;
@@ -2130,20 +2047,9 @@ ssl3_send_client_verify(SSL *s)
2130 * For TLS v1.2 send signature algorithm and signature using 2047 * For TLS v1.2 send signature algorithm and signature using
2131 * agreed digest and cached handshake records. 2048 * agreed digest and cached handshake records.
2132 */ 2049 */
2133 if (SSL_USE_SIGALGS(s)) { 2050 if (!ssl3_send_client_verify_sigalgs(s, pkey, sigalg,
2134 if (!ssl3_send_client_verify_sigalgs(s, pkey, sigalg, 2051 &cert_verify))
2135 &cert_verify))
2136 goto err;
2137 } else if (EVP_PKEY_id(pkey) == EVP_PKEY_RSA) {
2138 if (!ssl3_send_client_verify_rsa(s, pkey, &cert_verify))
2139 goto err;
2140 } else if (EVP_PKEY_id(pkey) == EVP_PKEY_EC) {
2141 if (!ssl3_send_client_verify_ec(s, pkey, &cert_verify))
2142 goto err;
2143 } else {
2144 SSLerror(s, ERR_R_INTERNAL_ERROR);
2145 goto err; 2052 goto err;
2146 }
2147 2053
2148 tls1_transcript_free(s); 2054 tls1_transcript_free(s);
2149 2055