Allow comments in test data files

This commit is contained in:
Gilles Peskine 2017-09-29 15:45:12 +02:00 committed by Simon Butcher
parent 01692531c6
commit b04e2c3d81
7 changed files with 42 additions and 7 deletions

View file

@ -2,6 +2,9 @@ mbed TLS ChangeLog (Sorted per branch, date)
= mbed TLS x.x.x released xxxx-xx-xx
Features
* Allow comments in test data files.
Bugfix
* Fix ssl_parse_record_header() to silently discard invalid DTLS records
as recommended in RFC 6347 Section 4.1.2.7.

View file

@ -49,6 +49,27 @@
# file name is used to replace the symbol 'TESTCASE_FILENAME' in the main
# code file above.
#
# A test data file consists of a sequence of paragraphs separated by
# a single empty line. Line breaks may be in Unix (LF) or Windows (CRLF)
# format. Lines starting with the character '#' are ignored
# (the parser behaves as if they were not present).
#
# Each paragraph describes one test case and must consist of: (1) one
# line which is the test case name; (2) an optional line starting with
# the 11-character prefix "depends_on:"; (3) a line containing the test
# function to execute and its parameters.
#
# A depends_on: line consists of a list of compile-time options
# separated by the character ':', with no whitespace. The test case
# is executed only if this compilation option is enabled in config.h.
#
# The last line of each paragraph contains a test function name and
# a list of parameters separated by the character ':'. Running the
# test case calls this function with the specified parameters. Each
# parameter may either be an integer written in decimal or hexadecimal,
# or a string surrounded by double quotes which may not contain the
# ':' character.
#
use strict;

View file

@ -140,14 +140,19 @@ int get_line( FILE *f, char *buf, size_t len )
{
char *ret;
ret = fgets( buf, len, f );
if( ret == NULL )
return( -1 );
buf[0] = '#';
if( strlen( buf ) && buf[strlen(buf) - 1] == '\n' )
buf[strlen(buf) - 1] = '\0';
if( strlen( buf ) && buf[strlen(buf) - 1] == '\r' )
buf[strlen(buf) - 1] = '\0';
while( buf[0] == '#' )
{
ret = fgets( buf, len, f );
if( ret == NULL )
return( -1 );
if( strlen( buf ) && buf[strlen(buf) - 1] == '\n' )
buf[strlen(buf) - 1] = '\0';
if( strlen( buf ) && buf[strlen(buf) - 1] == '\r' )
buf[strlen(buf) - 1] = '\0';
}
return( 0 );
}

View file

@ -1,3 +1,4 @@
# Tests of the generic message digest interface
MD process
mbedtls_md_process:

View file

@ -1,3 +1,4 @@
# Test MD2, MD4, MD5 and RIPEMD160
mbedtls_md2 Test vector RFC1319 #1
md2_text:"":"8350e5a3e24c153df2275c9f80692773"

View file

@ -1,5 +1,6 @@
RSA PKCS1 Verify v1.5 CAVS #1
depends_on:MBEDTLS_SHA1_C:MBEDTLS_PKCS1_V15
# Good padding but wrong hash
mbedtls_rsa_pkcs1_verify:"d6248c3e96b1a7e5fea978870fcc4c9786b4e5156e16b7faef4557d667f730b8bc4c784ef00c624df5309513c3a5de8ca94c2152e0459618666d3148092562ebc256ffca45b27fd2d63c68bd5e0a0aefbe496e9e63838a361b1db6fc272464f191490bf9c029643c49d2d9cd08833b8a70b4b3431f56fb1eb55ccd39e77a9c92":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA1:1024:16:"e28a13548525e5f36dccb24ecb7cc332cc689dfd64012604c9c7816d72a16c3f5fcdc0e86e7c03280b1c69b586ce0cd8aec722cc73a5d3b730310bf7dfebdc77ce5d94bbc369dc18a2f7b07bd505ab0f82224aef09fdc1e5063234255e0b3c40a52e9e8ae60898eb88a766bdd788fe9493d8fd86bcdd2884d5c06216c65469e5":16:"3":"3203b7647fb7e345aa457681e5131777f1adc371f2fba8534928c4e52ef6206a856425d6269352ecbf64db2f6ad82397768cafdd8cd272e512d617ad67992226da6bc291c31404c17fd4b7e2beb20eff284a44f4d7af47fd6629e2c95809fa7f2241a04f70ac70d3271bb13258af1ed5c5988c95df7fa26603515791075feccd":MBEDTLS_ERR_RSA_VERIFY_FAILED
RSA PKCS1 Verify v1.5 CAVS #2
@ -24,6 +25,7 @@ mbedtls_rsa_pkcs1_verify:"44637d3b8de525fd589237bc81229c8966d3af24540850c2403633
RSA PKCS1 Verify v1.5 CAVS #7
depends_on:MBEDTLS_SHA512_C:MBEDTLS_PKCS1_V15
# Bad padding after performing the public key operation
mbedtls_rsa_pkcs1_verify:"d03f12276f6ba7545b8fce719471bd253791878809694e8754f3b389f26c9253a758ed28b4c62535a8d5702d7a778731d5759ff2b3b39b192db680e791632918b6093c0e8ca25c2bf756a07fde4144a37f769fe4054455a45cb8cefe4462e7a9a45ce71f2189b4fef01b47aee8585d44dc9d6fa627a3e5f08801871731f234cd":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA384:1024:16:"e28a13548525e5f36dccb24ecb7cc332cc689dfd64012604c9c7816d72a16c3f5fcdc0e86e7c03280b1c69b586ce0cd8aec722cc73a5d3b730310bf7dfebdc77ce5d94bbc369dc18a2f7b07bd505ab0f82224aef09fdc1e5063234255e0b3c40a52e9e8ae60898eb88a766bdd788fe9493d8fd86bcdd2884d5c06216c65469e5":16:"3":"d93a878c1ce86571590b0e43794b3edb23552797c4b8c9e3da4fe1cc4ac0566acd3b10541fe9a7a79f5ea4892d3069ca6903efb5c40c47eb8a9c781eb4249281d40c3d96aae16da1bb4daaece6a26eca5f41c062b4124a64fc9d340cba5ab0d1f5affff6515a87f0933774fd4322d2fa497cd6f708a429ca56dcb1fd3db623d0":MBEDTLS_ERR_RSA_INVALID_PADDING
RSA PKCS1 Verify v1.5 CAVS #8
@ -365,6 +367,7 @@ RSA Generate Key - 2048 bit key
mbedtls_rsa_gen_key:2048:3:0
RSA Generate Key - 1025 bit key
# mbedtls_rsa_gen_key only supports even-sized keys
mbedtls_rsa_gen_key:1025:3:MBEDTLS_ERR_RSA_BAD_INPUT_DATA
RSA PKCS1 Encrypt Bad RNG

View file

@ -1,3 +1,4 @@
# Test the operation of SHA-1 and SHA-2
SHA-1 Test Vector NIST CAVS #1
depends_on:MBEDTLS_SHA1_C
mbedtls_sha1:"":"da39a3ee5e6b4b0d3255bfef95601890afd80709"