The Great Renaming
A simple execution of tmp/invoke-rename.pl
diff --git a/library/ccm.c b/library/ccm.c
index 6f3db01..72eed38 100644
--- a/library/ccm.c
+++ b/library/ccm.c
@@ -29,29 +29,29 @@
* RFC 5116 "An Interface and Algorithms for Authenticated Encryption"
*/
-#if !defined(POLARSSL_CONFIG_FILE)
+#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
-#include POLARSSL_CONFIG_FILE
+#include MBEDTLS_CONFIG_FILE
#endif
-#if defined(POLARSSL_CCM_C)
+#if defined(MBEDTLS_CCM_C)
#include "mbedtls/ccm.h"
#include <string.h>
-#if defined(POLARSSL_SELF_TEST) && defined(POLARSSL_AES_C)
-#if defined(POLARSSL_PLATFORM_C)
+#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
+#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdio.h>
-#define polarssl_printf printf
-#endif /* POLARSSL_PLATFORM_C */
-#endif /* POLARSSL_SELF_TEST && POLARSSL_AES_C */
+#define mbedtls_printf printf
+#endif /* MBEDTLS_PLATFORM_C */
+#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
/* Implementation that should never be optimized out by the compiler */
-static void polarssl_zeroize( void *v, size_t n ) {
+static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
}
@@ -61,28 +61,28 @@
/*
* Initialize context
*/
-int ccm_init( ccm_context *ctx, cipher_id_t cipher,
+int mbedtls_ccm_init( mbedtls_ccm_context *ctx, mbedtls_cipher_id_t cipher,
const unsigned char *key, unsigned int keysize )
{
int ret;
- const cipher_info_t *cipher_info;
+ const mbedtls_cipher_info_t *cipher_info;
- memset( ctx, 0, sizeof( ccm_context ) );
+ memset( ctx, 0, sizeof( mbedtls_ccm_context ) );
- cipher_init( &ctx->cipher_ctx );
+ mbedtls_cipher_init( &ctx->cipher_ctx );
- cipher_info = cipher_info_from_values( cipher, keysize, POLARSSL_MODE_ECB );
+ cipher_info = mbedtls_cipher_info_from_values( cipher, keysize, MBEDTLS_MODE_ECB );
if( cipher_info == NULL )
- return( POLARSSL_ERR_CCM_BAD_INPUT );
+ return( MBEDTLS_ERR_CCM_BAD_INPUT );
if( cipher_info->block_size != 16 )
- return( POLARSSL_ERR_CCM_BAD_INPUT );
+ return( MBEDTLS_ERR_CCM_BAD_INPUT );
- if( ( ret = cipher_init_ctx( &ctx->cipher_ctx, cipher_info ) ) != 0 )
+ if( ( ret = mbedtls_cipher_init_ctx( &ctx->cipher_ctx, cipher_info ) ) != 0 )
return( ret );
- if( ( ret = cipher_setkey( &ctx->cipher_ctx, key, keysize,
- POLARSSL_ENCRYPT ) ) != 0 )
+ if( ( ret = mbedtls_cipher_setkey( &ctx->cipher_ctx, key, keysize,
+ MBEDTLS_ENCRYPT ) ) != 0 )
{
return( ret );
}
@@ -93,10 +93,10 @@
/*
* Free context
*/
-void ccm_free( ccm_context *ctx )
+void mbedtls_ccm_free( mbedtls_ccm_context *ctx )
{
- cipher_free( &ctx->cipher_ctx );
- polarssl_zeroize( ctx, sizeof( ccm_context ) );
+ mbedtls_cipher_free( &ctx->cipher_ctx );
+ mbedtls_zeroize( ctx, sizeof( mbedtls_ccm_context ) );
}
/*
@@ -112,7 +112,7 @@
for( i = 0; i < 16; i++ ) \
y[i] ^= b[i]; \
\
- if( ( ret = cipher_update( &ctx->cipher_ctx, y, 16, y, &olen ) ) != 0 ) \
+ if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, y, 16, y, &olen ) ) != 0 ) \
return( ret );
/*
@@ -121,7 +121,7 @@
* This avoids allocating one more 16 bytes buffer while allowing src == dst.
*/
#define CTR_CRYPT( dst, src, len ) \
- if( ( ret = cipher_update( &ctx->cipher_ctx, ctr, 16, b, &olen ) ) != 0 ) \
+ if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctr, 16, b, &olen ) ) != 0 ) \
return( ret ); \
\
for( i = 0; i < len; i++ ) \
@@ -130,7 +130,7 @@
/*
* Authenticated encryption or decryption
*/
-static int ccm_auth_crypt( ccm_context *ctx, int mode, size_t length,
+static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length,
const unsigned char *iv, size_t iv_len,
const unsigned char *add, size_t add_len,
const unsigned char *input, unsigned char *output,
@@ -152,14 +152,14 @@
* 'length' checked later (when writing it to the first block)
*/
if( tag_len < 4 || tag_len > 16 || tag_len % 2 != 0 )
- return( POLARSSL_ERR_CCM_BAD_INPUT );
+ return( MBEDTLS_ERR_CCM_BAD_INPUT );
/* Also implies q is within bounds */
if( iv_len < 7 || iv_len > 13 )
- return( POLARSSL_ERR_CCM_BAD_INPUT );
+ return( MBEDTLS_ERR_CCM_BAD_INPUT );
if( add_len > 0xFF00 )
- return( POLARSSL_ERR_CCM_BAD_INPUT );
+ return( MBEDTLS_ERR_CCM_BAD_INPUT );
/*
* First block B_0:
@@ -184,7 +184,7 @@
b[15-i] = (unsigned char)( len_left & 0xFF );
if( len_left > 0 )
- return( POLARSSL_ERR_CCM_BAD_INPUT );
+ return( MBEDTLS_ERR_CCM_BAD_INPUT );
/* Start CBC-MAC with first block */
@@ -298,7 +298,7 @@
/*
* Authenticated encryption
*/
-int ccm_encrypt_and_tag( ccm_context *ctx, size_t length,
+int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
const unsigned char *iv, size_t iv_len,
const unsigned char *add, size_t add_len,
const unsigned char *input, unsigned char *output,
@@ -311,7 +311,7 @@
/*
* Authenticated decryption
*/
-int ccm_auth_decrypt( ccm_context *ctx, size_t length,
+int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
const unsigned char *iv, size_t iv_len,
const unsigned char *add, size_t add_len,
const unsigned char *input, unsigned char *output,
@@ -335,15 +335,15 @@
if( diff != 0 )
{
- polarssl_zeroize( output, length );
- return( POLARSSL_ERR_CCM_AUTH_FAILED );
+ mbedtls_zeroize( output, length );
+ return( MBEDTLS_ERR_CCM_AUTH_FAILED );
}
return( 0 );
}
-#if defined(POLARSSL_SELF_TEST) && defined(POLARSSL_AES_C)
+#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
/*
* Examples 1 to 3 from SP800-38C Appendix C
*/
@@ -391,17 +391,17 @@
0x48, 0x43, 0x92, 0xfb, 0xc1, 0xb0, 0x99, 0x51 }
};
-int ccm_self_test( int verbose )
+int mbedtls_ccm_self_test( int verbose )
{
- ccm_context ctx;
+ mbedtls_ccm_context ctx;
unsigned char out[32];
size_t i;
int ret;
- if( ccm_init( &ctx, POLARSSL_CIPHER_ID_AES, key, 8 * sizeof key ) != 0 )
+ if( mbedtls_ccm_init( &ctx, MBEDTLS_CIPHER_ID_AES, key, 8 * sizeof key ) != 0 )
{
if( verbose != 0 )
- polarssl_printf( " CCM: setup failed" );
+ mbedtls_printf( " CCM: setup failed" );
return( 1 );
}
@@ -409,9 +409,9 @@
for( i = 0; i < NB_TESTS; i++ )
{
if( verbose != 0 )
- polarssl_printf( " CCM-AES #%u: ", (unsigned int) i + 1 );
+ mbedtls_printf( " CCM-AES #%u: ", (unsigned int) i + 1 );
- ret = ccm_encrypt_and_tag( &ctx, msg_len[i],
+ ret = mbedtls_ccm_encrypt_and_tag( &ctx, msg_len[i],
iv, iv_len[i], ad, add_len[i],
msg, out,
out + msg_len[i], tag_len[i] );
@@ -420,12 +420,12 @@
memcmp( out, res[i], msg_len[i] + tag_len[i] ) != 0 )
{
if( verbose != 0 )
- polarssl_printf( "failed\n" );
+ mbedtls_printf( "failed\n" );
return( 1 );
}
- ret = ccm_auth_decrypt( &ctx, msg_len[i],
+ ret = mbedtls_ccm_auth_decrypt( &ctx, msg_len[i],
iv, iv_len[i], ad, add_len[i],
res[i], out,
res[i] + msg_len[i], tag_len[i] );
@@ -434,23 +434,23 @@
memcmp( out, msg, msg_len[i] ) != 0 )
{
if( verbose != 0 )
- polarssl_printf( "failed\n" );
+ mbedtls_printf( "failed\n" );
return( 1 );
}
if( verbose != 0 )
- polarssl_printf( "passed\n" );
+ mbedtls_printf( "passed\n" );
}
- ccm_free( &ctx );
+ mbedtls_ccm_free( &ctx );
if( verbose != 0 )
- polarssl_printf( "\n" );
+ mbedtls_printf( "\n" );
return( 0 );
}
-#endif /* POLARSSL_SELF_TEST && POLARSSL_AES_C */
+#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
-#endif /* POLARSSL_CCM_C */
+#endif /* MBEDTLS_CCM_C */