mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
- Added CMake makefiles as alternative to regular Makefiles.
- Added preliminary Code Coverage tests for AES, ARC4, Base64, MPI, SHA-family, MD-family and HMAC-SHA-family.
This commit is contained in:
105
tests/suites/test_suite_shax.function
Normal file
105
tests/suites/test_suite_shax.function
Normal file
@ -0,0 +1,105 @@
|
||||
BEGIN_HEADER
|
||||
#include <polarssl/sha1.h>
|
||||
#include <polarssl/sha2.h>
|
||||
#include <polarssl/sha4.h>
|
||||
END_HEADER
|
||||
|
||||
BEGIN_CASE
|
||||
sha1:hex_src_string:hex_hash_string
|
||||
{
|
||||
unsigned char src_str[10000];
|
||||
unsigned char hash_str[10000];
|
||||
unsigned char output[41];
|
||||
|
||||
memset(src_str, 0x00, 10000);
|
||||
memset(hash_str, 0x00, 10000);
|
||||
memset(output, 0x00, 41);
|
||||
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
sha1( src_str, src_len, output );
|
||||
hexify( hash_str, output, 20 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
sha224:hex_src_string:hex_hash_string
|
||||
{
|
||||
unsigned char src_str[10000];
|
||||
unsigned char hash_str[10000];
|
||||
unsigned char output[57];
|
||||
|
||||
memset(src_str, 0x00, 10000);
|
||||
memset(hash_str, 0x00, 10000);
|
||||
memset(output, 0x00, 57);
|
||||
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
sha2( src_str, src_len, output, 1 );
|
||||
hexify( hash_str, output, 28 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
sha256:hex_src_string:hex_hash_string
|
||||
{
|
||||
unsigned char src_str[10000];
|
||||
unsigned char hash_str[10000];
|
||||
unsigned char output[65];
|
||||
|
||||
memset(src_str, 0x00, 10000);
|
||||
memset(hash_str, 0x00, 10000);
|
||||
memset(output, 0x00, 65);
|
||||
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
sha2( src_str, src_len, output, 0 );
|
||||
hexify( hash_str, output, 32 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
sha384:hex_src_string:hex_hash_string
|
||||
{
|
||||
unsigned char src_str[10000];
|
||||
unsigned char hash_str[10000];
|
||||
unsigned char output[97];
|
||||
|
||||
memset(src_str, 0x00, 10000);
|
||||
memset(hash_str, 0x00, 10000);
|
||||
memset(output, 0x00, 97);
|
||||
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
sha4( src_str, src_len, output, 1 );
|
||||
hexify( hash_str, output, 48 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
sha512:hex_src_string:hex_hash_string
|
||||
{
|
||||
unsigned char src_str[10000];
|
||||
unsigned char hash_str[10000];
|
||||
unsigned char output[129];
|
||||
|
||||
memset(src_str, 0x00, 10000);
|
||||
memset(hash_str, 0x00, 10000);
|
||||
memset(output, 0x00, 129);
|
||||
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
sha4( src_str, src_len, output, 0);
|
||||
hexify( hash_str, output, 64 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
Reference in New Issue
Block a user