Skip to content

Commit 86cef2a

Browse files
Merge pull request #204 from gilles-peskine-arm/merge-crypto-development-20190806
Bring in changes from Mbed TLS as of 2019-08-06
2 parents e3223d1 + 3963993 commit 86cef2a

File tree

6 files changed

+71
-31
lines changed

6 files changed

+71
-31
lines changed

scripts/abi_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _get_clean_worktree_for_git_revision(self, version):
107107
)
108108
self.log.debug(worktree_output.decode("utf-8"))
109109
version.commit = subprocess.check_output(
110-
[self.git_command, "rev-parse", worktree_rev],
110+
[self.git_command, "rev-parse", "HEAD"],
111111
cwd=git_worktree_path,
112112
stderr=subprocess.STDOUT
113113
).decode("ascii").rstrip()

tests/data_files/Makefile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,19 @@ test-ca.req.sha256: $(test_ca_key_file_rsa)
4848
all_intermediate += test-ca.req.sha256
4949

5050
test-ca.crt: $(test_ca_key_file_rsa) test-ca.req.sha256
51-
$(MBEDTLS_CERT_WRITE) is_ca=1 serial=3 request_file=test-ca.req.sha256 selfsign=1 issuer_name="C=NL,O=PolarSSL,CN=PolarSSL Test CA" issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144400 not_after=20210212144400 md=SHA1 version=3 output_file=$@
52-
test-ca.der: test-ca.crt
51+
$(MBEDTLS_CERT_WRITE) is_ca=1 serial=3 request_file=test-ca.req.sha256 selfsign=1 issuer_name="C=NL,O=PolarSSL,CN=PolarSSL Test CA" issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20190210144400 not_after=20290210144400 md=SHA1 version=3 output_file=$@
52+
all_final += test-ca.crt
53+
54+
test-ca.crt.der: test-ca.crt
5355
$(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
54-
all_final += test-ca.crt test-ca.der
56+
all_final += test-ca.der
5557

5658
test-ca-sha1.crt: $(test_ca_key_file_rsa) test-ca.req.sha256
57-
$(MBEDTLS_CERT_WRITE) is_ca=1 serial=3 request_file=test-ca.req.sha256 selfsign=1 issuer_name="C=NL,O=PolarSSL,CN=PolarSSL Test CA" issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144400 not_after=20210212144400 md=SHA1 version=3 output_file=$@
59+
$(MBEDTLS_CERT_WRITE) is_ca=1 serial=3 request_file=test-ca.req.sha256 selfsign=1 issuer_name="C=NL,O=PolarSSL,CN=PolarSSL Test CA" issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20190210144400 not_after=20290210144400 md=SHA1 version=3 output_file=$@
5860
all_final += test-ca-sha1.crt
5961

6062
test-ca-sha256.crt: $(test_ca_key_file_rsa) test-ca.req.sha256
61-
$(MBEDTLS_CERT_WRITE) is_ca=1 serial=3 request_file=test-ca.req.sha256 selfsign=1 issuer_name="C=NL,O=PolarSSL,CN=PolarSSL Test CA" issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144400 not_after=20210212144400 md=SHA256 version=3 output_file=$@
63+
$(MBEDTLS_CERT_WRITE) is_ca=1 serial=3 request_file=test-ca.req.sha256 selfsign=1 issuer_name="C=NL,O=PolarSSL,CN=PolarSSL Test CA" issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20190210144400 not_after=20290210144400 md=SHA256 version=3 output_file=$@
6264
all_final += test-ca-sha256.crt
6365

6466
cli_crt_key_file_rsa = cli-rsa.key
@@ -68,10 +70,10 @@ cli-rsa.csr: $(cli_crt_key_file_rsa)
6870
all_intermediate += cli-rsa.csr
6971

7072
cli-rsa-sha1.crt: cli-rsa.csr
71-
$(MBEDTLS_CERT_WRITE) request_file=$< serial=4 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144406 not_after=20210212144406 md=SHA1 version=3 output_file=$@
73+
$(MBEDTLS_CERT_WRITE) request_file=$< serial=4 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20190210144406 not_after=20290210144406 md=SHA1 version=3 output_file=$@
7274

7375
cli-rsa-sha256.crt: cli-rsa.csr
74-
$(MBEDTLS_CERT_WRITE) request_file=$< serial=4 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144406 not_after=20210212144406 md=SHA256 version=3 output_file=$@
76+
$(MBEDTLS_CERT_WRITE) request_file=$< serial=4 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20190210144406 not_after=20290210144406 md=SHA256 version=3 output_file=$@
7577
all_final += cli-rsa-sha256.crt
7678

7779
test_ca_int_rsa1 = test-int-ca.crt
@@ -671,13 +673,15 @@ all_intermediate += server2.req.sha256
671673
# server2*
672674

673675
server2.crt: server2.req.sha256
674-
$(MBEDTLS_CERT_WRITE) request_file=server2.req.sha256 serial=2 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144406 not_after=20210212144406 md=SHA1 version=3 output_file=$@
676+
$(MBEDTLS_CERT_WRITE) request_file=server2.req.sha256 serial=2 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20190210144406 not_after=20290210144406 md=SHA1 version=3 output_file=$@
677+
all_final += server2.crt
678+
675679
server2.der: server2.crt
676680
$(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
677-
all_final += server2.crt server2.der
681+
all_final += server2.der
678682

679683
server2-sha256.crt: server2.req.sha256
680-
$(MBEDTLS_CERT_WRITE) request_file=server2.req.sha256 serial=2 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144406 not_after=20210212144406 md=SHA256 version=3 output_file=$@
684+
$(MBEDTLS_CERT_WRITE) request_file=server2.req.sha256 serial=2 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20190210144406 not_after=20290210144406 md=SHA256 version=3 output_file=$@
681685
all_final += server2-sha256.crt
682686

683687

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
-----BEGIN RSA PRIVATE KEY-----
2-
MIICXgIBAAKBgQCvBX05buhPt1/btcKxPH/lplSqiqJHC1Qe4f6wsS0lx5cRUxJJ
3-
4RKWKAQtu7bBINFENSTvTA5uHYlW7rIHevEjSd3u5USDvAbCxhlIzQKyAueWrr2U
4-
06fL+FnCwYGcMky4K5zTTt4mOiq//kcz8HeGnoZg99aDTaU9aQ73mF9rwwIDAQAB
5-
AoGBAIdL8P/C8qcdFGcd3QFxyVTX/b9QKB5PbZnqDh68+C+qWOe1lf+yk9Gr4X8R
6-
CzfEjMDzbDfoTYdmIdMn9ku+CEV9PsQJi6L6CjGfukEcKEHte+gxlqjN+dql0AaU
7-
vDNfxMMiF/4EiLzpy3IC5ZRoserRGQAEd9ssp5f6wZ7aP1jBAkEA4qt2CEG7nTCo
8-
HSIt4etzgdgiFEB/G5dcu/5OGpRn/ZitvXj2B4Nspb4ZKLnRYNl/1FwS1rUuLJhx
9-
oXTGa0iBEwJBAMWrJ2AhWa59byDDwu6FHkbcES5onijV/Lv5kKme+KkLi7RP02Rn
10-
5/wXic62Y6vaM4ZSw8c/ERd0kC6EBWWScJECQQC2zb01T331eaY7SLNkPjU7hImH
11-
d7SLFflOC/wFZ6auWRHVetZAnPdke/liZOm9h+uV4mO3EQuaH5+UrM7Q+vpNAkBx
12-
GV7sN+jSV97PxnKweuY58Qy7mwxznQyAmWjWRKlOP9btkocHehRYPzeQWPdqiuzU
13-
PGLcjA9BdmZQ1yUnWsShAkEAuzLRM+3C4EjUYziLe+nLS+KfS2JQvmA+cONkdQHJ
14-
fd3iCk5xvpX9XnF4TiWspLryW+Vziq5Zu/4cmXeBRHorJA==
2+
MIICXAIBAAKBgQDHOJLFw/RwEAhr+BM17PMBHIolD5WCNh6qHpYSVRqs+Ht1Mwtw
3+
VzOc2ZXxTUxEN8i+xKA/5GQ80/PJAkM9w3xbjnmqCYSughM3Cr+Fab0qNWJssf7k
4+
rOBCskF8e+SdJxSbLAdrjkM9P2x2OkaaHHANJZ28CMdA/NgCN2L/fev8LQIDAQAB
5+
AoGBAL2/t6Qf6PDXhH350apaHnYfjcCQ4FEeZQSZj0y0vGylW0mcrbd5hxJM+BDW
6+
E98h1tVEiHFygrqhEiCRRCROzmDhjlPVymxBXP+Jev4xeV5mvf2PzgwOR8MTdbFo
7+
dOSI6t9bhpCyp0Ln8eQzGXtuWsH6arJsyJJ9JzCrzeI48sjNAkEA+lgGSPNyWHZW
8+
E0zdtznvGphYKPMuDUTGzm1gTZ0oes6qjr4OA9rD3NTGHVW1FVLq63leTiqK8sOS
9+
uJduIauW4wJBAMu4214tyhB720BuLH7vD0mCKipzD0cEuAdf3NEel3KZxnHD4AK+
10+
xeiEfFCstMg5uMCNLkShGjMZ5zNfRIqxfa8CQDJjW0h9r6s8jlCuLQY/I/A/b6c2
11+
YzOKf1V3UGXu1wH47P10JZADDV86eHHZGWykVuJ0eFXVXEhGsxZybFlcly8CQDet
12+
Ks7fZsUAhJhkQ+bhAOWPHGUDkx5OrNjfGyNP4AYi/rgi1zsI1l/IrY0C1lmOZO7C
13+
5u08tkNXBfflRn89KOMCQAwCFgbZqd/VDFyemqwMZAXp+Y1HvGeZI0pr3vBJzO3W
14+
OvIa0KckJ793UjS6Iijfnyy9pWmKJLdKEMe/AtSRDi0=
1515
-----END RSA PRIVATE KEY-----

tests/suites/helpers.function

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,21 @@ typedef enum
187187
} \
188188
while( 0 )
189189

190+
/**
191+
* \brief This macro tests the expression passed to it and skips the
192+
* running test if it doesn't evaluate to 'true'.
193+
*
194+
* \param TEST The test expression to be tested.
195+
*/
196+
#define TEST_ASSUME( TEST ) \
197+
do { \
198+
if( ! (TEST) ) \
199+
{ \
200+
test_skip( #TEST, __LINE__, __FILE__ ); \
201+
goto exit; \
202+
} \
203+
} while( 0 )
204+
190205
#if defined(MBEDTLS_CHECK_PARAMS) && !defined(MBEDTLS_PARAM_FAILED_ALT)
191206
/**
192207
* \brief This macro tests the statement passed to it as a test step or
@@ -372,10 +387,17 @@ typedef enum
372387
/*----------------------------------------------------------------------------*/
373388
/* Global variables */
374389

390+
typedef enum
391+
{
392+
TEST_RESULT_SUCCESS = 0,
393+
TEST_RESULT_FAILED,
394+
TEST_RESULT_SKIPPED
395+
} test_result_t;
396+
375397
static struct
376398
{
377399
paramfail_test_state_t paramfail_test_state;
378-
int failed;
400+
test_result_t result;
379401
const char *test;
380402
const char *filename;
381403
int line_no;
@@ -411,7 +433,15 @@ jmp_buf jmp_tmp;
411433

412434
void test_fail( const char *test, int line_no, const char* filename )
413435
{
414-
test_info.failed = 1;
436+
test_info.result = TEST_RESULT_FAILED;
437+
test_info.test = test;
438+
test_info.line_no = line_no;
439+
test_info.filename = filename;
440+
}
441+
442+
void test_skip( const char *test, int line_no, const char* filename )
443+
{
444+
test_info.result = TEST_RESULT_SKIPPED;
415445
test_info.test = test;
416446
test_info.line_no = line_no;
417447
test_info.filename = filename;
@@ -450,7 +480,7 @@ void mbedtls_param_failed( const char *failure_condition,
450480
/* Record the location of the failure, but not as a failure yet, in case
451481
* it was part of the test */
452482
test_fail( failure_condition, line, file );
453-
test_info.failed = 0;
483+
test_info.result = TEST_RESULT_SUCCESS;
454484

455485
longjmp( param_fail_jmp, 1 );
456486
}

tests/suites/host_test.function

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@ int execute_tests( int argc , const char ** argv )
498498

499499
if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
500500
break;
501-
mbedtls_fprintf( stdout, "%s%.66s", test_info.failed ? "\n" : "", buf );
501+
mbedtls_fprintf( stdout, "%s%.66s",
502+
test_info.result == TEST_RESULT_FAILED ? "\n" : "", buf );
502503
mbedtls_fprintf( stdout, " " );
503504
for( i = strlen( buf ) + 1; i < 67; i++ )
504505
mbedtls_fprintf( stdout, "." );
@@ -545,7 +546,7 @@ int execute_tests( int argc , const char ** argv )
545546
// If there are no unmet dependencies execute the test
546547
if( unmet_dep_count == 0 )
547548
{
548-
test_info.failed = 0;
549+
test_info.result = TEST_RESULT_SUCCESS;
549550
test_info.paramfail_test_state = PARAMFAIL_TESTSTATE_IDLE;
550551

551552
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
@@ -610,10 +611,15 @@ int execute_tests( int argc , const char ** argv )
610611
}
611612
else if( ret == DISPATCH_TEST_SUCCESS )
612613
{
613-
if( test_info.failed == 0 )
614+
if( test_info.result == TEST_RESULT_SUCCESS )
614615
{
615616
mbedtls_fprintf( stdout, "PASS\n" );
616617
}
618+
else if( test_info.result == TEST_RESULT_SKIPPED )
619+
{
620+
mbedtls_fprintf( stdout, "----\n" );
621+
total_skipped++;
622+
}
617623
else
618624
{
619625
total_errors++;

tests/suites/main_test.function

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void execute_function_ptr(TestWrapper_t fp, void **params)
159159
else
160160
{
161161
/* Unexpected parameter validation error */
162-
test_info.failed = 1;
162+
test_info.result = TEST_RESULT_FAILED;
163163
}
164164

165165
memset( param_fail_jmp, 0, sizeof(jmp_buf) );

0 commit comments

Comments
 (0)