Skip to content

Commit 15fd5c9

Browse files
committed
ssl: remove support for MBEDTLS_DHM_C
Signed-off-by: Valerio Setti <[email protected]>
1 parent 461899e commit 15fd5c9

File tree

3 files changed

+0
-146
lines changed

3 files changed

+0
-146
lines changed

include/mbedtls/ssl.h

-56
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
#include "mbedtls/x509_crl.h"
2525
#endif
2626

27-
#if defined(MBEDTLS_DHM_C)
28-
#include "mbedtls/dhm.h"
29-
#endif
30-
3127
#include "mbedtls/md.h"
3228

3329
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDH_OR_ECDHE_ANY_ENABLED)
@@ -1562,11 +1558,6 @@ struct mbedtls_ssl_config {
15621558

15631559
const uint16_t *MBEDTLS_PRIVATE(group_list); /*!< allowed IANA NamedGroups */
15641560

1565-
#if defined(MBEDTLS_DHM_C)
1566-
mbedtls_mpi MBEDTLS_PRIVATE(dhm_P); /*!< prime modulus for DHM */
1567-
mbedtls_mpi MBEDTLS_PRIVATE(dhm_G); /*!< generator for DHM */
1568-
#endif
1569-
15701561
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_PSK_ENABLED)
15711562

15721563
mbedtls_svc_key_id_t MBEDTLS_PRIVATE(psk_opaque); /*!< PSA key slot holding opaque PSK. This field
@@ -1642,10 +1633,6 @@ struct mbedtls_ssl_config {
16421633

16431634
unsigned int MBEDTLS_PRIVATE(badmac_limit); /*!< limit of records with a bad MAC */
16441635

1645-
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
1646-
unsigned int MBEDTLS_PRIVATE(dhm_min_bitlen); /*!< min. bit length of the DHM prime */
1647-
#endif
1648-
16491636
/** User data pointer or handle.
16501637
*
16511638
* The library sets this to \p 0 when creating a context and does not
@@ -3753,49 +3740,6 @@ void mbedtls_ssl_conf_psk_cb(mbedtls_ssl_config *conf,
37533740
#endif /* MBEDTLS_SSL_SRV_C */
37543741
#endif /* MBEDTLS_SSL_HANDSHAKE_WITH_PSK_ENABLED */
37553742

3756-
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
3757-
/**
3758-
* \brief Set the Diffie-Hellman public P and G values
3759-
* from big-endian binary presentations.
3760-
* (Default values: MBEDTLS_DHM_RFC3526_MODP_2048_[PG]_BIN)
3761-
*
3762-
* \param conf SSL configuration
3763-
* \param dhm_P Diffie-Hellman-Merkle modulus in big-endian binary form
3764-
* \param P_len Length of DHM modulus
3765-
* \param dhm_G Diffie-Hellman-Merkle generator in big-endian binary form
3766-
* \param G_len Length of DHM generator
3767-
*
3768-
* \return 0 if successful
3769-
*/
3770-
int mbedtls_ssl_conf_dh_param_bin(mbedtls_ssl_config *conf,
3771-
const unsigned char *dhm_P, size_t P_len,
3772-
const unsigned char *dhm_G, size_t G_len);
3773-
3774-
/**
3775-
* \brief Set the Diffie-Hellman public P and G values,
3776-
* read from existing context (server-side only)
3777-
*
3778-
* \param conf SSL configuration
3779-
* \param dhm_ctx Diffie-Hellman-Merkle context
3780-
*
3781-
* \return 0 if successful
3782-
*/
3783-
int mbedtls_ssl_conf_dh_param_ctx(mbedtls_ssl_config *conf, mbedtls_dhm_context *dhm_ctx);
3784-
#endif /* MBEDTLS_DHM_C && defined(MBEDTLS_SSL_SRV_C) */
3785-
3786-
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
3787-
/**
3788-
* \brief Set the minimum length for Diffie-Hellman parameters.
3789-
* (Client-side only.)
3790-
* (Default: 1024 bits.)
3791-
*
3792-
* \param conf SSL configuration
3793-
* \param bitlen Minimum bit length of the DHM prime
3794-
*/
3795-
void mbedtls_ssl_conf_dhm_min_bitlen(mbedtls_ssl_config *conf,
3796-
unsigned int bitlen);
3797-
#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */
3798-
37993743
/**
38003744
* \brief Set the allowed groups in order of preference.
38013745
*

library/ssl_misc.h

-4
Original file line numberDiff line numberDiff line change
@@ -763,10 +763,6 @@ struct mbedtls_ssl_handshake_params {
763763
const uint16_t *sig_algs;
764764
#endif
765765

766-
#if defined(MBEDTLS_DHM_C)
767-
mbedtls_dhm_context dhm_ctx; /*!< DHM key exchange */
768-
#endif
769-
770766
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED)
771767
psa_key_type_t xxdh_psa_type;
772768
size_t xxdh_psa_bits;

library/ssl_tls.c

-86
Original file line numberDiff line numberDiff line change
@@ -911,9 +911,6 @@ static void ssl_handshake_params_init(mbedtls_ssl_handshake_params *handshake)
911911

912912
handshake->update_checksum = ssl_update_checksum_start;
913913

914-
#if defined(MBEDTLS_DHM_C)
915-
mbedtls_dhm_init(&handshake->dhm_ctx);
916-
#endif
917914
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
918915
handshake->psa_pake_ctx = psa_pake_operation_init();
919916
handshake->psa_pake_password = MBEDTLS_SVC_KEY_ID_INIT;
@@ -2431,57 +2428,6 @@ psa_status_t mbedtls_ssl_cipher_to_psa(mbedtls_cipher_type_t mbedtls_cipher_type
24312428
return PSA_SUCCESS;
24322429
}
24332430

