Skip to content

Commit ba2376c

Browse files
Merge pull request #10275 from ariwo17/remove-des-core-before-crypto
Remove DES from Mbed TLS core (except references blocked by TF PSA Crypto)
2 parents 7aa58bc + 5d8d299 commit ba2376c

File tree

5 files changed

+16
-64
lines changed

5 files changed

+16
-64
lines changed

programs/test/selftest.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "mbedtls/sha256.h"
2222
#include "mbedtls/sha512.h"
2323
#include "mbedtls/sha3.h"
24-
#include "mbedtls/des.h"
2524
#include "mbedtls/aes.h"
2625
#include "mbedtls/camellia.h"
2726
#include "mbedtls/aria.h"
@@ -296,9 +295,6 @@ const selftest_t selftests[] =
296295
defined(PSA_WANT_ALG_SHA3_512)
297296
{ "sha3", mbedtls_sha3_self_test },
298297
#endif
299-
#if defined(MBEDTLS_DES_C)
300-
{ "des", mbedtls_des_self_test },
301-
#endif
302298
#if defined(MBEDTLS_AES_C)
303299
{ "aes", mbedtls_aes_self_test },
304300
#endif
@@ -448,7 +444,8 @@ int main(int argc, char *argv[])
448444
} \
449445
} else { \
450446
mbedtls_printf("Padding checks only implemented for types of size 2, 4 or 8" \
451-
" - cannot check type '" #TYPE "' of size %" MBEDTLS_PRINTF_SIZET "\n", \
447+
" - cannot check type '" #TYPE "' of size %" MBEDTLS_PRINTF_SIZET \
448+
"\n", \
452449
sizeof(TYPE)); \
453450
mbedtls_exit(MBEDTLS_EXIT_FAILURE); \
454451
} \

scripts/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def realfull_adapter(_name, _value, _active):
7575
#pylint: disable=line-too-long
7676
'MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH', # interacts with CTR_DRBG_128_BIT_KEY
7777
'MBEDTLS_AES_USE_HARDWARE_ONLY', # hardware dependency
78-
'MBEDTLS_BLOCK_CIPHER_NO_DECRYPT', # incompatible with ECB in PSA, CBC/XTS/NIST_KW/DES
78+
'MBEDTLS_BLOCK_CIPHER_NO_DECRYPT', # incompatible with ECB in PSA, CBC/XTS/NIST_KW
7979
'MBEDTLS_CTR_DRBG_USE_128_BIT_KEY', # interacts with ENTROPY_FORCE_SHA256
8080
'MBEDTLS_DEPRECATED_REMOVED', # conflicts with deprecated options
8181
'MBEDTLS_DEPRECATED_WARNING', # conflicts with deprecated options

tests/compat.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,11 +599,6 @@ setup_arguments()
599599
*) O_SUPPORT_STATIC_ECDH="NO";;
600600
esac
601601

602-
case $($OPENSSL ciphers ALL) in
603-
*DES-CBC-*) O_SUPPORT_SINGLE_DES="YES";;
604-
*) O_SUPPORT_SINGLE_DES="NO";;
605-
esac
606-
607602
# OpenSSL <1.0.2 doesn't support DTLS 1.2. Check if OpenSSL
608603
# supports -dtls1_2 from the s_server help. (The s_client
609604
# help isn't accurate as of 1.0.2g: it supports DTLS 1.2

tests/scripts/components-configuration-crypto.sh

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,53 +1734,6 @@ component_test_psa_crypto_config_reference_hmac () {
17341734
make test
17351735
}
17361736

