97 lines
2.4 KiB
Plaintext
97 lines
2.4 KiB
Plaintext
/* BEGIN_HEADER */
|
|
#include "mbedtls/sha1.h"
|
|
#include "mbedtls/sha256.h"
|
|
#include "mbedtls/sha512.h"
|
|
/* END_HEADER */
|
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_SHA1_C */
|
|
void mbedtls_sha1( data_t * src_str, data_t * hex_hash_string )
|
|
{
|
|
unsigned char output[41];
|
|
|
|
memset(output, 0x00, 41);
|
|
|
|
|
|
TEST_ASSERT( mbedtls_sha1_ret( src_str->x, src_str->len, output ) == 0 );
|
|
|
|
TEST_ASSERT( hexcmp( output, hex_hash_string->x, 20, hex_hash_string->len ) == 0 );
|
|
}
|
|
/* END_CASE */
|
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */
|
|
void sha224( data_t * src_str, data_t * hex_hash_string )
|
|
{
|
|
unsigned char output[57];
|
|
|
|
memset(output, 0x00, 57);
|
|
|
|
|
|
TEST_ASSERT( mbedtls_sha256_ret( src_str->x, src_str->len, output, 1 ) == 0 );
|
|
|
|
TEST_ASSERT( hexcmp( output, hex_hash_string->x, 28, hex_hash_string->len ) == 0 );
|
|
}
|
|
/* END_CASE */
|
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */
|
|
void mbedtls_sha256( data_t * src_str, data_t * hex_hash_string )
|
|
{
|
|
unsigned char output[65];
|
|
|
|
memset(output, 0x00, 65);
|
|
|
|
|
|
TEST_ASSERT( mbedtls_sha256_ret( src_str->x, src_str->len, output, 0 ) == 0 );
|
|
|
|
TEST_ASSERT( hexcmp( output, hex_hash_string->x, 32, hex_hash_string->len ) == 0 );
|
|
}
|
|
/* END_CASE */
|
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C */
|
|
void sha384( data_t * src_str, data_t * hex_hash_string )
|
|
{
|
|
unsigned char output[97];
|
|
|
|
memset(output, 0x00, 97);
|
|
|
|
|
|
TEST_ASSERT( mbedtls_sha512_ret( src_str->x, src_str->len, output, 1 ) == 0 );
|
|
|
|
TEST_ASSERT( hexcmp( output, hex_hash_string->x, 48, hex_hash_string->len ) == 0 );
|
|
}
|
|
/* END_CASE */
|
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C */
|
|
void mbedtls_sha512( data_t * src_str, data_t * hex_hash_string )
|
|
{
|
|
unsigned char output[129];
|
|
|
|
memset(output, 0x00, 129);
|
|
|
|
|
|
TEST_ASSERT( mbedtls_sha512_ret( src_str->x, src_str->len, output, 0 ) == 0 );
|
|
|
|
TEST_ASSERT( hexcmp( output, hex_hash_string->x, 64, hex_hash_string->len ) == 0 );
|
|
}
|
|
/* END_CASE */
|
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_SHA1_C:MBEDTLS_SELF_TEST */
|
|
void sha1_selftest( )
|
|
{
|
|
TEST_ASSERT( mbedtls_sha1_self_test( 1 ) == 0 );
|
|
}
|
|
/* END_CASE */
|
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C:MBEDTLS_SELF_TEST */
|
|
void sha256_selftest( )
|
|
{
|
|
TEST_ASSERT( mbedtls_sha256_self_test( 1 ) == 0 );
|
|
}
|
|
/* END_CASE */
|
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C:MBEDTLS_SELF_TEST */
|
|
void sha512_selftest( )
|
|
{
|
|
TEST_ASSERT( mbedtls_sha512_self_test( 1 ) == 0 );
|
|
}
|
|
/* END_CASE */
|