2434-
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
2435-
int mbedtls_ssl_conf_dh_param_bin(mbedtls_ssl_config *conf,
2436-
const unsigned char *dhm_P, size_t P_len,
2437-
const unsigned char *dhm_G, size_t G_len)
2438-
{
2439-
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
2440-
2441-
mbedtls_mpi_free(&conf->dhm_P);
2442-
mbedtls_mpi_free(&conf->dhm_G);
2443-
2444-
if ((ret = mbedtls_mpi_read_binary(&conf->dhm_P, dhm_P, P_len)) != 0 ||
2445-
(ret = mbedtls_mpi_read_binary(&conf->dhm_G, dhm_G, G_len)) != 0) {
2446-
mbedtls_mpi_free(&conf->dhm_P);
2447-
mbedtls_mpi_free(&conf->dhm_G);
2448-
return ret;
2449-
}
2450-
2451-
return 0;
2452-
}
2453-
2454-
int mbedtls_ssl_conf_dh_param_ctx(mbedtls_ssl_config *conf, mbedtls_dhm_context *dhm_ctx)
2455-
{
2456-
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
2457-
2458-
mbedtls_mpi_free(&conf->dhm_P);
2459-
mbedtls_mpi_free(&conf->dhm_G);
2460-
2461-
if ((ret = mbedtls_dhm_get_value(dhm_ctx, MBEDTLS_DHM_PARAM_P,
2462-
&conf->dhm_P)) != 0 ||
2463-
(ret = mbedtls_dhm_get_value(dhm_ctx, MBEDTLS_DHM_PARAM_G,
2464-
&conf->dhm_G)) != 0) {
2465-
mbedtls_mpi_free(&conf->dhm_P);
2466-
mbedtls_mpi_free(&conf->dhm_G);
2467-
return ret;
2468-
}
2469-
2470-
return 0;
2471-
}
2472-
#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_SRV_C */
2473-
2474-
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
2475-
/*
2476-
* Set the minimum length for Diffie-Hellman parameters
2477-
*/
2478-
void mbedtls_ssl_conf_dhm_min_bitlen(mbedtls_ssl_config *conf,
2479-
unsigned int bitlen)
2480-
{
2481-
conf->dhm_min_bitlen = bitlen;
2482-
}
2483-
#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */
2484-
24852431
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
24862432
#if !defined(MBEDTLS_DEPRECATED_REMOVED) && defined(MBEDTLS_SSL_PROTO_TLS1_2)
24872433
/*
@@ -4537,10 +4483,6 @@ void mbedtls_ssl_handshake_free(mbedtls_ssl_context *ssl)
45374483
psa_hash_abort(&handshake->fin_sha384_psa);
45384484
#endif
45394485

4540-
#if defined(MBEDTLS_DHM_C)
4541-
mbedtls_dhm_free(&handshake->dhm_ctx);
4542-
#endif
4543-
45444486
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
45454487
psa_pake_abort(&handshake->psa_pake_ctx);
45464488
/*
@@ -5551,10 +5493,6 @@ static int ssl_check_no_sig_alg_duplication(const uint16_t *sig_algs)
55515493
int mbedtls_ssl_config_defaults(mbedtls_ssl_config *conf,
55525494
int endpoint, int transport, int preset)
55535495
{
5554-
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
5555-
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
5556-
#endif
5557-
55585496
#if defined(MBEDTLS_DEBUG_C) && defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
55595497
if (ssl_check_no_sig_alg_duplication(ssl_preset_suiteb_sig_algs)) {
55605498
mbedtls_printf("ssl_preset_suiteb_sig_algs has duplicated entries\n");
@@ -5629,21 +5567,6 @@ int mbedtls_ssl_config_defaults(mbedtls_ssl_config *conf,
56295567
memset(conf->renego_period + 2, 0xFF, 6);
56305568
#endif
56315569

5632-
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
5633-
if (endpoint == MBEDTLS_SSL_IS_SERVER) {
5634-
const unsigned char dhm_p[] =
5635-
MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN;
5636-
const unsigned char dhm_g[] =
5637-
MBEDTLS_DHM_RFC3526_MODP_2048_G_BIN;
5638-
5639-
if ((ret = mbedtls_ssl_conf_dh_param_bin(conf,
5640-
dhm_p, sizeof(dhm_p),
5641-
dhm_g, sizeof(dhm_g))) != 0) {
5642-
return ret;
5643-
}
5644-
}
5645-
#endif
5646-
56475570
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
56485571

56495572
#if defined(MBEDTLS_SSL_EARLY_DATA)
@@ -5733,10 +5656,6 @@ int mbedtls_ssl_config_defaults(mbedtls_ssl_config *conf,
57335656
#endif /* MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED */
57345657

57355658
conf->group_list = ssl_preset_default_groups;
5736-
5737-
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
5738-
conf->dhm_min_bitlen = 1024;
5739-
#endif
57405659
}
57415660

57425661
return 0;
@@ -5751,11 +5670,6 @@ void mbedtls_ssl_config_free(mbedtls_ssl_config *conf)
57515670
return;
57525671
}
57535672

5754-
#if defined(MBEDTLS_DHM_C)
5755-
mbedtls_mpi_free(&conf->dhm_P);
5756-
mbedtls_mpi_free(&conf->dhm_G);
5757-
#endif
5758-
57595673
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_PSK_ENABLED)
57605674
if (!mbedtls_svc_key_id_is_null(conf->psk_opaque)) {
57615675
conf->psk_opaque = MBEDTLS_SVC_KEY_ID_INIT;

0 commit comments

Comments
 (0)