2009-06-28 21:50:27 +00:00
|
|
|
BEGIN_HEADER
|
|
|
|
#include <polarssl/base64.h>
|
|
|
|
END_HEADER
|
|
|
|
|
2011-05-26 13:16:06 +00:00
|
|
|
BEGIN_DEPENDENCIES
|
|
|
|
depends_on:POLARSSL_BASE64_C
|
|
|
|
END_DEPENDENCIES
|
|
|
|
|
2009-06-28 21:50:27 +00:00
|
|
|
BEGIN_CASE
|
2009-07-11 15:29:30 +00:00
|
|
|
base64_encode:src_string:dst_string:dst_buf_size:result
|
2009-06-28 21:50:27 +00:00
|
|
|
{
|
|
|
|
unsigned char src_str[1000];
|
|
|
|
unsigned char dst_str[1000];
|
2011-04-24 15:53:29 +00:00
|
|
|
size_t len = {dst_buf_size};
|
2009-06-28 21:50:27 +00:00
|
|
|
|
|
|
|
memset(src_str, 0x00, 1000);
|
|
|
|
memset(dst_str, 0x00, 1000);
|
|
|
|
|
|
|
|
strcpy( (char *) src_str, {src_string} );
|
2009-07-11 15:29:30 +00:00
|
|
|
TEST_ASSERT( base64_encode( dst_str, &len, src_str, strlen( (char *) src_str ) ) == {result} );
|
|
|
|
if( {result} == 0 )
|
|
|
|
{
|
|
|
|
TEST_ASSERT( strcmp( (char *) dst_str, {dst_string} ) == 0 );
|
|
|
|
}
|
2009-06-28 21:50:27 +00:00
|
|
|
}
|
|
|
|
END_CASE
|
|
|
|
|
|
|
|
BEGIN_CASE
|
2009-07-11 15:29:30 +00:00
|
|
|
base64_decode:src_string:dst_string:result
|
2009-06-28 21:50:27 +00:00
|
|
|
{
|
|
|
|
unsigned char src_str[1000];
|
|
|
|
unsigned char dst_str[1000];
|
2011-04-24 15:53:29 +00:00
|
|
|
size_t len = 1000;
|
2009-06-28 21:50:27 +00:00
|
|
|
int res;
|
|
|
|
|
|
|
|
memset(src_str, 0x00, 1000);
|
|
|
|
memset(dst_str, 0x00, 1000);
|
|
|
|
|
|
|
|
strcpy( (char *) src_str, {src_string} );
|
2009-07-11 15:29:30 +00:00
|
|
|
TEST_ASSERT( res = base64_decode( dst_str, &len, src_str, strlen( (char *) src_str ) ) == {result} );
|
|
|
|
if( {result} == 0 )
|
|
|
|
{
|
|
|
|
TEST_ASSERT( strcmp( (char *) dst_str, {dst_string} ) == 0 );
|
|
|
|
}
|
2009-06-28 21:50:27 +00:00
|
|
|
}
|
|
|
|
END_CASE
|
2009-07-05 11:29:38 +00:00
|
|
|
|
|
|
|
BEGIN_CASE
|
|
|
|
base64_selftest:
|
|
|
|
{
|
|
|
|
TEST_ASSERT( base64_self_test( 0 ) == 0 );
|
|
|
|
}
|
|
|
|
END_CASE
|