1#!/usr/bin/env python3 2"""Test the configuration checks generated by generate_config_checks.py. 3""" 4 5## Copyright The Mbed TLS Contributors 6## SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 7 8import unittest 9 10import scripts_path # pylint: disable=unused-import 11from mbedtls_framework import unittest_config_checks 12 13 14class MbedtlsTestConfigChecks(unittest_config_checks.TestConfigChecks): 15 """Mbed TLS unit tests for checks generated by config_checks_generator.""" 16 17 #pylint: disable=invalid-name # uppercase letters make sense here 18 19 PROJECT_CONFIG_C = 'library/mbedtls_config.c' 20 PROJECT_SPECIFIC_INCLUDE_DIRECTORIES = [ 21 'tf-psa-crypto/include', 22 'tf-psa-crypto/drivers/builtin/include', 23 ] 24 25 @unittest.skip("At this time, mbedtls does not go through crypto's check_config.h.") 26 def test_crypto_no_fs_io(self) -> None: 27 """A sample error expected from crypto's check_config.h.""" 28 self.bad_case('#undef MBEDTLS_FS_IO', 29 None, 30 error=('MBEDTLS_PSA_ITS_FILE_C')) 31 32 def test_mbedtls_no_session_tickets_for_early_data(self) -> None: 33 """An error expected from mbedtls_check_config.h based on the TLS configuration.""" 34 self.bad_case(None, 35 ''' 36 #define MBEDTLS_SSL_EARLY_DATA 37 #undef MBEDTLS_SSL_SESSION_TICKETS 38 ''', 39 error=('MBEDTLS_SSL_EARLY_DATA')) 40 41 def test_mbedtls_no_ecdsa(self) -> None: 42 """An error expected from mbedtls_check_config.h based on crypto+TLS configuration.""" 43 self.bad_case(''' 44 #undef PSA_WANT_ALG_ECDSA 45 #undef PSA_WANT_ALG_DETERMINISTIC_ECDSA 46 #undef MBEDTLS_ECDSA_C 47 ''', 48 ''' 49 #if defined(PSA_WANT_ALG_ECDSA) 50 #error PSA_WANT_ALG_ECDSA unexpected 51 #endif 52 #if defined(PSA_WANT_ALG_DETERMINSTIC_ECDSA) 53 #error PSA_WANT_ALG_DETERMINSTIC_ECDSA unexpected 54 #endif 55 #if defined(MBEDTLS_ECDSA_C) 56 #error MBEDTLS_ECDSA_C unexpected 57 #endif 58 ''', 59 error=('MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED')) 60 61 62if __name__ == '__main__': 63 unittest.main() 64