From 53443e4fa42a9d79c89b55b41f1d36df79a85876 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Sun, 4 Oct 2009 15:22:11 +0000 Subject: [PATCH] - Merged trunk changes 796:817 into the 0.12 branch --- CMakeLists.txt | 2 +- ChangeLog | 11 ++++ README | 6 ++ include/polarssl/camellia.h | 10 ++-- include/polarssl/xtea.h | 10 ++-- library/x509parse.c | 29 ++++++++-- tests/scripts/generate_code.pl | 30 +++++++++- tests/suites/test_suite_mdx.data | 52 +++++++++++++++++ tests/suites/test_suite_rsa.data | 6 ++ tests/suites/test_suite_rsa.function | 79 ++++++++++++++++++++------ tests/suites/test_suite_x509parse.data | 12 ++++ 11 files changed, 212 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f66d2b390..589fb043f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,5 +14,5 @@ endif(CMAKE_BUILD_TYPE STREQUAL "Coverage") include_directories(include/) add_subdirectory(library) -add_subdirectory(programs) add_subdirectory(tests) +add_subdirectory(programs) diff --git a/ChangeLog b/ChangeLog index b6ab21d07..1002e9d8d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ PolarSSL ChangeLog += Version 0.12.1 released on 2009-10-04 +Changes + * Coverage test definitions now support 'depends_on' + tagging system. + * Tests requiring specific hashing algorithms now honor + the defines. + +Bug fixes + * Changed typo in #ifdef in x509parse.c (found + by Eduardo) + = Version 0.12.0 released on 2009-07-28 Features * Added CMake makefiles as alternative to regular Makefiles. diff --git a/README b/README index 01f727422..7f7d0b66d 100644 --- a/README +++ b/README @@ -12,6 +12,9 @@ The main system used for development is CMake. That system is always the most up In order to build the source using Make, just enter at the command line: make +In order to run the tests, enter: +make check + --- CMake In order to build the source using CMake, just enter at the command line: cmake . @@ -28,6 +31,9 @@ There are 3 different active build modes specified within the CMake buildsystem: Switching build modes in CMake is simple. For debug mode, enter at the command line: cmake -D CMAKE_BUILD_TYPE:String="Debug" . +In order to run the tests, enter: +make test + --- Microsoft Visual Studio The build files for Microsoft Visual Studio are generated for Visual Studio 6.0 all future Visual Studio's should be able to open and use this older version of the build files. diff --git a/include/polarssl/camellia.h b/include/polarssl/camellia.h index 2037e73bc..be8a42b32 100644 --- a/include/polarssl/camellia.h +++ b/include/polarssl/camellia.h @@ -20,12 +20,12 @@ */ #ifndef POLARSSL_CAMELLIA_H #define POLARSSL_CAMELLIA_H - -#ifdef _MSC_VER -#include -typedef UINT32 uint32_t; + +#ifdef _MSC_VER +#include +typedef UINT32 uint32_t; #else -#include +#include #endif #define CAMELLIA_ENCRYPT 1 diff --git a/include/polarssl/xtea.h b/include/polarssl/xtea.h index 1e1f4dc66..9d3dadd8f 100644 --- a/include/polarssl/xtea.h +++ b/include/polarssl/xtea.h @@ -21,11 +21,11 @@ #ifndef POLARSSL_XTEA_H #define POLARSSL_XTEA_H -#ifdef _MSC_VER -#include -typedef UINT32 uint32_t; -#else -#include +#ifdef _MSC_VER +#include +typedef UINT32 uint32_t; +#else +#include #endif #define XTEA_ENCRYPT 1 diff --git a/library/x509parse.c b/library/x509parse.c index 9d1846bf9..97a1755e3 100644 --- a/library/x509parse.c +++ b/library/x509parse.c @@ -1495,7 +1495,7 @@ int x509parse_crlfile( x509_crl *chain, char *path ) return( ret ); } -#if defined(POLARSSL_DES_C) +#if defined(POLARSSL_DES_C) && defined(POLARSSL_MD5_C) /* * Read a 16-byte hex string and convert it to binary */ @@ -1569,7 +1569,12 @@ int x509parse_key( rsa_context *rsa, unsigned char *buf, int buflen, int ret, len, enc; unsigned char *s1, *s2; unsigned char *p, *end; +#if defined(POLARSSL_DES_C) && defined(POLARSSL_MD5_C) unsigned char des3_iv[8]; +#else + ((void) pwd); + ((void) pwdlen); +#endif s1 = (unsigned char *) strstr( (char *) buf, "-----BEGIN RSA PRIVATE KEY-----" ); @@ -1591,7 +1596,7 @@ int x509parse_key( rsa_context *rsa, unsigned char *buf, int buflen, if( memcmp( s1, "Proc-Type: 4,ENCRYPTED", 22 ) == 0 ) { -#if defined(POLARSSL_DES_C) +#if defined(POLARSSL_DES_C) && defined(POLARSSL_MD5_C) enc++; s1 += 22; @@ -1634,7 +1639,7 @@ int x509parse_key( rsa_context *rsa, unsigned char *buf, int buflen, if( enc != 0 ) { -#if defined(POLARSSL_DES_C) +#if defined(POLARSSL_DES_C) && defined(POLARSSL_MD5_C) if( pwd == NULL ) { free( buf ); @@ -2126,6 +2131,11 @@ int x509parse_revoked( x509_cert *crt, x509_crl *crl ) return( 0 ); } +/* + * Wrapper for x509 hashes. + * + * @param out Buffer to receive the hash (Should be at least 64 bytes) + */ static void x509_hash( unsigned char *in, int len, int alg, unsigned char *out ) { @@ -2137,18 +2147,22 @@ static void x509_hash( unsigned char *in, int len, int alg, #if defined(POLARSSL_MD4_C) case SIG_RSA_MD4 : md4( in, len, out ); break; #endif +#if defined(POLARSSL_MD5_C) case SIG_RSA_MD5 : md5( in, len, out ); break; +#endif +#if defined(POLARSSL_SHA1_C) case SIG_RSA_SHA1 : sha1( in, len, out ); break; +#endif #if defined(POLARSSL_SHA2_C) case SIG_RSA_SHA224 : sha2( in, len, out, 1 ); break; case SIG_RSA_SHA256 : sha2( in, len, out, 0 ); break; #endif -#if defined(POLARSSL_SHA2_C) +#if defined(POLARSSL_SHA4_C) case SIG_RSA_SHA384 : sha4( in, len, out, 1 ); break; case SIG_RSA_SHA512 : sha4( in, len, out, 0 ); break; #endif default: - memset( out, '\xFF', len ); + memset( out, '\xFF', 64 ); break; } } @@ -2447,6 +2461,7 @@ void x509_crl_free( x509_crl *crl ) */ int x509_self_test( int verbose ) { +#if defined(POLARSSL_MD5_C) int ret, i, j; x509_cert cacert; x509_cert clicert; @@ -2515,6 +2530,10 @@ int x509_self_test( int verbose ) rsa_free( &rsa ); return( 0 ); +#else + ((void) verbose); + return( POLARSSL_ERR_X509_FEATURE_UNAVAILABLE ); +#endif } #endif diff --git a/tests/scripts/generate_code.pl b/tests/scripts/generate_code.pl index f712395ce..0ccd4959e 100755 --- a/tests/scripts/generate_code.pl +++ b/tests/scripts/generate_code.pl @@ -43,13 +43,36 @@ while (my $line = ) { my $description = $line; $line = ; - my $command_line = $line; - $line = ; my $test_name = $description; $test_name =~ tr/A-Z \-/a-z__/; $test_name =~ tr/a-z0-9_//cd; + # Carve the defines required for this test case + my $requirements; + if ($line =~ /^depends_on:/) + { + my $depends_on_line = $line; + $line = ; + + ( $requirements ) = $depends_on_line =~ /^depends_on:(.*)$/; + } + + my @var_req_arr = split(/:/, $requirements); + my $pre_code; + my $post_code; + + while (@var_req_arr) + { + my $req = shift @var_req_arr; + + $pre_code .= "#ifdef $req\n"; + $post_code .= "#endif\n"; + } + + my $command_line = $line; + $line = ; + # Carve the case name and variable values # my ( $case, $var_value ) = $command_line =~ /^([\w_]+):(.*)$/; @@ -82,10 +105,11 @@ while (my $line = ) print TEST_FILE << "END"; +$pre_code FCT_TEST_BGN($test_name) $case_code FCT_TEST_END(); - +$post_code END } diff --git a/tests/suites/test_suite_mdx.data b/tests/suites/test_suite_mdx.data index 6800e6f31..039fbee9a 100644 --- a/tests/suites/test_suite_mdx.data +++ b/tests/suites/test_suite_mdx.data @@ -1,155 +1,207 @@ md2 Test vector RFC1319 #1 +depends_on:POLARSSL_MD2_C md2_text:"":"8350e5a3e24c153df2275c9f80692773" md2 Test vector RFC1319 #2 +depends_on:POLARSSL_MD2_C md2_text:"a":"32ec01ec4a6dac72c0ab96fb34c0b5d1" md2 Test vector RFC1319 #3 +depends_on:POLARSSL_MD2_C md2_text:"abc":"da853b0d3f88d99b30283a69e6ded6bb" md2 Test vector RFC1319 #4 +depends_on:POLARSSL_MD2_C md2_text:"message digest":"ab4f496bfb2a530b219ff33031fe06b0" md2 Test vector RFC1319 #5 +depends_on:POLARSSL_MD2_C md2_text:"abcdefghijklmnopqrstuvwxyz":"4e8ddff3650292ab5a4108c3aa47940b" md2 Test vector RFC1319 #6 +depends_on:POLARSSL_MD2_C md2_text:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789":"da33def2a42df13975352846c30338cd" md2 Test vector RFC1319 #7 +depends_on:POLARSSL_MD2_C md2_text:"12345678901234567890123456789012345678901234567890123456789012345678901234567890":"d5976f79d83d3a0dc9806c3c66f3efd8" md4 Test vector RFC1320 #1 +depends_on:POLARSSL_MD4_C md4_text:"":"31d6cfe0d16ae931b73c59d7e0c089c0" md4 Test vector RFC1320 #2 +depends_on:POLARSSL_MD4_C md4_text:"a":"bde52cb31de33e46245e05fbdbd6fb24" md4 Test vector RFC1320 #3 +depends_on:POLARSSL_MD4_C md4_text:"abc":"a448017aaf21d8525fc10ae87aa6729d" md4 Test vector RFC1320 #4 +depends_on:POLARSSL_MD4_C md4_text:"message digest":"d9130a8164549fe818874806e1c7014b" md4 Test vector RFC1320 #5 +depends_on:POLARSSL_MD4_C md4_text:"abcdefghijklmnopqrstuvwxyz":"d79e1c308aa5bbcdeea8ed63df412da9" md4 Test vector RFC1320 #6 +depends_on:POLARSSL_MD4_C md4_text:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789":"043f8582f241db351ce627e153e7f0e4" md4 Test vector RFC1320 #7 +depends_on:POLARSSL_MD4_C md4_text:"12345678901234567890123456789012345678901234567890123456789012345678901234567890":"e33b4ddc9c38f2199c3e7b164fcc0536" md5 Test vector RFC1321 #1 +depends_on:POLARSSL_MD5_C md5_text:"":"d41d8cd98f00b204e9800998ecf8427e" md5 Test vector RFC1321 #2 +depends_on:POLARSSL_MD5_C md5_text:"a":"0cc175b9c0f1b6a831c399e269772661" md5 Test vector RFC1321 #3 +depends_on:POLARSSL_MD5_C md5_text:"abc":"900150983cd24fb0d6963f7d28e17f72" md5 Test vector RFC1321 #4 +depends_on:POLARSSL_MD5_C md5_text:"message digest":"f96b697d7cb7938d525a2f31aaf161d0" md5 Test vector RFC1321 #5 +depends_on:POLARSSL_MD5_C md5_text:"abcdefghijklmnopqrstuvwxyz":"c3fcd3d76192e4007dfb496cca67e13b" md5 Test vector RFC1321 #6 +depends_on:POLARSSL_MD5_C md5_text:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789":"d174ab98d277d9f5a5611c2c9f419d9f" md5 Test vector RFC1321 #7 +depends_on:POLARSSL_MD5_C md5_text:"12345678901234567890123456789012345678901234567890123456789012345678901234567890":"57edf4a22be3c955ac49da2e2107b67a" HMAC-MD2 Hash File OpenSSL test #1 +depends_on:POLARSSL_MD2_C md2_hmac:16:"61616161616161616161616161616161":"b91ce5ac77d33c234e61002ed6":"65046fb54ae83e4f52ec102e3a139a84" HMAC-MD2 Hash File OpenSSL test #2 +depends_on:POLARSSL_MD2_C md2_hmac:16:"61616161616161616161616161616161":"270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5":"545addf6466d11b94782312d42f55817" HMAC-MD2 Hash File OpenSSL test #3 +depends_on:POLARSSL_MD2_C md2_hmac:16:"61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161":"b91ce5ac77d33c234e61002ed6":"cefddfc3ffbcb83136e78c75fe0860ce" HMAC-MD4 Hash File OpenSSL test #1 +depends_on:POLARSSL_MD4_C md4_hmac:16:"61616161616161616161616161616161":"b91ce5ac77d33c234e61002ed6":"eabd0fbefb82fb0063a25a6d7b8bdc0f" HMAC-MD4 Hash File OpenSSL test #2 +depends_on:POLARSSL_MD4_C md4_hmac:16:"61616161616161616161616161616161":"270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5":"cec3c5e421a7b783aa89cacf78daf6dc" HMAC-MD4 Hash File OpenSSL test #3 +depends_on:POLARSSL_MD4_C md4_hmac:16:"61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161":"b91ce5ac77d33c234e61002ed6":"ad5f0a04116109b397b57f9cc9b6df4b" HMAC-MD5 Hash File OpenSSL test #1 +depends_on:POLARSSL_MD5_C md5_hmac:16:"61616161616161616161616161616161":"b91ce5ac77d33c234e61002ed6":"42552882f00bd4633ea81135a184b284" HMAC-MD5 Hash File OpenSSL test #2 +depends_on:POLARSSL_MD5_C md5_hmac:16:"61616161616161616161616161616161":"270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5":"a16a842891786d01fe50ba7731db7464" HMAC-MD5 Hash File OpenSSL test #3 +depends_on:POLARSSL_MD5_C md5_hmac:16:"61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161":"b91ce5ac77d33c234e61002ed6":"e97f623936f98a7f741c4bd0612fecc2" HMAC-MD5 Test Vector RFC2202 #1 +depends_on:POLARSSL_MD5_C md5_hmac:16:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"4869205468657265":"9294727a3638bb1c13f48ef8158bfc9d" HMAC-MD5 Test Vector RFC2202 #2 +depends_on:POLARSSL_MD5_C md5_hmac:16:"4a656665":"7768617420646f2079612077616e7420666f72206e6f7468696e673f":"750c783e6ab0b503eaa86e310a5db738" HMAC-MD5 Test Vector RFC2202 #3 +depends_on:POLARSSL_MD5_C md5_hmac:16:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd":"56be34521d144c88dbb8c733f0e8b3f6" HMAC-MD5 Test Vector RFC2202 #4 +depends_on:POLARSSL_MD5_C md5_hmac:16:"0102030405060708090a0b0c0d0e0f10111213141516171819":"cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd":"697eaf0aca3a3aea3a75164746ffaa79" HMAC-MD5 Test Vector RFC2202 #5 +depends_on:POLARSSL_MD5_C md5_hmac:12:"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c":"546573742057697468205472756e636174696f6e":"56461ef2342edc00f9bab995" HMAC-MD5 Test Vector RFC2202 #6 +depends_on:POLARSSL_MD5_C md5_hmac:16:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374":"6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd" HMAC-MD5 Test Vector RFC2202 #7 +depends_on:POLARSSL_MD5_C md5_hmac:16:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b657920616e64204c6172676572205468616e204f6e6520426c6f636b2d53697a652044617461":"6f630fad67cda0ee1fb1f562db3aa53e" MD2 Hash file #1 +depends_on:POLARSSL_MD2_C md2_file:"data_files/hash_file_1":"b593c098712d2e21628c8986695451a8" MD2 Hash file #2 +depends_on:POLARSSL_MD2_C md2_file:"data_files/hash_file_2":"3c027b7409909a4c4b26bbab69ad9f4f" MD2 Hash file #3 +depends_on:POLARSSL_MD2_C md2_file:"data_files/hash_file_3":"6bb43eb285e81f414083a94cdbe2989d" MD2 Hash file #4 +depends_on:POLARSSL_MD4_C md2_file:"data_files/hash_file_4":"8350e5a3e24c153df2275c9f80692773" MD4 Hash file #1 +depends_on:POLARSSL_MD4_C md4_file:"data_files/hash_file_1":"8d19772c176bd27153b9486715e2c0b9" MD4 Hash file #2 +depends_on:POLARSSL_MD4_C md4_file:"data_files/hash_file_2":"f2ac53b8542882a5a0007c6f84b4d9fd" MD4 Hash file #3 +depends_on:POLARSSL_MD4_C md4_file:"data_files/hash_file_3":"195c15158e2d07881d9a654095ce4a42" MD4 Hash file #4 +depends_on:POLARSSL_MD4_C md4_file:"data_files/hash_file_4":"31d6cfe0d16ae931b73c59d7e0c089c0" MD5 Hash file #1 +depends_on:POLARSSL_MD5_C md5_file:"data_files/hash_file_1":"52bcdc983c9ed64fc148a759b3c7a415" MD5 Hash file #2 +depends_on:POLARSSL_MD5_C md5_file:"data_files/hash_file_2":"d17d466f15891df10542207ae78277f0" MD5 Hash file #3 +depends_on:POLARSSL_MD5_C md5_file:"data_files/hash_file_3":"d945bcc6200ea95d061a2a818167d920" MD5 Hash file #4 +depends_on:POLARSSL_MD5_C md5_file:"data_files/hash_file_4":"d41d8cd98f00b204e9800998ecf8427e" MD2 Selftest +depends_on:POLARSSL_MD2_C md2_selftest: MD4 Selftest +depends_on:POLARSSL_MD4_C md4_selftest: MD5 Selftest +depends_on:POLARSSL_MD5_C md5_selftest: diff --git a/tests/suites/test_suite_rsa.data b/tests/suites/test_suite_rsa.data index 8cbdc5c3c..6c105c8f0 100644 --- a/tests/suites/test_suite_rsa.data +++ b/tests/suites/test_suite_rsa.data @@ -128,21 +128,27 @@ RSA PKCS1 Sign #4 Verify rsa_pkcs1_verify:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":RSA_PKCS_V15:SIG_RSA_SHA384:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"40dcc96822e5612eb33f1dca247a35109ba3845c7a3d556a60e656624bf1c103d94686ca7379e9e329ccd1b19b52bfd48b608df9f59a96a82d3feb0101096dbcb80e46da543b4c982ac6bb1717f24f9fe3f76b7154492b47525be1ddcaf4631d33481531be8f3e685837b40bdf4a02827d79f6a32374147174680f51c8e0d8eed9d5c445a563a7bce9ef4236e7cfdc12b2223ef457c3e8ccc6dd65cc23e977a1f03f5ef584feb9af00efc71a701f9d413b0290af17692cb821a1e863d5778e174b1130659f30583f434f09cb1212471a41dd65c102de64a194b6ae3e43cd75928049db78042c58e980aff3ea2774e42845bcf217410a118cf5deeaa64224dbc8":0 RSA PKCS1 Sign #5 (MD2, 2048 bits RSA) +depends_on:POLARSSL_MD2_C rsa_pkcs1_sign:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":RSA_PKCS_V15:SIG_RSA_MD2:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"6cbb0e4019d64dd5cd2d48fa43446e5cba1a7edbb79d91b199be75c7d3e7ae0820c44d3a120cd2910f73cbb315e15963a60ea7da3452015d9d6beb5ac998fddbd1fa3e5908abc9151f3ffb70365aaee6fb0cd440d3f5591868fc136fae38ac7bcdb3bde3c6a0362dd8b814f7edadd4a51b2edf2227a40d1e34c29f608add7746731425858eb93661c633b7a90942fca3cd594ab4ec170052d44105643518020782e76235def34d014135bad8daed590200482325c3416c3d66417e80d9f9c6322a54683638247b577445ecd0be2765ce96c4ee45213204026dfba24d5ee89e1ea75538ba39f7149a5ac0fc12d7c53cbc12481d4a8e2d410ec633d800ad4b4304":0 RSA PKCS1 Sign #5 Verify +depends_on:POLARSSL_MD2_C rsa_pkcs1_verify:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":RSA_PKCS_V15:SIG_RSA_MD2:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"6cbb0e4019d64dd5cd2d48fa43446e5cba1a7edbb79d91b199be75c7d3e7ae0820c44d3a120cd2910f73cbb315e15963a60ea7da3452015d9d6beb5ac998fddbd1fa3e5908abc9151f3ffb70365aaee6fb0cd440d3f5591868fc136fae38ac7bcdb3bde3c6a0362dd8b814f7edadd4a51b2edf2227a40d1e34c29f608add7746731425858eb93661c633b7a90942fca3cd594ab4ec170052d44105643518020782e76235def34d014135bad8daed590200482325c3416c3d66417e80d9f9c6322a54683638247b577445ecd0be2765ce96c4ee45213204026dfba24d5ee89e1ea75538ba39f7149a5ac0fc12d7c53cbc12481d4a8e2d410ec633d800ad4b4304":0 RSA PKCS1 Sign #6 (MD4, 2048 bits RSA) +depends_on:POLARSSL_MD4_C rsa_pkcs1_sign:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":RSA_PKCS_V15:SIG_RSA_MD4:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"b0e60dc4dfaf0f636a3a4414eae2d7bce7c3ce505a46e38f3f654d8769b31b7891ba18f89672fce204bbac6e3764355e65447c087994731cd44f086710e79e8c3ebc6e2cb61edc5d3e05848ab733d95efe2d0252a691e810c17fa57fd2dd296374c9ba17fea704685677f45d668a386c8ca433fbbb56d3bbfb43a489ed9518b1c9ab13ce497a1cec91467453bfe533145a31a095c2de541255141768ccc6fdff3fc790b5050f1122c93c3044a9346947e1b23e8125bf7edbf38c64a4286dfc1b829e983db3117959a2559a8ef97687ab673e231be213d88edc632637b58cdb2d69c51fbf6bf894cff319216718b1e696f75cd4366f53dc2e28b2a00017984207":0 RSA PKCS1 Sign #6 Verify +depends_on:POLARSSL_MD4_C rsa_pkcs1_verify:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":RSA_PKCS_V15:SIG_RSA_MD4:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"b0e60dc4dfaf0f636a3a4414eae2d7bce7c3ce505a46e38f3f654d8769b31b7891ba18f89672fce204bbac6e3764355e65447c087994731cd44f086710e79e8c3ebc6e2cb61edc5d3e05848ab733d95efe2d0252a691e810c17fa57fd2dd296374c9ba17fea704685677f45d668a386c8ca433fbbb56d3bbfb43a489ed9518b1c9ab13ce497a1cec91467453bfe533145a31a095c2de541255141768ccc6fdff3fc790b5050f1122c93c3044a9346947e1b23e8125bf7edbf38c64a4286dfc1b829e983db3117959a2559a8ef97687ab673e231be213d88edc632637b58cdb2d69c51fbf6bf894cff319216718b1e696f75cd4366f53dc2e28b2a00017984207":0 RSA PKCS1 Sign #7 (MD5, 2048 bits RSA) +depends_on:POLARSSL_MD5_C rsa_pkcs1_sign:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":RSA_PKCS_V15:SIG_RSA_MD5:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"3bcf673c3b27f6e2ece4bb97c7a37161e6c6ee7419ef366efc3cfee0f15f415ff6d9d4390937386c6fec1771acba73f24ec6b0469ea8b88083f0b4e1b6069d7bf286e67cf94182a548663137e82a6e09c35de2c27779da0503f1f5bedfebadf2a875f17763a0564df4a6d945a5a3e46bc90fb692af3a55106aafc6b577587456ff8d49cfd5c299d7a2b776dbe4c1ae777b0f64aa3bab27689af32d6cc76157c7dc6900a3469e18a7d9b6bfe4951d1105a08864575e4f4ec05b3e053f9b7a2d5653ae085e50a63380d6bdd6f58ab378d7e0a2be708c559849891317089ab04c82d8bc589ea088b90b11dea5cf85856ff7e609cc1adb1d403beead4c126ff29021":0 RSA PKCS1 Sign #7 Verify +depends_on:POLARSSL_MD5_C rsa_pkcs1_verify:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":RSA_PKCS_V15:SIG_RSA_MD5:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"3bcf673c3b27f6e2ece4bb97c7a37161e6c6ee7419ef366efc3cfee0f15f415ff6d9d4390937386c6fec1771acba73f24ec6b0469ea8b88083f0b4e1b6069d7bf286e67cf94182a548663137e82a6e09c35de2c27779da0503f1f5bedfebadf2a875f17763a0564df4a6d945a5a3e46bc90fb692af3a55106aafc6b577587456ff8d49cfd5c299d7a2b776dbe4c1ae777b0f64aa3bab27689af32d6cc76157c7dc6900a3469e18a7d9b6bfe4951d1105a08864575e4f4ec05b3e053f9b7a2d5653ae085e50a63380d6bdd6f58ab378d7e0a2be708c559849891317089ab04c82d8bc589ea088b90b11dea5cf85856ff7e609cc1adb1d403beead4c126ff29021":0 RSA PKCS1 Sign #8 (RAW, 2048 bits RSA) diff --git a/tests/suites/test_suite_rsa.function b/tests/suites/test_suite_rsa.function index 065e84c0d..ed6cbf0b7 100644 --- a/tests/suites/test_suite_rsa.function +++ b/tests/suites/test_suite_rsa.function @@ -1,4 +1,5 @@ BEGIN_HEADER +#include #include #include #include @@ -47,22 +48,45 @@ rsa_pkcs1_sign:message_hex_string:padding_mode:digest:mod:radix_P:input_P:radix_ msg_len = unhexify( message_str, {message_hex_string} ); - if( {digest} == SIG_RSA_MD2 ) + switch( {digest} ) + { +#ifdef POLARSSL_MD2_C + case SIG_RSA_MD2: md2( message_str, msg_len, hash_result ); - else if( {digest} == SIG_RSA_MD4 ) + break; +#endif +#ifdef POLARSSL_MD4_C + case SIG_RSA_MD4: md4( message_str, msg_len, hash_result ); - else if( {digest} == SIG_RSA_MD5 ) + break; +#endif +#ifdef POLARSSL_MD5_C + case SIG_RSA_MD5: md5( message_str, msg_len, hash_result ); - else if( {digest} == SIG_RSA_SHA1 ) + break; +#endif +#ifdef POLARSSL_SHA1_C + case SIG_RSA_SHA1: sha1( message_str, msg_len, hash_result ); - else if( {digest} == SIG_RSA_SHA224 ) + break; +#endif +#ifdef POLARSSL_SHA2_C + case SIG_RSA_SHA224: sha2( message_str, msg_len, hash_result, 1 ); - else if( {digest} == SIG_RSA_SHA256 ) + break; + case SIG_RSA_SHA256: sha2( message_str, msg_len, hash_result, 0 ); - else if( {digest} == SIG_RSA_SHA384 ) + break; +#endif +#ifdef POLARSSL_SHA4_C + case SIG_RSA_SHA384: sha4( message_str, msg_len, hash_result, 1 ); - else if( {digest} == SIG_RSA_SHA512 ) + break; + case SIG_RSA_SHA512: sha4( message_str, msg_len, hash_result, 0 ); + break; +#endif + } TEST_ASSERT( rsa_pkcs1_sign( &ctx, RSA_PRIVATE, {digest}, 0, hash_result, output ) == {result} ); if( {result} == 0 ) @@ -97,22 +121,45 @@ rsa_pkcs1_verify:message_hex_string:padding_mode:digest:mod:radix_N:input_N:radi msg_len = unhexify( message_str, {message_hex_string} ); unhexify( result_str, {result_hex_str} ); - if( {digest} == SIG_RSA_MD2 ) + switch( {digest} ) + { +#ifdef POLARSSL_MD2_C + case SIG_RSA_MD2: md2( message_str, msg_len, hash_result ); - else if( {digest} == SIG_RSA_MD4 ) + break; +#endif +#ifdef POLARSSL_MD4_C + case SIG_RSA_MD4: md4( message_str, msg_len, hash_result ); - else if( {digest} == SIG_RSA_MD5 ) + break; +#endif +#ifdef POLARSSL_MD5_C + case SIG_RSA_MD5: md5( message_str, msg_len, hash_result ); - else if( {digest} == SIG_RSA_SHA1 ) + break; +#endif +#ifdef POLARSSL_SHA1_C + case SIG_RSA_SHA1: sha1( message_str, msg_len, hash_result ); - else if( {digest} == SIG_RSA_SHA224 ) + break; +#endif +#ifdef POLARSSL_SHA2_C + case SIG_RSA_SHA224: sha2( message_str, msg_len, hash_result, 1 ); - else if( {digest} == SIG_RSA_SHA256 ) + break; + case SIG_RSA_SHA256: sha2( message_str, msg_len, hash_result, 0 ); - else if( {digest} == SIG_RSA_SHA384 ) + break; +#endif +#ifdef POLARSSL_SHA4_C + case SIG_RSA_SHA384: sha4( message_str, msg_len, hash_result, 1 ); - else if( {digest} == SIG_RSA_SHA512 ) + break; + case SIG_RSA_SHA512: sha4( message_str, msg_len, hash_result, 0 ); + break; +#endif + } TEST_ASSERT( rsa_pkcs1_verify( &ctx, RSA_PUBLIC, {digest}, 0, hash_result, result_str ) == {result} ); } diff --git a/tests/suites/test_suite_x509parse.data b/tests/suites/test_suite_x509parse.data index ff1b9edf5..e565c07f1 100644 --- a/tests/suites/test_suite_x509parse.data +++ b/tests/suites/test_suite_x509parse.data @@ -59,12 +59,15 @@ X509 CRL Information SHA512 Digest x509_crl_info:"data_files/crl_sha512.pem":"CRL version \: 1\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nthis update \: 2009-07-19 19\:56\:37\nnext update \: 2009-09-17 19\:56\:37\nRevoked certificates\:\nserial number\: 01 revocation date\: 2009-02-09 21\:12\:36\nserial number\: 03 revocation date\: 2009-02-09 21\:12\:36\nsigned using \: RSA+SHA512\n" X509 Parse Key #1 (No password when required) +depends_on:POLARSSL_MD5_C x509parse_keyfile:"data_files/test-ca.key":NULL:POLARSSL_ERR_X509_KEY_PASSWORD_REQUIRED X509 Parse Key #2 (Correct password) +depends_on:POLARSSL_MD5_C x509parse_keyfile:"data_files/test-ca.key":"PolarSSLTest":0 X509 Parse Key #3 (Wrong password) +depends_on:POLARSSL_MD5_C x509parse_keyfile:"data_files/test-ca.key":"PolarSSLWRONG":POLARSSL_ERR_X509_KEY_PASSWORD_MISMATCH X509 Get Distinguished Name #1 @@ -128,30 +131,39 @@ X509 Certificate verification #10 (Not trusted Cert, Expired CRL) x509_verify:"data_files/server2.crt":"data_files/server1.crt":"data_files/crl_expired.pem":NULL:BADCERT_NOT_TRUSTED X509 Certificate verification #11 (Valid Cert MD2 Digest) +depends_on:POLARSSL_MD2_C x509_verify:"data_files/cert_md2.crt":"data_files/test-ca.crt":"data_files/crl.pem":NULL:0 X509 Certificate verification #12 (Valid Cert MD4 Digest) +depends_on:POLARSSL_MD4_C x509_verify:"data_files/cert_md4.crt":"data_files/test-ca.crt":"data_files/crl.pem":NULL:0 X509 Certificate verification #13 (Valid Cert MD5 Digest) +depends_on:POLARSSL_MD5_C x509_verify:"data_files/cert_md5.crt":"data_files/test-ca.crt":"data_files/crl.pem":NULL:0 X509 Certificate verification #14 (Valid Cert SHA1 Digest) +depends_on:POLARSSL_SHA1_C x509_verify:"data_files/cert_sha1.crt":"data_files/test-ca.crt":"data_files/crl.pem":NULL:0 X509 Certificate verification #15 (Valid Cert SHA224 Digest) +depends_on:POLARSSL_SHA2_C x509_verify:"data_files/cert_sha224.crt":"data_files/test-ca.crt":"data_files/crl.pem":NULL:0 X509 Certificate verification #16 (Valid Cert SHA256 Digest) +depends_on:POLARSSL_SHA2_C x509_verify:"data_files/cert_sha256.crt":"data_files/test-ca.crt":"data_files/crl.pem":NULL:0 X509 Certificate verification #17 (Valid Cert SHA384 Digest) +depends_on:POLARSSL_SHA4_C x509_verify:"data_files/cert_sha384.crt":"data_files/test-ca.crt":"data_files/crl.pem":NULL:0 X509 Certificate verification #18 (Valid Cert SHA512 Digest) +depends_on:POLARSSL_SHA4_C x509_verify:"data_files/cert_sha512.crt":"data_files/test-ca.crt":"data_files/crl.pem":NULL:0 X509 Parse Selftest +depends_on:POLARSSL_MD5_C x509_selftest: X509 Certificate ASN1 (Incorrect first tag)