The Great Renaming
A simple execution of tmp/invoke-rename.pl
diff --git a/library/xtea.c b/library/xtea.c
index 8fac8c1..c44892e 100644
--- a/library/xtea.c
+++ b/library/xtea.c
@@ -20,31 +20,31 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#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_XTEA_C)
+#if defined(MBEDTLS_XTEA_C)
#include "mbedtls/xtea.h"
#include <string.h>
-#if defined(POLARSSL_SELF_TEST)
-#if defined(POLARSSL_PLATFORM_C)
+#if defined(MBEDTLS_SELF_TEST)
+#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 */
+#define mbedtls_printf printf
+#endif /* MBEDTLS_PLATFORM_C */
+#endif /* MBEDTLS_SELF_TEST */
-#if !defined(POLARSSL_XTEA_ALT)
+#if !defined(MBEDTLS_XTEA_ALT)
/* 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;
}
@@ -71,27 +71,27 @@
}
#endif
-void xtea_init( xtea_context *ctx )
+void mbedtls_xtea_init( mbedtls_xtea_context *ctx )
{
- memset( ctx, 0, sizeof( xtea_context ) );
+ memset( ctx, 0, sizeof( mbedtls_xtea_context ) );
}
-void xtea_free( xtea_context *ctx )
+void mbedtls_xtea_free( mbedtls_xtea_context *ctx )
{
if( ctx == NULL )
return;
- polarssl_zeroize( ctx, sizeof( xtea_context ) );
+ mbedtls_zeroize( ctx, sizeof( mbedtls_xtea_context ) );
}
/*
* XTEA key schedule
*/
-void xtea_setup( xtea_context *ctx, const unsigned char key[16] )
+void mbedtls_xtea_setup( mbedtls_xtea_context *ctx, const unsigned char key[16] )
{
int i;
- memset( ctx, 0, sizeof(xtea_context) );
+ memset( ctx, 0, sizeof(mbedtls_xtea_context) );
for( i = 0; i < 4; i++ )
{
@@ -102,7 +102,7 @@
/*
* XTEA encrypt function
*/
-int xtea_crypt_ecb( xtea_context *ctx, int mode,
+int mbedtls_xtea_crypt_ecb( mbedtls_xtea_context *ctx, int mode,
const unsigned char input[8], unsigned char output[8])
{
uint32_t *k, v0, v1, i;
@@ -112,7 +112,7 @@
GET_UINT32_BE( v0, input, 0 );
GET_UINT32_BE( v1, input, 4 );
- if( mode == XTEA_ENCRYPT )
+ if( mode == MBEDTLS_XTEA_ENCRYPT )
{
uint32_t sum = 0, delta = 0x9E3779B9;
@@ -123,7 +123,7 @@
v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum>>11) & 3]);
}
}
- else /* XTEA_DECRYPT */
+ else /* MBEDTLS_XTEA_DECRYPT */
{
uint32_t delta = 0x9E3779B9, sum = delta * 32;
@@ -141,11 +141,11 @@
return( 0 );
}
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
/*
* XTEA-CBC buffer encryption/decryption
*/
-int xtea_crypt_cbc( xtea_context *ctx, int mode, size_t length,
+int mbedtls_xtea_crypt_cbc( mbedtls_xtea_context *ctx, int mode, size_t length,
unsigned char iv[8], const unsigned char *input,
unsigned char *output)
{
@@ -153,14 +153,14 @@
unsigned char temp[8];
if( length % 8 )
- return( POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH );
+ return( MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH );
- if( mode == XTEA_DECRYPT )
+ if( mode == MBEDTLS_XTEA_DECRYPT )
{
while( length > 0 )
{
memcpy( temp, input, 8 );
- xtea_crypt_ecb( ctx, mode, input, output );
+ mbedtls_xtea_crypt_ecb( ctx, mode, input, output );
for( i = 0; i < 8; i++ )
output[i] = (unsigned char)( output[i] ^ iv[i] );
@@ -179,7 +179,7 @@
for( i = 0; i < 8; i++ )
output[i] = (unsigned char)( input[i] ^ iv[i] );
- xtea_crypt_ecb( ctx, mode, output, output );
+ mbedtls_xtea_crypt_ecb( ctx, mode, output, output );
memcpy( iv, output, 8 );
input += 8;
@@ -190,10 +190,10 @@
return( 0 );
}
-#endif /* POLARSSL_CIPHER_MODE_CBC */
-#endif /* !POLARSSL_XTEA_ALT */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
+#endif /* !MBEDTLS_XTEA_ALT */
-#if defined(POLARSSL_SELF_TEST)
+#if defined(MBEDTLS_SELF_TEST)
/*
* XTEA tests vectors (non-official)
@@ -238,45 +238,45 @@
/*
* Checkup routine
*/
-int xtea_self_test( int verbose )
+int mbedtls_xtea_self_test( int verbose )
{
int i, ret = 0;
unsigned char buf[8];
- xtea_context ctx;
+ mbedtls_xtea_context ctx;
- xtea_init( &ctx );
+ mbedtls_xtea_init( &ctx );
for( i = 0; i < 6; i++ )
{
if( verbose != 0 )
- polarssl_printf( " XTEA test #%d: ", i + 1 );
+ mbedtls_printf( " XTEA test #%d: ", i + 1 );
memcpy( buf, xtea_test_pt[i], 8 );
- xtea_setup( &ctx, xtea_test_key[i] );
- xtea_crypt_ecb( &ctx, XTEA_ENCRYPT, buf, buf );
+ mbedtls_xtea_setup( &ctx, xtea_test_key[i] );
+ mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_ENCRYPT, buf, buf );
if( memcmp( buf, xtea_test_ct[i], 8 ) != 0 )
{
if( verbose != 0 )
- polarssl_printf( "failed\n" );
+ mbedtls_printf( "failed\n" );
ret = 1;
goto exit;
}
if( verbose != 0 )
- polarssl_printf( "passed\n" );
+ mbedtls_printf( "passed\n" );
}
if( verbose != 0 )
- polarssl_printf( "\n" );
+ mbedtls_printf( "\n" );
exit:
- xtea_free( &ctx );
+ mbedtls_xtea_free( &ctx );
return( ret );
}
-#endif /* POLARSSL_SELF_TEST */
+#endif /* MBEDTLS_SELF_TEST */
-#endif /* POLARSSL_XTEA_C */
+#endif /* MBEDTLS_XTEA_C */