Merge pull request #9954 from gabor-mezei-arm/9753_migrate_RSA_key_exchange_tests
Migrate RSA-decryption test cases
diff --git a/ChangeLog.d/9956.txt b/ChangeLog.d/9956.txt
new file mode 100644
index 0000000..cea4af1
--- /dev/null
+++ b/ChangeLog.d/9956.txt
@@ -0,0 +1,6 @@
+Removals
+ * Following the removal of DHM module (#9972 and TF-PSA-Crypto#175) the
+ following SSL functions are removed:
+ - mbedtls_ssl_conf_dh_param_bin
+ - mbedtls_ssl_conf_dh_param_ctx
+ - mbedtls_ssl_conf_dhm_min_bitlen
diff --git a/doxygen/input/doc_encdec.h b/doxygen/input/doc_encdec.h
index cf77690..068e716 100644
--- a/doxygen/input/doc_encdec.h
+++ b/doxygen/input/doc_encdec.h
@@ -39,8 +39,6 @@
* and \c mbedtls_des3_crypt_cbc()).
* - GCM (AES-GCM and CAMELLIA-GCM) (see \c mbedtls_gcm_init())
* - Asymmetric:
- * - Diffie-Hellman-Merkle (see \c mbedtls_dhm_read_public(), \c mbedtls_dhm_make_public()
- * and \c mbedtls_dhm_calc_secret()).
* - RSA (see \c mbedtls_rsa_public() and \c mbedtls_rsa_private()).
* - Elliptic Curves over GF(p) (see \c mbedtls_ecp_point_init()).
* - Elliptic Curve Digital Signature Algorithm (ECDSA) (see \c mbedtls_ecdsa_init()).
diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h
index e0c0eae..958ee9b 100644
--- a/include/mbedtls/ssl.h
+++ b/include/mbedtls/ssl.h
@@ -24,10 +24,6 @@
#include "mbedtls/x509_crl.h"
#endif
-#if defined(MBEDTLS_DHM_C)
-#include "mbedtls/dhm.h"
-#endif
-
#include "mbedtls/md.h"
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDH_OR_ECDHE_ANY_ENABLED)
@@ -1562,11 +1558,6 @@
const uint16_t *MBEDTLS_PRIVATE(group_list); /*!< allowed IANA NamedGroups */
-#if defined(MBEDTLS_DHM_C)
- mbedtls_mpi MBEDTLS_PRIVATE(dhm_P); /*!< prime modulus for DHM */
- mbedtls_mpi MBEDTLS_PRIVATE(dhm_G); /*!< generator for DHM */
-#endif
-
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_PSK_ENABLED)
mbedtls_svc_key_id_t MBEDTLS_PRIVATE(psk_opaque); /*!< PSA key slot holding opaque PSK. This field
@@ -1642,10 +1633,6 @@
unsigned int MBEDTLS_PRIVATE(badmac_limit); /*!< limit of records with a bad MAC */
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
- unsigned int MBEDTLS_PRIVATE(dhm_min_bitlen); /*!< min. bit length of the DHM prime */
-#endif
-
/** User data pointer or handle.
*
* The library sets this to \p 0 when creating a context and does not
@@ -3753,49 +3740,6 @@
#endif /* MBEDTLS_SSL_SRV_C */
#endif /* MBEDTLS_SSL_HANDSHAKE_WITH_PSK_ENABLED */
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
-/**
- * \brief Set the Diffie-Hellman public P and G values
- * from big-endian binary presentations.
- * (Default values: MBEDTLS_DHM_RFC3526_MODP_2048_[PG]_BIN)
- *
- * \param conf SSL configuration
- * \param dhm_P Diffie-Hellman-Merkle modulus in big-endian binary form
- * \param P_len Length of DHM modulus
- * \param dhm_G Diffie-Hellman-Merkle generator in big-endian binary form
- * \param G_len Length of DHM generator
- *
- * \return 0 if successful
- */
-int mbedtls_ssl_conf_dh_param_bin(mbedtls_ssl_config *conf,
- const unsigned char *dhm_P, size_t P_len,
- const unsigned char *dhm_G, size_t G_len);
-
-/**
- * \brief Set the Diffie-Hellman public P and G values,
- * read from existing context (server-side only)
- *
- * \param conf SSL configuration
- * \param dhm_ctx Diffie-Hellman-Merkle context
- *
- * \return 0 if successful
- */
-int mbedtls_ssl_conf_dh_param_ctx(mbedtls_ssl_config *conf, mbedtls_dhm_context *dhm_ctx);
-#endif /* MBEDTLS_DHM_C && defined(MBEDTLS_SSL_SRV_C) */
-
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
-/**
- * \brief Set the minimum length for Diffie-Hellman parameters.
- * (Client-side only.)
- * (Default: 1024 bits.)
- *
- * \param conf SSL configuration
- * \param bitlen Minimum bit length of the DHM prime
- */
-void mbedtls_ssl_conf_dhm_min_bitlen(mbedtls_ssl_config *conf,
- unsigned int bitlen);
-#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */
-
/**
* \brief Set the allowed groups in order of preference.
*
diff --git a/library/Makefile b/library/Makefile
index b874acf..61b2623 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -139,7 +139,6 @@
$(TF_PSA_CRYPTO_DRIVERS_BUILTIN_SRC_PATH)/constant_time.o \
$(TF_PSA_CRYPTO_DRIVERS_BUILTIN_SRC_PATH)/ctr_drbg.o \
$(TF_PSA_CRYPTO_DRIVERS_BUILTIN_SRC_PATH)/des.o \
- $(TF_PSA_CRYPTO_DRIVERS_BUILTIN_SRC_PATH)/dhm.o \
$(TF_PSA_CRYPTO_DRIVERS_BUILTIN_SRC_PATH)/ecdh.o \
$(TF_PSA_CRYPTO_DRIVERS_BUILTIN_SRC_PATH)/ecdsa.o \
$(TF_PSA_CRYPTO_DRIVERS_BUILTIN_SRC_PATH)/ecjpake.o \
diff --git a/library/ssl_misc.h b/library/ssl_misc.h
index 9f91861..9ff0fca 100644
--- a/library/ssl_misc.h
+++ b/library/ssl_misc.h
@@ -763,10 +763,6 @@
const uint16_t *sig_algs;
#endif
-#if defined(MBEDTLS_DHM_C)
- mbedtls_dhm_context dhm_ctx; /*!< DHM key exchange */
-#endif
-
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED)
psa_key_type_t xxdh_psa_type;
size_t xxdh_psa_bits;
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 60f2e1c..ec4272a 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -911,9 +911,6 @@
handshake->update_checksum = ssl_update_checksum_start;
-#if defined(MBEDTLS_DHM_C)
- mbedtls_dhm_init(&handshake->dhm_ctx);
-#endif
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
handshake->psa_pake_ctx = psa_pake_operation_init();
handshake->psa_pake_password = MBEDTLS_SVC_KEY_ID_INIT;
@@ -2431,57 +2428,6 @@
return PSA_SUCCESS;
}
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
-int mbedtls_ssl_conf_dh_param_bin(mbedtls_ssl_config *conf,
- const unsigned char *dhm_P, size_t P_len,
- const unsigned char *dhm_G, size_t G_len)
-{
- int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
-
- mbedtls_mpi_free(&conf->dhm_P);
- mbedtls_mpi_free(&conf->dhm_G);
-
- if ((ret = mbedtls_mpi_read_binary(&conf->dhm_P, dhm_P, P_len)) != 0 ||
- (ret = mbedtls_mpi_read_binary(&conf->dhm_G, dhm_G, G_len)) != 0) {
- mbedtls_mpi_free(&conf->dhm_P);
- mbedtls_mpi_free(&conf->dhm_G);
- return ret;
- }
-
- return 0;
-}
-
-int mbedtls_ssl_conf_dh_param_ctx(mbedtls_ssl_config *conf, mbedtls_dhm_context *dhm_ctx)
-{
- int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
-
- mbedtls_mpi_free(&conf->dhm_P);
- mbedtls_mpi_free(&conf->dhm_G);
-
- if ((ret = mbedtls_dhm_get_value(dhm_ctx, MBEDTLS_DHM_PARAM_P,
- &conf->dhm_P)) != 0 ||
- (ret = mbedtls_dhm_get_value(dhm_ctx, MBEDTLS_DHM_PARAM_G,
- &conf->dhm_G)) != 0) {
- mbedtls_mpi_free(&conf->dhm_P);
- mbedtls_mpi_free(&conf->dhm_G);
- return ret;
- }
-
- return 0;
-}
-#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_SRV_C */
-
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
-/*
- * Set the minimum length for Diffie-Hellman parameters
- */
-void mbedtls_ssl_conf_dhm_min_bitlen(mbedtls_ssl_config *conf,
- unsigned int bitlen)
-{
- conf->dhm_min_bitlen = bitlen;
-}
-#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */
-
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
#if !defined(MBEDTLS_DEPRECATED_REMOVED) && defined(MBEDTLS_SSL_PROTO_TLS1_2)
/*
@@ -4537,10 +4483,6 @@
psa_hash_abort(&handshake->fin_sha384_psa);
#endif
-#if defined(MBEDTLS_DHM_C)
- mbedtls_dhm_free(&handshake->dhm_ctx);
-#endif
-
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
psa_pake_abort(&handshake->psa_pake_ctx);
/*
@@ -5551,10 +5493,6 @@
int mbedtls_ssl_config_defaults(mbedtls_ssl_config *conf,
int endpoint, int transport, int preset)
{
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
- int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
-#endif
-
#if defined(MBEDTLS_DEBUG_C) && defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
if (ssl_check_no_sig_alg_duplication(ssl_preset_suiteb_sig_algs)) {
mbedtls_printf("ssl_preset_suiteb_sig_algs has duplicated entries\n");
@@ -5629,21 +5567,6 @@
memset(conf->renego_period + 2, 0xFF, 6);
#endif
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
- if (endpoint == MBEDTLS_SSL_IS_SERVER) {
- const unsigned char dhm_p[] =
- MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN;
- const unsigned char dhm_g[] =
- MBEDTLS_DHM_RFC3526_MODP_2048_G_BIN;
-
- if ((ret = mbedtls_ssl_conf_dh_param_bin(conf,
- dhm_p, sizeof(dhm_p),
- dhm_g, sizeof(dhm_g))) != 0) {
- return ret;
- }
- }
-#endif
-
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
#if defined(MBEDTLS_SSL_EARLY_DATA)
@@ -5733,10 +5656,6 @@
#endif /* MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED */
conf->group_list = ssl_preset_default_groups;
-
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
- conf->dhm_min_bitlen = 1024;
-#endif
}
return 0;
@@ -5751,11 +5670,6 @@
return;
}
-#if defined(MBEDTLS_DHM_C)
- mbedtls_mpi_free(&conf->dhm_P);
- mbedtls_mpi_free(&conf->dhm_G);
-#endif
-
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_PSK_ENABLED)
if (!mbedtls_svc_key_id_is_null(conf->psk_opaque)) {
conf->psk_opaque = MBEDTLS_SVC_KEY_ID_INIT;
diff --git a/programs/Makefile b/programs/Makefile
index 79bb402..9a4237c 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -41,9 +41,7 @@
hash/generic_sum \
hash/hello \
hash/md_hmac_demo \
- pkey/dh_client \
pkey/dh_genprime \
- pkey/dh_server \
pkey/ecdh_curve25519 \
pkey/ecdsa \
pkey/gen_key \
@@ -177,18 +175,10 @@
echo " CC hash/md_hmac_demo.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) hash/md_hmac_demo.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
-pkey/dh_client$(EXEXT): pkey/dh_client.c $(DEP)
- echo " CC pkey/dh_client.c"
- $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/dh_client.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
-
pkey/dh_genprime$(EXEXT): pkey/dh_genprime.c $(DEP)
echo " CC pkey/dh_genprime.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/dh_genprime.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
-pkey/dh_server$(EXEXT): pkey/dh_server.c $(DEP)
- echo " CC pkey/dh_server.c"
- $(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/dh_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
-
pkey/ecdh_curve25519$(EXEXT): pkey/ecdh_curve25519.c $(DEP)
echo " CC pkey/ecdh_curve25519.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/ecdh_curve25519.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
diff --git a/programs/README.md b/programs/README.md
index 5e5f40a..2d9c187 100644
--- a/programs/README.md
+++ b/programs/README.md
@@ -41,8 +41,6 @@
### Diffie-Hellman key exchange examples
-* [`pkey/dh_client.c`](pkey/dh_client.c), [`pkey/dh_server.c`](pkey/dh_server.c): secure channel demonstrators (client, server). This pair of programs illustrates how to set up a secure channel using RSA for authentication and Diffie-Hellman to generate a shared AES session key.
-
* [`pkey/ecdh_curve25519.c`](pkey/ecdh_curve25519.c): demonstration of a elliptic curve Diffie-Hellman (ECDH) key agreement.
### Bignum (`mpi`) usage examples
diff --git a/programs/pkey/CMakeLists.txt b/programs/pkey/CMakeLists.txt
index c782ad4..df63ffc 100644
--- a/programs/pkey/CMakeLists.txt
+++ b/programs/pkey/CMakeLists.txt
@@ -1,16 +1,3 @@
-set(executables_mbedtls
- dh_client
- dh_server
-)
-add_dependencies(${programs_target} ${executables_mbedtls})
-
-foreach(exe IN LISTS executables_mbedtls)
- add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
- set_base_compile_options(${exe})
- target_link_libraries(${exe} ${mbedtls_target} ${CMAKE_THREAD_LIBS_INIT})
- target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
-endforeach()
-
set(executables_mbedcrypto
dh_genprime
ecdh_curve25519
@@ -40,6 +27,6 @@
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
endforeach()
-install(TARGETS ${executables_mbedtls} ${executables_mbedcrypto}
+install(TARGETS ${executables_mbedcrypto}
DESTINATION "bin"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
diff --git a/programs/pkey/dh_client.c b/programs/pkey/dh_client.c
deleted file mode 100644
index a3bc49d..0000000
--- a/programs/pkey/dh_client.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Diffie-Hellman-Merkle key exchange (client side)
- *
- * Copyright The Mbed TLS Contributors
- * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
- */
-
-#include "mbedtls/build_info.h"
-
-#include "mbedtls/platform.h"
-/* md.h is included this early since MD_CAN_XXX macros are defined there. */
-#include "mbedtls/md.h"
-
-#if defined(MBEDTLS_AES_C) && defined(MBEDTLS_DHM_C) && \
- defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_NET_C) && \
- defined(MBEDTLS_RSA_C) && defined(MBEDTLS_SHA256_C) && \
- defined(MBEDTLS_FS_IO) && defined(MBEDTLS_CTR_DRBG_C)
-#include "mbedtls/net_sockets.h"
-#include "mbedtls/aes.h"
-#include "mbedtls/dhm.h"
-#include "mbedtls/rsa.h"
-#include "mbedtls/sha256.h"
-#include "mbedtls/entropy.h"
-#include "mbedtls/ctr_drbg.h"
-
-#include <stdio.h>
-#include <string.h>
-#endif
-
-#define SERVER_NAME "localhost"
-#define SERVER_PORT "11999"
-
-#if !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_DHM_C) || \
- !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NET_C) || \
- !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_SHA256_C) || \
- !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_CTR_DRBG_C)
-int main(void)
-{
- mbedtls_printf("MBEDTLS_AES_C and/or MBEDTLS_DHM_C and/or MBEDTLS_ENTROPY_C "
- "and/or MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
- "PSA_WANT_ALG_SHA_256 and/or MBEDTLS_FS_IO and/or "
- "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_SHA1_C not defined.\n");
- mbedtls_exit(0);
-}
-
-#elif defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
-int main(void)
-{
- mbedtls_printf("MBEDTLS_BLOCK_CIPHER_NO_DECRYPT defined.\n");
- mbedtls_exit(0);
-}
-#else
-
-
-int main(void)
-{
- FILE *f;
-
- int ret = 1;
- int exit_code = MBEDTLS_EXIT_FAILURE;
- unsigned int mdlen;
- size_t n, buflen;
- mbedtls_net_context server_fd;
-
- unsigned char *p, *end;
- unsigned char buf[2048];
- unsigned char hash[MBEDTLS_MD_MAX_SIZE];
- mbedtls_mpi N, E;
- const char *pers = "dh_client";
-
- mbedtls_entropy_context entropy;
- mbedtls_ctr_drbg_context ctr_drbg;
- mbedtls_rsa_context rsa;
- mbedtls_dhm_context dhm;
- mbedtls_aes_context aes;
-
- mbedtls_net_init(&server_fd);
- mbedtls_dhm_init(&dhm);
- mbedtls_aes_init(&aes);
- mbedtls_ctr_drbg_init(&ctr_drbg);
- mbedtls_mpi_init(&N);
- mbedtls_mpi_init(&E);
-
- /*
- * 1. Setup the RNG
- */
- mbedtls_printf("\n . Seeding the random number generator");
- fflush(stdout);
-
- mbedtls_entropy_init(&entropy);
- if ((ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
- (const unsigned char *) pers,
- strlen(pers))) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret);
- goto exit;
- }
-
- /*
- * 2. Read the server's public RSA key
- */
- mbedtls_printf("\n . Reading public key from rsa_pub.txt");
- fflush(stdout);
-
- if ((f = fopen("rsa_pub.txt", "rb")) == NULL) {
- mbedtls_printf(" failed\n ! Could not open rsa_pub.txt\n" \
- " ! Please run rsa_genkey first\n\n");
- goto exit;
- }
-
- mbedtls_rsa_init(&rsa);
- if ((ret = mbedtls_mpi_read_file(&N, 16, f)) != 0 ||
- (ret = mbedtls_mpi_read_file(&E, 16, f)) != 0 ||
- (ret = mbedtls_rsa_import(&rsa, &N, NULL, NULL, NULL, &E) != 0)) {
- mbedtls_printf(" failed\n ! mbedtls_mpi_read_file returned %d\n\n", ret);
- fclose(f);
- goto exit;
- }
- fclose(f);
-
- /*
- * 3. Initiate the connection
- */
- mbedtls_printf("\n . Connecting to tcp/%s/%s", SERVER_NAME,
- SERVER_PORT);
- fflush(stdout);
-
- if ((ret = mbedtls_net_connect(&server_fd, SERVER_NAME,
- SERVER_PORT, MBEDTLS_NET_PROTO_TCP)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_net_connect returned %d\n\n", ret);
- goto exit;
- }
-
- /*
- * 4a. First get the buffer length
- */
- mbedtls_printf("\n . Receiving the server's DH parameters");
- fflush(stdout);
-
- memset(buf, 0, sizeof(buf));
-
- if ((ret = mbedtls_net_recv(&server_fd, buf, 2)) != 2) {
- mbedtls_printf(" failed\n ! mbedtls_net_recv returned %d\n\n", ret);
- goto exit;
- }
-
- n = buflen = (buf[0] << 8) | buf[1];
- if (buflen < 1 || buflen > sizeof(buf)) {
- mbedtls_printf(" failed\n ! Got an invalid buffer length\n\n");
- goto exit;
- }
-
- /*
- * 4b. Get the DHM parameters: P, G and Ys = G^Xs mod P
- */
- memset(buf, 0, sizeof(buf));
-
- if ((ret = mbedtls_net_recv(&server_fd, buf, n)) != (int) n) {
- mbedtls_printf(" failed\n ! mbedtls_net_recv returned %d\n\n", ret);
- goto exit;
- }
-
- p = buf, end = buf + buflen;
-
- if ((ret = mbedtls_dhm_read_params(&dhm, &p, end)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_dhm_read_params returned %d\n\n", ret);
- goto exit;
- }
-
- n = mbedtls_dhm_get_len(&dhm);
- if (n < 64 || n > 512) {
- mbedtls_printf(" failed\n ! Invalid DHM modulus size\n\n");
- goto exit;
- }
-
- /*
- * 5. Check that the server's RSA signature matches
- * the SHA-256 hash of (P,G,Ys)
- */
- mbedtls_printf("\n . Verifying the server's RSA signature");
- fflush(stdout);
-
- p += 2;
-
- if ((n = (size_t) (end - p)) != mbedtls_rsa_get_len(&rsa)) {
- mbedtls_printf(" failed\n ! Invalid RSA signature size\n\n");
- goto exit;
- }
-
- mdlen = (unsigned int) mbedtls_md_get_size(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256));
- if (mdlen == 0) {
- mbedtls_printf(" failed\n ! Invalid digest type\n\n");
- goto exit;
- }
-
- if ((ret = mbedtls_sha256(buf, (int) (p - 2 - buf), hash, 0)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_sha256 returned %d\n\n", ret);
- goto exit;
- }
-
- if ((ret = mbedtls_rsa_pkcs1_verify(&rsa, MBEDTLS_MD_SHA256,
- mdlen, hash, p)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_rsa_pkcs1_verify returned %d\n\n", ret);
- goto exit;
- }
-
- /*
- * 6. Send our public value: Yc = G ^ Xc mod P
- */
- mbedtls_printf("\n . Sending own public value to server");
- fflush(stdout);
-
- n = mbedtls_dhm_get_len(&dhm);
- if ((ret = mbedtls_dhm_make_public(&dhm, (int) n, buf, n,
- mbedtls_ctr_drbg_random, &ctr_drbg)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_dhm_make_public returned %d\n\n", ret);
- goto exit;
- }
-
- if ((ret = mbedtls_net_send(&server_fd, buf, n)) != (int) n) {
- mbedtls_printf(" failed\n ! mbedtls_net_send returned %d\n\n", ret);
- goto exit;
- }
-
- /*
- * 7. Derive the shared secret: K = Ys ^ Xc mod P
- */
- mbedtls_printf("\n . Shared secret: ");
- fflush(stdout);
-
- if ((ret = mbedtls_dhm_calc_secret(&dhm, buf, sizeof(buf), &n,
- mbedtls_ctr_drbg_random, &ctr_drbg)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_dhm_calc_secret returned %d\n\n", ret);
- goto exit;
- }
-
- for (n = 0; n < 16; n++) {
- mbedtls_printf("%02x", buf[n]);
- }
-
- /*
- * 8. Setup the AES-256 decryption key
- *
- * This is an overly simplified example; best practice is
- * to hash the shared secret with a random value to derive
- * the keying material for the encryption/decryption keys,
- * IVs and MACs.
- */
- mbedtls_printf("...\n . Receiving and decrypting the ciphertext");
- fflush(stdout);
-
- ret = mbedtls_aes_setkey_dec(&aes, buf, 256);
- if (ret != 0) {
- goto exit;
- }
-
- memset(buf, 0, sizeof(buf));
-
- if ((ret = mbedtls_net_recv(&server_fd, buf, 16)) != 16) {
- mbedtls_printf(" failed\n ! mbedtls_net_recv returned %d\n\n", ret);
- goto exit;
- }
-
- ret = mbedtls_aes_crypt_ecb(&aes, MBEDTLS_AES_DECRYPT, buf, buf);
- if (ret != 0) {
- goto exit;
- }
- buf[16] = '\0';
- mbedtls_printf("\n . Plaintext is \"%s\"\n\n", (char *) buf);
-
- exit_code = MBEDTLS_EXIT_SUCCESS;
-
-exit:
-
- mbedtls_net_free(&server_fd);
-
- mbedtls_aes_free(&aes);
- mbedtls_rsa_free(&rsa);
- mbedtls_dhm_free(&dhm);
- mbedtls_ctr_drbg_free(&ctr_drbg);
- mbedtls_entropy_free(&entropy);
- mbedtls_mpi_free(&N);
- mbedtls_mpi_free(&E);
-
- mbedtls_exit(exit_code);
-}
-#endif /* MBEDTLS_AES_C && MBEDTLS_DHM_C && MBEDTLS_ENTROPY_C &&
- MBEDTLS_NET_C && MBEDTLS_RSA_C && PSA_WANT_ALG_SHA_256 &&
- MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */
diff --git a/programs/pkey/dh_server.c b/programs/pkey/dh_server.c
deleted file mode 100644
index 26b48e3..0000000
--- a/programs/pkey/dh_server.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Diffie-Hellman-Merkle key exchange (server side)
- *
- * Copyright The Mbed TLS Contributors
- * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
- */
-
-#include "mbedtls/build_info.h"
-
-#include "mbedtls/platform.h"
-/* md.h is included this early since MD_CAN_XXX macros are defined there. */
-#include "mbedtls/md.h"
-
-#if defined(MBEDTLS_AES_C) && defined(MBEDTLS_DHM_C) && \
- defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_NET_C) && \
- defined(MBEDTLS_RSA_C) && defined(MBEDTLS_SHA256_C) && \
- defined(MBEDTLS_FS_IO) && defined(MBEDTLS_CTR_DRBG_C)
-#include "mbedtls/net_sockets.h"
-#include "mbedtls/aes.h"
-#include "mbedtls/dhm.h"
-#include "mbedtls/rsa.h"
-#include "mbedtls/sha256.h"
-#include "mbedtls/entropy.h"
-#include "mbedtls/ctr_drbg.h"
-
-#include <stdio.h>
-#include <string.h>
-#endif
-
-#define SERVER_PORT "11999"
-#define PLAINTEXT "==Hello there!=="
-
-#if !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_DHM_C) || \
- !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NET_C) || \
- !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_SHA256_C) || \
- !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_CTR_DRBG_C)
-int main(void)
-{
- mbedtls_printf("MBEDTLS_AES_C and/or MBEDTLS_DHM_C and/or MBEDTLS_ENTROPY_C "
- "and/or MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
- "PSA_WANT_ALG_SHA_256 and/or MBEDTLS_FS_IO and/or "
- "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_SHA1_C not defined.\n");
- mbedtls_exit(0);
-}
-#else
-
-
-int main(void)
-{
- FILE *f;
-
- int ret = 1;
- int exit_code = MBEDTLS_EXIT_FAILURE;
- unsigned int mdlen;
- size_t n, buflen;
- mbedtls_net_context listen_fd, client_fd;
-
- unsigned char buf[2048];
- unsigned char hash[MBEDTLS_MD_MAX_SIZE];
- unsigned char buf2[2];
- const char *pers = "dh_server";
-
- mbedtls_entropy_context entropy;
- mbedtls_ctr_drbg_context ctr_drbg;
- mbedtls_rsa_context rsa;
- mbedtls_dhm_context dhm;
- mbedtls_aes_context aes;
-
- mbedtls_mpi N, P, Q, D, E, dhm_P, dhm_G;
-
- mbedtls_net_init(&listen_fd);
- mbedtls_net_init(&client_fd);
- mbedtls_dhm_init(&dhm);
- mbedtls_aes_init(&aes);
- mbedtls_ctr_drbg_init(&ctr_drbg);
-
- mbedtls_mpi_init(&N); mbedtls_mpi_init(&P); mbedtls_mpi_init(&Q);
- mbedtls_mpi_init(&D); mbedtls_mpi_init(&E); mbedtls_mpi_init(&dhm_P);
- mbedtls_mpi_init(&dhm_G);
- /*
- * 1. Setup the RNG
- */
- mbedtls_printf("\n . Seeding the random number generator");
- fflush(stdout);
-
- mbedtls_entropy_init(&entropy);
- if ((ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
- (const unsigned char *) pers,
- strlen(pers))) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret);
- goto exit;
- }
-
- /*
- * 2a. Read the server's private RSA key
- */
- mbedtls_printf("\n . Reading private key from rsa_priv.txt");
- fflush(stdout);
-
- if ((f = fopen("rsa_priv.txt", "rb")) == NULL) {
- mbedtls_printf(" failed\n ! Could not open rsa_priv.txt\n" \
- " ! Please run rsa_genkey first\n\n");
- goto exit;
- }
-
- mbedtls_rsa_init(&rsa);
-
- if ((ret = mbedtls_mpi_read_file(&N, 16, f)) != 0 ||
- (ret = mbedtls_mpi_read_file(&E, 16, f)) != 0 ||
- (ret = mbedtls_mpi_read_file(&D, 16, f)) != 0 ||
- (ret = mbedtls_mpi_read_file(&P, 16, f)) != 0 ||
- (ret = mbedtls_mpi_read_file(&Q, 16, f)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_mpi_read_file returned %d\n\n",
- ret);
- fclose(f);
- goto exit;
- }
- fclose(f);
-
- if ((ret = mbedtls_rsa_import(&rsa, &N, &P, &Q, &D, &E)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_rsa_import returned %d\n\n",
- ret);
- goto exit;
- }
-
- if ((ret = mbedtls_rsa_complete(&rsa)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_rsa_complete returned %d\n\n",
- ret);
- goto exit;
- }
-
- /*
- * 2b. Get the DHM modulus and generator
- */
- mbedtls_printf("\n . Reading DH parameters from dh_prime.txt");
- fflush(stdout);
-
- if ((f = fopen("dh_prime.txt", "rb")) == NULL) {
- mbedtls_printf(" failed\n ! Could not open dh_prime.txt\n" \
- " ! Please run dh_genprime first\n\n");
- goto exit;
- }
-
- if ((ret = mbedtls_mpi_read_file(&dhm_P, 16, f)) != 0 ||
- (ret = mbedtls_mpi_read_file(&dhm_G, 16, f)) != 0 ||
- (ret = mbedtls_dhm_set_group(&dhm, &dhm_P, &dhm_G) != 0)) {
- mbedtls_printf(" failed\n ! Invalid DH parameter file\n\n");
- fclose(f);
- goto exit;
- }
-
- fclose(f);
-
- /*
- * 3. Wait for a client to connect
- */
- mbedtls_printf("\n . Waiting for a remote connection");
- fflush(stdout);
-
- if ((ret = mbedtls_net_bind(&listen_fd, NULL, SERVER_PORT, MBEDTLS_NET_PROTO_TCP)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_net_bind returned %d\n\n", ret);
- goto exit;
- }
-
- if ((ret = mbedtls_net_accept(&listen_fd, &client_fd,
- NULL, 0, NULL)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_net_accept returned %d\n\n", ret);
- goto exit;
- }
-
- /*
- * 4. Setup the DH parameters (P,G,Ys)
- */
- mbedtls_printf("\n . Sending the server's DH parameters");
- fflush(stdout);
-
- memset(buf, 0, sizeof(buf));
-
- if ((ret =
- mbedtls_dhm_make_params(&dhm, (int) mbedtls_dhm_get_len(&dhm), buf, &n,
- mbedtls_ctr_drbg_random, &ctr_drbg)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_dhm_make_params returned %d\n\n", ret);
- goto exit;
- }
-
- /*
- * 5. Sign the parameters and send them
- */
-
- mdlen = (unsigned int) mbedtls_md_get_size(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256));
- if (mdlen == 0) {
- mbedtls_printf(" failed\n ! Invalid digest type\n\n");
- goto exit;
- }
-
- if ((ret = mbedtls_sha256(buf, n, hash, 0)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_sha256 returned %d\n\n", ret);
- goto exit;
- }
-
- const size_t rsa_key_len = mbedtls_rsa_get_len(&rsa);
- buf[n] = (unsigned char) (rsa_key_len >> 8);
- buf[n + 1] = (unsigned char) (rsa_key_len);
-
- if ((ret = mbedtls_rsa_pkcs1_sign(&rsa, mbedtls_ctr_drbg_random, &ctr_drbg,
- MBEDTLS_MD_SHA256, mdlen,
- hash, buf + n + 2)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_rsa_pkcs1_sign returned %d\n\n", ret);
- goto exit;
- }
-
- buflen = n + 2 + rsa_key_len;
- buf2[0] = (unsigned char) (buflen >> 8);
- buf2[1] = (unsigned char) (buflen);
-
- if ((ret = mbedtls_net_send(&client_fd, buf2, 2)) != 2 ||
- (ret = mbedtls_net_send(&client_fd, buf, buflen)) != (int) buflen) {
- mbedtls_printf(" failed\n ! mbedtls_net_send returned %d\n\n", ret);
- goto exit;
- }
-
- /*
- * 6. Get the client's public value: Yc = G ^ Xc mod P
- */
- mbedtls_printf("\n . Receiving the client's public value");
- fflush(stdout);
-
- memset(buf, 0, sizeof(buf));
-
- n = mbedtls_dhm_get_len(&dhm);
- if ((ret = mbedtls_net_recv(&client_fd, buf, n)) != (int) n) {
- mbedtls_printf(" failed\n ! mbedtls_net_recv returned %d\n\n", ret);
- goto exit;
- }
-
- if ((ret = mbedtls_dhm_read_public(&dhm, buf, n)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_dhm_read_public returned %d\n\n", ret);
- goto exit;
- }
-
- /*
- * 7. Derive the shared secret: K = Ys ^ Xc mod P
- */
- mbedtls_printf("\n . Shared secret: ");
- fflush(stdout);
-
- if ((ret = mbedtls_dhm_calc_secret(&dhm, buf, sizeof(buf), &n,
- mbedtls_ctr_drbg_random, &ctr_drbg)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_dhm_calc_secret returned %d\n\n", ret);
- goto exit;
- }
-
- for (n = 0; n < 16; n++) {
- mbedtls_printf("%02x", buf[n]);
- }
-
- /*
- * 8. Setup the AES-256 encryption key
- *
- * This is an overly simplified example; best practice is
- * to hash the shared secret with a random value to derive
- * the keying material for the encryption/decryption keys
- * and MACs.
- */
- mbedtls_printf("...\n . Encrypting and sending the ciphertext");
- fflush(stdout);
-
- ret = mbedtls_aes_setkey_enc(&aes, buf, 256);
- if (ret != 0) {
- goto exit;
- }
- memcpy(buf, PLAINTEXT, 16);
- ret = mbedtls_aes_crypt_ecb(&aes, MBEDTLS_AES_ENCRYPT, buf, buf);
- if (ret != 0) {
- goto exit;
- }
-
- if ((ret = mbedtls_net_send(&client_fd, buf, 16)) != 16) {
- mbedtls_printf(" failed\n ! mbedtls_net_send returned %d\n\n", ret);
- goto exit;
- }
-
- mbedtls_printf("\n\n");
-
- exit_code = MBEDTLS_EXIT_SUCCESS;
-
-exit:
-
- mbedtls_mpi_free(&N); mbedtls_mpi_free(&P); mbedtls_mpi_free(&Q);
- mbedtls_mpi_free(&D); mbedtls_mpi_free(&E); mbedtls_mpi_free(&dhm_P);
- mbedtls_mpi_free(&dhm_G);
-
- mbedtls_net_free(&client_fd);
- mbedtls_net_free(&listen_fd);
-
- mbedtls_aes_free(&aes);
- mbedtls_rsa_free(&rsa);
- mbedtls_dhm_free(&dhm);
- mbedtls_ctr_drbg_free(&ctr_drbg);
- mbedtls_entropy_free(&entropy);
-
- mbedtls_exit(exit_code);
-}
-#endif /* MBEDTLS_AES_C && MBEDTLS_DHM_C && MBEDTLS_ENTROPY_C &&
- MBEDTLS_NET_C && MBEDTLS_RSA_C && PSA_WANT_ALG_SHA_256 &&
- MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */
diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c
index f009a31..6742925 100644
--- a/programs/ssl/ssl_client2.c
+++ b/programs/ssl/ssl_client2.c
@@ -71,7 +71,6 @@
#define DFL_MFL_CODE MBEDTLS_SSL_MAX_FRAG_LEN_NONE
#define DFL_TRUNC_HMAC -1
#define DFL_RECSPLIT -1
-#define DFL_DHMLEN -1
#define DFL_RECONNECT 0
#define DFL_RECO_SERVER_NAME NULL
#define DFL_RECO_DELAY 0
@@ -234,13 +233,6 @@
#define USAGE_MAX_FRAG_LEN ""
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
-#if defined(MBEDTLS_DHM_C)
-#define USAGE_DHMLEN \
- " dhmlen=%%d default: (library default: 1024 bits)\n"
-#else
-#define USAGE_DHMLEN
-#endif
-
#if defined(MBEDTLS_SSL_ALPN)
#define USAGE_ALPN \
" alpn=%%s default: \"\" (disabled)\n" \
@@ -433,7 +425,6 @@
USAGE_GROUPS \
USAGE_SIG_ALGS \
USAGE_EARLY_DATA \
- USAGE_DHMLEN \
USAGE_KEY_OPAQUE_ALGS \
"\n"
@@ -508,7 +499,6 @@
unsigned char mfl_code; /* code for maximum fragment length */
int trunc_hmac; /* negotiate truncated hmac or not */
int recsplit; /* enable record splitting? */
- int dhmlen; /* minimum DHM params len in bits */
int reconnect; /* attempt to resume session */
const char *reco_server_name; /* hostname of the server (re-connect) */
int reco_delay; /* delay in seconds before resuming session */
@@ -956,7 +946,6 @@
opt.mfl_code = DFL_MFL_CODE;
opt.trunc_hmac = DFL_TRUNC_HMAC;
opt.recsplit = DFL_RECSPLIT;
- opt.dhmlen = DFL_DHMLEN;
opt.reconnect = DFL_RECONNECT;
opt.reco_server_name = DFL_RECO_SERVER_NAME;
opt.reco_delay = DFL_RECO_DELAY;
@@ -1388,11 +1377,6 @@
if (opt.recsplit < 0 || opt.recsplit > 1) {
goto usage;
}
- } else if (strcmp(p, "dhmlen") == 0) {
- opt.dhmlen = atoi(q);
- if (opt.dhmlen < 0) {
- goto usage;
- }
} else if (strcmp(p, "query_config") == 0) {
opt.query_config_mode = 1;
query_config_ret = query_config(q);
@@ -1898,12 +1882,6 @@
}
#endif
-#if defined(MBEDTLS_DHM_C)
- if (opt.dhmlen != DFL_DHMLEN) {
- mbedtls_ssl_conf_dhm_min_bitlen(&conf, opt.dhmlen);
- }
-#endif
-
#if defined(MBEDTLS_SSL_ALPN)
if (opt.alpn_string != NULL) {
if ((ret = mbedtls_ssl_conf_alpn_protocols(&conf, alpn_list)) != 0) {
diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c
index d9e5701..dc7ca8f 100644
--- a/programs/ssl/ssl_server2.c
+++ b/programs/ssl/ssl_server2.c
@@ -58,7 +58,6 @@
#endif
#include "mbedtls/pk.h"
-#include "mbedtls/dhm.h"
/* Size of memory to be allocated for the heap, when using the library's memory
* management and MBEDTLS_MEMORY_BUFFER_ALLOC_C is enabled. */
@@ -127,7 +126,6 @@
#define DFL_EARLY_DATA -1
#define DFL_MAX_EARLY_DATA_SIZE ((uint32_t) -1)
#define DFL_SIG_ALGS NULL
-#define DFL_DHM_FILE NULL
#define DFL_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM
#define DFL_COOKIES 1
#define DFL_ANTI_REPLAY -1
@@ -192,9 +190,7 @@
" note: if neither crt_file/key_file nor crt_file2/key_file2 are used,\n" \
" preloaded certificate(s) and key(s) are used if available\n" \
" key_pwd2=%%s Password for key specified by key_file2 argument\n" \
- " default: none\n" \
- " dhm_file=%%s File containing Diffie-Hellman parameters\n" \
- " default: preloaded parameters\n"
+ " default: none\n"
#else
#define USAGE_IO \
"\n" \
@@ -675,7 +671,6 @@
const char *groups; /* list of supported groups */
const char *sig_algs; /* supported TLS 1.3 signature algorithms */
const char *alpn_string; /* ALPN supported protocols */
- const char *dhm_file; /* the file with the DH parameters */
int extended_ms; /* allow negotiation of extended MS? */
int etm; /* allow negotiation of encrypt-then-MAC? */
int transport; /* TLS or DTLS? */
@@ -1590,9 +1585,6 @@
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
ssl_async_key_context_t ssl_async_keys;
#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO)
- mbedtls_dhm_context dhm;
-#endif
#if defined(MBEDTLS_SSL_CACHE_C)
mbedtls_ssl_cache_context cache;
#endif
@@ -1681,9 +1673,6 @@
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
memset(&ssl_async_keys, 0, sizeof(ssl_async_keys));
#endif
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO)
- mbedtls_dhm_init(&dhm);
-#endif
#if defined(MBEDTLS_SSL_CACHE_C)
mbedtls_ssl_cache_init(&cache);
#endif
@@ -1793,7 +1782,6 @@
opt.max_early_data_size = DFL_MAX_EARLY_DATA_SIZE;
#endif
opt.sig_algs = DFL_SIG_ALGS;
- opt.dhm_file = DFL_DHM_FILE;
opt.transport = DFL_TRANSPORT;
opt.cookies = DFL_COOKIES;
opt.anti_replay = DFL_ANTI_REPLAY;
@@ -1943,8 +1931,6 @@
opt.key_file2 = q;
} else if (strcmp(p, "key_pwd2") == 0) {
opt.key_pwd2 = q;
- } else if (strcmp(p, "dhm_file") == 0) {
- opt.dhm_file = q;
}
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
else if (strcmp(p, "async_operations") == 0) {
@@ -2787,21 +2773,6 @@
key_cert_init2 ? mbedtls_pk_get_name(&pkey2) : "none");
#endif /* MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED */
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO)
- if (opt.dhm_file != NULL) {
- mbedtls_printf(" . Loading DHM parameters...");
- fflush(stdout);
-
- if ((ret = mbedtls_dhm_parse_dhmfile(&dhm, opt.dhm_file)) != 0) {
- mbedtls_printf(" failed\n ! mbedtls_dhm_parse_dhmfile returned -0x%04X\n\n",
- (unsigned int) -ret);
- goto exit;
- }
-
- mbedtls_printf(" ok\n");
- }
-#endif
-
#if defined(SNI_OPTION)
if (opt.sni != NULL) {
mbedtls_printf(" . Setting up SNI information...");
@@ -3269,22 +3240,6 @@
}
#endif
-#if defined(MBEDTLS_DHM_C)
- /*
- * Use different group than default DHM group
- */
-#if defined(MBEDTLS_FS_IO)
- if (opt.dhm_file != NULL) {
- ret = mbedtls_ssl_conf_dh_param_ctx(&conf, &dhm);
- }
-#endif
- if (ret != 0) {
- mbedtls_printf(" failed\n mbedtls_ssl_conf_dh_param returned -0x%04X\n\n",
- (unsigned int) -ret);
- goto exit;
- }
-#endif
-
if (opt.min_version != DFL_MIN_VERSION) {
mbedtls_ssl_conf_min_tls_version(&conf, opt.min_version);
}
@@ -4284,10 +4239,6 @@
#endif
#endif
-#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO)
- mbedtls_dhm_free(&dhm);
-#endif
-
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
for (i = 0; (size_t) i < ssl_async_keys.slots_used; i++) {
if (ssl_async_keys.slots[i].pk_owned) {
diff --git a/programs/test/selftest.c b/programs/test/selftest.c
index e72386f..41252b6 100644
--- a/programs/test/selftest.c
+++ b/programs/test/selftest.c
@@ -10,7 +10,6 @@
#include "mbedtls/entropy.h"
#include "mbedtls/hmac_drbg.h"
#include "mbedtls/ctr_drbg.h"
-#include "mbedtls/dhm.h"
#include "mbedtls/gcm.h"
#include "mbedtls/ccm.h"
#include "mbedtls/cmac.h"
@@ -350,9 +349,6 @@
#if defined(MBEDTLS_ECJPAKE_C)
{ "ecjpake", mbedtls_ecjpake_self_test },
#endif
-#if defined(MBEDTLS_DHM_C)
- { "dhm", mbedtls_dhm_self_test },
-#endif
#if defined(MBEDTLS_ENTROPY_C)
{ "entropy", mbedtls_entropy_self_test_wrapper },
#endif
diff --git a/scripts/data_files/query_config.fmt b/scripts/data_files/query_config.fmt
index b60aba0..9be9674 100644
--- a/scripts/data_files/query_config.fmt
+++ b/scripts/data_files/query_config.fmt
@@ -34,7 +34,6 @@
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/debug.h"
#include "mbedtls/des.h"
-#include "mbedtls/dhm.h"
#include "mbedtls/ecdh.h"
#include "mbedtls/ecdsa.h"
#include "mbedtls/ecjpake.h"
diff --git a/scripts/generate_errors.pl b/scripts/generate_errors.pl
index c051842..aae1fc8 100755
--- a/scripts/generate_errors.pl
+++ b/scripts/generate_errors.pl
@@ -40,7 +40,7 @@
ENTROPY ERROR GCM HKDF HMAC_DRBG LMS MD5
NET OID PBKDF2 PLATFORM POLY1305 RIPEMD160
SHA1 SHA256 SHA512 SHA3 THREADING );
-my @high_level_modules = qw( CIPHER DHM ECP MD
+my @high_level_modules = qw( CIPHER ECP MD
PEM PK PKCS12 PKCS5
RSA SSL X509 PKCS7 );
diff --git a/tests/include/test/certs.h b/tests/include/test/certs.h
index db69536..31f4477 100644
--- a/tests/include/test/certs.h
+++ b/tests/include/test/certs.h
@@ -1,7 +1,7 @@
/**
* \file certs.h
*
- * \brief Sample certificates and DHM parameters for testing
+ * \brief Sample certificates for testing
*/
/*
* Copyright The Mbed TLS Contributors
diff --git a/tests/scripts/analyze_outcomes.py b/tests/scripts/analyze_outcomes.py
index e68c2cb..5f8f910 100755
--- a/tests/scripts/analyze_outcomes.py
+++ b/tests/scripts/analyze_outcomes.py
@@ -474,7 +474,7 @@
DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
IGNORED_SUITES = [
# Modules replaced by drivers
- 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
+ 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
'bignum.generated', 'bignum.misc',
# Unit tests for the built-in implementation
@@ -483,7 +483,6 @@
IGNORED_TESTS = {
'test_suite_config': [
re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
- re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
],
@@ -516,11 +515,7 @@
class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
REFERENCE = 'test_psa_crypto_config_reference_ffdh'
DRIVER = 'test_psa_crypto_config_accel_ffdh'
- IGNORED_SUITES = ['dhm']
IGNORED_TESTS = {
- 'test_suite_config': [
- re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
- ],
'test_suite_platform': [
# Incompatible with sanitizers (e.g. ASan). If the driver
# component uses a sanitizer but the reference component
diff --git a/tests/scripts/components-configuration-crypto.sh b/tests/scripts/components-configuration-crypto.sh
index 34b3107..8ba4161 100644
--- a/tests/scripts/components-configuration-crypto.sh
+++ b/tests/scripts/components-configuration-crypto.sh
@@ -668,9 +668,6 @@
# start with full (USE_PSA and TLS 1.3)
helper_libtestdriver1_adjust_config "full"
- # Disable the module that's accelerated
- scripts/config.py unset MBEDTLS_DHM_C
-
# Build
# -----
@@ -679,7 +676,7 @@
helper_libtestdriver1_make_main "$loc_accel_list"
# Make sure this was not re-enabled by accident (additive config)
- not grep mbedtls_dhm_ ${BUILTIN_SRC_PATH}/dhm.o
+ not grep mbedtls_psa_ffdh_key_agreement ${BUILTIN_SRC_PATH}/psa_crypto_ffdh.o
# Run the tests
# -------------
@@ -1178,12 +1175,6 @@
scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_FFDH
scripts/config.py -f "$CRYPTO_CONFIG_H" unset-all "PSA_WANT_KEY_TYPE_DH_[0-9A-Z_a-z]*"
scripts/config.py -f "$CRYPTO_CONFIG_H" unset-all "PSA_WANT_DH_RFC7919_[0-9]*"
- scripts/config.py unset MBEDTLS_DHM_C
- else
- # When testing ECC and DH instead, we disable DHM.
- if [ "$driver_only" -eq 1 ]; then
- scripts/config.py unset MBEDTLS_DHM_C
- fi
fi
# Restartable feature is not yet supported by PSA. Once it will in
@@ -1255,16 +1246,15 @@
not grep mbedtls_ecdsa_ ${BUILTIN_SRC_PATH}/ecdsa.o
not grep mbedtls_ecdh_ ${BUILTIN_SRC_PATH}/ecdh.o
not grep mbedtls_ecjpake_ ${BUILTIN_SRC_PATH}/ecjpake.o
- # Also ensure that ECP, RSA, [DHM] or BIGNUM modules were not re-enabled
+ # Also ensure that ECP, RSA or BIGNUM modules were not re-enabled
not grep mbedtls_ecp_ ${BUILTIN_SRC_PATH}/ecp.o
not grep mbedtls_rsa_ ${BUILTIN_SRC_PATH}/rsa.o
not grep mbedtls_mpi_ ${BUILTIN_SRC_PATH}/bignum.o
- not grep mbedtls_dhm_ ${BUILTIN_SRC_PATH}/dhm.o
# Run the tests
# -------------
- msg "test suites: full + accelerated $accel_text algs + USE_PSA - $removed_text - DHM - BIGNUM"
+ msg "test suites: full + accelerated $accel_text algs + USE_PSA - $removed_text - BIGNUM"
make test
@@ -1362,10 +1352,9 @@
not grep mbedtls_ecdsa_ ${BUILTIN_SRC_PATH}/ecdsa.o
not grep mbedtls_ecdh_ ${BUILTIN_SRC_PATH}/ecdh.o
not grep mbedtls_ecjpake_ ${BUILTIN_SRC_PATH}/ecjpake.o
- # Also ensure that ECP, RSA, DHM or BIGNUM modules were not re-enabled
+ # Also ensure that ECP, RSA or BIGNUM modules were not re-enabled
not grep mbedtls_ecp_ ${BUILTIN_SRC_PATH}/ecp.o
not grep mbedtls_rsa_ ${BUILTIN_SRC_PATH}/rsa.o
- not grep mbedtls_dhm_ ${BUILTIN_SRC_PATH}/dhm.o
not grep mbedtls_mpi_ ${BUILTIN_SRC_PATH}/bignum.o
# Check that p256m was built
grep -q p256_ecdsa_ library/libmbedcrypto.a
diff --git a/tests/scripts/components-configuration-tls.sh b/tests/scripts/components-configuration-tls.sh
index 293e88e..6b3f9c2 100644
--- a/tests/scripts/components-configuration-tls.sh
+++ b/tests/scripts/components-configuration-tls.sh
@@ -473,7 +473,6 @@
scripts/config.py unset MBEDTLS_ECDH_C
scripts/config.py unset MBEDTLS_ECDSA_C
scripts/config.py unset MBEDTLS_PKCS1_V21
- scripts/config.py unset MBEDTLS_DHM_C
make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
diff --git a/tests/scripts/set_psa_test_dependencies.py b/tests/scripts/set_psa_test_dependencies.py
index f68dfcb..2267311 100755
--- a/tests/scripts/set_psa_test_dependencies.py
+++ b/tests/scripts/set_psa_test_dependencies.py
@@ -58,7 +58,6 @@
'MBEDTLS_CMAC_C',
'MBEDTLS_CTR_DRBG_C',
'MBEDTLS_DES_C',
- 'MBEDTLS_DHM_C',
'MBEDTLS_ECDH_C',
'MBEDTLS_ECDSA_C',
'MBEDTLS_ECJPAKE_C',
diff --git a/tf-psa-crypto b/tf-psa-crypto
index 2574203..7d60bf1 160000
--- a/tf-psa-crypto
+++ b/tf-psa-crypto
@@ -1 +1 @@
-Subproject commit 25742030e4eddfb29913cb82642703ee0fe5d0d7
+Subproject commit 7d60bf1078578bfc809f1516c195c54cefdb510d