First pass at constant flow tests for base64
This contains working CF tests for encode, however I have not yet got decode to pass the tests. Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
dadd10d656
commit
448d54610c
1 changed files with 11 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
/* BEGIN_HEADER */
|
/* BEGIN_HEADER */
|
||||||
#include "mbedtls/base64.h"
|
#include "mbedtls/base64.h"
|
||||||
|
#include <test/constant_flow.h>
|
||||||
/* END_HEADER */
|
/* END_HEADER */
|
||||||
|
|
||||||
/* BEGIN_DEPENDENCIES
|
/* BEGIN_DEPENDENCIES
|
||||||
|
@ -13,13 +14,18 @@ void mbedtls_base64_encode( char * src_string, char * dst_string,
|
||||||
{
|
{
|
||||||
unsigned char src_str[1000];
|
unsigned char src_str[1000];
|
||||||
unsigned char dst_str[1000];
|
unsigned char dst_str[1000];
|
||||||
size_t len;
|
size_t len, src_len;
|
||||||
|
|
||||||
memset(src_str, 0x00, 1000);
|
memset(src_str, 0x00, 1000);
|
||||||
memset(dst_str, 0x00, 1000);
|
memset(dst_str, 0x00, 1000);
|
||||||
|
|
||||||
strncpy( (char *) src_str, src_string, sizeof(src_str) - 1 );
|
strncpy( (char *) src_str, src_string, sizeof(src_str) - 1 );
|
||||||
TEST_ASSERT( mbedtls_base64_encode( dst_str, dst_buf_size, &len, src_str, strlen( (char *) src_str ) ) == result );
|
src_len = strlen( (char *) src_str );
|
||||||
|
|
||||||
|
TEST_CF_SECRET( src_str, sizeof( src_str ) );
|
||||||
|
TEST_ASSERT( mbedtls_base64_encode( dst_str, dst_buf_size, &len, src_str, src_len) == result );
|
||||||
|
TEST_CF_PUBLIC( src_str, sizeof( src_str ) );
|
||||||
|
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
TEST_ASSERT( strcmp( (char *) dst_str, dst_string ) == 0 );
|
TEST_ASSERT( strcmp( (char *) dst_str, dst_string ) == 0 );
|
||||||
|
@ -57,7 +63,10 @@ void base64_encode_hex( data_t * src, char * dst, int dst_buf_size,
|
||||||
|
|
||||||
res = mbedtls_test_zero_alloc( dst_buf_size );
|
res = mbedtls_test_zero_alloc( dst_buf_size );
|
||||||
|
|
||||||
|
TEST_CF_SECRET( src->x, src->len );
|
||||||
TEST_ASSERT( mbedtls_base64_encode( res, dst_buf_size, &len, src->x, src->len ) == result );
|
TEST_ASSERT( mbedtls_base64_encode( res, dst_buf_size, &len, src->x, src->len ) == result );
|
||||||
|
TEST_CF_PUBLIC( src->x, src->len );
|
||||||
|
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
TEST_ASSERT( len == strlen( dst ) );
|
TEST_ASSERT( len == strlen( dst ) );
|
||||||
|
|
Loading…
Reference in a new issue