From 7b9f33cc8ce8bd4b904d3bece0af44f900e22f95 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 18 Feb 2021 16:30:35 +0000 Subject: [PATCH 01/18] Move include/mbedtls/rsa_internal.h to library/rsa_internal.h Only move `rsa_internal.h` for now to test dependancies. Other internal headers will be moved in following commits. Signed-off-by: Chris Jones --- library/rsa.c | 2 +- library/rsa_internal.c | 2 +- {include/mbedtls => library}/rsa_internal.h | 0 programs/test/cpp_dummy_build.cpp | 2 +- tests/suites/test_suite_rsa.function | 2 +- visualc/VS2010/mbedTLS.vcxproj | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename {include/mbedtls => library}/rsa_internal.h (100%) diff --git a/library/rsa.c b/library/rsa.c index 9fe551d51..b9e4a0ceb 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -40,7 +40,7 @@ #if defined(MBEDTLS_RSA_C) #include "mbedtls/rsa.h" -#include "mbedtls/rsa_internal.h" +#include "rsa_internal.h" #include "mbedtls/oid.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" diff --git a/library/rsa_internal.c b/library/rsa_internal.c index d6ba97a14..0be08e79e 100644 --- a/library/rsa_internal.c +++ b/library/rsa_internal.c @@ -24,7 +24,7 @@ #include "mbedtls/rsa.h" #include "mbedtls/bignum.h" -#include "mbedtls/rsa_internal.h" +#include "rsa_internal.h" /* * Compute RSA prime factors from public and private exponents diff --git a/include/mbedtls/rsa_internal.h b/library/rsa_internal.h similarity index 100% rename from include/mbedtls/rsa_internal.h rename to library/rsa_internal.h diff --git a/programs/test/cpp_dummy_build.cpp b/programs/test/cpp_dummy_build.cpp index 0ddfb066b..75714cfa6 100644 --- a/programs/test/cpp_dummy_build.cpp +++ b/programs/test/cpp_dummy_build.cpp @@ -80,7 +80,7 @@ #include "mbedtls/psa_util.h" #include "mbedtls/ripemd160.h" #include "mbedtls/rsa.h" -#include "mbedtls/rsa_internal.h" +#include "rsa_internal.h" #include "mbedtls/sha1.h" #include "mbedtls/sha256.h" #include "mbedtls/sha512.h" diff --git a/tests/suites/test_suite_rsa.function b/tests/suites/test_suite_rsa.function index 6c73e3947..65ccf90fc 100644 --- a/tests/suites/test_suite_rsa.function +++ b/tests/suites/test_suite_rsa.function @@ -1,6 +1,6 @@ /* BEGIN_HEADER */ #include "mbedtls/rsa.h" -#include "mbedtls/rsa_internal.h" +#include "rsa_internal.h" #include "mbedtls/md2.h" #include "mbedtls/md4.h" #include "mbedtls/md5.h" diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj index bb3baf1ad..004d83b18 100644 --- a/visualc/VS2010/mbedTLS.vcxproj +++ b/visualc/VS2010/mbedTLS.vcxproj @@ -201,7 +201,6 @@ - @@ -252,6 +251,7 @@ + From f6643ccd90694ae99d05541990b78738a8444ab0 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 19 Feb 2021 12:49:17 +0000 Subject: [PATCH 02/18] Add library/*_internal.h to build files Build scripts modified to refer to all internal headers being in `library/*_internal.h`. Signed-off-by: Chris Jones --- tests/scripts/list-enum-consts.pl | 1 + tests/scripts/list-identifiers.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/scripts/list-enum-consts.pl b/tests/scripts/list-enum-consts.pl index 3b9fcdaaf..25bea4dff 100755 --- a/tests/scripts/list-enum-consts.pl +++ b/tests/scripts/list-enum-consts.pl @@ -24,6 +24,7 @@ use open qw(:std utf8); -d 'include/mbedtls' or die "$0: must be run from root\n"; @ARGV = ; +push @ARGV, ; push @ARGV, "3rdparty/everest/include/everest/everest.h"; push @ARGV, "3rdparty/everest/include/everest/x25519.h"; diff --git a/tests/scripts/list-identifiers.sh b/tests/scripts/list-identifiers.sh index a52207e3f..b8a6d5352 100755 --- a/tests/scripts/list-identifiers.sh +++ b/tests/scripts/list-identifiers.sh @@ -47,9 +47,9 @@ done if [ $INTERNAL ] then - HEADERS=$( ls include/mbedtls/*_internal.h library/*.h | egrep -v 'bn_mul' ) + HEADERS=$( ls library/*.h ) else - HEADERS=$( ls include/mbedtls/*.h include/psa/*.h library/*.h | egrep -v 'bn_mul' ) + HEADERS=$( ls include/mbedtls/*.h include/psa/*.h library/*.h ) HEADERS="$HEADERS 3rdparty/everest/include/everest/everest.h 3rdparty/everest/include/everest/x25519.h" fi From 35ac46a3a3f7483e2827aa51af5e01b65df40bb0 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 19 Feb 2021 15:41:29 +0000 Subject: [PATCH 03/18] Move internal headers from include/mbedtls/ to library/ `cipher_internal.h`, `ecp_internal.h`, `md_internal.h`, `pk_internal.h` and `ssl_internal.h` have all been moved. Includes and dependnecies have not been renamed yet, only direct mv. Signed-off-by: Chris Jones --- {include/mbedtls => library}/cipher_internal.h | 0 {include/mbedtls => library}/ecp_internal.h | 0 {include/mbedtls => library}/md_internal.h | 0 {include/mbedtls => library}/pk_internal.h | 0 {include/mbedtls => library}/ssl_internal.h | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename {include/mbedtls => library}/cipher_internal.h (100%) rename {include/mbedtls => library}/ecp_internal.h (100%) rename {include/mbedtls => library}/md_internal.h (100%) rename {include/mbedtls => library}/pk_internal.h (100%) rename {include/mbedtls => library}/ssl_internal.h (100%) diff --git a/include/mbedtls/cipher_internal.h b/library/cipher_internal.h similarity index 100% rename from include/mbedtls/cipher_internal.h rename to library/cipher_internal.h diff --git a/include/mbedtls/ecp_internal.h b/library/ecp_internal.h similarity index 100% rename from include/mbedtls/ecp_internal.h rename to library/ecp_internal.h diff --git a/include/mbedtls/md_internal.h b/library/md_internal.h similarity index 100% rename from include/mbedtls/md_internal.h rename to library/md_internal.h diff --git a/include/mbedtls/pk_internal.h b/library/pk_internal.h similarity index 100% rename from include/mbedtls/pk_internal.h rename to library/pk_internal.h diff --git a/include/mbedtls/ssl_internal.h b/library/ssl_internal.h similarity index 100% rename from include/mbedtls/ssl_internal.h rename to library/ssl_internal.h From e2191cd789193ef33e87a7f75af0cdc54eddf14d Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 19 Feb 2021 16:04:15 +0000 Subject: [PATCH 04/18] Update includes to use library/ instead of include/mbedtls/ Simple find and replace using `#include (<|")mbedtls/(.*)_internal.h(>|")` and `#include $1$2_internal.h$3`. Also re-generated visualc files by running `scripts/generate_visualc_files.pl`. Signed-off-by: Chris Jones --- library/cipher.c | 2 +- library/cipher_wrap.c | 2 +- library/ecp.c | 2 +- library/md.c | 2 +- library/pk.c | 2 +- library/pk_wrap.c | 2 +- library/psa_crypto.c | 4 ++-- library/ssl_cache.c | 2 +- library/ssl_cli.c | 2 +- library/ssl_cookie.c | 2 +- library/ssl_msg.c | 2 +- library/ssl_srv.c | 2 +- library/ssl_ticket.c | 2 +- library/ssl_tls.c | 2 +- library/ssl_tls13_keys.c | 2 +- programs/ssl/ssl_context_info.c | 2 +- programs/test/cpp_dummy_build.cpp | 10 +++++----- programs/test/query_config.c | 2 +- scripts/data_files/query_config.fmt | 2 +- tests/suites/test_suite_hkdf.function | 2 +- tests/suites/test_suite_ssl.function | 2 +- visualc/VS2010/mbedTLS.vcxproj | 10 +++++----- 22 files changed, 31 insertions(+), 31 deletions(-) diff --git a/library/cipher.c b/library/cipher.c index 457f8f660..8d5bff665 100644 --- a/library/cipher.c +++ b/library/cipher.c @@ -26,7 +26,7 @@ #if defined(MBEDTLS_CIPHER_C) #include "mbedtls/cipher.h" -#include "mbedtls/cipher_internal.h" +#include "cipher_internal.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" diff --git a/library/cipher_wrap.c b/library/cipher_wrap.c index 57eb3cb67..35bd76f3e 100644 --- a/library/cipher_wrap.c +++ b/library/cipher_wrap.c @@ -25,7 +25,7 @@ #if defined(MBEDTLS_CIPHER_C) -#include "mbedtls/cipher_internal.h" +#include "cipher_internal.h" #include "mbedtls/error.h" #if defined(MBEDTLS_CHACHAPOLY_C) diff --git a/library/ecp.c b/library/ecp.c index 05a0b0175..ac17ff164 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -97,7 +97,7 @@ #define mbedtls_free free #endif -#include "mbedtls/ecp_internal.h" +#include "ecp_internal.h" #if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG) #if defined(MBEDTLS_HMAC_DRBG_C) diff --git a/library/md.c b/library/md.c index de77b164b..6553393f8 100644 --- a/library/md.c +++ b/library/md.c @@ -26,7 +26,7 @@ #if defined(MBEDTLS_MD_C) #include "mbedtls/md.h" -#include "mbedtls/md_internal.h" +#include "md_internal.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" diff --git a/library/pk.c b/library/pk.c index ecf002d45..3824e7912 100644 --- a/library/pk.c +++ b/library/pk.c @@ -21,7 +21,7 @@ #if defined(MBEDTLS_PK_C) #include "mbedtls/pk.h" -#include "mbedtls/pk_internal.h" +#include "pk_internal.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" diff --git a/library/pk_wrap.c b/library/pk_wrap.c index 107e912ac..74d7ce16c 100644 --- a/library/pk_wrap.c +++ b/library/pk_wrap.c @@ -20,7 +20,7 @@ #include "common.h" #if defined(MBEDTLS_PK_C) -#include "mbedtls/pk_internal.h" +#include "pk_internal.h" #include "mbedtls/error.h" /* Even if RSA not activated, for the sake of RSA-alt */ diff --git a/library/psa_crypto.c b/library/psa_crypto.c index b7c459166..2213657ff 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -73,9 +73,9 @@ #include "mbedtls/md4.h" #include "mbedtls/md5.h" #include "mbedtls/md.h" -#include "mbedtls/md_internal.h" +#include "md_internal.h" #include "mbedtls/pk.h" -#include "mbedtls/pk_internal.h" +#include "pk_internal.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" #include "mbedtls/ripemd160.h" diff --git a/library/ssl_cache.c b/library/ssl_cache.c index 7e9d4da05..141c480df 100644 --- a/library/ssl_cache.c +++ b/library/ssl_cache.c @@ -34,7 +34,7 @@ #endif #include "mbedtls/ssl_cache.h" -#include "mbedtls/ssl_internal.h" +#include "ssl_internal.h" #include diff --git a/library/ssl_cli.c b/library/ssl_cli.c index a8331d9bb..27e02469a 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -30,7 +30,7 @@ #endif #include "mbedtls/ssl.h" -#include "mbedtls/ssl_internal.h" +#include "ssl_internal.h" #include "mbedtls/debug.h" #include "mbedtls/error.h" diff --git a/library/ssl_cookie.c b/library/ssl_cookie.c index c8bd1bd52..0824cd909 100644 --- a/library/ssl_cookie.c +++ b/library/ssl_cookie.c @@ -33,7 +33,7 @@ #endif #include "mbedtls/ssl_cookie.h" -#include "mbedtls/ssl_internal.h" +#include "ssl_internal.h" #include "mbedtls/error.h" #include "mbedtls/platform_util.h" diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 72f09bb42..06da868aa 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -39,7 +39,7 @@ #endif #include "mbedtls/ssl.h" -#include "mbedtls/ssl_internal.h" +#include "ssl_internal.h" #include "mbedtls/debug.h" #include "mbedtls/error.h" #include "mbedtls/platform_util.h" diff --git a/library/ssl_srv.c b/library/ssl_srv.c index e33b828ad..9385d4f77 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -30,7 +30,7 @@ #endif #include "mbedtls/ssl.h" -#include "mbedtls/ssl_internal.h" +#include "ssl_internal.h" #include "mbedtls/debug.h" #include "mbedtls/error.h" #include "mbedtls/platform_util.h" diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c index 626d137cc..cd1ea7e58 100644 --- a/library/ssl_ticket.c +++ b/library/ssl_ticket.c @@ -29,7 +29,7 @@ #define mbedtls_free free #endif -#include "mbedtls/ssl_internal.h" +#include "ssl_internal.h" #include "mbedtls/ssl_ticket.h" #include "mbedtls/error.h" #include "mbedtls/platform_util.h" diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 336cbea37..659ef6b9c 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -38,7 +38,7 @@ #endif #include "mbedtls/ssl.h" -#include "mbedtls/ssl_internal.h" +#include "ssl_internal.h" #include "mbedtls/debug.h" #include "mbedtls/error.h" #include "mbedtls/platform_util.h" diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index c39e0322b..f197c05c8 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -22,7 +22,7 @@ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) #include "mbedtls/hkdf.h" -#include "mbedtls/ssl_internal.h" +#include "ssl_internal.h" #include "ssl_tls13_keys.h" #include diff --git a/programs/ssl/ssl_context_info.c b/programs/ssl/ssl_context_info.c index a204d9ead..868951b60 100644 --- a/programs/ssl/ssl_context_info.c +++ b/programs/ssl/ssl_context_info.c @@ -48,7 +48,7 @@ int main( void ) #include "mbedtls/error.h" #include "mbedtls/base64.h" #include "mbedtls/md.h" -#include "mbedtls/md_internal.h" +#include "../../library/md_internal.h" #include "mbedtls/x509_crt.h" #include "mbedtls/ssl_ciphersuites.h" diff --git a/programs/test/cpp_dummy_build.cpp b/programs/test/cpp_dummy_build.cpp index 75714cfa6..41617c2d0 100644 --- a/programs/test/cpp_dummy_build.cpp +++ b/programs/test/cpp_dummy_build.cpp @@ -41,7 +41,7 @@ #include "mbedtls/chachapoly.h" #include "mbedtls/check_config.h" #include "mbedtls/cipher.h" -#include "mbedtls/cipher_internal.h" +#include "cipher_internal.h" #include "mbedtls/cmac.h" #include "mbedtls/ctr_drbg.h" #include "mbedtls/debug.h" @@ -51,7 +51,7 @@ #include "mbedtls/ecdsa.h" #include "mbedtls/ecjpake.h" #include "mbedtls/ecp.h" -#include "mbedtls/ecp_internal.h" +#include "ecp_internal.h" #include "mbedtls/entropy.h" #include "mbedtls/entropy_poll.h" #include "mbedtls/error.h" @@ -62,7 +62,7 @@ #include "mbedtls/md2.h" #include "mbedtls/md4.h" #include "mbedtls/md5.h" -#include "mbedtls/md_internal.h" +#include "md_internal.h" #include "mbedtls/net.h" #include "mbedtls/net_sockets.h" #include "mbedtls/nist_kw.h" @@ -70,7 +70,7 @@ #include "mbedtls/padlock.h" #include "mbedtls/pem.h" #include "mbedtls/pk.h" -#include "mbedtls/pk_internal.h" +#include "pk_internal.h" #include "mbedtls/pkcs11.h" #include "mbedtls/pkcs12.h" #include "mbedtls/pkcs5.h" @@ -88,7 +88,7 @@ #include "mbedtls/ssl_cache.h" #include "mbedtls/ssl_ciphersuites.h" #include "mbedtls/ssl_cookie.h" -#include "mbedtls/ssl_internal.h" +#include "ssl_internal.h" #include "mbedtls/ssl_ticket.h" #include "mbedtls/threading.h" #include "mbedtls/timing.h" diff --git a/programs/test/query_config.c b/programs/test/query_config.c index bc8389fd0..0bb6c1c44 100644 --- a/programs/test/query_config.c +++ b/programs/test/query_config.c @@ -92,7 +92,6 @@ #include "mbedtls/ssl_cache.h" #include "mbedtls/ssl_ciphersuites.h" #include "mbedtls/ssl_cookie.h" -#include "mbedtls/ssl_internal.h" #include "mbedtls/ssl_ticket.h" #include "mbedtls/threading.h" #include "mbedtls/timing.h" @@ -102,6 +101,7 @@ #include "mbedtls/x509_crt.h" #include "mbedtls/x509_csr.h" #include "mbedtls/xtea.h" +#include "../../library/ssl_internal.h" #include diff --git a/scripts/data_files/query_config.fmt b/scripts/data_files/query_config.fmt index 97020904f..eff225e8a 100644 --- a/scripts/data_files/query_config.fmt +++ b/scripts/data_files/query_config.fmt @@ -92,7 +92,6 @@ #include "mbedtls/ssl_cache.h" #include "mbedtls/ssl_ciphersuites.h" #include "mbedtls/ssl_cookie.h" -#include "mbedtls/ssl_internal.h" #include "mbedtls/ssl_ticket.h" #include "mbedtls/threading.h" #include "mbedtls/timing.h" @@ -102,6 +101,7 @@ #include "mbedtls/x509_crt.h" #include "mbedtls/x509_csr.h" #include "mbedtls/xtea.h" +#include "../../library/ssl_internal.h" #include diff --git a/tests/suites/test_suite_hkdf.function b/tests/suites/test_suite_hkdf.function index 4c597c3f9..174d6accf 100644 --- a/tests/suites/test_suite_hkdf.function +++ b/tests/suites/test_suite_hkdf.function @@ -1,6 +1,6 @@ /* BEGIN_HEADER */ #include "mbedtls/hkdf.h" -#include "mbedtls/md_internal.h" +#include "md_internal.h" /* END_HEADER */ /* BEGIN_DEPENDENCIES diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index f377ffa99..bd282774a 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -1,6 +1,6 @@ /* BEGIN_HEADER */ #include -#include +#include #include #include #include diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj index 004d83b18..0e2c060af 100644 --- a/visualc/VS2010/mbedTLS.vcxproj +++ b/visualc/VS2010/mbedTLS.vcxproj @@ -158,7 +158,6 @@ - @@ -170,7 +169,6 @@ - @@ -181,7 +179,6 @@ - @@ -190,7 +187,6 @@ - @@ -208,7 +204,6 @@ - @@ -241,7 +236,11 @@ + + + + @@ -252,6 +251,7 @@ + From 4c5819c318a90dba634cd8ed49eb81dae29efd49 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 3 Mar 2021 17:45:34 +0000 Subject: [PATCH 05/18] Move bn_mul.h to library/ Move `include/mbedtls/bn_mul.h` to `library/bn_mul.h`. Update includes and references to `bn_mul.h` to new location. Also remove internal headers from `cpp_dummy_build.cpp` as it should only test public headers in the library. Signed-off-by: Chris Jones --- configs/config-psa-crypto.h | 2 +- include/mbedtls/config.h | 2 +- library/bignum.c | 2 +- {include/mbedtls => library}/bn_mul.h | 0 programs/test/cpp_dummy_build.cpp | 8 -------- visualc/VS2010/mbedTLS.vcxproj | 2 +- 6 files changed, 4 insertions(+), 12 deletions(-) rename {include/mbedtls => library}/bn_mul.h (100%) diff --git a/configs/config-psa-crypto.h b/configs/config-psa-crypto.h index 5635e9891..dc0632ca3 100644 --- a/configs/config-psa-crypto.h +++ b/configs/config-psa-crypto.h @@ -48,7 +48,7 @@ * Used in: * library/aria.c * library/timing.c - * include/mbedtls/bn_mul.h + * library/bn_mul.h * * Required by: * MBEDTLS_AESNI_C diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h index 46941e27f..c7871eb1d 100644 --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h @@ -48,7 +48,7 @@ * Used in: * library/aria.c * library/timing.c - * include/mbedtls/bn_mul.h + * library/bn_mul.h * * Required by: * MBEDTLS_AESNI_C diff --git a/library/bignum.c b/library/bignum.c index 9cc5d66e3..1f6444e4c 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -38,7 +38,7 @@ #if defined(MBEDTLS_BIGNUM_C) #include "mbedtls/bignum.h" -#include "mbedtls/bn_mul.h" +#include "bn_mul.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" diff --git a/include/mbedtls/bn_mul.h b/library/bn_mul.h similarity index 100% rename from include/mbedtls/bn_mul.h rename to library/bn_mul.h diff --git a/programs/test/cpp_dummy_build.cpp b/programs/test/cpp_dummy_build.cpp index 41617c2d0..c2fdf501d 100644 --- a/programs/test/cpp_dummy_build.cpp +++ b/programs/test/cpp_dummy_build.cpp @@ -33,7 +33,6 @@ #include "mbedtls/base64.h" #include "mbedtls/bignum.h" #include "mbedtls/blowfish.h" -#include "mbedtls/bn_mul.h" #include "mbedtls/camellia.h" #include "mbedtls/ccm.h" #include "mbedtls/certs.h" @@ -41,7 +40,6 @@ #include "mbedtls/chachapoly.h" #include "mbedtls/check_config.h" #include "mbedtls/cipher.h" -#include "cipher_internal.h" #include "mbedtls/cmac.h" #include "mbedtls/ctr_drbg.h" #include "mbedtls/debug.h" @@ -51,7 +49,6 @@ #include "mbedtls/ecdsa.h" #include "mbedtls/ecjpake.h" #include "mbedtls/ecp.h" -#include "ecp_internal.h" #include "mbedtls/entropy.h" #include "mbedtls/entropy_poll.h" #include "mbedtls/error.h" @@ -62,7 +59,6 @@ #include "mbedtls/md2.h" #include "mbedtls/md4.h" #include "mbedtls/md5.h" -#include "md_internal.h" #include "mbedtls/net.h" #include "mbedtls/net_sockets.h" #include "mbedtls/nist_kw.h" @@ -70,7 +66,6 @@ #include "mbedtls/padlock.h" #include "mbedtls/pem.h" #include "mbedtls/pk.h" -#include "pk_internal.h" #include "mbedtls/pkcs11.h" #include "mbedtls/pkcs12.h" #include "mbedtls/pkcs5.h" @@ -80,7 +75,6 @@ #include "mbedtls/psa_util.h" #include "mbedtls/ripemd160.h" #include "mbedtls/rsa.h" -#include "rsa_internal.h" #include "mbedtls/sha1.h" #include "mbedtls/sha256.h" #include "mbedtls/sha512.h" @@ -88,7 +82,6 @@ #include "mbedtls/ssl_cache.h" #include "mbedtls/ssl_ciphersuites.h" #include "mbedtls/ssl_cookie.h" -#include "ssl_internal.h" #include "mbedtls/ssl_ticket.h" #include "mbedtls/threading.h" #include "mbedtls/timing.h" @@ -109,7 +102,6 @@ #include "psa/crypto.h" #include "psa/crypto_se_driver.h" -#include "../library/psa_crypto_its.h" int main() { diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj index 0e2c060af..350eea8be 100644 --- a/visualc/VS2010/mbedTLS.vcxproj +++ b/visualc/VS2010/mbedTLS.vcxproj @@ -150,7 +150,6 @@ - @@ -235,6 +234,7 @@ + From 84a773f8e6cd97f749ff1c64680ad0e982900aed Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 5 Mar 2021 18:38:47 +0000 Subject: [PATCH 06/18] Rename ssl_internal.h to ssl_misc.h Signed-off-by: Chris Jones --- include/mbedtls/cipher.h | 6 +++--- include/mbedtls/ssl.h | 2 +- library/ssl_cache.c | 2 +- library/ssl_cli.c | 2 +- library/ssl_cookie.c | 2 +- library/{ssl_internal.h => ssl_misc.h} | 8 ++++---- library/ssl_msg.c | 2 +- library/ssl_srv.c | 2 +- library/ssl_ticket.c | 2 +- library/ssl_tls.c | 2 +- library/ssl_tls13_keys.c | 2 +- programs/test/query_config.c | 2 +- scripts/data_files/query_config.fmt | 2 +- tests/suites/test_suite_ssl.function | 2 +- visualc/VS2010/mbedTLS.vcxproj | 2 +- 15 files changed, 20 insertions(+), 20 deletions(-) rename library/{ssl_internal.h => ssl_misc.h} (99%) diff --git a/include/mbedtls/cipher.h b/include/mbedtls/cipher.h index 1cafa6ec2..f5f56b55d 100644 --- a/include/mbedtls/cipher.h +++ b/include/mbedtls/cipher.h @@ -229,13 +229,13 @@ enum { /** Maximum length of any IV, in Bytes. */ /* This should ideally be derived automatically from list of ciphers. * This should be kept in sync with MBEDTLS_SSL_MAX_IV_LENGTH defined - * in ssl_internal.h. */ + * in ssl_misc.h. */ #define MBEDTLS_MAX_IV_LENGTH 16 /** Maximum block size of any cipher, in Bytes. */ /* This should ideally be derived automatically from list of ciphers. * This should be kept in sync with MBEDTLS_SSL_MAX_BLOCK_LENGTH defined - * in ssl_internal.h. */ + * in ssl_misc.h. */ #define MBEDTLS_MAX_BLOCK_LENGTH 16 /** Maximum key length, in Bytes. */ @@ -243,7 +243,7 @@ enum { * For now, only check whether XTS is enabled which uses 64 Byte keys, * and use 32 Bytes as an upper bound for the maximum key length otherwise. * This should be kept in sync with MBEDTLS_SSL_MAX_BLOCK_LENGTH defined - * in ssl_internal.h, which however deliberately ignores the case of XTS + * in ssl_misc.h, which however deliberately ignores the case of XTS * since the latter isn't used in SSL/TLS. */ #if defined(MBEDTLS_CIPHER_MODE_XTS) #define MBEDTLS_MAX_KEY_LENGTH 64 diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 7815ad9d0..16ed5b70f 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -619,7 +619,7 @@ typedef struct mbedtls_ssl_session mbedtls_ssl_session; typedef struct mbedtls_ssl_context mbedtls_ssl_context; typedef struct mbedtls_ssl_config mbedtls_ssl_config; -/* Defined in ssl_internal.h */ +/* Defined in ssl_misc.h */ typedef struct mbedtls_ssl_transform mbedtls_ssl_transform; typedef struct mbedtls_ssl_handshake_params mbedtls_ssl_handshake_params; typedef struct mbedtls_ssl_sig_hash_set_t mbedtls_ssl_sig_hash_set_t; diff --git a/library/ssl_cache.c b/library/ssl_cache.c index 141c480df..bb5007bd1 100644 --- a/library/ssl_cache.c +++ b/library/ssl_cache.c @@ -34,7 +34,7 @@ #endif #include "mbedtls/ssl_cache.h" -#include "ssl_internal.h" +#include "ssl_misc.h" #include diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 27e02469a..be68bcd2c 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -30,7 +30,7 @@ #endif #include "mbedtls/ssl.h" -#include "ssl_internal.h" +#include "ssl_misc.h" #include "mbedtls/debug.h" #include "mbedtls/error.h" diff --git a/library/ssl_cookie.c b/library/ssl_cookie.c index 0824cd909..fa89a07d3 100644 --- a/library/ssl_cookie.c +++ b/library/ssl_cookie.c @@ -33,7 +33,7 @@ #endif #include "mbedtls/ssl_cookie.h" -#include "ssl_internal.h" +#include "ssl_misc.h" #include "mbedtls/error.h" #include "mbedtls/platform_util.h" diff --git a/library/ssl_internal.h b/library/ssl_misc.h similarity index 99% rename from library/ssl_internal.h rename to library/ssl_misc.h index 2097a6dd9..85f7fc46a 100644 --- a/library/ssl_internal.h +++ b/library/ssl_misc.h @@ -1,5 +1,5 @@ /** - * \file ssl_internal.h + * \file ssl_misc.h * * \brief Internal functions shared by the SSL modules */ @@ -19,8 +19,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MBEDTLS_SSL_INTERNAL_H -#define MBEDTLS_SSL_INTERNAL_H +#ifndef MBEDTLS_SSL_MISC_H +#define MBEDTLS_SSL_MISC_H #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" @@ -1306,4 +1306,4 @@ void mbedtls_ssl_buffering_free( mbedtls_ssl_context *ssl ); void mbedtls_ssl_flight_free( mbedtls_ssl_flight_item *flight ); #endif /* MBEDTLS_SSL_PROTO_DTLS */ -#endif /* ssl_internal.h */ +#endif /* ssl_misc.h */ diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 06da868aa..17348f1d1 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -39,7 +39,7 @@ #endif #include "mbedtls/ssl.h" -#include "ssl_internal.h" +#include "ssl_misc.h" #include "mbedtls/debug.h" #include "mbedtls/error.h" #include "mbedtls/platform_util.h" diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 9385d4f77..66b9654ae 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -30,7 +30,7 @@ #endif #include "mbedtls/ssl.h" -#include "ssl_internal.h" +#include "ssl_misc.h" #include "mbedtls/debug.h" #include "mbedtls/error.h" #include "mbedtls/platform_util.h" diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c index cd1ea7e58..940e1a67a 100644 --- a/library/ssl_ticket.c +++ b/library/ssl_ticket.c @@ -29,7 +29,7 @@ #define mbedtls_free free #endif -#include "ssl_internal.h" +#include "ssl_misc.h" #include "mbedtls/ssl_ticket.h" #include "mbedtls/error.h" #include "mbedtls/platform_util.h" diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 659ef6b9c..59870bf92 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -38,7 +38,7 @@ #endif #include "mbedtls/ssl.h" -#include "ssl_internal.h" +#include "ssl_misc.h" #include "mbedtls/debug.h" #include "mbedtls/error.h" #include "mbedtls/platform_util.h" diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index f197c05c8..4e8fb433b 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -22,7 +22,7 @@ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) #include "mbedtls/hkdf.h" -#include "ssl_internal.h" +#include "ssl_misc.h" #include "ssl_tls13_keys.h" #include diff --git a/programs/test/query_config.c b/programs/test/query_config.c index 0bb6c1c44..93bca4b26 100644 --- a/programs/test/query_config.c +++ b/programs/test/query_config.c @@ -101,7 +101,7 @@ #include "mbedtls/x509_crt.h" #include "mbedtls/x509_csr.h" #include "mbedtls/xtea.h" -#include "../../library/ssl_internal.h" +#include "../../library/ssl_misc.h" #include diff --git a/scripts/data_files/query_config.fmt b/scripts/data_files/query_config.fmt index eff225e8a..ef8f7177d 100644 --- a/scripts/data_files/query_config.fmt +++ b/scripts/data_files/query_config.fmt @@ -101,7 +101,7 @@ #include "mbedtls/x509_crt.h" #include "mbedtls/x509_csr.h" #include "mbedtls/xtea.h" -#include "../../library/ssl_internal.h" +#include "../../library/ssl_misc.h" #include diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index bd282774a..cff642b18 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -1,6 +1,6 @@ /* BEGIN_HEADER */ #include -#include +#include #include #include #include diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj index 350eea8be..7c79493e1 100644 --- a/visualc/VS2010/mbedTLS.vcxproj +++ b/visualc/VS2010/mbedTLS.vcxproj @@ -251,8 +251,8 @@ - + From 66a4cd46fdd99f87197cd6d87ad89dffa2cac8a2 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 9 Mar 2021 16:04:12 +0000 Subject: [PATCH 07/18] Rename rsa_internal.* to rsa_alt_helpers.* Rename both `rsa_internal.h` and `rsa_internal.c` to more descriptive names: `rsa_alt_helpers.h` and `rsa_alt_helpers.c`. Also re-orders `rsa_internal.c` to match the order in `rsa_internal.h` Signed-off-by: Chris Jones --- configs/config-psa-crypto.h | 4 +- include/mbedtls/config.h | 4 +- library/CMakeLists.txt | 2 +- library/Makefile | 2 +- library/rsa.c | 2 +- library/{rsa_internal.c => rsa_alt_helpers.c} | 160 +++++++++--------- library/{rsa_internal.h => rsa_alt_helpers.h} | 4 +- tests/suites/test_suite_rsa.function | 2 +- visualc/VS2010/mbedTLS.vcxproj | 4 +- 9 files changed, 92 insertions(+), 92 deletions(-) rename library/{rsa_internal.c => rsa_alt_helpers.c} (99%) rename library/{rsa_internal.h => rsa_alt_helpers.h} (99%) diff --git a/configs/config-psa-crypto.h b/configs/config-psa-crypto.h index dc0632ca3..20cf92831 100644 --- a/configs/config-psa-crypto.h +++ b/configs/config-psa-crypto.h @@ -1955,7 +1955,7 @@ * library/ecp.c * library/ecdsa.c * library/rsa.c - * library/rsa_internal.c + * library/rsa_alt_helpers.h * library/ssl_tls.c * * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. @@ -2722,7 +2722,7 @@ * Enable the RSA public-key cryptosystem. * * Module: library/rsa.c - * library/rsa_internal.c + * library/rsa_alt_helpers.h * Caller: library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h index c7871eb1d..a2e8b85d5 100644 --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h @@ -2400,7 +2400,7 @@ * library/ecp.c * library/ecdsa.c * library/rsa.c - * library/rsa_internal.c + * library/rsa_alt_helpers.h * library/ssl_tls.c * * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. @@ -3198,7 +3198,7 @@ * Enable the RSA public-key cryptosystem. * * Module: library/rsa.c - * library/rsa_internal.c + * library/rsa_alt_helpers.h * Caller: library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 4fef36c7f..7817aa8a5 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -67,7 +67,7 @@ set(src_crypto psa_its_file.c ripemd160.c rsa.c - rsa_internal.c + rsa_alt_helpers.c sha1.c sha256.c sha512.c diff --git a/library/Makefile b/library/Makefile index 3aab662f8..a588eaa53 100644 --- a/library/Makefile +++ b/library/Makefile @@ -124,7 +124,7 @@ OBJS_CRYPTO= \ psa_its_file.o \ ripemd160.o \ rsa.o \ - rsa_internal.o \ + rsa_alt_helpers.o \ sha1.o \ sha256.o \ sha512.o \ diff --git a/library/rsa.c b/library/rsa.c index b9e4a0ceb..78d877f3e 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -40,7 +40,7 @@ #if defined(MBEDTLS_RSA_C) #include "mbedtls/rsa.h" -#include "rsa_internal.h" +#include "rsa_alt_helpers.h" #include "mbedtls/oid.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" diff --git a/library/rsa_internal.c b/library/rsa_alt_helpers.c similarity index 99% rename from library/rsa_internal.c rename to library/rsa_alt_helpers.c index 0be08e79e..dff2d9345 100644 --- a/library/rsa_internal.c +++ b/library/rsa_alt_helpers.c @@ -24,7 +24,7 @@ #include "mbedtls/rsa.h" #include "mbedtls/bignum.h" -#include "rsa_internal.h" +#include "rsa_alt_helpers.h" /* * Compute RSA prime factors from public and private exponents @@ -237,90 +237,36 @@ cleanup: return( ret ); } -/* - * Check that RSA CRT parameters are in accordance with core parameters. - */ -int mbedtls_rsa_validate_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q, - const mbedtls_mpi *D, const mbedtls_mpi *DP, - const mbedtls_mpi *DQ, const mbedtls_mpi *QP ) +int mbedtls_rsa_deduce_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q, + const mbedtls_mpi *D, mbedtls_mpi *DP, + mbedtls_mpi *DQ, mbedtls_mpi *QP ) { int ret = 0; - - mbedtls_mpi K, L; + mbedtls_mpi K; mbedtls_mpi_init( &K ); - mbedtls_mpi_init( &L ); - /* Check that DP - D == 0 mod P - 1 */ + /* DP = D mod P-1 */ if( DP != NULL ) { - if( P == NULL ) - { - ret = MBEDTLS_ERR_RSA_BAD_INPUT_DATA; - goto cleanup; - } - - MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, P, 1 ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &L, DP, D ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &L, &L, &K ) ); - - if( mbedtls_mpi_cmp_int( &L, 0 ) != 0 ) - { - ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED; - goto cleanup; - } + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, P, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( DP, D, &K ) ); } - /* Check that DQ - D == 0 mod Q - 1 */ + /* DQ = D mod Q-1 */ if( DQ != NULL ) { - if( Q == NULL ) - { - ret = MBEDTLS_ERR_RSA_BAD_INPUT_DATA; - goto cleanup; - } - - MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, Q, 1 ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &L, DQ, D ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &L, &L, &K ) ); - - if( mbedtls_mpi_cmp_int( &L, 0 ) != 0 ) - { - ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED; - goto cleanup; - } + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, Q, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( DQ, D, &K ) ); } - /* Check that QP * Q - 1 == 0 mod P */ + /* QP = Q^{-1} mod P */ if( QP != NULL ) { - if( P == NULL || Q == NULL ) - { - ret = MBEDTLS_ERR_RSA_BAD_INPUT_DATA; - goto cleanup; - } - - MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &K, QP, Q ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, &K, 1 ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &K, &K, P ) ); - if( mbedtls_mpi_cmp_int( &K, 0 ) != 0 ) - { - ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED; - goto cleanup; - } + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( QP, Q, P ) ); } cleanup: - - /* Wrap MPI error codes by RSA check failure error code */ - if( ret != 0 && - ret != MBEDTLS_ERR_RSA_KEY_CHECK_FAILED && - ret != MBEDTLS_ERR_RSA_BAD_INPUT_DATA ) - { - ret += MBEDTLS_ERR_RSA_KEY_CHECK_FAILED; - } - mbedtls_mpi_free( &K ); - mbedtls_mpi_free( &L ); return( ret ); } @@ -449,36 +395,90 @@ cleanup: return( ret ); } -int mbedtls_rsa_deduce_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q, - const mbedtls_mpi *D, mbedtls_mpi *DP, - mbedtls_mpi *DQ, mbedtls_mpi *QP ) +/* + * Check that RSA CRT parameters are in accordance with core parameters. + */ +int mbedtls_rsa_validate_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q, + const mbedtls_mpi *D, const mbedtls_mpi *DP, + const mbedtls_mpi *DQ, const mbedtls_mpi *QP ) { int ret = 0; - mbedtls_mpi K; - mbedtls_mpi_init( &K ); - /* DP = D mod P-1 */ + mbedtls_mpi K, L; + mbedtls_mpi_init( &K ); + mbedtls_mpi_init( &L ); + + /* Check that DP - D == 0 mod P - 1 */ if( DP != NULL ) { - MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, P, 1 ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( DP, D, &K ) ); + if( P == NULL ) + { + ret = MBEDTLS_ERR_RSA_BAD_INPUT_DATA; + goto cleanup; + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, P, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &L, DP, D ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &L, &L, &K ) ); + + if( mbedtls_mpi_cmp_int( &L, 0 ) != 0 ) + { + ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED; + goto cleanup; + } } - /* DQ = D mod Q-1 */ + /* Check that DQ - D == 0 mod Q - 1 */ if( DQ != NULL ) { - MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, Q, 1 ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( DQ, D, &K ) ); + if( Q == NULL ) + { + ret = MBEDTLS_ERR_RSA_BAD_INPUT_DATA; + goto cleanup; + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, Q, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &L, DQ, D ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &L, &L, &K ) ); + + if( mbedtls_mpi_cmp_int( &L, 0 ) != 0 ) + { + ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED; + goto cleanup; + } } - /* QP = Q^{-1} mod P */ + /* Check that QP * Q - 1 == 0 mod P */ if( QP != NULL ) { - MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( QP, Q, P ) ); + if( P == NULL || Q == NULL ) + { + ret = MBEDTLS_ERR_RSA_BAD_INPUT_DATA; + goto cleanup; + } + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &K, QP, Q ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, &K, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &K, &K, P ) ); + if( mbedtls_mpi_cmp_int( &K, 0 ) != 0 ) + { + ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED; + goto cleanup; + } } cleanup: + + /* Wrap MPI error codes by RSA check failure error code */ + if( ret != 0 && + ret != MBEDTLS_ERR_RSA_KEY_CHECK_FAILED && + ret != MBEDTLS_ERR_RSA_BAD_INPUT_DATA ) + { + ret += MBEDTLS_ERR_RSA_KEY_CHECK_FAILED; + } + mbedtls_mpi_free( &K ); + mbedtls_mpi_free( &L ); return( ret ); } diff --git a/library/rsa_internal.h b/library/rsa_alt_helpers.h similarity index 99% rename from library/rsa_internal.h rename to library/rsa_alt_helpers.h index d55492bb1..90c88a29f 100644 --- a/library/rsa_internal.h +++ b/library/rsa_alt_helpers.h @@ -1,5 +1,5 @@ /** - * \file rsa_internal.h + * \file rsa_alt_helpers.h * * \brief Context-independent RSA helper functions * @@ -221,4 +221,4 @@ int mbedtls_rsa_validate_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q, } #endif -#endif /* rsa_internal.h */ +#endif /* rsa_alt_helpers.h */ diff --git a/tests/suites/test_suite_rsa.function b/tests/suites/test_suite_rsa.function index 65ccf90fc..23a4a6f11 100644 --- a/tests/suites/test_suite_rsa.function +++ b/tests/suites/test_suite_rsa.function @@ -1,6 +1,6 @@ /* BEGIN_HEADER */ #include "mbedtls/rsa.h" -#include "rsa_internal.h" +#include "rsa_alt_helpers.h" #include "mbedtls/md2.h" #include "mbedtls/md4.h" #include "mbedtls/md5.h" diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj index 7c79493e1..c53e54bf5 100644 --- a/visualc/VS2010/mbedTLS.vcxproj +++ b/visualc/VS2010/mbedTLS.vcxproj @@ -250,7 +250,7 @@ - + @@ -320,7 +320,7 @@ - + From 59cda7f427db25c0e8d4beca8ed6d1bc3bf66294 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 9 Mar 2021 16:10:29 +0000 Subject: [PATCH 08/18] Rename ecp_internal.h to ecp_alt.h This gives it a more descriptive name and indicates to alt developers that the definitions inside are not fully internal and are available to alt developers for use. Signed-off-by: Chris Jones --- library/ecp.c | 2 +- library/{ecp_internal.h => ecp_alt.h} | 4 ++-- visualc/VS2010/mbedTLS.vcxproj | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename library/{ecp_internal.h => ecp_alt.h} (99%) diff --git a/library/ecp.c b/library/ecp.c index ac17ff164..55d7281fb 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -97,7 +97,7 @@ #define mbedtls_free free #endif -#include "ecp_internal.h" +#include "ecp_alt.h" #if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG) #if defined(MBEDTLS_HMAC_DRBG_C) diff --git a/library/ecp_internal.h b/library/ecp_alt.h similarity index 99% rename from library/ecp_internal.h rename to library/ecp_alt.h index 6a47a8ff2..6b1b29f70 100644 --- a/library/ecp_internal.h +++ b/library/ecp_alt.h @@ -1,5 +1,5 @@ /** - * \file ecp_internal.h + * \file ecp_alt.h * * \brief Function declarations for alternative implementation of elliptic curve * point arithmetic. @@ -293,5 +293,5 @@ int mbedtls_internal_ecp_normalize_mxz( const mbedtls_ecp_group *grp, #endif /* MBEDTLS_ECP_INTERNAL_ALT */ -#endif /* ecp_internal.h */ +#endif /* ecp_alt.h */ diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj index c53e54bf5..3459397c7 100644 --- a/visualc/VS2010/mbedTLS.vcxproj +++ b/visualc/VS2010/mbedTLS.vcxproj @@ -238,7 +238,7 @@ - + From daacb59c2e287a14efa4b99537f8f8edaa9cc7e0 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 9 Mar 2021 17:03:29 +0000 Subject: [PATCH 09/18] Rename _internal.h to *_wrap.h Revert changes introduced in 50518f419589d2c4746f4b6d6be0a2569a3386a8 as it is now clear that these headers are internal without the `*_internal.h` suffix. Signed-off-by: Chris Jones --- include/mbedtls/md.h | 2 +- library/cipher.c | 2 +- library/cipher_wrap.c | 2 +- library/{cipher_internal.h => cipher_wrap.h} | 2 +- library/md.c | 2 +- library/{md_internal.h => md_wrap.h} | 2 +- library/pk.c | 2 +- library/pk_wrap.c | 2 +- library/{pk_internal.h => pk_wrap.h} | 2 +- library/psa_crypto.c | 4 ++-- programs/ssl/ssl_context_info.c | 2 +- tests/suites/test_suite_hkdf.function | 2 +- visualc/VS2010/mbedTLS.vcxproj | 6 +++--- 13 files changed, 16 insertions(+), 16 deletions(-) rename library/{cipher_internal.h => cipher_wrap.h} (99%) rename library/{md_internal.h => md_wrap.h} (99%) rename library/{pk_internal.h => pk_wrap.h} (99%) diff --git a/include/mbedtls/md.h b/include/mbedtls/md.h index e4354badc..25e785e12 100644 --- a/include/mbedtls/md.h +++ b/include/mbedtls/md.h @@ -79,7 +79,7 @@ typedef enum { #endif /** - * Opaque struct defined in md_internal.h. + * Opaque struct defined in md_wrap.h. */ typedef struct mbedtls_md_info_t mbedtls_md_info_t; diff --git a/library/cipher.c b/library/cipher.c index 8d5bff665..c88d6666d 100644 --- a/library/cipher.c +++ b/library/cipher.c @@ -26,7 +26,7 @@ #if defined(MBEDTLS_CIPHER_C) #include "mbedtls/cipher.h" -#include "cipher_internal.h" +#include "cipher_wrap.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" diff --git a/library/cipher_wrap.c b/library/cipher_wrap.c index 35bd76f3e..7f2338725 100644 --- a/library/cipher_wrap.c +++ b/library/cipher_wrap.c @@ -25,7 +25,7 @@ #if defined(MBEDTLS_CIPHER_C) -#include "cipher_internal.h" +#include "cipher_wrap.h" #include "mbedtls/error.h" #if defined(MBEDTLS_CHACHAPOLY_C) diff --git a/library/cipher_internal.h b/library/cipher_wrap.h similarity index 99% rename from library/cipher_internal.h rename to library/cipher_wrap.h index 2484c01c7..5635982b4 100644 --- a/library/cipher_internal.h +++ b/library/cipher_wrap.h @@ -1,5 +1,5 @@ /** - * \file cipher_internal.h + * \file cipher_wrap.h * * \brief Cipher wrappers. * diff --git a/library/md.c b/library/md.c index 6553393f8..4f9c1d0fa 100644 --- a/library/md.c +++ b/library/md.c @@ -26,7 +26,7 @@ #if defined(MBEDTLS_MD_C) #include "mbedtls/md.h" -#include "md_internal.h" +#include "md_wrap.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" diff --git a/library/md_internal.h b/library/md_wrap.h similarity index 99% rename from library/md_internal.h rename to library/md_wrap.h index f33cdf608..83a5ba35e 100644 --- a/library/md_internal.h +++ b/library/md_wrap.h @@ -1,5 +1,5 @@ /** - * \file md_internal.h + * \file md_wrap.h * * \brief Message digest wrappers. * diff --git a/library/pk.c b/library/pk.c index 3824e7912..16b2dd046 100644 --- a/library/pk.c +++ b/library/pk.c @@ -21,7 +21,7 @@ #if defined(MBEDTLS_PK_C) #include "mbedtls/pk.h" -#include "pk_internal.h" +#include "pk_wrap.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" diff --git a/library/pk_wrap.c b/library/pk_wrap.c index 74d7ce16c..a454f1a91 100644 --- a/library/pk_wrap.c +++ b/library/pk_wrap.c @@ -20,7 +20,7 @@ #include "common.h" #if defined(MBEDTLS_PK_C) -#include "pk_internal.h" +#include "pk_wrap.h" #include "mbedtls/error.h" /* Even if RSA not activated, for the sake of RSA-alt */ diff --git a/library/pk_internal.h b/library/pk_wrap.h similarity index 99% rename from library/pk_internal.h rename to library/pk_wrap.h index 47f776770..f7f938a88 100644 --- a/library/pk_internal.h +++ b/library/pk_wrap.h @@ -1,5 +1,5 @@ /** - * \file pk_internal.h + * \file pk_wrap.h * * \brief Public Key abstraction layer: wrapper functions */ diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 2213657ff..5c0e84c0a 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -73,9 +73,9 @@ #include "mbedtls/md4.h" #include "mbedtls/md5.h" #include "mbedtls/md.h" -#include "md_internal.h" +#include "md_wrap.h" #include "mbedtls/pk.h" -#include "pk_internal.h" +#include "pk_wrap.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" #include "mbedtls/ripemd160.h" diff --git a/programs/ssl/ssl_context_info.c b/programs/ssl/ssl_context_info.c index 868951b60..929a0f29a 100644 --- a/programs/ssl/ssl_context_info.c +++ b/programs/ssl/ssl_context_info.c @@ -48,7 +48,7 @@ int main( void ) #include "mbedtls/error.h" #include "mbedtls/base64.h" #include "mbedtls/md.h" -#include "../../library/md_internal.h" +#include "../../library/md_wrap.h" #include "mbedtls/x509_crt.h" #include "mbedtls/ssl_ciphersuites.h" diff --git a/tests/suites/test_suite_hkdf.function b/tests/suites/test_suite_hkdf.function index 174d6accf..6cb111830 100644 --- a/tests/suites/test_suite_hkdf.function +++ b/tests/suites/test_suite_hkdf.function @@ -1,6 +1,6 @@ /* BEGIN_HEADER */ #include "mbedtls/hkdf.h" -#include "md_internal.h" +#include "md_wrap.h" /* END_HEADER */ /* BEGIN_DEPENDENCIES diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj index 3459397c7..8313c111b 100644 --- a/visualc/VS2010/mbedTLS.vcxproj +++ b/visualc/VS2010/mbedTLS.vcxproj @@ -236,11 +236,11 @@ - + - - + + From 187782f41ed540245025d92bf088529520b90094 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 9 Mar 2021 17:28:35 +0000 Subject: [PATCH 10/18] Move aesni.h to library `aesni.h` is an internal header and is moved accordingly. Also removes some references to internal headers in scripts with only public headers. Signed-off-by: Chris Jones --- library/aes.c | 2 +- library/aesni.c | 2 +- {include/mbedtls => library}/aesni.h | 0 library/gcm.c | 2 +- programs/test/cpp_dummy_build.cpp | 1 - programs/test/query_config.c | 2 -- scripts/data_files/query_config.fmt | 2 -- visualc/VS2010/mbedTLS.vcxproj | 2 +- 8 files changed, 4 insertions(+), 9 deletions(-) rename {include/mbedtls => library}/aesni.h (100%) diff --git a/library/aes.c b/library/aes.c index 3f616427a..5201aed4f 100644 --- a/library/aes.c +++ b/library/aes.c @@ -37,7 +37,7 @@ #include "mbedtls/padlock.h" #endif #if defined(MBEDTLS_AESNI_C) -#include "mbedtls/aesni.h" +#include "aesni.h" #endif #if defined(MBEDTLS_SELF_TEST) diff --git a/library/aesni.c b/library/aesni.c index 996292ff6..be226c9c0 100644 --- a/library/aesni.c +++ b/library/aesni.c @@ -32,7 +32,7 @@ #endif #endif -#include "mbedtls/aesni.h" +#include "aesni.h" #include diff --git a/include/mbedtls/aesni.h b/library/aesni.h similarity index 100% rename from include/mbedtls/aesni.h rename to library/aesni.h diff --git a/library/gcm.c b/library/gcm.c index 2363e584e..d2d2eca50 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -38,7 +38,7 @@ #include #if defined(MBEDTLS_AESNI_C) -#include "mbedtls/aesni.h" +#include "aesni.h" #endif #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) diff --git a/programs/test/cpp_dummy_build.cpp b/programs/test/cpp_dummy_build.cpp index c2fdf501d..ae6919434 100644 --- a/programs/test/cpp_dummy_build.cpp +++ b/programs/test/cpp_dummy_build.cpp @@ -25,7 +25,6 @@ #endif #include "mbedtls/aes.h" -#include "mbedtls/aesni.h" #include "mbedtls/arc4.h" #include "mbedtls/aria.h" #include "mbedtls/asn1.h" diff --git a/programs/test/query_config.c b/programs/test/query_config.c index 93bca4b26..395763ec3 100644 --- a/programs/test/query_config.c +++ b/programs/test/query_config.c @@ -37,7 +37,6 @@ * default value when that configuration is not set in the config.h. */ #include "mbedtls/aes.h" -#include "mbedtls/aesni.h" #include "mbedtls/arc4.h" #include "mbedtls/aria.h" #include "mbedtls/asn1.h" @@ -101,7 +100,6 @@ #include "mbedtls/x509_crt.h" #include "mbedtls/x509_csr.h" #include "mbedtls/xtea.h" -#include "../../library/ssl_misc.h" #include diff --git a/scripts/data_files/query_config.fmt b/scripts/data_files/query_config.fmt index ef8f7177d..ed1060809 100644 --- a/scripts/data_files/query_config.fmt +++ b/scripts/data_files/query_config.fmt @@ -37,7 +37,6 @@ * default value when that configuration is not set in the config.h. */ #include "mbedtls/aes.h" -#include "mbedtls/aesni.h" #include "mbedtls/arc4.h" #include "mbedtls/aria.h" #include "mbedtls/asn1.h" @@ -101,7 +100,6 @@ #include "mbedtls/x509_crt.h" #include "mbedtls/x509_csr.h" #include "mbedtls/xtea.h" -#include "../../library/ssl_misc.h" #include diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj index 8313c111b..794150d37 100644 --- a/visualc/VS2010/mbedTLS.vcxproj +++ b/visualc/VS2010/mbedTLS.vcxproj @@ -142,7 +142,6 @@ - @@ -234,6 +233,7 @@ + From 16dbaeb9ebd923b27845456cf084f24bbee76dce Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 9 Mar 2021 17:47:55 +0000 Subject: [PATCH 11/18] Move padlock.h to library `padlock.h` is actually an internal header and is moved accordingly. Signed-off-by: Chris Jones --- library/aes.c | 2 +- library/error.c | 9 --------- library/padlock.c | 2 +- {include/mbedtls => library}/padlock.h | 0 programs/test/cpp_dummy_build.cpp | 1 - programs/test/query_config.c | 1 - scripts/data_files/query_config.fmt | 1 - visualc/VS2010/mbedTLS.vcxproj | 2 +- 8 files changed, 3 insertions(+), 15 deletions(-) rename {include/mbedtls => library}/padlock.h (100%) diff --git a/library/aes.c b/library/aes.c index 5201aed4f..b36b81c73 100644 --- a/library/aes.c +++ b/library/aes.c @@ -34,7 +34,7 @@ #include "mbedtls/platform_util.h" #include "mbedtls/error.h" #if defined(MBEDTLS_PADLOCK_C) -#include "mbedtls/padlock.h" +#include "padlock.h" #endif #if defined(MBEDTLS_AESNI_C) #include "aesni.h" diff --git a/library/error.c b/library/error.c index 901a3699a..bb6e965a9 100644 --- a/library/error.c +++ b/library/error.c @@ -146,10 +146,6 @@ #include "mbedtls/oid.h" #endif -#if defined(MBEDTLS_PADLOCK_C) -#include "mbedtls/padlock.h" -#endif - #if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C) #include "mbedtls/pem.h" #endif @@ -822,11 +818,6 @@ const char * mbedtls_low_level_strerr( int error_code ) return( "OID - output buffer is too small" ); #endif /* MBEDTLS_OID_C */ -#if defined(MBEDTLS_PADLOCK_C) - case -(MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED): - return( "PADLOCK - Input data should be aligned" ); -#endif /* MBEDTLS_PADLOCK_C */ - #if defined(MBEDTLS_PLATFORM_C) case -(MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED): return( "PLATFORM - Hardware accelerator failed" ); diff --git a/library/padlock.c b/library/padlock.c index 837337413..b8ba1058a 100644 --- a/library/padlock.c +++ b/library/padlock.c @@ -27,7 +27,7 @@ #if defined(MBEDTLS_PADLOCK_C) -#include "mbedtls/padlock.h" +#include "padlock.h" #include diff --git a/include/mbedtls/padlock.h b/library/padlock.h similarity index 100% rename from include/mbedtls/padlock.h rename to library/padlock.h diff --git a/programs/test/cpp_dummy_build.cpp b/programs/test/cpp_dummy_build.cpp index ae6919434..5706bc798 100644 --- a/programs/test/cpp_dummy_build.cpp +++ b/programs/test/cpp_dummy_build.cpp @@ -62,7 +62,6 @@ #include "mbedtls/net_sockets.h" #include "mbedtls/nist_kw.h" #include "mbedtls/oid.h" -#include "mbedtls/padlock.h" #include "mbedtls/pem.h" #include "mbedtls/pk.h" #include "mbedtls/pkcs11.h" diff --git a/programs/test/query_config.c b/programs/test/query_config.c index 395763ec3..7b508d872 100644 --- a/programs/test/query_config.c +++ b/programs/test/query_config.c @@ -73,7 +73,6 @@ #include "mbedtls/net_sockets.h" #include "mbedtls/nist_kw.h" #include "mbedtls/oid.h" -#include "mbedtls/padlock.h" #include "mbedtls/pem.h" #include "mbedtls/pk.h" #include "mbedtls/pkcs11.h" diff --git a/scripts/data_files/query_config.fmt b/scripts/data_files/query_config.fmt index ed1060809..f24622026 100644 --- a/scripts/data_files/query_config.fmt +++ b/scripts/data_files/query_config.fmt @@ -73,7 +73,6 @@ #include "mbedtls/net_sockets.h" #include "mbedtls/nist_kw.h" #include "mbedtls/oid.h" -#include "mbedtls/padlock.h" #include "mbedtls/pem.h" #include "mbedtls/pk.h" #include "mbedtls/pkcs11.h" diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj index 794150d37..80a8cd1c5 100644 --- a/visualc/VS2010/mbedTLS.vcxproj +++ b/visualc/VS2010/mbedTLS.vcxproj @@ -182,7 +182,6 @@ - @@ -240,6 +239,7 @@ + From ea0a865c69b643fbadbd79e40eda18e9f7f82995 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 9 Mar 2021 19:11:19 +0000 Subject: [PATCH 12/18] Move entropy_poll.h to library `entropy_poll.h` is not supposed to be used by application code and is therefore being made internal. Signed-off-by: Chris Jones --- library/entropy.c | 2 +- library/entropy_poll.c | 2 +- {include/mbedtls => library}/entropy_poll.h | 0 library/psa_crypto.c | 2 +- programs/test/cpp_dummy_build.cpp | 1 - programs/test/query_config.c | 1 - programs/test/selftest.c | 2 +- scripts/data_files/query_config.fmt | 1 - tests/suites/test_suite_entropy.function | 2 +- tests/suites/test_suite_psa_crypto_entropy.function | 2 +- tests/suites/test_suite_psa_crypto_init.function | 2 +- visualc/VS2010/mbedTLS.vcxproj | 2 +- 12 files changed, 8 insertions(+), 11 deletions(-) rename {include/mbedtls => library}/entropy_poll.h (100%) diff --git a/library/entropy.c b/library/entropy.c index deda97c50..1ac4cf540 100644 --- a/library/entropy.c +++ b/library/entropy.c @@ -28,7 +28,7 @@ #endif #include "mbedtls/entropy.h" -#include "mbedtls/entropy_poll.h" +#include "entropy_poll.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" diff --git a/library/entropy_poll.c b/library/entropy_poll.c index a3200d90f..4fbe1ee11 100644 --- a/library/entropy_poll.c +++ b/library/entropy_poll.c @@ -29,7 +29,7 @@ #if defined(MBEDTLS_ENTROPY_C) #include "mbedtls/entropy.h" -#include "mbedtls/entropy_poll.h" +#include "entropy_poll.h" #include "mbedtls/error.h" #if defined(MBEDTLS_TIMING_C) diff --git a/include/mbedtls/entropy_poll.h b/library/entropy_poll.h similarity index 100% rename from include/mbedtls/entropy_poll.h rename to library/entropy_poll.h diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 5c0e84c0a..91e56436f 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -6482,7 +6482,7 @@ int mbedtls_psa_get_random( void *p_rng, #endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */ #if defined(MBEDTLS_PSA_INJECT_ENTROPY) -#include "mbedtls/entropy_poll.h" +#include "entropy_poll.h" psa_status_t mbedtls_psa_inject_entropy( const uint8_t *seed, size_t seed_size ) diff --git a/programs/test/cpp_dummy_build.cpp b/programs/test/cpp_dummy_build.cpp index 5706bc798..f45be5463 100644 --- a/programs/test/cpp_dummy_build.cpp +++ b/programs/test/cpp_dummy_build.cpp @@ -49,7 +49,6 @@ #include "mbedtls/ecjpake.h" #include "mbedtls/ecp.h" #include "mbedtls/entropy.h" -#include "mbedtls/entropy_poll.h" #include "mbedtls/error.h" #include "mbedtls/gcm.h" #include "mbedtls/hkdf.h" diff --git a/programs/test/query_config.c b/programs/test/query_config.c index 7b508d872..f13be2ab7 100644 --- a/programs/test/query_config.c +++ b/programs/test/query_config.c @@ -60,7 +60,6 @@ #include "mbedtls/ecjpake.h" #include "mbedtls/ecp.h" #include "mbedtls/entropy.h" -#include "mbedtls/entropy_poll.h" #include "mbedtls/error.h" #include "mbedtls/gcm.h" #include "mbedtls/hkdf.h" diff --git a/programs/test/selftest.c b/programs/test/selftest.c index 41d704073..02e1d1214 100644 --- a/programs/test/selftest.c +++ b/programs/test/selftest.c @@ -24,7 +24,6 @@ #endif #include "mbedtls/entropy.h" -#include "mbedtls/entropy_poll.h" #include "mbedtls/hmac_drbg.h" #include "mbedtls/ctr_drbg.h" #include "mbedtls/dhm.h" @@ -56,6 +55,7 @@ #include "mbedtls/ecjpake.h" #include "mbedtls/timing.h" #include "mbedtls/nist_kw.h" +#include "../library/entropy_poll.h" #include diff --git a/scripts/data_files/query_config.fmt b/scripts/data_files/query_config.fmt index f24622026..6b55a2eeb 100644 --- a/scripts/data_files/query_config.fmt +++ b/scripts/data_files/query_config.fmt @@ -60,7 +60,6 @@ #include "mbedtls/ecjpake.h" #include "mbedtls/ecp.h" #include "mbedtls/entropy.h" -#include "mbedtls/entropy_poll.h" #include "mbedtls/error.h" #include "mbedtls/gcm.h" #include "mbedtls/hkdf.h" diff --git a/tests/suites/test_suite_entropy.function b/tests/suites/test_suite_entropy.function index d9ea44149..88698962d 100644 --- a/tests/suites/test_suite_entropy.function +++ b/tests/suites/test_suite_entropy.function @@ -1,6 +1,6 @@ /* BEGIN_HEADER */ #include "mbedtls/entropy.h" -#include "mbedtls/entropy_poll.h" +#include "entropy_poll.h" #include "mbedtls/md.h" #include "string.h" diff --git a/tests/suites/test_suite_psa_crypto_entropy.function b/tests/suites/test_suite_psa_crypto_entropy.function index 8c1fdab1a..3019b7b95 100644 --- a/tests/suites/test_suite_psa_crypto_entropy.function +++ b/tests/suites/test_suite_psa_crypto_entropy.function @@ -5,7 +5,7 @@ #include #include "mbedtls/entropy.h" -#include "mbedtls/entropy_poll.h" +#include "entropy_poll.h" /* Calculating the minimum allowed entropy size in bytes */ #define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE) diff --git a/tests/suites/test_suite_psa_crypto_init.function b/tests/suites/test_suite_psa_crypto_init.function index 5fa29d74e..d612548d7 100644 --- a/tests/suites/test_suite_psa_crypto_init.function +++ b/tests/suites/test_suite_psa_crypto_init.function @@ -5,7 +5,7 @@ #include "psa_crypto_invasive.h" #include "mbedtls/entropy.h" -#include "mbedtls/entropy_poll.h" +#include "entropy_poll.h" #define ENTROPY_MIN_NV_SEED_SIZE \ MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE) diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj index 80a8cd1c5..7c083f726 100644 --- a/visualc/VS2010/mbedTLS.vcxproj +++ b/visualc/VS2010/mbedTLS.vcxproj @@ -168,7 +168,6 @@ - @@ -238,6 +237,7 @@ + From 1508fd10649b83c3b177dfe527abe2bafc17ca14 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 10 Mar 2021 10:21:01 +0000 Subject: [PATCH 13/18] Remove broken doxygen link to internal macro Removes a broken doxygen link to a macro that is now internal and cannot be seen from the public API anymore. Signed-off-by: Chris Jones --- include/psa/crypto_extra.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/psa/crypto_extra.h b/include/psa/crypto_extra.h index 9abce33d5..8d9819058 100644 --- a/include/psa/crypto_extra.h +++ b/include/psa/crypto_extra.h @@ -297,7 +297,7 @@ void mbedtls_psa_get_stats( mbedtls_psa_stats_t *stats ); * \param[in] seed Buffer containing the seed value to inject. * \param[in] seed_size Size of the \p seed buffer. * The size of the seed in bytes must be greater - * or equal to both #MBEDTLS_ENTROPY_MIN_PLATFORM + * or equal to both MBEDTLS_ENTROPY_MIN_PLATFORM * and #MBEDTLS_ENTROPY_BLOCK_SIZE. * It must be less or equal to * #MBEDTLS_ENTROPY_MAX_SEED_SIZE. From 3848e31eac791d509b24a56e90906d179a82afa5 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 11 Mar 2021 16:17:59 +0000 Subject: [PATCH 14/18] Fix internal references in public documentation Signed-off-by: Chris Jones --- include/mbedtls/cipher.h | 6 +++--- include/mbedtls/config.h | 7 ++++--- include/mbedtls/md.h | 9 ++++++++- include/mbedtls/pk.h | 2 +- include/mbedtls/ssl.h | 2 +- include/psa/crypto_extra.h | 6 ++++-- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/include/mbedtls/cipher.h b/include/mbedtls/cipher.h index f5f56b55d..bfc911fc1 100644 --- a/include/mbedtls/cipher.h +++ b/include/mbedtls/cipher.h @@ -229,13 +229,13 @@ enum { /** Maximum length of any IV, in Bytes. */ /* This should ideally be derived automatically from list of ciphers. * This should be kept in sync with MBEDTLS_SSL_MAX_IV_LENGTH defined - * in ssl_misc.h. */ + * in library/ssl_misc.h. */ #define MBEDTLS_MAX_IV_LENGTH 16 /** Maximum block size of any cipher, in Bytes. */ /* This should ideally be derived automatically from list of ciphers. * This should be kept in sync with MBEDTLS_SSL_MAX_BLOCK_LENGTH defined - * in ssl_misc.h. */ + * in library/ssl_misc.h. */ #define MBEDTLS_MAX_BLOCK_LENGTH 16 /** Maximum key length, in Bytes. */ @@ -243,7 +243,7 @@ enum { * For now, only check whether XTS is enabled which uses 64 Byte keys, * and use 32 Bytes as an upper bound for the maximum key length otherwise. * This should be kept in sync with MBEDTLS_SSL_MAX_BLOCK_LENGTH defined - * in ssl_misc.h, which however deliberately ignores the case of XTS + * in library/ssl_misc.h, which however deliberately ignores the case of XTS * since the latter isn't used in SSL/TLS. */ #if defined(MBEDTLS_CIPHER_MODE_XTS) #define MBEDTLS_MAX_KEY_LENGTH 64 diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h index a2e8b85d5..f6647f009 100644 --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h @@ -547,7 +547,8 @@ * hardware entropy collector. * * Your function must be called \c mbedtls_hardware_poll(), have the same - * prototype as declared in entropy_poll.h, and accept NULL as first argument. + * prototype as declared in library/entropy_poll.h, and accept NULL as first + * argument. * * Uncomment to use your own hardware entropy collector. */ @@ -2400,7 +2401,7 @@ * library/ecp.c * library/ecdsa.c * library/rsa.c - * library/rsa_alt_helpers.h + * library/rsa_alt_helpers.c * library/ssl_tls.c * * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. @@ -3198,7 +3199,7 @@ * Enable the RSA public-key cryptosystem. * * Module: library/rsa.c - * library/rsa_alt_helpers.h + * library/rsa_alt_helpers.c * Caller: library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c diff --git a/include/mbedtls/md.h b/include/mbedtls/md.h index 25e785e12..edb37f1e8 100644 --- a/include/mbedtls/md.h +++ b/include/mbedtls/md.h @@ -79,8 +79,15 @@ typedef enum { #endif /** - * Opaque struct defined in md_wrap.h. + * Opaque struct. + * + * Constructed using either #mbedtls_md_info_from_string or + * #mbedtls_md_info_from_type. + * + * Fields can be accessed with #mbedtls_md_get_size, + * #mbedtls_md_get_type and #mbedtls_md_get_name. */ +/* Defined internally in library/md_wrap.h. */ typedef struct mbedtls_md_info_t mbedtls_md_info_t; /** diff --git a/include/mbedtls/pk.h b/include/mbedtls/pk.h index 85e553add..f3866563d 100644 --- a/include/mbedtls/pk.h +++ b/include/mbedtls/pk.h @@ -118,7 +118,7 @@ typedef struct mbedtls_pk_rsassa_pss_options /* For RSA, the signature can be as large as the bignum module allows. * For RSA_ALT, the signature size is not necessarily tied to what the * bignum module can do, but in the absence of any specific setting, - * we use that (rsa_alt_sign_wrap in pk_wrap will check). */ + * we use that (rsa_alt_sign_wrap in library/pk_wrap.h will check). */ #undef MBEDTLS_PK_SIGNATURE_MAX_SIZE #define MBEDTLS_PK_SIGNATURE_MAX_SIZE MBEDTLS_MPI_MAX_SIZE #endif diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 16ed5b70f..e7150f2a0 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -619,7 +619,7 @@ typedef struct mbedtls_ssl_session mbedtls_ssl_session; typedef struct mbedtls_ssl_context mbedtls_ssl_context; typedef struct mbedtls_ssl_config mbedtls_ssl_config; -/* Defined in ssl_misc.h */ +/* Defined in library/ssl_misc.h */ typedef struct mbedtls_ssl_transform mbedtls_ssl_transform; typedef struct mbedtls_ssl_handshake_params mbedtls_ssl_handshake_params; typedef struct mbedtls_ssl_sig_hash_set_t mbedtls_ssl_sig_hash_set_t; diff --git a/include/psa/crypto_extra.h b/include/psa/crypto_extra.h index 8d9819058..75dd84dc9 100644 --- a/include/psa/crypto_extra.h +++ b/include/psa/crypto_extra.h @@ -297,8 +297,10 @@ void mbedtls_psa_get_stats( mbedtls_psa_stats_t *stats ); * \param[in] seed Buffer containing the seed value to inject. * \param[in] seed_size Size of the \p seed buffer. * The size of the seed in bytes must be greater - * or equal to both MBEDTLS_ENTROPY_MIN_PLATFORM - * and #MBEDTLS_ENTROPY_BLOCK_SIZE. + * or equal to both #MBEDTLS_ENTROPY_BLOCK_SIZE + * and the value of \c MBEDTLS_ENTROPY_MIN_PLATFORM + * in `library/entropy_poll.h` in the Mbed TLS source + * code. * It must be less or equal to * #MBEDTLS_ENTROPY_MAX_SEED_SIZE. * From a1df4949b9524f5363c9c81739e971fa647b3e15 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 11 Mar 2021 17:44:43 +0000 Subject: [PATCH 15/18] Remove internal file references in programs/ `entropy_poll.h` and `md_wrap.h` were still being used in some of the example programs. As these headers are now internal, remove their references and replace them with publicly available functions. Signed-off-by: Chris Jones --- include/mbedtls/entropy.h | 8 ++++++++ programs/ssl/ssl_context_info.c | 3 +-- programs/test/selftest.c | 1 - 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/mbedtls/entropy.h b/include/mbedtls/entropy.h index a4fd0be88..0ba30af50 100644 --- a/include/mbedtls/entropy.h +++ b/include/mbedtls/entropy.h @@ -134,6 +134,14 @@ typedef struct mbedtls_entropy_context } mbedtls_entropy_context; +#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY) +/** + * \brief Platform-specific entropy poll callback + */ +int mbedtls_platform_entropy_poll( void *data, + unsigned char *output, size_t len, size_t *olen ); +#endif + /** * \brief Initialize the context * diff --git a/programs/ssl/ssl_context_info.c b/programs/ssl/ssl_context_info.c index 929a0f29a..4a7c77340 100644 --- a/programs/ssl/ssl_context_info.c +++ b/programs/ssl/ssl_context_info.c @@ -48,7 +48,6 @@ int main( void ) #include "mbedtls/error.h" #include "mbedtls/base64.h" #include "mbedtls/md.h" -#include "../../library/md_wrap.h" #include "mbedtls/x509_crt.h" #include "mbedtls/ssl_ciphersuites.h" @@ -638,7 +637,7 @@ void print_deserialized_ssl_session( const uint8_t *ssl, uint32_t len, } else { - printf( "\tMessage-Digest : %s\n", md_info->name ); + printf( "\tMessage-Digest : %s\n", mbedtls_md_get_name( md_info ) ); } } diff --git a/programs/test/selftest.c b/programs/test/selftest.c index 02e1d1214..26c1997fb 100644 --- a/programs/test/selftest.c +++ b/programs/test/selftest.c @@ -55,7 +55,6 @@ #include "mbedtls/ecjpake.h" #include "mbedtls/timing.h" #include "mbedtls/nist_kw.h" -#include "../library/entropy_poll.h" #include From ca38fabf0cf77976c02ebc3b3233afd8c1866efc Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 12 Mar 2021 09:57:26 +0000 Subject: [PATCH 16/18] Add move_internal_headers changelog Signed-off-by: Chris Jones --- ChangeLog.d/move_internal_headers.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 ChangeLog.d/move_internal_headers.txt diff --git a/ChangeLog.d/move_internal_headers.txt b/ChangeLog.d/move_internal_headers.txt new file mode 100644 index 000000000..25e8922e2 --- /dev/null +++ b/ChangeLog.d/move_internal_headers.txt @@ -0,0 +1,6 @@ +API changes + * Move internal headers. + All internal headers have been moved to library/ to unify them in one + location that is separate from the public API. This includes some files + that were previously not explicitly internal such as: `bn_mul.h`, + `aesni.h`, `padlock.h` and `entropy_poll.h`. From d02f4c2e44edb2e18c8bb38da73f9c1852f31149 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 19 Mar 2021 15:14:48 +0000 Subject: [PATCH 17/18] Reword move_internal_headers changelog entry Reword the changelog entry to tailor it for users of the library as opposed to developers of the library. Signed-off-by: Chris Jones --- ChangeLog.d/move_internal_headers.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog.d/move_internal_headers.txt b/ChangeLog.d/move_internal_headers.txt index 25e8922e2..8a38fe68d 100644 --- a/ChangeLog.d/move_internal_headers.txt +++ b/ChangeLog.d/move_internal_headers.txt @@ -1,6 +1,6 @@ API changes * Move internal headers. - All internal headers have been moved to library/ to unify them in one - location that is separate from the public API. This includes some files - that were previously not explicitly internal such as: `bn_mul.h`, - `aesni.h`, `padlock.h` and `entropy_poll.h`. + Header files that were only meant for the library's internal use and + were not meant to be used in application code have been moved out of + the include/ directory. The headers concerned are bn_mul.h, aesni.h, + padlock.h, entropy_poll.h and *_internal.h. From 8d2bc90b4e16a62a7d3c49d9631128de7d502324 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 19 Mar 2021 15:17:23 +0000 Subject: [PATCH 18/18] Add changelog entry for alt implementors Files available for use by alt implementations have been moved and renamed so alt implementators should be told about the changes specific to them. Signed-off-by: Chris Jones --- ChangeLog.d/move_alt_helpers.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 ChangeLog.d/move_alt_helpers.txt diff --git a/ChangeLog.d/move_alt_helpers.txt b/ChangeLog.d/move_alt_helpers.txt new file mode 100644 index 000000000..ba96c9d1a --- /dev/null +++ b/ChangeLog.d/move_alt_helpers.txt @@ -0,0 +1,7 @@ +API changes + * Move alt helpers and definitions. + Various helpers and definitions available for use in alt implementations + have been moved out of the include/ directory and into the library/ + directory. The files concerned are ecp_internal.h and rsa_internal.h + which have also been renamed to ecp_alt.h and rsa_alt_helpers.h + respectively.