diff options
| author | jsing <> | 2026-05-31 14:34:44 +0000 |
|---|---|---|
| committer | jsing <> | 2026-05-31 14:34:44 +0000 |
| commit | 220b0356be08906dac6ccaa9ba6cf9e0289b3435 (patch) | |
| tree | 89953440f661f3c880d44b48db9a1e891f88879e /src/lib/libssl/ssl_srvr.c | |
| parent | e10fcd3d372e2b1cc95379aa034431113c0aa7b4 (diff) | |
| download | openbsd-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_srvr.c')
| -rw-r--r-- | src/lib/libssl/ssl_srvr.c | 148 |
1 files changed, 38 insertions, 110 deletions
diff --git a/src/lib/libssl/ssl_srvr.c b/src/lib/libssl/ssl_srvr.c index af4b20f6ce..f9c4ef918a 100644 --- a/src/lib/libssl/ssl_srvr.c +++ b/src/lib/libssl/ssl_srvr.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_srvr.c,v 1.168 2026/04/03 12:58:19 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_srvr.c,v 1.169 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 | * |
| @@ -568,33 +568,14 @@ ssl3_accept(SSL *s) | |||
| 568 | } | 568 | } |
| 569 | 569 | ||
| 570 | alg_k = s->s3->hs.cipher->algorithm_mkey; | 570 | alg_k = s->s3->hs.cipher->algorithm_mkey; |
| 571 | if (SSL_USE_SIGALGS(s)) { | 571 | s->s3->hs.state = SSL3_ST_SR_CERT_VRFY_A; |
| 572 | s->s3->hs.state = SSL3_ST_SR_CERT_VRFY_A; | 572 | s->init_num = 0; |
| 573 | s->init_num = 0; | 573 | if (s->session->peer_cert != NULL) { |
| 574 | if (!s->session->peer_cert) | ||
| 575 | break; | ||
| 576 | /* | 574 | /* |
| 577 | * Freeze the transcript for use during client | 575 | * Freeze the transcript for use during client |
| 578 | * certificate verification. | 576 | * certificate verification. |
| 579 | */ | 577 | */ |
| 580 | tls1_transcript_freeze(s); | 578 | tls1_transcript_freeze(s); |
| 581 | } else { | ||
| 582 | s->s3->hs.state = SSL3_ST_SR_CERT_VRFY_A; | ||
| 583 | s->init_num = 0; | ||
| 584 | |||
| 585 | tls1_transcript_free(s); | ||
| 586 | |||
| 587 | /* | ||
| 588 | * We need to get hashes here so if there is | ||
| 589 | * a client cert, it can be verified. | ||
| 590 | */ | ||
| 591 | if (!tls1_transcript_hash_value(s, | ||
| 592 | s->s3->hs.tls12.cert_verify, | ||
| 593 | sizeof(s->s3->hs.tls12.cert_verify), | ||
| 594 | NULL)) { | ||
| 595 | ret = -1; | ||
| 596 | goto end; | ||
| 597 | } | ||
| 598 | } | 579 | } |
| 599 | break; | 580 | break; |
| 600 | 581 | ||
| @@ -1142,7 +1123,7 @@ ssl3_get_client_hello(SSL *s) | |||
| 1142 | if (!tls1_transcript_hash_init(s)) | 1123 | if (!tls1_transcript_hash_init(s)) |
| 1143 | goto err; | 1124 | goto err; |
| 1144 | 1125 | ||
| 1145 | if (!SSL_USE_SIGALGS(s) || !(s->verify_mode & SSL_VERIFY_PEER)) | 1126 | if (!(s->verify_mode & SSL_VERIFY_PEER)) |
| 1146 | tls1_transcript_free(s); | 1127 | tls1_transcript_free(s); |
| 1147 | 1128 | ||
| 1148 | /* | 1129 | /* |
| @@ -1501,12 +1482,10 @@ ssl3_send_server_key_exchange(SSL *s) | |||
| 1501 | s->s3->hs.our_sigalg = sigalg; | 1482 | s->s3->hs.our_sigalg = sigalg; |
| 1502 | 1483 | ||
| 1503 | /* Send signature algorithm. */ | 1484 | /* Send signature algorithm. */ |
| 1504 | if (SSL_USE_SIGALGS(s)) { | 1485 | if (!CBB_add_u16(&server_kex, sigalg->value)) { |
| 1505 | if (!CBB_add_u16(&server_kex, sigalg->value)) { | 1486 | al = SSL_AD_INTERNAL_ERROR; |
| 1506 | al = SSL_AD_INTERNAL_ERROR; | 1487 | SSLerror(s, ERR_R_INTERNAL_ERROR); |
| 1507 | SSLerror(s, ERR_R_INTERNAL_ERROR); | 1488 | goto fatal_err; |
| 1508 | goto fatal_err; | ||
| 1509 | } | ||
| 1510 | } | 1489 | } |
| 1511 | 1490 | ||
| 1512 | if (!EVP_DigestSignInit(md_ctx, &pctx, md, NULL, pkey)) { | 1491 | if (!EVP_DigestSignInit(md_ctx, &pctx, md, NULL, pkey)) { |
| @@ -1591,14 +1570,11 @@ ssl3_send_certificate_request(SSL *s) | |||
| 1591 | if (!ssl3_get_req_cert_types(s, &cert_types)) | 1570 | if (!ssl3_get_req_cert_types(s, &cert_types)) |
| 1592 | goto err; | 1571 | goto err; |
| 1593 | 1572 | ||
| 1594 | if (SSL_USE_SIGALGS(s)) { | 1573 | if (!CBB_add_u16_length_prefixed(&cert_request, &sigalgs)) |
| 1595 | if (!CBB_add_u16_length_prefixed(&cert_request, | 1574 | goto err; |
| 1596 | &sigalgs)) | 1575 | if (!ssl_sigalgs_build(s->s3->hs.negotiated_tls_version, |
| 1597 | goto err; | 1576 | &sigalgs, SSL_get_security_level(s))) |
| 1598 | if (!ssl_sigalgs_build(s->s3->hs.negotiated_tls_version, | 1577 | goto err; |
| 1599 | &sigalgs, SSL_get_security_level(s))) | ||
| 1600 | goto err; | ||
| 1601 | } | ||
| 1602 | 1578 | ||
| 1603 | if (!CBB_add_u16_length_prefixed(&cert_request, &cert_auth)) | 1579 | if (!CBB_add_u16_length_prefixed(&cert_request, &cert_auth)) |
| 1604 | goto err; | 1580 | goto err; |
| @@ -1879,7 +1855,8 @@ ssl3_get_cert_verify(SSL *s) | |||
| 1879 | EVP_PKEY *pkey; | 1855 | EVP_PKEY *pkey; |
| 1880 | X509 *peer_cert = NULL; | 1856 | X509 *peer_cert = NULL; |
| 1881 | EVP_MD_CTX *mctx = NULL; | 1857 | EVP_MD_CTX *mctx = NULL; |
| 1882 | int al, verify; | 1858 | EVP_PKEY_CTX *pctx; |
| 1859 | int al; | ||
| 1883 | const unsigned char *hdata; | 1860 | const unsigned char *hdata; |
| 1884 | size_t hdatalen; | 1861 | size_t hdatalen; |
| 1885 | int type = 0; | 1862 | int type = 0; |
| @@ -1932,10 +1909,9 @@ ssl3_get_cert_verify(SSL *s) | |||
| 1932 | goto fatal_err; | 1909 | goto fatal_err; |
| 1933 | } | 1910 | } |
| 1934 | 1911 | ||
| 1935 | if (SSL_USE_SIGALGS(s)) { | 1912 | if (!CBS_get_u16(&cbs, &sigalg_value)) |
| 1936 | if (!CBS_get_u16(&cbs, &sigalg_value)) | 1913 | goto decode_err; |
| 1937 | goto decode_err; | 1914 | |
| 1938 | } | ||
| 1939 | if (!CBS_get_u16_length_prefixed(&cbs, &signature)) | 1915 | if (!CBS_get_u16_length_prefixed(&cbs, &signature)) |
| 1940 | goto err; | 1916 | goto err; |
| 1941 | if (CBS_len(&cbs) != 0) { | 1917 | if (CBS_len(&cbs) != 0) { |
| @@ -1957,74 +1933,26 @@ ssl3_get_cert_verify(SSL *s) | |||
| 1957 | } | 1933 | } |
| 1958 | s->s3->hs.peer_sigalg = sigalg; | 1934 | s->s3->hs.peer_sigalg = sigalg; |
| 1959 | 1935 | ||
| 1960 | if (SSL_USE_SIGALGS(s)) { | 1936 | if (!tls1_transcript_data(s, &hdata, &hdatalen)) { |
| 1961 | EVP_PKEY_CTX *pctx; | ||
| 1962 | |||
| 1963 | if (!tls1_transcript_data(s, &hdata, &hdatalen)) { | ||
| 1964 | SSLerror(s, ERR_R_INTERNAL_ERROR); | ||
| 1965 | al = SSL_AD_INTERNAL_ERROR; | ||
| 1966 | goto fatal_err; | ||
| 1967 | } | ||
| 1968 | if (!EVP_DigestVerifyInit(mctx, &pctx, sigalg->md(), | ||
| 1969 | NULL, pkey)) { | ||
| 1970 | SSLerror(s, ERR_R_EVP_LIB); | ||
| 1971 | al = SSL_AD_INTERNAL_ERROR; | ||
| 1972 | goto fatal_err; | ||
| 1973 | } | ||
| 1974 | if ((sigalg->flags & SIGALG_FLAG_RSA_PSS) && | ||
| 1975 | (!EVP_PKEY_CTX_set_rsa_padding(pctx, | ||
| 1976 | RSA_PKCS1_PSS_PADDING) || | ||
| 1977 | !EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1))) { | ||
| 1978 | al = SSL_AD_INTERNAL_ERROR; | ||
| 1979 | goto fatal_err; | ||
| 1980 | } | ||
| 1981 | if (EVP_DigestVerify(mctx, CBS_data(&signature), | ||
| 1982 | CBS_len(&signature), hdata, hdatalen) <= 0) { | ||
| 1983 | SSLerror(s, ERR_R_EVP_LIB); | ||
| 1984 | al = SSL_AD_INTERNAL_ERROR; | ||
| 1985 | goto fatal_err; | ||
| 1986 | } | ||
| 1987 | } else if (EVP_PKEY_id(pkey) == EVP_PKEY_RSA) { | ||
| 1988 | RSA *rsa; | ||
| 1989 | |||
| 1990 | if ((rsa = EVP_PKEY_get0_RSA(pkey)) == NULL) { | ||
| 1991 | al = SSL_AD_INTERNAL_ERROR; | ||
| 1992 | SSLerror(s, ERR_R_EVP_LIB); | ||
| 1993 | goto fatal_err; | ||
| 1994 | } | ||
| 1995 | verify = RSA_verify(NID_md5_sha1, s->s3->hs.tls12.cert_verify, | ||
| 1996 | MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, CBS_data(&signature), | ||
| 1997 | CBS_len(&signature), rsa); | ||
| 1998 | if (verify < 0) { | ||
| 1999 | al = SSL_AD_DECRYPT_ERROR; | ||
| 2000 | SSLerror(s, SSL_R_BAD_RSA_DECRYPT); | ||
| 2001 | goto fatal_err; | ||
| 2002 | } | ||
| 2003 | if (verify == 0) { | ||
| 2004 | al = SSL_AD_DECRYPT_ERROR; | ||
| 2005 | SSLerror(s, SSL_R_BAD_RSA_SIGNATURE); | ||
| 2006 | goto fatal_err; | ||
| 2007 | } | ||
| 2008 | } else if (EVP_PKEY_id(pkey) == EVP_PKEY_EC) { | ||
| 2009 | EC_KEY *eckey; | ||
| 2010 | |||
| 2011 | if ((eckey = EVP_PKEY_get0_EC_KEY(pkey)) == NULL) { | ||
| 2012 | al = SSL_AD_INTERNAL_ERROR; | ||
| 2013 | SSLerror(s, ERR_R_EVP_LIB); | ||
| 2014 | goto fatal_err; | ||
| 2015 | } | ||
| 2016 | verify = ECDSA_verify(0, | ||
| 2017 | &(s->s3->hs.tls12.cert_verify[MD5_DIGEST_LENGTH]), | ||
| 2018 | SHA_DIGEST_LENGTH, CBS_data(&signature), | ||
| 2019 | CBS_len(&signature), eckey); | ||
| 2020 | if (verify <= 0) { | ||
| 2021 | al = SSL_AD_DECRYPT_ERROR; | ||
| 2022 | SSLerror(s, SSL_R_BAD_ECDSA_SIGNATURE); | ||
| 2023 | goto fatal_err; | ||
| 2024 | } | ||
| 2025 | } else { | ||
| 2026 | SSLerror(s, ERR_R_INTERNAL_ERROR); | 1937 | SSLerror(s, ERR_R_INTERNAL_ERROR); |
| 2027 | al = SSL_AD_UNSUPPORTED_CERTIFICATE; | 1938 | al = SSL_AD_INTERNAL_ERROR; |
| 1939 | goto fatal_err; | ||
| 1940 | } | ||
| 1941 | if (!EVP_DigestVerifyInit(mctx, &pctx, sigalg->md(), NULL, pkey)) { | ||
| 1942 | SSLerror(s, ERR_R_EVP_LIB); | ||
| 1943 | al = SSL_AD_INTERNAL_ERROR; | ||
| 1944 | goto fatal_err; | ||
| 1945 | } | ||
| 1946 | if ((sigalg->flags & SIGALG_FLAG_RSA_PSS) && | ||
| 1947 | (!EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING) || | ||
| 1948 | !EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1))) { | ||
| 1949 | al = SSL_AD_INTERNAL_ERROR; | ||
| 1950 | goto fatal_err; | ||
| 1951 | } | ||
| 1952 | if (EVP_DigestVerify(mctx, CBS_data(&signature), CBS_len(&signature), | ||
| 1953 | hdata, hdatalen) <= 0) { | ||
| 1954 | SSLerror(s, ERR_R_EVP_LIB); | ||
| 1955 | al = SSL_AD_INTERNAL_ERROR; | ||
| 2028 | goto fatal_err; | 1956 | goto fatal_err; |
| 2029 | } | 1957 | } |
| 2030 | 1958 | ||
