5 # Copyright (c) 2017, ARM Limited, All Rights Reserved
9 # To test the code dependencies on individual PK algs (those that can be used
10 # from the PK layer, so currently signature and encryption but not key
11 # exchange) in each test suite. This is a verification step to ensure we don't
12 # ship test suites that do not work for some build options.
15 # for each possible PK alg
16 # build the library and test suites with that alg disabled
17 # execute the test suites
19 # And any test suite with the wrong dependencies will fail.
21 # Usage: tests/scripts/depends-pkalgs.pl
23 # This script should be executed from the root of the project directory.
25 # For best effect, run either with cmake disabled, or cmake enabled in a mode
26 # that includes -Werror.
31 -d 'library' && -d 'include' && -d 'tests' or die "Must be run from root\n";
33 my $config_h = 'include/mbedtls/config.h';
35 # Some algorithms can't be disabled on their own as others depend on them, so
36 # we list those reverse-dependencies here to keep check_config.h happy.
38 'MBEDTLS_ECDSA_C' => ['MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED'],
39 'MBEDTLS_ECP_C' => ['MBEDTLS_ECDSA_C',
42 'MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED',
43 'MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED',
44 'MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED',
45 'MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED',
46 'MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED'],
47 'MBEDTLS_X509_RSASSA_PSS_SUPPORT' => [],
48 'MBEDTLS_PKCS1_V21' => ['MBEDTLS_X509_RSASSA_PSS_SUPPORT'],
49 'MBEDTLS_PKCS1_V15' => ['MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED',
50 'MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED',
51 'MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED',
52 'MBEDTLS_KEY_EXCHANGE_RSA_ENABLED'],
53 'MBEDTLS_RSA_C' => ['MBEDTLS_X509_RSASSA_PSS_SUPPORT',
54 'MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED',
55 'MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED',
56 'MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED',
57 'MBEDTLS_KEY_EXCHANGE_RSA_ENABLED'],
60 system( "cp $config_h $config_h.bak" ) and die;
62 system( "mv $config_h.bak $config_h" ) and warn "$config_h not restored\n";
63 # use an exit code between 1 and 124 for git bisect (die returns 255)
68 while( my ($alg, $extras) = each %algs ) {
69 system( "cp $config_h.bak $config_h" ) and die "$config_h not restored\n";
70 system( "make clean" ) and die;
72 print "\n******************************************\n";
73 print "* Testing without alg: $alg\n";
74 print "******************************************\n";
76 system( "scripts/config.pl unset $alg" )
77 and abort "Failed to disable $alg\n";
78 for my $opt (@$extras) {
79 system( "scripts/config.pl unset $opt" )
80 and abort "Failed to disable $opt\n";
83 system( "CFLAGS='-Werror -Wall -Wextra' make lib" )
84 and abort "Failed to build lib: $alg\n";
85 system( "cd tests && make" ) and abort "Failed to build tests: $alg\n";
86 system( "make test" ) and abort "Failed test suite: $alg\n";
89 system( "mv $config_h.bak $config_h" ) and die "$config_h not restored\n";
90 system( "make clean" ) and die;