The Great Renaming
A simple execution of tmp/invoke-rename.pl
diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function
index 76aca14..2d51019 100644
--- a/tests/suites/test_suite_cipher.function
+++ b/tests/suites/test_suite_cipher.function
@@ -1,92 +1,92 @@
/* BEGIN_HEADER */
#include "mbedtls/cipher.h"
-#if defined(POLARSSL_GCM_C)
+#if defined(MBEDTLS_GCM_C)
#include "mbedtls/gcm.h"
#endif
/* END_HEADER */
/* BEGIN_DEPENDENCIES
- * depends_on:POLARSSL_CIPHER_C
+ * depends_on:MBEDTLS_CIPHER_C
* END_DEPENDENCIES
*/
/* BEGIN_CASE */
-void cipher_list( )
+void mbedtls_cipher_list( )
{
const int *cipher_type;
- for( cipher_type = cipher_list(); *cipher_type != 0; cipher_type++ )
- TEST_ASSERT( cipher_info_from_type( *cipher_type ) != NULL );
+ for( cipher_type = mbedtls_cipher_list(); *cipher_type != 0; cipher_type++ )
+ TEST_ASSERT( mbedtls_cipher_info_from_type( *cipher_type ) != NULL );
}
/* END_CASE */
/* BEGIN_CASE */
void cipher_null_args( )
{
- cipher_context_t ctx;
- const cipher_info_t *info = cipher_info_from_type( *( cipher_list() ) );
+ mbedtls_cipher_context_t ctx;
+ const mbedtls_cipher_info_t *info = mbedtls_cipher_info_from_type( *( mbedtls_cipher_list() ) );
unsigned char buf[1] = { 0 };
size_t olen;
- cipher_init( &ctx );
+ mbedtls_cipher_init( &ctx );
- TEST_ASSERT( cipher_get_block_size( NULL ) == 0 );
- TEST_ASSERT( cipher_get_block_size( &ctx ) == 0 );
+ TEST_ASSERT( mbedtls_cipher_get_block_size( NULL ) == 0 );
+ TEST_ASSERT( mbedtls_cipher_get_block_size( &ctx ) == 0 );
- TEST_ASSERT( cipher_get_cipher_mode( NULL ) == POLARSSL_MODE_NONE );
- TEST_ASSERT( cipher_get_cipher_mode( &ctx ) == POLARSSL_MODE_NONE );
+ TEST_ASSERT( mbedtls_cipher_get_cipher_mode( NULL ) == MBEDTLS_MODE_NONE );
+ TEST_ASSERT( mbedtls_cipher_get_cipher_mode( &ctx ) == MBEDTLS_MODE_NONE );
- TEST_ASSERT( cipher_get_iv_size( NULL ) == 0 );
- TEST_ASSERT( cipher_get_iv_size( &ctx ) == 0 );
+ TEST_ASSERT( mbedtls_cipher_get_iv_size( NULL ) == 0 );
+ TEST_ASSERT( mbedtls_cipher_get_iv_size( &ctx ) == 0 );
- TEST_ASSERT( cipher_info_from_string( NULL ) == NULL );
+ TEST_ASSERT( mbedtls_cipher_info_from_string( NULL ) == NULL );
- TEST_ASSERT( cipher_init_ctx( &ctx, NULL )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_init_ctx( NULL, info )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_init_ctx( &ctx, NULL )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_init_ctx( NULL, info )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_setkey( NULL, buf, 0, POLARSSL_ENCRYPT )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_setkey( &ctx, buf, 0, POLARSSL_ENCRYPT )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_setkey( NULL, buf, 0, MBEDTLS_ENCRYPT )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_setkey( &ctx, buf, 0, MBEDTLS_ENCRYPT )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_set_iv( NULL, buf, 0 )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_set_iv( &ctx, buf, 0 )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_set_iv( NULL, buf, 0 )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_set_iv( &ctx, buf, 0 )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_reset( NULL ) == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_reset( &ctx ) == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_reset( NULL ) == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_reset( &ctx ) == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
-#if defined(POLARSSL_GCM_C)
- TEST_ASSERT( cipher_update_ad( NULL, buf, 0 )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_update_ad( &ctx, buf, 0 )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
+#if defined(MBEDTLS_GCM_C)
+ TEST_ASSERT( mbedtls_cipher_update_ad( NULL, buf, 0 )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_update_ad( &ctx, buf, 0 )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
#endif
- TEST_ASSERT( cipher_update( NULL, buf, 0, buf, &olen )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_update( &ctx, buf, 0, buf, &olen )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_update( NULL, buf, 0, buf, &olen )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_update( &ctx, buf, 0, buf, &olen )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_finish( NULL, buf, &olen )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_finish( &ctx, buf, &olen )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_finish( NULL, buf, &olen )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_finish( &ctx, buf, &olen )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
-#if defined(POLARSSL_GCM_C)
- TEST_ASSERT( cipher_write_tag( NULL, buf, olen )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_write_tag( &ctx, buf, olen )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
+#if defined(MBEDTLS_GCM_C)
+ TEST_ASSERT( mbedtls_cipher_write_tag( NULL, buf, olen )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_write_tag( &ctx, buf, olen )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_check_tag( NULL, buf, olen )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
- TEST_ASSERT( cipher_check_tag( &ctx, buf, olen )
- == POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_check_tag( NULL, buf, olen )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ TEST_ASSERT( mbedtls_cipher_check_tag( &ctx, buf, olen )
+ == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
#endif
}
/* END_CASE */
@@ -104,39 +104,39 @@
unsigned char encbuf[64];
unsigned char decbuf[64];
- const cipher_info_t *cipher_info;
- cipher_context_t ctx_dec;
- cipher_context_t ctx_enc;
+ const mbedtls_cipher_info_t *cipher_info;
+ mbedtls_cipher_context_t ctx_dec;
+ mbedtls_cipher_context_t ctx_enc;
/*
* Prepare contexts
*/
- cipher_init( &ctx_dec );
- cipher_init( &ctx_enc );
+ mbedtls_cipher_init( &ctx_dec );
+ mbedtls_cipher_init( &ctx_enc );
memset( key, 0x2a, sizeof( key ) );
/* Check and get info structures */
- cipher_info = cipher_info_from_type( cipher_id );
+ cipher_info = mbedtls_cipher_info_from_type( cipher_id );
TEST_ASSERT( NULL != cipher_info );
- TEST_ASSERT( cipher_info_from_string( cipher_string ) == cipher_info );
+ TEST_ASSERT( mbedtls_cipher_info_from_string( cipher_string ) == cipher_info );
/* Initialise enc and dec contexts */
- TEST_ASSERT( 0 == cipher_init_ctx( &ctx_dec, cipher_info ) );
- TEST_ASSERT( 0 == cipher_init_ctx( &ctx_enc, cipher_info ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_init_ctx( &ctx_dec, cipher_info ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_init_ctx( &ctx_enc, cipher_info ) );
- TEST_ASSERT( 0 == cipher_setkey( &ctx_dec, key, key_len, POLARSSL_DECRYPT ) );
- TEST_ASSERT( 0 == cipher_setkey( &ctx_enc, key, key_len, POLARSSL_ENCRYPT ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx_dec, key, key_len, MBEDTLS_DECRYPT ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx_enc, key, key_len, MBEDTLS_ENCRYPT ) );
-#if defined(POLARSSL_CIPHER_MODE_WITH_PADDING)
+#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING)
if( -1 != pad_mode )
{
- TEST_ASSERT( 0 == cipher_set_padding_mode( &ctx_dec, pad_mode ) );
- TEST_ASSERT( 0 == cipher_set_padding_mode( &ctx_enc, pad_mode ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_set_padding_mode( &ctx_dec, pad_mode ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_set_padding_mode( &ctx_enc, pad_mode ) );
}
#else
(void) pad_mode;
-#endif /* POLARSSL_CIPHER_MODE_WITH_PADDING */
+#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
/*
* Do a few encode/decode cycles
@@ -151,52 +151,52 @@
memset( decbuf, 0, sizeof( decbuf ) );
memset( tag, 0, sizeof( tag ) );
- TEST_ASSERT( 0 == cipher_set_iv( &ctx_dec, iv, sizeof( iv ) ) );
- TEST_ASSERT( 0 == cipher_set_iv( &ctx_enc, iv, sizeof( iv ) ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_dec, iv, sizeof( iv ) ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_enc, iv, sizeof( iv ) ) );
- TEST_ASSERT( 0 == cipher_reset( &ctx_dec ) );
- TEST_ASSERT( 0 == cipher_reset( &ctx_enc ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_enc ) );
-#if defined(POLARSSL_GCM_C)
- TEST_ASSERT( 0 == cipher_update_ad( &ctx_dec, ad, sizeof( ad ) - i ) );
- TEST_ASSERT( 0 == cipher_update_ad( &ctx_enc, ad, sizeof( ad ) - i ) );
+#if defined(MBEDTLS_GCM_C)
+ TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_dec, ad, sizeof( ad ) - i ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_enc, ad, sizeof( ad ) - i ) );
#endif
/* encode length number of bytes from inbuf */
- TEST_ASSERT( 0 == cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
total_len = outlen;
TEST_ASSERT( total_len == length ||
- ( total_len % cipher_get_block_size( &ctx_enc ) == 0 &&
+ ( total_len % mbedtls_cipher_get_block_size( &ctx_enc ) == 0 &&
total_len < length &&
- total_len + cipher_get_block_size( &ctx_enc ) > length ) );
+ total_len + mbedtls_cipher_get_block_size( &ctx_enc ) > length ) );
- TEST_ASSERT( 0 == cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
total_len += outlen;
-#if defined(POLARSSL_GCM_C)
- TEST_ASSERT( 0 == cipher_write_tag( &ctx_enc, tag, sizeof( tag ) ) );
+#if defined(MBEDTLS_GCM_C)
+ TEST_ASSERT( 0 == mbedtls_cipher_write_tag( &ctx_enc, tag, sizeof( tag ) ) );
#endif
TEST_ASSERT( total_len == length ||
- ( total_len % cipher_get_block_size( &ctx_enc ) == 0 &&
+ ( total_len % mbedtls_cipher_get_block_size( &ctx_enc ) == 0 &&
total_len > length &&
- total_len <= length + cipher_get_block_size( &ctx_enc ) ) );
+ total_len <= length + mbedtls_cipher_get_block_size( &ctx_enc ) ) );
/* decode the previously encoded string */
- TEST_ASSERT( 0 == cipher_update( &ctx_dec, encbuf, total_len, decbuf, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx_dec, encbuf, total_len, decbuf, &outlen ) );
total_len = outlen;
TEST_ASSERT( total_len == length ||
- ( total_len % cipher_get_block_size( &ctx_dec ) == 0 &&
+ ( total_len % mbedtls_cipher_get_block_size( &ctx_dec ) == 0 &&
total_len < length &&
- total_len + cipher_get_block_size( &ctx_dec ) >= length ) );
+ total_len + mbedtls_cipher_get_block_size( &ctx_dec ) >= length ) );
- TEST_ASSERT( 0 == cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
total_len += outlen;
-#if defined(POLARSSL_GCM_C)
- TEST_ASSERT( 0 == cipher_check_tag( &ctx_dec, tag, sizeof( tag ) ) );
+#if defined(MBEDTLS_GCM_C)
+ TEST_ASSERT( 0 == mbedtls_cipher_check_tag( &ctx_dec, tag, sizeof( tag ) ) );
#endif
/* check result */
@@ -208,8 +208,8 @@
* Done
*/
exit:
- cipher_free( &ctx_dec );
- cipher_free( &ctx_enc );
+ mbedtls_cipher_free( &ctx_dec );
+ mbedtls_cipher_free( &ctx_enc );
}
/* END_CASE */
@@ -221,8 +221,8 @@
unsigned char key[32];
unsigned char iv[16];
- const cipher_info_t *cipher_info;
- cipher_context_t ctx;
+ const mbedtls_cipher_info_t *cipher_info;
+ mbedtls_cipher_context_t ctx;
unsigned char inbuf[64];
unsigned char encbuf[64];
@@ -232,36 +232,36 @@
memset( key, 0, 32 );
memset( iv , 0, 16 );
- cipher_init( &ctx );
+ mbedtls_cipher_init( &ctx );
memset( inbuf, 5, 64 );
memset( encbuf, 0, 64 );
/* Check and get info structures */
- cipher_info = cipher_info_from_type( cipher_id );
+ cipher_info = mbedtls_cipher_info_from_type( cipher_id );
TEST_ASSERT( NULL != cipher_info );
/* Initialise context */
- TEST_ASSERT( 0 == cipher_init_ctx( &ctx, cipher_info ) );
- TEST_ASSERT( 0 == cipher_setkey( &ctx, key, key_len, POLARSSL_ENCRYPT ) );
-#if defined(POLARSSL_CIPHER_MODE_WITH_PADDING)
- TEST_ASSERT( 0 == cipher_set_padding_mode( &ctx, pad_mode ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_init_ctx( &ctx, cipher_info ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key, key_len, MBEDTLS_ENCRYPT ) );
+#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING)
+ TEST_ASSERT( 0 == mbedtls_cipher_set_padding_mode( &ctx, pad_mode ) );
#else
(void) pad_mode;
-#endif /* POLARSSL_CIPHER_MODE_WITH_PADDING */
- TEST_ASSERT( 0 == cipher_set_iv( &ctx, iv, 16 ) );
- TEST_ASSERT( 0 == cipher_reset( &ctx ) );
-#if defined(POLARSSL_GCM_C)
- TEST_ASSERT( 0 == cipher_update_ad( &ctx, NULL, 0 ) );
+#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
+ TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx, iv, 16 ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx ) );
+#if defined(MBEDTLS_GCM_C)
+ TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx, NULL, 0 ) );
#endif
/* encode length number of bytes from inbuf */
- TEST_ASSERT( 0 == cipher_update( &ctx, inbuf, length, encbuf, &outlen ) );
- TEST_ASSERT( ret == cipher_finish( &ctx, encbuf + outlen, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx, inbuf, length, encbuf, &outlen ) );
+ TEST_ASSERT( ret == mbedtls_cipher_finish( &ctx, encbuf + outlen, &outlen ) );
/* done */
exit:
- cipher_free( &ctx );
+ mbedtls_cipher_free( &ctx );
}
/* END_CASE */
@@ -271,8 +271,8 @@
unsigned char key[32];
unsigned char iv[16];
- cipher_context_t ctx_dec;
- const cipher_info_t *cipher_info;
+ mbedtls_cipher_context_t ctx_dec;
+ const mbedtls_cipher_info_t *cipher_info;
unsigned char encbuf[64];
unsigned char decbuf[64];
@@ -282,36 +282,36 @@
memset( key, 0, 32 );
memset( iv , 0, 16 );
- cipher_init( &ctx_dec );
+ mbedtls_cipher_init( &ctx_dec );
memset( encbuf, 0, 64 );
memset( decbuf, 0, 64 );
/* Initialise context */
- cipher_info = cipher_info_from_type( POLARSSL_CIPHER_AES_128_CBC );
+ cipher_info = mbedtls_cipher_info_from_type( MBEDTLS_CIPHER_AES_128_CBC );
TEST_ASSERT( NULL != cipher_info);
- TEST_ASSERT( 0 == cipher_init_ctx( &ctx_dec, cipher_info ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_init_ctx( &ctx_dec, cipher_info ) );
- TEST_ASSERT( 0 == cipher_setkey( &ctx_dec, key, 128, POLARSSL_DECRYPT ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx_dec, key, 128, MBEDTLS_DECRYPT ) );
- TEST_ASSERT( 0 == cipher_set_iv( &ctx_dec, iv, 16 ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_dec, iv, 16 ) );
- TEST_ASSERT( 0 == cipher_reset( &ctx_dec ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) );
-#if defined(POLARSSL_GCM_C)
- TEST_ASSERT( 0 == cipher_update_ad( &ctx_dec, NULL, 0 ) );
+#if defined(MBEDTLS_GCM_C)
+ TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_dec, NULL, 0 ) );
#endif
/* decode 0-byte string */
- TEST_ASSERT( 0 == cipher_update( &ctx_dec, encbuf, 0, decbuf, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx_dec, encbuf, 0, decbuf, &outlen ) );
TEST_ASSERT( 0 == outlen );
- TEST_ASSERT( POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED == cipher_finish(
+ TEST_ASSERT( MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED == mbedtls_cipher_finish(
&ctx_dec, decbuf + outlen, &outlen ) );
TEST_ASSERT( 0 == outlen );
exit:
- cipher_free( &ctx_dec );
+ mbedtls_cipher_free( &ctx_dec );
}
/* END_CASE */
@@ -325,9 +325,9 @@
unsigned char key[32];
unsigned char iv[16];
- cipher_context_t ctx_dec;
- cipher_context_t ctx_enc;
- const cipher_info_t *cipher_info;
+ mbedtls_cipher_context_t ctx_dec;
+ mbedtls_cipher_context_t ctx_enc;
+ const mbedtls_cipher_info_t *cipher_info;
unsigned char inbuf[64];
unsigned char encbuf[64];
@@ -339,61 +339,61 @@
memset( key, 0, 32 );
memset( iv , 0, 16 );
- cipher_init( &ctx_dec );
- cipher_init( &ctx_enc );
+ mbedtls_cipher_init( &ctx_dec );
+ mbedtls_cipher_init( &ctx_enc );
memset( inbuf, 5, 64 );
memset( encbuf, 0, 64 );
memset( decbuf, 0, 64 );
/* Initialise enc and dec contexts */
- cipher_info = cipher_info_from_type( cipher_id );
+ cipher_info = mbedtls_cipher_info_from_type( cipher_id );
TEST_ASSERT( NULL != cipher_info);
- TEST_ASSERT( 0 == cipher_init_ctx( &ctx_dec, cipher_info ) );
- TEST_ASSERT( 0 == cipher_init_ctx( &ctx_enc, cipher_info ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_init_ctx( &ctx_dec, cipher_info ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_init_ctx( &ctx_enc, cipher_info ) );
- TEST_ASSERT( 0 == cipher_setkey( &ctx_dec, key, key_len, POLARSSL_DECRYPT ) );
- TEST_ASSERT( 0 == cipher_setkey( &ctx_enc, key, key_len, POLARSSL_ENCRYPT ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx_dec, key, key_len, MBEDTLS_DECRYPT ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx_enc, key, key_len, MBEDTLS_ENCRYPT ) );
- TEST_ASSERT( 0 == cipher_set_iv( &ctx_dec, iv, 16 ) );
- TEST_ASSERT( 0 == cipher_set_iv( &ctx_enc, iv, 16 ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_dec, iv, 16 ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_enc, iv, 16 ) );
- TEST_ASSERT( 0 == cipher_reset( &ctx_dec ) );
- TEST_ASSERT( 0 == cipher_reset( &ctx_enc ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_enc ) );
-#if defined(POLARSSL_GCM_C)
- TEST_ASSERT( 0 == cipher_update_ad( &ctx_dec, NULL, 0 ) );
- TEST_ASSERT( 0 == cipher_update_ad( &ctx_enc, NULL, 0 ) );
+#if defined(MBEDTLS_GCM_C)
+ TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_dec, NULL, 0 ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_enc, NULL, 0 ) );
#endif
/* encode length number of bytes from inbuf */
- TEST_ASSERT( 0 == cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
totaloutlen = outlen;
- TEST_ASSERT( 0 == cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
totaloutlen += outlen;
TEST_ASSERT( totaloutlen == length ||
- ( totaloutlen % cipher_get_block_size( &ctx_enc ) == 0 &&
+ ( totaloutlen % mbedtls_cipher_get_block_size( &ctx_enc ) == 0 &&
totaloutlen < length &&
- totaloutlen + cipher_get_block_size( &ctx_enc ) > length ) );
+ totaloutlen + mbedtls_cipher_get_block_size( &ctx_enc ) > length ) );
- TEST_ASSERT( 0 == cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
totaloutlen += outlen;
TEST_ASSERT( totaloutlen == length ||
- ( totaloutlen % cipher_get_block_size( &ctx_enc ) == 0 &&
+ ( totaloutlen % mbedtls_cipher_get_block_size( &ctx_enc ) == 0 &&
totaloutlen > length &&
- totaloutlen <= length + cipher_get_block_size( &ctx_enc ) ) );
+ totaloutlen <= length + mbedtls_cipher_get_block_size( &ctx_enc ) ) );
/* decode the previously encoded string */
- TEST_ASSERT( 0 == cipher_update( &ctx_dec, encbuf, totaloutlen, decbuf, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx_dec, encbuf, totaloutlen, decbuf, &outlen ) );
totaloutlen = outlen;
TEST_ASSERT( totaloutlen == length ||
- ( totaloutlen % cipher_get_block_size( &ctx_dec ) == 0 &&
+ ( totaloutlen % mbedtls_cipher_get_block_size( &ctx_dec ) == 0 &&
totaloutlen < length &&
- totaloutlen + cipher_get_block_size( &ctx_dec ) >= length ) );
+ totaloutlen + mbedtls_cipher_get_block_size( &ctx_dec ) >= length ) );
- TEST_ASSERT( 0 == cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
totaloutlen += outlen;
TEST_ASSERT( totaloutlen == length );
@@ -401,8 +401,8 @@
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );
exit:
- cipher_free( &ctx_dec );
- cipher_free( &ctx_enc );
+ mbedtls_cipher_free( &ctx_dec );
+ mbedtls_cipher_free( &ctx_enc );
}
/* END_CASE */
@@ -420,14 +420,14 @@
unsigned char ad[200];
unsigned char tag[20];
size_t key_len, iv_len, cipher_len, clear_len;
-#if defined(POLARSSL_GCM_C)
+#if defined(MBEDTLS_GCM_C)
size_t ad_len, tag_len;
#endif
- cipher_context_t ctx;
+ mbedtls_cipher_context_t ctx;
unsigned char output[200];
size_t outlen, total_len;
- cipher_init( &ctx );
+ mbedtls_cipher_init( &ctx );
memset( key, 0x00, sizeof( key ) );
memset( iv, 0x00, sizeof( iv ) );
@@ -441,7 +441,7 @@
iv_len = unhexify( iv, hex_iv );
cipher_len = unhexify( cipher, hex_cipher );
clear_len = unhexify( clear, hex_clear );
-#if defined(POLARSSL_GCM_C)
+#if defined(MBEDTLS_GCM_C)
ad_len = unhexify( ad, hex_ad );
tag_len = unhexify( tag, hex_tag );
#else
@@ -450,30 +450,30 @@
#endif
/* Prepare context */
- TEST_ASSERT( 0 == cipher_init_ctx( &ctx,
- cipher_info_from_type( cipher_id ) ) );
- TEST_ASSERT( 0 == cipher_setkey( &ctx, key, 8 * key_len, POLARSSL_DECRYPT ) );
-#if defined(POLARSSL_CIPHER_MODE_WITH_PADDING)
+ TEST_ASSERT( 0 == mbedtls_cipher_init_ctx( &ctx,
+ mbedtls_cipher_info_from_type( cipher_id ) ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key, 8 * key_len, MBEDTLS_DECRYPT ) );
+#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING)
if( pad_mode != -1 )
- TEST_ASSERT( 0 == cipher_set_padding_mode( &ctx, pad_mode ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_set_padding_mode( &ctx, pad_mode ) );
#else
(void) pad_mode;
-#endif /* POLARSSL_CIPHER_MODE_WITH_PADDING */
- TEST_ASSERT( 0 == cipher_set_iv( &ctx, iv, iv_len ) );
- TEST_ASSERT( 0 == cipher_reset( &ctx ) );
-#if defined(POLARSSL_GCM_C)
- TEST_ASSERT( 0 == cipher_update_ad( &ctx, ad, ad_len ) );
+#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
+ TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx, iv, iv_len ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx ) );
+#if defined(MBEDTLS_GCM_C)
+ TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx, ad, ad_len ) );
#endif
/* decode buffer and check tag */
total_len = 0;
- TEST_ASSERT( 0 == cipher_update( &ctx, cipher, cipher_len, output, &outlen ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx, cipher, cipher_len, output, &outlen ) );
total_len += outlen;
- TEST_ASSERT( finish_result == cipher_finish( &ctx, output + outlen,
+ TEST_ASSERT( finish_result == mbedtls_cipher_finish( &ctx, output + outlen,
&outlen ) );
total_len += outlen;
-#if defined(POLARSSL_GCM_C)
- TEST_ASSERT( tag_result == cipher_check_tag( &ctx, tag, tag_len ) );
+#if defined(MBEDTLS_GCM_C)
+ TEST_ASSERT( tag_result == mbedtls_cipher_check_tag( &ctx, tag, tag_len ) );
#endif
/* check plaintext only if everything went fine */
@@ -484,11 +484,11 @@
}
exit:
- cipher_free( &ctx );
+ mbedtls_cipher_free( &ctx );
}
/* END_CASE */
-/* BEGIN_CASE depends_on:POLARSSL_CIPHER_MODE_AEAD */
+/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_AEAD */
void auth_crypt_tv( int cipher_id, char *hex_key, char *hex_iv,
char *hex_ad, char *hex_cipher,
char *hex_tag, char *hex_clear )
@@ -502,11 +502,11 @@
unsigned char tag[20];
unsigned char my_tag[20];
size_t key_len, iv_len, cipher_len, clear_len, ad_len, tag_len;
- cipher_context_t ctx;
+ mbedtls_cipher_context_t ctx;
unsigned char output[200];
size_t outlen;
- cipher_init( &ctx );
+ mbedtls_cipher_init( &ctx );
memset( key, 0x00, sizeof( key ) );
memset( iv, 0x00, sizeof( iv ) );
@@ -524,12 +524,12 @@
tag_len = unhexify( tag, hex_tag );
/* Prepare context */
- TEST_ASSERT( 0 == cipher_init_ctx( &ctx,
- cipher_info_from_type( cipher_id ) ) );
- TEST_ASSERT( 0 == cipher_setkey( &ctx, key, 8 * key_len, POLARSSL_DECRYPT ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_init_ctx( &ctx,
+ mbedtls_cipher_info_from_type( cipher_id ) ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key, 8 * key_len, MBEDTLS_DECRYPT ) );
/* decode buffer and check tag */
- ret = cipher_auth_decrypt( &ctx, iv, iv_len, ad, ad_len,
+ ret = mbedtls_cipher_auth_decrypt( &ctx, iv, iv_len, ad, ad_len,
cipher, cipher_len, output, &outlen,
tag, tag_len );
@@ -540,7 +540,7 @@
/* make sure the message is rejected if it should be */
if( strcmp( hex_clear, "FAIL" ) == 0 )
{
- TEST_ASSERT( ret == POLARSSL_ERR_CIPHER_AUTH_FAILED );
+ TEST_ASSERT( ret == MBEDTLS_ERR_CIPHER_AUTH_FAILED );
goto exit;
}
@@ -555,7 +555,7 @@
memset( output, 0xFF, sizeof( output ) );
outlen = 0;
- ret = cipher_auth_encrypt( &ctx, iv, iv_len, ad, ad_len,
+ ret = mbedtls_cipher_auth_encrypt( &ctx, iv, iv_len, ad, ad_len,
clear, clear_len, output, &outlen,
my_tag, tag_len );
TEST_ASSERT( ret == 0 );
@@ -572,7 +572,7 @@
exit:
- cipher_free( &ctx );
+ mbedtls_cipher_free( &ctx );
}
/* END_CASE */
@@ -585,11 +585,11 @@
unsigned char input[16];
unsigned char result[16];
size_t key_len;
- cipher_context_t ctx;
+ mbedtls_cipher_context_t ctx;
unsigned char output[32];
size_t outlen;
- cipher_init( &ctx );
+ mbedtls_cipher_init( &ctx );
memset( key, 0x00, sizeof( key ) );
memset( input, 0x00, sizeof( input ) );
@@ -597,68 +597,68 @@
memset( output, 0x00, sizeof( output ) );
/* Prepare context */
- TEST_ASSERT( 0 == cipher_init_ctx( &ctx,
- cipher_info_from_type( cipher_id ) ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_init_ctx( &ctx,
+ mbedtls_cipher_info_from_type( cipher_id ) ) );
key_len = unhexify( key, hex_key );
TEST_ASSERT( unhexify( input, hex_input ) ==
- (int) cipher_get_block_size( &ctx ) );
+ (int) mbedtls_cipher_get_block_size( &ctx ) );
TEST_ASSERT( unhexify( result, hex_result ) ==
- (int) cipher_get_block_size( &ctx ) );
+ (int) mbedtls_cipher_get_block_size( &ctx ) );
- TEST_ASSERT( 0 == cipher_setkey( &ctx, key, 8 * key_len, operation ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key, 8 * key_len, operation ) );
- TEST_ASSERT( 0 == cipher_update( &ctx, input,
- cipher_get_block_size( &ctx ),
+ TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx, input,
+ mbedtls_cipher_get_block_size( &ctx ),
output, &outlen ) );
- TEST_ASSERT( outlen == cipher_get_block_size( &ctx ) );
- TEST_ASSERT( finish_result == cipher_finish( &ctx, output + outlen,
+ TEST_ASSERT( outlen == mbedtls_cipher_get_block_size( &ctx ) );
+ TEST_ASSERT( finish_result == mbedtls_cipher_finish( &ctx, output + outlen,
&outlen ) );
TEST_ASSERT( 0 == outlen );
/* check plaintext only if everything went fine */
if( 0 == finish_result )
TEST_ASSERT( 0 == memcmp( output, result,
- cipher_get_block_size( &ctx ) ) );
+ mbedtls_cipher_get_block_size( &ctx ) ) );
exit:
- cipher_free( &ctx );
+ mbedtls_cipher_free( &ctx );
}
/* END_CASE */
-/* BEGIN_CASE depends_on:POLARSSL_CIPHER_MODE_WITH_PADDING */
+/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_WITH_PADDING */
void set_padding( int cipher_id, int pad_mode, int ret )
{
- const cipher_info_t *cipher_info;
- cipher_context_t ctx;
+ const mbedtls_cipher_info_t *cipher_info;
+ mbedtls_cipher_context_t ctx;
- cipher_init( &ctx );
+ mbedtls_cipher_init( &ctx );
- cipher_info = cipher_info_from_type( cipher_id );
+ cipher_info = mbedtls_cipher_info_from_type( cipher_id );
TEST_ASSERT( NULL != cipher_info );
- TEST_ASSERT( 0 == cipher_init_ctx( &ctx, cipher_info ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_init_ctx( &ctx, cipher_info ) );
- TEST_ASSERT( ret == cipher_set_padding_mode( &ctx, pad_mode ) );
+ TEST_ASSERT( ret == mbedtls_cipher_set_padding_mode( &ctx, pad_mode ) );
exit:
- cipher_free( &ctx );
+ mbedtls_cipher_free( &ctx );
}
/* END_CASE */
-/* BEGIN_CASE depends_on:POLARSSL_CIPHER_MODE_CBC */
+/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */
void check_padding( int pad_mode, char *input_str, int ret, int dlen_check )
{
- cipher_info_t cipher_info;
- cipher_context_t ctx;
+ mbedtls_cipher_info_t cipher_info;
+ mbedtls_cipher_context_t ctx;
unsigned char input[16];
size_t ilen, dlen;
/* build a fake context just for getting access to get_padding */
- cipher_init( &ctx );
- cipher_info.mode = POLARSSL_MODE_CBC;
+ mbedtls_cipher_init( &ctx );
+ cipher_info.mode = MBEDTLS_MODE_CBC;
ctx.cipher_info = &cipher_info;
- TEST_ASSERT( 0 == cipher_set_padding_mode( &ctx, pad_mode ) );
+ TEST_ASSERT( 0 == mbedtls_cipher_set_padding_mode( &ctx, pad_mode ) );
ilen = unhexify( input, input_str );