1737-
component_test_psa_crypto_config_accel_des () {
1738-
msg "test: accelerated DES"
1739-
1740-
# Albeit this components aims at accelerating DES which should only support
1741-
# CBC and ECB modes, we need to accelerate more than that otherwise DES_C
1742-
# would automatically be re-enabled by "config_adjust_legacy_from_psa.c"
1743-
loc_accel_list="ALG_ECB_NO_PADDING ALG_CBC_NO_PADDING ALG_CBC_PKCS7 \
1744-
ALG_CTR ALG_CFB ALG_OFB ALG_XTS ALG_CMAC \
1745-
KEY_TYPE_DES"
1746-
1747-
# Note: we cannot accelerate all ciphers' key types otherwise we would also
1748-
# have to either disable CCM/GCM or accelerate them, but that's out of scope
1749-
# of this component. This limitation will be addressed by #8598.
1750-
1751-
# Configure
1752-
# ---------
1753-
1754-
# Start from the full config
1755-
helper_libtestdriver1_adjust_config "full"
1756-
1757-
# Disable the things that are being accelerated
1758-
scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
1759-
scripts/config.py unset MBEDTLS_CIPHER_PADDING_PKCS7
1760-
scripts/config.py unset MBEDTLS_CIPHER_MODE_CTR
1761-
scripts/config.py unset MBEDTLS_CIPHER_MODE_CFB
1762-
scripts/config.py unset MBEDTLS_CIPHER_MODE_OFB
1763-
scripts/config.py unset MBEDTLS_CIPHER_MODE_XTS
1764-
scripts/config.py unset MBEDTLS_DES_C
1765-
scripts/config.py unset MBEDTLS_CMAC_C
1766-
1767-
# Build
1768-
# -----
1769-
1770-
helper_libtestdriver1_make_drivers "$loc_accel_list"
1771-
1772-
helper_libtestdriver1_make_main "$loc_accel_list"
1773-
1774-
# Make sure this was not re-enabled by accident (additive config)
1775-
not grep mbedtls_des ${BUILTIN_SRC_PATH}/des.o
1776-
1777-
# Run the tests
1778-
# -------------
1779-
1780-
msg "test: accelerated DES"
1781-
make test
1782-
}
1783-
17841737
component_test_psa_crypto_config_accel_aead () {
17851738
msg "test: accelerated AEAD"
17861739

@@ -1841,7 +1794,7 @@ component_test_psa_crypto_config_accel_cipher_aead_cmac () {
18411794
loc_accel_list="ALG_ECB_NO_PADDING ALG_CBC_NO_PADDING ALG_CBC_PKCS7 ALG_CTR ALG_CFB \
18421795
ALG_OFB ALG_XTS ALG_STREAM_CIPHER ALG_CCM_STAR_NO_TAG \
18431796
ALG_GCM ALG_CCM ALG_CHACHA20_POLY1305 ALG_CMAC \
1844-
KEY_TYPE_DES KEY_TYPE_AES KEY_TYPE_ARIA KEY_TYPE_CHACHA20 KEY_TYPE_CAMELLIA"
1797+
KEY_TYPE_AES KEY_TYPE_ARIA KEY_TYPE_CHACHA20 KEY_TYPE_CAMELLIA"
18451798

18461799
# Configure
18471800
# ---------
@@ -1865,6 +1818,10 @@ component_test_psa_crypto_config_accel_cipher_aead_cmac () {
18651818
scripts/config.py unset MBEDTLS_CHACHA20_C
18661819
scripts/config.py unset MBEDTLS_CAMELLIA_C
18671820

1821+
# Disable DES, if it still exists.
1822+
# This can be removed once we remove DES from the library.
1823+
scripts/config.py unset PSA_WANT_KEY_TYPE_DES
1824+
18681825
# Disable CIPHER_C entirely as all ciphers/AEADs are accelerated and PSA
18691826
# does not depend on it.
18701827
scripts/config.py unset MBEDTLS_CIPHER_C
@@ -1878,7 +1835,6 @@ component_test_psa_crypto_config_accel_cipher_aead_cmac () {
18781835

18791836
# Make sure this was not re-enabled by accident (additive config)
18801837
not grep mbedtls_cipher ${BUILTIN_SRC_PATH}/cipher.o
1881-
not grep mbedtls_des ${BUILTIN_SRC_PATH}/des.o
18821838
not grep mbedtls_aes ${BUILTIN_SRC_PATH}/aes.o
18831839
not grep mbedtls_aria ${BUILTIN_SRC_PATH}/aria.o
18841840
not grep mbedtls_camellia ${BUILTIN_SRC_PATH}/camellia.o
@@ -1904,6 +1860,10 @@ component_test_psa_crypto_config_reference_cipher_aead_cmac () {
19041860
msg "build: full config with non-accelerated cipher inc. AEAD and CMAC"
19051861
common_psa_crypto_config_accel_cipher_aead_cmac
19061862

1863+
# Disable DES, if it still exists.
1864+
# This can be removed once we remove DES from the library.
1865+
scripts/config.py unset PSA_WANT_KEY_TYPE_DES
1866+
19071867
make
19081868

19091869
msg "test: full config with non-accelerated cipher inc. AEAD and CMAC"
@@ -2168,7 +2128,7 @@ component_build_aes_variations () {
21682128
cd "$MBEDTLS_ROOT_DIR"
21692129
msg "build: aes.o for all combinations of relevant config options + BLOCK_CIPHER_NO_DECRYPT"
21702130

2171-
# MBEDTLS_BLOCK_CIPHER_NO_DECRYPT is incompatible with ECB in PSA, CBC/XTS/NIST_KW/DES,
2131+
# MBEDTLS_BLOCK_CIPHER_NO_DECRYPT is incompatible with ECB in PSA, CBC/XTS/NIST_KW,
21722132
# manually set or unset those configurations to check
21732133
# MBEDTLS_BLOCK_CIPHER_NO_DECRYPT with various combinations in aes.o.
21742134
scripts/config.py set MBEDTLS_BLOCK_CIPHER_NO_DECRYPT

tests/scripts/components-configuration-tls.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ component_test_tls1_2_default_stream_cipher_only () {
6363
# Disable CBC. Note: When implemented, PSA_WANT_ALG_CBC_MAC will also need to be unset here to fully disable CBC
6464
scripts/config.py -c $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_NO_PADDING
6565
scripts/config.py -c $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_PKCS7
66-
# Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
66+
# Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia))
6767
# Note: The unset below is to be removed for 4.0
6868
scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
6969
# Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
@@ -96,7 +96,7 @@ component_test_tls1_2_default_cbc_legacy_cipher_only () {
9696
scripts/config.py unset MBEDTLS_CHACHAPOLY_C
9797
#Disable TLS 1.3 (as no AEAD)
9898
scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
99-
# Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
99+
# Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia))
100100
scripts/config.py -c $CRYPTO_CONFIG_H set PSA_WANT_ALG_CBC_NO_PADDING
101101
# Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
102102
scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
@@ -129,7 +129,7 @@ component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only () {
129129
scripts/config.py unset MBEDTLS_CHACHAPOLY_C
130130
#Disable TLS 1.3 (as no AEAD)
131131
scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
132-
# Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
132+
# Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia))
133133
scripts/config.py -c $CRYPTO_CONFIG_H set PSA_WANT_ALG_CBC_NO_PADDING
134134
# Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
135135
scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC

0 commit comments

Comments
 (0)