The Great Renaming
A simple execution of tmp/invoke-rename.pl
diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c
index a9cba6f..56e31e0 100644
--- a/programs/test/benchmark.c
+++ b/programs/test/benchmark.c
@@ -20,26 +20,26 @@
* 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_PLATFORM_C)
+#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdio.h>
-#define polarssl_exit exit
-#define polarssl_printf printf
-#define polarssl_snprintf snprintf
-#define polarssl_free free
+#define mbedtls_exit exit
+#define mbedtls_printf printf
+#define mbedtls_snprintf snprintf
+#define mbedtls_free free
#endif
-#if !defined(POLARSSL_TIMING_C)
+#if !defined(MBEDTLS_TIMING_C)
int main( void )
{
- polarssl_printf("POLARSSL_TIMING_C not defined.\n");
+ mbedtls_printf("MBEDTLS_TIMING_C not defined.\n");
return( 0 );
}
#else
@@ -70,7 +70,7 @@
#include "mbedtls/ecdh.h"
#include "mbedtls/error.h"
-#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
#include "mbedtls/memory_buffer_alloc.h"
#endif
@@ -97,68 +97,68 @@
#define DHM_SIZES 3
#define OPTIONS \
- "md4, md5, ripemd160, sha1, sha256, sha512,\n" \
+ "mbedtls_md4, mbedtls_md5, mbedtls_ripemd160, mbedtls_sha1, mbedtls_sha256, mbedtls_sha512,\n" \
"arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish,\n" \
"havege, ctr_drbg, hmac_drbg\n" \
"rsa, dhm, ecdsa, ecdh.\n"
-#if defined(POLARSSL_ERROR_C)
+#if defined(MBEDTLS_ERROR_C)
#define PRINT_ERROR \
- polarssl_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \
- polarssl_printf( "FAILED: %s\n", tmp );
+ mbedtls_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \
+ mbedtls_printf( "FAILED: %s\n", tmp );
#else
#define PRINT_ERROR \
- polarssl_printf( "FAILED: -0x%04x\n", -ret );
+ mbedtls_printf( "FAILED: -0x%04x\n", -ret );
#endif
#define TIME_AND_TSC( TITLE, CODE ) \
do { \
unsigned long i, j, tsc; \
\
- polarssl_printf( HEADER_FORMAT, TITLE ); \
+ mbedtls_printf( HEADER_FORMAT, TITLE ); \
fflush( stdout ); \
\
- set_alarm( 1 ); \
- for( i = 1; ! alarmed; i++ ) \
+ mbedtls_set_alarm( 1 ); \
+ for( i = 1; ! mbedtls_timing_alarmed; i++ ) \
{ \
CODE; \
} \
\
- tsc = hardclock(); \
+ tsc = mbedtls_timing_hardclock(); \
for( j = 0; j < 1024; j++ ) \
{ \
CODE; \
} \
\
- polarssl_printf( "%9lu Kb/s, %9lu cycles/byte\n", \
+ mbedtls_printf( "%9lu Kb/s, %9lu cycles/byte\n", \
i * BUFSIZE / 1024, \
- ( hardclock() - tsc ) / ( j * BUFSIZE ) ); \
+ ( mbedtls_timing_hardclock() - tsc ) / ( j * BUFSIZE ) ); \
} while( 0 )
-#if defined(POLARSSL_ERROR_C)
+#if defined(MBEDTLS_ERROR_C)
#define PRINT_ERROR \
- polarssl_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \
- polarssl_printf( "FAILED: %s\n", tmp );
+ mbedtls_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \
+ mbedtls_printf( "FAILED: %s\n", tmp );
#else
#define PRINT_ERROR \
- polarssl_printf( "FAILED: -0x%04x\n", -ret );
+ mbedtls_printf( "FAILED: -0x%04x\n", -ret );
#endif
-#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && defined(POLARSSL_MEMORY_DEBUG)
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG)
#define MEMORY_MEASURE_INIT \
size_t max_used, max_blocks, max_bytes; \
size_t prv_used, prv_blocks; \
- memory_buffer_alloc_cur_get( &prv_used, &prv_blocks ); \
- memory_buffer_alloc_max_reset( );
+ mbedtls_memory_buffer_alloc_cur_get( &prv_used, &prv_blocks ); \
+ mbedtls_memory_buffer_alloc_max_reset( );
#define MEMORY_MEASURE_PRINT( title_len ) \
- memory_buffer_alloc_max_get( &max_used, &max_blocks ); \
- for( i = 12 - title_len; i != 0; i-- ) polarssl_printf( " " ); \
+ mbedtls_memory_buffer_alloc_max_get( &max_used, &max_blocks ); \
+ for( i = 12 - title_len; i != 0; i-- ) mbedtls_printf( " " ); \
max_used -= prv_used; \
max_blocks -= prv_blocks; \
max_bytes = max_used + MEM_BLOCK_OVERHEAD * max_blocks; \
- polarssl_printf( "%6u heap bytes", (unsigned) max_bytes );
+ mbedtls_printf( "%6u heap bytes", (unsigned) max_bytes );
#else
#define MEMORY_MEASURE_INIT
@@ -171,12 +171,12 @@
int ret; \
MEMORY_MEASURE_INIT; \
\
- polarssl_printf( HEADER_FORMAT, TITLE ); \
+ mbedtls_printf( HEADER_FORMAT, TITLE ); \
fflush( stdout ); \
- set_alarm( 3 ); \
+ mbedtls_set_alarm( 3 ); \
\
ret = 0; \
- for( i = 1; ! alarmed && ! ret ; i++ ) \
+ for( i = 1; ! mbedtls_timing_alarmed && ! ret ; i++ ) \
{ \
CODE; \
} \
@@ -187,9 +187,9 @@
} \
else \
{ \
- polarssl_printf( "%6lu " TYPE "/s", i / 3 ); \
+ mbedtls_printf( "%6lu " TYPE "/s", i / 3 ); \
MEMORY_MEASURE_PRINT( sizeof( TYPE ) + 1 ); \
- polarssl_printf( "\n" ); \
+ mbedtls_printf( "\n" ); \
} \
} while( 0 )
@@ -219,15 +219,15 @@
/*
* Clear some memory that was used to prepare the context
*/
-#if defined(POLARSSL_ECP_C)
-void ecp_clear_precomputed( ecp_group *grp )
+#if defined(MBEDTLS_ECP_C)
+void ecp_clear_precomputed( mbedtls_ecp_group *grp )
{
if( grp->T != NULL )
{
size_t i;
for( i = 0; i < grp->T_size; i++ )
- ecp_point_free( &grp->T[i] );
- polarssl_free( grp->T );
+ mbedtls_ecp_point_free( &grp->T[i] );
+ mbedtls_free( grp->T );
}
grp->T = NULL;
grp->T_size = 0;
@@ -239,7 +239,7 @@
unsigned char buf[BUFSIZE];
typedef struct {
- char md4, md5, ripemd160, sha1, sha256, sha512,
+ char mbedtls_md4, mbedtls_md5, mbedtls_ripemd160, mbedtls_sha1, mbedtls_sha256, mbedtls_sha512,
arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish,
havege, ctr_drbg, hmac_drbg,
rsa, dhm, ecdsa, ecdh;
@@ -251,7 +251,7 @@
unsigned char tmp[200];
char title[TITLE_LEN];
todo_list todo;
-#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
unsigned char malloc_buf[HEAP_SIZE] = { 0 };
#endif
@@ -265,18 +265,18 @@
for( i = 1; i < argc; i++ )
{
- if( strcmp( argv[i], "md4" ) == 0 )
- todo.md4 = 1;
- else if( strcmp( argv[i], "md5" ) == 0 )
- todo.md5 = 1;
- else if( strcmp( argv[i], "ripemd160" ) == 0 )
- todo.ripemd160 = 1;
- else if( strcmp( argv[i], "sha1" ) == 0 )
- todo.sha1 = 1;
- else if( strcmp( argv[i], "sha256" ) == 0 )
- todo.sha256 = 1;
- else if( strcmp( argv[i], "sha512" ) == 0 )
- todo.sha512 = 1;
+ if( strcmp( argv[i], "mbedtls_md4" ) == 0 )
+ todo.mbedtls_md4 = 1;
+ else if( strcmp( argv[i], "mbedtls_md5" ) == 0 )
+ todo.mbedtls_md5 = 1;
+ else if( strcmp( argv[i], "mbedtls_ripemd160" ) == 0 )
+ todo.mbedtls_ripemd160 = 1;
+ else if( strcmp( argv[i], "mbedtls_sha1" ) == 0 )
+ todo.mbedtls_sha1 = 1;
+ else if( strcmp( argv[i], "mbedtls_sha256" ) == 0 )
+ todo.mbedtls_sha256 = 1;
+ else if( strcmp( argv[i], "mbedtls_sha512" ) == 0 )
+ todo.mbedtls_sha512 = 1;
else if( strcmp( argv[i], "arc4" ) == 0 )
todo.arc4 = 1;
else if( strcmp( argv[i], "des3" ) == 0 )
@@ -309,518 +309,518 @@
todo.ecdh = 1;
else
{
- polarssl_printf( "Unrecognized option: %s\n", argv[i] );
- polarssl_printf( "Available options: " OPTIONS );
+ mbedtls_printf( "Unrecognized option: %s\n", argv[i] );
+ mbedtls_printf( "Available options: " OPTIONS );
}
}
}
- polarssl_printf( "\n" );
+ mbedtls_printf( "\n" );
-#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
- memory_buffer_alloc_init( malloc_buf, sizeof( malloc_buf ) );
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
+ mbedtls_memory_buffer_alloc_init( malloc_buf, sizeof( malloc_buf ) );
#endif
memset( buf, 0xAA, sizeof( buf ) );
memset( tmp, 0xBB, sizeof( tmp ) );
-#if defined(POLARSSL_MD4_C)
- if( todo.md4 )
- TIME_AND_TSC( "MD4", md4( buf, BUFSIZE, tmp ) );
+#if defined(MBEDTLS_MD4_C)
+ if( todo.mbedtls_md4 )
+ TIME_AND_TSC( "MD4", mbedtls_md4( buf, BUFSIZE, tmp ) );
#endif
-#if defined(POLARSSL_MD5_C)
- if( todo.md5 )
- TIME_AND_TSC( "MD5", md5( buf, BUFSIZE, tmp ) );
+#if defined(MBEDTLS_MD5_C)
+ if( todo.mbedtls_md5 )
+ TIME_AND_TSC( "MD5", mbedtls_md5( buf, BUFSIZE, tmp ) );
#endif
-#if defined(POLARSSL_RIPEMD160_C)
- if( todo.ripemd160 )
- TIME_AND_TSC( "RIPEMD160", ripemd160( buf, BUFSIZE, tmp ) );
+#if defined(MBEDTLS_RIPEMD160_C)
+ if( todo.mbedtls_ripemd160 )
+ TIME_AND_TSC( "RIPEMD160", mbedtls_ripemd160( buf, BUFSIZE, tmp ) );
#endif
-#if defined(POLARSSL_SHA1_C)
- if( todo.sha1 )
- TIME_AND_TSC( "SHA-1", sha1( buf, BUFSIZE, tmp ) );
+#if defined(MBEDTLS_SHA1_C)
+ if( todo.mbedtls_sha1 )
+ TIME_AND_TSC( "SHA-1", mbedtls_sha1( buf, BUFSIZE, tmp ) );
#endif
-#if defined(POLARSSL_SHA256_C)
- if( todo.sha256 )
- TIME_AND_TSC( "SHA-256", sha256( buf, BUFSIZE, tmp, 0 ) );
+#if defined(MBEDTLS_SHA256_C)
+ if( todo.mbedtls_sha256 )
+ TIME_AND_TSC( "SHA-256", mbedtls_sha256( buf, BUFSIZE, tmp, 0 ) );
#endif
-#if defined(POLARSSL_SHA512_C)
- if( todo.sha512 )
- TIME_AND_TSC( "SHA-512", sha512( buf, BUFSIZE, tmp, 0 ) );
+#if defined(MBEDTLS_SHA512_C)
+ if( todo.mbedtls_sha512 )
+ TIME_AND_TSC( "SHA-512", mbedtls_sha512( buf, BUFSIZE, tmp, 0 ) );
#endif
-#if defined(POLARSSL_ARC4_C)
+#if defined(MBEDTLS_ARC4_C)
if( todo.arc4 )
{
- arc4_context arc4;
- arc4_init( &arc4 );
- arc4_setup( &arc4, tmp, 32 );
- TIME_AND_TSC( "ARC4", arc4_crypt( &arc4, BUFSIZE, buf, buf ) );
- arc4_free( &arc4 );
+ mbedtls_arc4_context arc4;
+ mbedtls_arc4_init( &arc4 );
+ mbedtls_arc4_setup( &arc4, tmp, 32 );
+ TIME_AND_TSC( "ARC4", mbedtls_arc4_crypt( &arc4, BUFSIZE, buf, buf ) );
+ mbedtls_arc4_free( &arc4 );
}
#endif
-#if defined(POLARSSL_DES_C) && defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_DES_C) && defined(MBEDTLS_CIPHER_MODE_CBC)
if( todo.des3 )
{
- des3_context des3;
- des3_init( &des3 );
- des3_set3key_enc( &des3, tmp );
+ mbedtls_des3_context des3;
+ mbedtls_des3_init( &des3 );
+ mbedtls_des3_set3key_enc( &des3, tmp );
TIME_AND_TSC( "3DES",
- des3_crypt_cbc( &des3, DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
- des3_free( &des3 );
+ mbedtls_des3_crypt_cbc( &des3, MBEDTLS_DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
+ mbedtls_des3_free( &des3 );
}
if( todo.des )
{
- des_context des;
- des_init( &des );
- des_setkey_enc( &des, tmp );
+ mbedtls_des_context des;
+ mbedtls_des_init( &des );
+ mbedtls_des_setkey_enc( &des, tmp );
TIME_AND_TSC( "DES",
- des_crypt_cbc( &des, DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
- des_free( &des );
+ mbedtls_des_crypt_cbc( &des, MBEDTLS_DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
+ mbedtls_des_free( &des );
}
#endif
-#if defined(POLARSSL_AES_C)
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_AES_C)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
if( todo.aes_cbc )
{
int keysize;
- aes_context aes;
- aes_init( &aes );
+ mbedtls_aes_context aes;
+ mbedtls_aes_init( &aes );
for( keysize = 128; keysize <= 256; keysize += 64 )
{
- polarssl_snprintf( title, sizeof( title ), "AES-CBC-%d", keysize );
+ mbedtls_snprintf( title, sizeof( title ), "AES-CBC-%d", keysize );
memset( buf, 0, sizeof( buf ) );
memset( tmp, 0, sizeof( tmp ) );
- aes_setkey_enc( &aes, tmp, keysize );
+ mbedtls_aes_setkey_enc( &aes, tmp, keysize );
TIME_AND_TSC( title,
- aes_crypt_cbc( &aes, AES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
+ mbedtls_aes_crypt_cbc( &aes, MBEDTLS_AES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
}
- aes_free( &aes );
+ mbedtls_aes_free( &aes );
}
#endif
-#if defined(POLARSSL_GCM_C)
+#if defined(MBEDTLS_GCM_C)
if( todo.aes_gcm )
{
int keysize;
- gcm_context gcm;
+ mbedtls_gcm_context gcm;
for( keysize = 128; keysize <= 256; keysize += 64 )
{
- polarssl_snprintf( title, sizeof( title ), "AES-GCM-%d", keysize );
+ mbedtls_snprintf( title, sizeof( title ), "AES-GCM-%d", keysize );
memset( buf, 0, sizeof( buf ) );
memset( tmp, 0, sizeof( tmp ) );
- gcm_init( &gcm, POLARSSL_CIPHER_ID_AES, tmp, keysize );
+ mbedtls_gcm_init( &gcm, MBEDTLS_CIPHER_ID_AES, tmp, keysize );
TIME_AND_TSC( title,
- gcm_crypt_and_tag( &gcm, GCM_ENCRYPT, BUFSIZE, tmp,
+ mbedtls_gcm_crypt_and_tag( &gcm, MBEDTLS_GCM_ENCRYPT, BUFSIZE, tmp,
12, NULL, 0, buf, buf, 16, tmp ) );
- gcm_free( &gcm );
+ mbedtls_gcm_free( &gcm );
}
}
#endif
-#if defined(POLARSSL_CCM_C)
+#if defined(MBEDTLS_CCM_C)
if( todo.aes_ccm )
{
int keysize;
- ccm_context ccm;
+ mbedtls_ccm_context ccm;
for( keysize = 128; keysize <= 256; keysize += 64 )
{
- polarssl_snprintf( title, sizeof( title ), "AES-CCM-%d", keysize );
+ mbedtls_snprintf( title, sizeof( title ), "AES-CCM-%d", keysize );
memset( buf, 0, sizeof( buf ) );
memset( tmp, 0, sizeof( tmp ) );
- ccm_init( &ccm, POLARSSL_CIPHER_ID_AES, tmp, keysize );
+ mbedtls_ccm_init( &ccm, MBEDTLS_CIPHER_ID_AES, tmp, keysize );
TIME_AND_TSC( title,
- ccm_encrypt_and_tag( &ccm, BUFSIZE, tmp,
+ mbedtls_ccm_encrypt_and_tag( &ccm, BUFSIZE, tmp,
12, NULL, 0, buf, buf, tmp, 16 ) );
- ccm_free( &ccm );
+ mbedtls_ccm_free( &ccm );
}
}
#endif
#endif
-#if defined(POLARSSL_CAMELLIA_C) && defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CAMELLIA_C) && defined(MBEDTLS_CIPHER_MODE_CBC)
if( todo.camellia )
{
int keysize;
- camellia_context camellia;
- camellia_init( &camellia );
+ mbedtls_camellia_context camellia;
+ mbedtls_camellia_init( &camellia );
for( keysize = 128; keysize <= 256; keysize += 64 )
{
- polarssl_snprintf( title, sizeof( title ), "CAMELLIA-CBC-%d", keysize );
+ mbedtls_snprintf( title, sizeof( title ), "CAMELLIA-CBC-%d", keysize );
memset( buf, 0, sizeof( buf ) );
memset( tmp, 0, sizeof( tmp ) );
- camellia_setkey_enc( &camellia, tmp, keysize );
+ mbedtls_camellia_setkey_enc( &camellia, tmp, keysize );
TIME_AND_TSC( title,
- camellia_crypt_cbc( &camellia, CAMELLIA_ENCRYPT,
+ mbedtls_camellia_crypt_cbc( &camellia, MBEDTLS_CAMELLIA_ENCRYPT,
BUFSIZE, tmp, buf, buf ) );
}
- camellia_free( &camellia );
+ mbedtls_camellia_free( &camellia );
}
#endif
-#if defined(POLARSSL_BLOWFISH_C) && defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_BLOWFISH_C) && defined(MBEDTLS_CIPHER_MODE_CBC)
if( todo.blowfish )
{
int keysize;
- blowfish_context blowfish;
- blowfish_init( &blowfish );
+ mbedtls_blowfish_context blowfish;
+ mbedtls_blowfish_init( &blowfish );
for( keysize = 128; keysize <= 256; keysize += 64 )
{
- polarssl_snprintf( title, sizeof( title ), "BLOWFISH-CBC-%d", keysize );
+ mbedtls_snprintf( title, sizeof( title ), "BLOWFISH-CBC-%d", keysize );
memset( buf, 0, sizeof( buf ) );
memset( tmp, 0, sizeof( tmp ) );
- blowfish_setkey( &blowfish, tmp, keysize );
+ mbedtls_blowfish_setkey( &blowfish, tmp, keysize );
TIME_AND_TSC( title,
- blowfish_crypt_cbc( &blowfish, BLOWFISH_ENCRYPT, BUFSIZE,
+ mbedtls_blowfish_crypt_cbc( &blowfish, MBEDTLS_BLOWFISH_ENCRYPT, BUFSIZE,
tmp, buf, buf ) );
}
- blowfish_free( &blowfish );
+ mbedtls_blowfish_free( &blowfish );
}
#endif
-#if defined(POLARSSL_HAVEGE_C)
+#if defined(MBEDTLS_HAVEGE_C)
if( todo.havege )
{
- havege_state hs;
- havege_init( &hs );
- TIME_AND_TSC( "HAVEGE", havege_random( &hs, buf, BUFSIZE ) );
- havege_free( &hs );
+ mbedtls_havege_state hs;
+ mbedtls_havege_init( &hs );
+ TIME_AND_TSC( "HAVEGE", mbedtls_havege_random( &hs, buf, BUFSIZE ) );
+ mbedtls_havege_free( &hs );
}
#endif
-#if defined(POLARSSL_CTR_DRBG_C)
+#if defined(MBEDTLS_CTR_DRBG_C)
if( todo.ctr_drbg )
{
- ctr_drbg_context ctr_drbg;
+ mbedtls_ctr_drbg_context ctr_drbg;
- if( ctr_drbg_init( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 )
- polarssl_exit(1);
+ if( mbedtls_ctr_drbg_init( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 )
+ mbedtls_exit(1);
TIME_AND_TSC( "CTR_DRBG (NOPR)",
- if( ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 )
- polarssl_exit(1) );
+ if( mbedtls_ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 )
+ mbedtls_exit(1) );
- if( ctr_drbg_init( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 )
- polarssl_exit(1);
- ctr_drbg_set_prediction_resistance( &ctr_drbg, CTR_DRBG_PR_ON );
+ if( mbedtls_ctr_drbg_init( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 )
+ mbedtls_exit(1);
+ mbedtls_ctr_drbg_set_prediction_resistance( &ctr_drbg, MBEDTLS_CTR_DRBG_PR_ON );
TIME_AND_TSC( "CTR_DRBG (PR)",
- if( ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 )
- polarssl_exit(1) );
- ctr_drbg_free( &ctr_drbg );
+ if( mbedtls_ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 )
+ mbedtls_exit(1) );
+ mbedtls_ctr_drbg_free( &ctr_drbg );
}
#endif
-#if defined(POLARSSL_HMAC_DRBG_C)
+#if defined(MBEDTLS_HMAC_DRBG_C)
if( todo.hmac_drbg )
{
- hmac_drbg_context hmac_drbg;
- const md_info_t *md_info;
+ mbedtls_hmac_drbg_context hmac_drbg;
+ const mbedtls_md_info_t *md_info;
-#if defined(POLARSSL_SHA1_C)
- if( ( md_info = md_info_from_type( POLARSSL_MD_SHA1 ) ) == NULL )
- polarssl_exit(1);
+#if defined(MBEDTLS_SHA1_C)
+ if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 ) ) == NULL )
+ mbedtls_exit(1);
- if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
- polarssl_exit(1);
+ if( mbedtls_hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
+ mbedtls_exit(1);
TIME_AND_TSC( "HMAC_DRBG SHA-1 (NOPR)",
- if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
- polarssl_exit(1) );
- hmac_drbg_free( &hmac_drbg );
+ if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
+ mbedtls_exit(1) );
+ mbedtls_hmac_drbg_free( &hmac_drbg );
- if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
- polarssl_exit(1);
- hmac_drbg_set_prediction_resistance( &hmac_drbg,
- POLARSSL_HMAC_DRBG_PR_ON );
+ if( mbedtls_hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
+ mbedtls_exit(1);
+ mbedtls_hmac_drbg_set_prediction_resistance( &hmac_drbg,
+ MBEDTLS_HMAC_DRBG_PR_ON );
TIME_AND_TSC( "HMAC_DRBG SHA-1 (PR)",
- if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
- polarssl_exit(1) );
- hmac_drbg_free( &hmac_drbg );
+ if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
+ mbedtls_exit(1) );
+ mbedtls_hmac_drbg_free( &hmac_drbg );
#endif
-#if defined(POLARSSL_SHA256_C)
- if( ( md_info = md_info_from_type( POLARSSL_MD_SHA256 ) ) == NULL )
- polarssl_exit(1);
+#if defined(MBEDTLS_SHA256_C)
+ if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ) ) == NULL )
+ mbedtls_exit(1);
- if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
- polarssl_exit(1);
+ if( mbedtls_hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
+ mbedtls_exit(1);
TIME_AND_TSC( "HMAC_DRBG SHA-256 (NOPR)",
- if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
- polarssl_exit(1) );
- hmac_drbg_free( &hmac_drbg );
+ if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
+ mbedtls_exit(1) );
+ mbedtls_hmac_drbg_free( &hmac_drbg );
- if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
- polarssl_exit(1);
- hmac_drbg_set_prediction_resistance( &hmac_drbg,
- POLARSSL_HMAC_DRBG_PR_ON );
+ if( mbedtls_hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
+ mbedtls_exit(1);
+ mbedtls_hmac_drbg_set_prediction_resistance( &hmac_drbg,
+ MBEDTLS_HMAC_DRBG_PR_ON );
TIME_AND_TSC( "HMAC_DRBG SHA-256 (PR)",
- if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
- polarssl_exit(1) );
- hmac_drbg_free( &hmac_drbg );
+ if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
+ mbedtls_exit(1) );
+ mbedtls_hmac_drbg_free( &hmac_drbg );
#endif
}
#endif
-#if defined(POLARSSL_RSA_C) && defined(POLARSSL_GENPRIME)
+#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_GENPRIME)
if( todo.rsa )
{
int keysize;
- rsa_context rsa;
+ mbedtls_rsa_context rsa;
for( keysize = 1024; keysize <= 4096; keysize *= 2 )
{
- polarssl_snprintf( title, sizeof( title ), "RSA-%d", keysize );
+ mbedtls_snprintf( title, sizeof( title ), "RSA-%d", keysize );
- rsa_init( &rsa, RSA_PKCS_V15, 0 );
- rsa_gen_key( &rsa, myrand, NULL, keysize, 65537 );
+ mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
+ mbedtls_rsa_gen_key( &rsa, myrand, NULL, keysize, 65537 );
TIME_PUBLIC( title, " public",
buf[0] = 0;
- ret = rsa_public( &rsa, buf, buf ) );
+ ret = mbedtls_rsa_public( &rsa, buf, buf ) );
TIME_PUBLIC( title, "private",
buf[0] = 0;
- ret = rsa_private( &rsa, myrand, NULL, buf, buf ) );
+ ret = mbedtls_rsa_private( &rsa, myrand, NULL, buf, buf ) );
- rsa_free( &rsa );
+ mbedtls_rsa_free( &rsa );
}
}
#endif
-#if defined(POLARSSL_DHM_C) && defined(POLARSSL_BIGNUM_C)
+#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_BIGNUM_C)
if( todo.dhm )
{
int dhm_sizes[DHM_SIZES] = { 1024, 2048, 3072 };
const char *dhm_P[DHM_SIZES] = {
- POLARSSL_DHM_RFC5114_MODP_1024_P,
- POLARSSL_DHM_RFC3526_MODP_2048_P,
- POLARSSL_DHM_RFC3526_MODP_3072_P,
+ MBEDTLS_DHM_RFC5114_MODP_1024_P,
+ MBEDTLS_DHM_RFC3526_MODP_2048_P,
+ MBEDTLS_DHM_RFC3526_MODP_3072_P,
};
const char *dhm_G[DHM_SIZES] = {
- POLARSSL_DHM_RFC5114_MODP_1024_G,
- POLARSSL_DHM_RFC3526_MODP_2048_G,
- POLARSSL_DHM_RFC3526_MODP_3072_G,
+ MBEDTLS_DHM_RFC5114_MODP_1024_G,
+ MBEDTLS_DHM_RFC3526_MODP_2048_G,
+ MBEDTLS_DHM_RFC3526_MODP_3072_G,
};
- dhm_context dhm;
+ mbedtls_dhm_context dhm;
size_t olen;
for( i = 0; i < DHM_SIZES; i++ )
{
- dhm_init( &dhm );
+ mbedtls_dhm_init( &dhm );
- if( mpi_read_string( &dhm.P, 16, dhm_P[i] ) != 0 ||
- mpi_read_string( &dhm.G, 16, dhm_G[i] ) != 0 )
+ if( mbedtls_mpi_read_string( &dhm.P, 16, dhm_P[i] ) != 0 ||
+ mbedtls_mpi_read_string( &dhm.G, 16, dhm_G[i] ) != 0 )
{
- polarssl_exit( 1 );
+ mbedtls_exit( 1 );
}
- dhm.len = mpi_size( &dhm.P );
- dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len, myrand, NULL );
- if( mpi_copy( &dhm.GY, &dhm.GX ) != 0 )
- polarssl_exit( 1 );
+ dhm.len = mbedtls_mpi_size( &dhm.P );
+ mbedtls_dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len, myrand, NULL );
+ if( mbedtls_mpi_copy( &dhm.GY, &dhm.GX ) != 0 )
+ mbedtls_exit( 1 );
- polarssl_snprintf( title, sizeof( title ), "DHE-%d", dhm_sizes[i] );
+ mbedtls_snprintf( title, sizeof( title ), "DHE-%d", dhm_sizes[i] );
TIME_PUBLIC( title, "handshake",
olen = sizeof( buf );
- ret |= dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len,
+ ret |= mbedtls_dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len,
myrand, NULL );
- ret |= dhm_calc_secret( &dhm, buf, &olen, myrand, NULL ) );
+ ret |= mbedtls_dhm_calc_secret( &dhm, buf, &olen, myrand, NULL ) );
- polarssl_snprintf( title, sizeof( title ), "DH-%d", dhm_sizes[i] );
+ mbedtls_snprintf( title, sizeof( title ), "DH-%d", dhm_sizes[i] );
TIME_PUBLIC( title, "handshake",
olen = sizeof( buf );
- ret |= dhm_calc_secret( &dhm, buf, &olen, myrand, NULL ) );
+ ret |= mbedtls_dhm_calc_secret( &dhm, buf, &olen, myrand, NULL ) );
- dhm_free( &dhm );
+ mbedtls_dhm_free( &dhm );
}
}
#endif
-#if defined(POLARSSL_ECDSA_C) && defined(POLARSSL_SHA256_C)
+#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_SHA256_C)
if( todo.ecdsa )
{
- ecdsa_context ecdsa;
- const ecp_curve_info *curve_info;
+ mbedtls_ecdsa_context ecdsa;
+ const mbedtls_ecp_curve_info *curve_info;
size_t sig_len;
memset( buf, 0x2A, sizeof( buf ) );
- for( curve_info = ecp_curve_list();
- curve_info->grp_id != POLARSSL_ECP_DP_NONE;
+ for( curve_info = mbedtls_ecp_curve_list();
+ curve_info->grp_id != MBEDTLS_ECP_DP_NONE;
curve_info++ )
{
- ecdsa_init( &ecdsa );
+ mbedtls_ecdsa_init( &ecdsa );
- if( ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 )
- polarssl_exit( 1 );
+ if( mbedtls_ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 )
+ mbedtls_exit( 1 );
ecp_clear_precomputed( &ecdsa.grp );
- polarssl_snprintf( title, sizeof( title ), "ECDSA-%s",
+ mbedtls_snprintf( title, sizeof( title ), "ECDSA-%s",
curve_info->name );
TIME_PUBLIC( title, "sign",
- ret = ecdsa_write_signature( &ecdsa, POLARSSL_MD_SHA256, buf, curve_info->size,
+ ret = mbedtls_ecdsa_write_signature( &ecdsa, MBEDTLS_MD_SHA256, buf, curve_info->size,
tmp, &sig_len, myrand, NULL ) );
- ecdsa_free( &ecdsa );
+ mbedtls_ecdsa_free( &ecdsa );
}
- for( curve_info = ecp_curve_list();
- curve_info->grp_id != POLARSSL_ECP_DP_NONE;
+ for( curve_info = mbedtls_ecp_curve_list();
+ curve_info->grp_id != MBEDTLS_ECP_DP_NONE;
curve_info++ )
{
- ecdsa_init( &ecdsa );
+ mbedtls_ecdsa_init( &ecdsa );
- if( ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 ||
- ecdsa_write_signature( &ecdsa, POLARSSL_MD_SHA256, buf, curve_info->size,
+ if( mbedtls_ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 ||
+ mbedtls_ecdsa_write_signature( &ecdsa, MBEDTLS_MD_SHA256, buf, curve_info->size,
tmp, &sig_len, myrand, NULL ) != 0 )
{
- polarssl_exit( 1 );
+ mbedtls_exit( 1 );
}
ecp_clear_precomputed( &ecdsa.grp );
- polarssl_snprintf( title, sizeof( title ), "ECDSA-%s",
+ mbedtls_snprintf( title, sizeof( title ), "ECDSA-%s",
curve_info->name );
TIME_PUBLIC( title, "verify",
- ret = ecdsa_read_signature( &ecdsa, buf, curve_info->size,
+ ret = mbedtls_ecdsa_read_signature( &ecdsa, buf, curve_info->size,
tmp, sig_len ) );
- ecdsa_free( &ecdsa );
+ mbedtls_ecdsa_free( &ecdsa );
}
}
#endif
-#if defined(POLARSSL_ECDH_C)
+#if defined(MBEDTLS_ECDH_C)
if( todo.ecdh )
{
- ecdh_context ecdh;
-#if defined(POLARSSL_ECP_DP_M255_ENABLED)
- mpi z;
+ mbedtls_ecdh_context ecdh;
+#if defined(MBEDTLS_ECP_DP_M255_ENABLED)
+ mbedtls_mpi z;
#endif
- const ecp_curve_info *curve_info;
+ const mbedtls_ecp_curve_info *curve_info;
size_t olen;
- for( curve_info = ecp_curve_list();
- curve_info->grp_id != POLARSSL_ECP_DP_NONE;
+ for( curve_info = mbedtls_ecp_curve_list();
+ curve_info->grp_id != MBEDTLS_ECP_DP_NONE;
curve_info++ )
{
- ecdh_init( &ecdh );
+ mbedtls_ecdh_init( &ecdh );
- if( ecp_use_known_dp( &ecdh.grp, curve_info->grp_id ) != 0 ||
- ecdh_make_public( &ecdh, &olen, buf, sizeof( buf),
+ if( mbedtls_ecp_use_known_dp( &ecdh.grp, curve_info->grp_id ) != 0 ||
+ mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf),
myrand, NULL ) != 0 ||
- ecp_copy( &ecdh.Qp, &ecdh.Q ) != 0 )
+ mbedtls_ecp_copy( &ecdh.Qp, &ecdh.Q ) != 0 )
{
- polarssl_exit( 1 );
+ mbedtls_exit( 1 );
}
ecp_clear_precomputed( &ecdh.grp );
- polarssl_snprintf( title, sizeof( title ), "ECDHE-%s",
+ mbedtls_snprintf( title, sizeof( title ), "ECDHE-%s",
curve_info->name );
TIME_PUBLIC( title, "handshake",
- ret |= ecdh_make_public( &ecdh, &olen, buf, sizeof( buf),
+ ret |= mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf),
myrand, NULL );
- ret |= ecdh_calc_secret( &ecdh, &olen, buf, sizeof( buf ),
+ ret |= mbedtls_ecdh_calc_secret( &ecdh, &olen, buf, sizeof( buf ),
myrand, NULL ) );
- ecdh_free( &ecdh );
+ mbedtls_ecdh_free( &ecdh );
}
/* Curve25519 needs to be handled separately */
-#if defined(POLARSSL_ECP_DP_M255_ENABLED)
- ecdh_init( &ecdh );
- mpi_init( &z );
+#if defined(MBEDTLS_ECP_DP_M255_ENABLED)
+ mbedtls_ecdh_init( &ecdh );
+ mbedtls_mpi_init( &z );
- if( ecp_use_known_dp( &ecdh.grp, POLARSSL_ECP_DP_M255 ) != 0 ||
- ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, myrand, NULL ) != 0 )
+ if( mbedtls_ecp_use_known_dp( &ecdh.grp, MBEDTLS_ECP_DP_M255 ) != 0 ||
+ mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, myrand, NULL ) != 0 )
{
- polarssl_exit( 1 );
+ mbedtls_exit( 1 );
}
TIME_PUBLIC( "ECDHE-Curve25519", "handshake",
- ret |= ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q,
+ ret |= mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q,
myrand, NULL );
- ret |= ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d,
+ ret |= mbedtls_ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d,
myrand, NULL ) );
- ecdh_free( &ecdh );
- mpi_free( &z );
+ mbedtls_ecdh_free( &ecdh );
+ mbedtls_mpi_free( &z );
#endif
- for( curve_info = ecp_curve_list();
- curve_info->grp_id != POLARSSL_ECP_DP_NONE;
+ for( curve_info = mbedtls_ecp_curve_list();
+ curve_info->grp_id != MBEDTLS_ECP_DP_NONE;
curve_info++ )
{
- ecdh_init( &ecdh );
+ mbedtls_ecdh_init( &ecdh );
- if( ecp_use_known_dp( &ecdh.grp, curve_info->grp_id ) != 0 ||
- ecdh_make_public( &ecdh, &olen, buf, sizeof( buf),
+ if( mbedtls_ecp_use_known_dp( &ecdh.grp, curve_info->grp_id ) != 0 ||
+ mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf),
myrand, NULL ) != 0 ||
- ecp_copy( &ecdh.Qp, &ecdh.Q ) != 0 ||
- ecdh_make_public( &ecdh, &olen, buf, sizeof( buf),
+ mbedtls_ecp_copy( &ecdh.Qp, &ecdh.Q ) != 0 ||
+ mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf),
myrand, NULL ) != 0 )
{
- polarssl_exit( 1 );
+ mbedtls_exit( 1 );
}
ecp_clear_precomputed( &ecdh.grp );
- polarssl_snprintf( title, sizeof( title ), "ECDH-%s",
+ mbedtls_snprintf( title, sizeof( title ), "ECDH-%s",
curve_info->name );
TIME_PUBLIC( title, "handshake",
- ret |= ecdh_calc_secret( &ecdh, &olen, buf, sizeof( buf ),
+ ret |= mbedtls_ecdh_calc_secret( &ecdh, &olen, buf, sizeof( buf ),
myrand, NULL ) );
- ecdh_free( &ecdh );
+ mbedtls_ecdh_free( &ecdh );
}
/* Curve25519 needs to be handled separately */
-#if defined(POLARSSL_ECP_DP_M255_ENABLED)
- ecdh_init( &ecdh );
- mpi_init( &z );
+#if defined(MBEDTLS_ECP_DP_M255_ENABLED)
+ mbedtls_ecdh_init( &ecdh );
+ mbedtls_mpi_init( &z );
- if( ecp_use_known_dp( &ecdh.grp, POLARSSL_ECP_DP_M255 ) != 0 ||
- ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp,
+ if( mbedtls_ecp_use_known_dp( &ecdh.grp, MBEDTLS_ECP_DP_M255 ) != 0 ||
+ mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp,
myrand, NULL ) != 0 ||
- ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, myrand, NULL ) != 0 )
+ mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, myrand, NULL ) != 0 )
{
- polarssl_exit( 1 );
+ mbedtls_exit( 1 );
}
TIME_PUBLIC( "ECDH-Curve25519", "handshake",
- ret |= ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d,
+ ret |= mbedtls_ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d,
myrand, NULL ) );
- ecdh_free( &ecdh );
- mpi_free( &z );
+ mbedtls_ecdh_free( &ecdh );
+ mbedtls_mpi_free( &z );
#endif
}
#endif
- polarssl_printf( "\n" );
+ mbedtls_printf( "\n" );
-#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
- memory_buffer_alloc_free();
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
+ mbedtls_memory_buffer_alloc_free();
#endif
#if defined(_WIN32)
- polarssl_printf( " Press Enter to exit this program.\n" );
+ mbedtls_printf( " Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
return( 0 );
}
-#endif /* POLARSSL_TIMING_C */
+#endif /* MBEDTLS_TIMING_C */
diff --git a/programs/test/selftest.c b/programs/test/selftest.c
index d4ce1f7..902225e 100644
--- a/programs/test/selftest.c
+++ b/programs/test/selftest.c
@@ -20,10 +20,10 @@
* 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
#include "mbedtls/entropy.h"
@@ -55,21 +55,21 @@
#include <stdio.h>
#include <string.h>
-#if defined(POLARSSL_PLATFORM_C)
+#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdio.h>
-#define polarssl_printf printf
+#define mbedtls_printf printf
#endif
-#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
#include "mbedtls/memory_buffer_alloc.h"
#endif
int main( int argc, char *argv[] )
{
int ret = 0, v;
-#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
unsigned char buf[1000000];
#endif
@@ -78,166 +78,166 @@
else
{
v = 1;
- polarssl_printf( "\n" );
+ mbedtls_printf( "\n" );
}
-#if defined(POLARSSL_SELF_TEST)
+#if defined(MBEDTLS_SELF_TEST)
-#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
- memory_buffer_alloc_init( buf, sizeof(buf) );
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
+ mbedtls_memory_buffer_alloc_init( buf, sizeof(buf) );
#endif
-#if defined(POLARSSL_MD2_C)
- if( ( ret = md2_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_MD2_C)
+ if( ( ret = mbedtls_md2_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_MD4_C)
- if( ( ret = md4_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_MD4_C)
+ if( ( ret = mbedtls_md4_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_MD5_C)
- if( ( ret = md5_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_MD5_C)
+ if( ( ret = mbedtls_md5_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_RIPEMD160_C)
- if( ( ret = ripemd160_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_RIPEMD160_C)
+ if( ( ret = mbedtls_ripemd160_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_SHA1_C)
- if( ( ret = sha1_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_SHA1_C)
+ if( ( ret = mbedtls_sha1_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_SHA256_C)
- if( ( ret = sha256_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_SHA256_C)
+ if( ( ret = mbedtls_sha256_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_SHA512_C)
- if( ( ret = sha512_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_SHA512_C)
+ if( ( ret = mbedtls_sha512_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_ARC4_C)
- if( ( ret = arc4_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_ARC4_C)
+ if( ( ret = mbedtls_arc4_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_DES_C)
- if( ( ret = des_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_DES_C)
+ if( ( ret = mbedtls_des_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_AES_C)
- if( ( ret = aes_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_AES_C)
+ if( ( ret = mbedtls_aes_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_GCM_C) && defined(POLARSSL_AES_C)
- if( ( ret = gcm_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C)
+ if( ( ret = mbedtls_gcm_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_CCM_C) && defined(POLARSSL_AES_C)
- if( ( ret = ccm_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C)
+ if( ( ret = mbedtls_ccm_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_BASE64_C)
- if( ( ret = base64_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_BASE64_C)
+ if( ( ret = mbedtls_base64_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_BIGNUM_C)
- if( ( ret = mpi_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_BIGNUM_C)
+ if( ( ret = mbedtls_mpi_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_RSA_C)
- if( ( ret = rsa_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_RSA_C)
+ if( ( ret = mbedtls_rsa_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_X509_USE_C)
- if( ( ret = x509_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_X509_USE_C)
+ if( ( ret = mbedtls_x509_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_XTEA_C)
- if( ( ret = xtea_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_XTEA_C)
+ if( ( ret = mbedtls_xtea_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_CAMELLIA_C)
- if( ( ret = camellia_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_CAMELLIA_C)
+ if( ( ret = mbedtls_camellia_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_CTR_DRBG_C)
- if( ( ret = ctr_drbg_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_CTR_DRBG_C)
+ if( ( ret = mbedtls_ctr_drbg_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_HMAC_DRBG_C)
- if( ( ret = hmac_drbg_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_HMAC_DRBG_C)
+ if( ( ret = mbedtls_hmac_drbg_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_ECP_C)
- if( ( ret = ecp_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_ECP_C)
+ if( ( ret = mbedtls_ecp_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_DHM_C)
- if( ( ret = dhm_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_DHM_C)
+ if( ( ret = mbedtls_dhm_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_ENTROPY_C)
- if( ( ret = entropy_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_ENTROPY_C)
+ if( ( ret = mbedtls_entropy_self_test( v ) ) != 0 )
return( ret );
#endif
-#if defined(POLARSSL_PKCS5_C)
- if( ( ret = pkcs5_self_test( v ) ) != 0 )
+#if defined(MBEDTLS_PKCS5_C)
+ if( ( ret = mbedtls_pkcs5_self_test( v ) ) != 0 )
return( ret );
#endif
/* Slow tests last */
/* Not stable enough on Windows and FreeBSD yet */
-#if __linux__ && defined(POLARSSL_TIMING_C)
- if( ( ret = timing_self_test( v ) ) != 0 )
+#if __linux__ && defined(MBEDTLS_TIMING_C)
+ if( ( ret = mbedtls_timing_self_test( v ) ) != 0 )
return( ret );
#endif
#else
- polarssl_printf( " POLARSSL_SELF_TEST not defined.\n" );
+ mbedtls_printf( " MBEDTLS_SELF_TEST not defined.\n" );
#endif
if( v != 0 )
{
-#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && defined(POLARSSL_MEMORY_DEBUG)
- memory_buffer_alloc_status();
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG)
+ mbedtls_memory_buffer_alloc_status();
#endif
}
-#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
- memory_buffer_alloc_free();
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
+ mbedtls_memory_buffer_alloc_free();
- if( ( ret = memory_buffer_alloc_self_test( v ) ) != 0 )
+ if( ( ret = mbedtls_memory_buffer_alloc_self_test( v ) ) != 0 )
return( ret );
#endif
if( v != 0 )
{
- polarssl_printf( " [ All tests passed ]\n\n" );
+ mbedtls_printf( " [ All tests passed ]\n\n" );
#if defined(_WIN32)
- polarssl_printf( " Press Enter to exit this program.\n" );
+ mbedtls_printf( " Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
}
diff --git a/programs/test/ssl_cert_test.c b/programs/test/ssl_cert_test.c
index d9960d2..3c0c526 100644
--- a/programs/test/ssl_cert_test.c
+++ b/programs/test/ssl_cert_test.c
@@ -20,23 +20,23 @@
* 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_PLATFORM_C)
+#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdio.h>
-#define polarssl_snprintf snprintf
-#define polarssl_printf printf
-#define polarssl_snprintf snprintf
+#define mbedtls_snprintf snprintf
+#define mbedtls_printf printf
+#define mbedtls_snprintf snprintf
#endif
-#if defined(POLARSSL_RSA_C) && defined(POLARSSL_X509_CRT_PARSE_C) && \
- defined(POLARSSL_FS_IO) && defined(POLARSSL_X509_CRL_PARSE_C)
+#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_X509_CRT_PARSE_C) && \
+ defined(MBEDTLS_FS_IO) && defined(MBEDTLS_X509_CRL_PARSE_C)
#include "mbedtls/certs.h"
#include "mbedtls/x509_crt.h"
@@ -50,12 +50,12 @@
#define MAX_CLIENT_CERTS 8
-#if !defined(POLARSSL_RSA_C) || !defined(POLARSSL_X509_CRT_PARSE_C) || \
- !defined(POLARSSL_FS_IO) || !defined(POLARSSL_X509_CRL_PARSE_C)
+#if !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \
+ !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_X509_CRL_PARSE_C)
int main( void )
{
- polarssl_printf("POLARSSL_RSA_C and/or POLARSSL_X509_CRT_PARSE_C "
- "POLARSSL_FS_IO and/or POLARSSL_X509_CRL_PARSE_C "
+ mbedtls_printf("MBEDTLS_RSA_C and/or MBEDTLS_X509_CRT_PARSE_C "
+ "MBEDTLS_FS_IO and/or MBEDTLS_X509_CRL_PARSE_C "
"not defined.\n");
return( 0 );
}
@@ -87,52 +87,52 @@
int main( void )
{
int ret, i;
- x509_crt cacert;
- x509_crl crl;
+ mbedtls_x509_crt cacert;
+ mbedtls_x509_crl crl;
char buf[10240];
- x509_crt_init( &cacert );
- x509_crl_init( &crl );
+ mbedtls_x509_crt_init( &cacert );
+ mbedtls_x509_crl_init( &crl );
/*
* 1.1. Load the trusted CA
*/
- polarssl_printf( "\n . Loading the CA root certificate ..." );
+ mbedtls_printf( "\n . Loading the CA root certificate ..." );
fflush( stdout );
/*
* Alternatively, you may load the CA certificates from a .pem or
- * .crt file by calling x509_crt_parse_file( &cacert, "myca.crt" ).
+ * .crt file by calling mbedtls_x509_crt_parse_file( &cacert, "myca.crt" ).
*/
- ret = x509_crt_parse_file( &cacert, "ssl/test-ca/test-ca.crt" );
+ ret = mbedtls_x509_crt_parse_file( &cacert, "ssl/test-ca/test-ca.crt" );
if( ret != 0 )
{
- polarssl_printf( " failed\n ! x509_crt_parse_file returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned %d\n\n", ret );
goto exit;
}
- polarssl_printf( " ok\n" );
+ mbedtls_printf( " ok\n" );
- x509_crt_info( buf, 1024, "CRT: ", &cacert );
- polarssl_printf("%s\n", buf );
+ mbedtls_x509_crt_info( buf, 1024, "CRT: ", &cacert );
+ mbedtls_printf("%s\n", buf );
/*
* 1.2. Load the CRL
*/
- polarssl_printf( " . Loading the CRL ..." );
+ mbedtls_printf( " . Loading the CRL ..." );
fflush( stdout );
- ret = x509_crl_parse_file( &crl, "ssl/test-ca/crl.pem" );
+ ret = mbedtls_x509_crl_parse_file( &crl, "ssl/test-ca/crl.pem" );
if( ret != 0 )
{
- polarssl_printf( " failed\n ! x509_crl_parse_file returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_x509_crl_parse_file returned %d\n\n", ret );
goto exit;
}
- polarssl_printf( " ok\n" );
+ mbedtls_printf( " ok\n" );
- x509_crl_info( buf, 1024, "CRL: ", &crl );
- polarssl_printf("%s\n", buf );
+ mbedtls_x509_crl_info( buf, 1024, "CRL: ", &crl );
+ mbedtls_printf("%s\n", buf );
for( i = 0; i < MAX_CLIENT_CERTS; i++ )
{
@@ -141,127 +141,127 @@
*/
char name[512];
int flags;
- x509_crt clicert;
- pk_context pk;
+ mbedtls_x509_crt clicert;
+ mbedtls_pk_context pk;
- x509_crt_init( &clicert );
- pk_init( &pk );
+ mbedtls_x509_crt_init( &clicert );
+ mbedtls_pk_init( &pk );
- polarssl_snprintf(name, 512, "ssl/test-ca/%s", client_certificates[i]);
+ mbedtls_snprintf(name, 512, "ssl/test-ca/%s", client_certificates[i]);
- polarssl_printf( " . Loading the client certificate %s...", name );
+ mbedtls_printf( " . Loading the client certificate %s...", name );
fflush( stdout );
- ret = x509_crt_parse_file( &clicert, name );
+ ret = mbedtls_x509_crt_parse_file( &clicert, name );
if( ret != 0 )
{
- polarssl_printf( " failed\n ! x509_crt_parse_file returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned %d\n\n", ret );
goto exit;
}
- polarssl_printf( " ok\n" );
+ mbedtls_printf( " ok\n" );
/*
* 1.4. Verify certificate validity with CA certificate
*/
- polarssl_printf( " . Verify the client certificate with CA certificate..." );
+ mbedtls_printf( " . Verify the client certificate with CA certificate..." );
fflush( stdout );
- ret = x509_crt_verify( &clicert, &cacert, &crl, NULL, &flags, NULL,
+ ret = mbedtls_x509_crt_verify( &clicert, &cacert, &crl, NULL, &flags, NULL,
NULL );
if( ret != 0 )
{
- if( ret == POLARSSL_ERR_X509_CERT_VERIFY_FAILED )
+ if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED )
{
- if( flags & BADCERT_CN_MISMATCH )
- polarssl_printf( " CN_MISMATCH " );
- if( flags & BADCERT_EXPIRED )
- polarssl_printf( " EXPIRED " );
- if( flags & BADCERT_REVOKED )
- polarssl_printf( " REVOKED " );
- if( flags & BADCERT_NOT_TRUSTED )
- polarssl_printf( " NOT_TRUSTED " );
- if( flags & BADCRL_NOT_TRUSTED )
- polarssl_printf( " CRL_NOT_TRUSTED " );
- if( flags & BADCRL_EXPIRED )
- polarssl_printf( " CRL_EXPIRED " );
+ if( flags & MBEDTLS_X509_BADCERT_CN_MISMATCH )
+ mbedtls_printf( " CN_MISMATCH " );
+ if( flags & MBEDTLS_BADCERT_EXPIRED )
+ mbedtls_printf( " EXPIRED " );
+ if( flags & MBEDTLS_X509_BADCERT_REVOKED )
+ mbedtls_printf( " REVOKED " );
+ if( flags & MBEDTLS_X509_BADCERT_NOT_TRUSTED )
+ mbedtls_printf( " NOT_TRUSTED " );
+ if( flags & MBEDTLS_X509_BADCRL_NOT_TRUSTED )
+ mbedtls_printf( " CRL_NOT_TRUSTED " );
+ if( flags & MBEDTLS_X509_BADCRL_EXPIRED )
+ mbedtls_printf( " CRL_EXPIRED " );
} else {
- polarssl_printf( " failed\n ! x509_crt_verify returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_x509_crt_verify returned %d\n\n", ret );
goto exit;
}
}
- polarssl_printf( " ok\n" );
+ mbedtls_printf( " ok\n" );
/*
* 1.5. Load own private key
*/
- polarssl_snprintf(name, 512, "ssl/test-ca/%s", client_private_keys[i]);
+ mbedtls_snprintf(name, 512, "ssl/test-ca/%s", client_private_keys[i]);
- polarssl_printf( " . Loading the client private key %s...", name );
+ mbedtls_printf( " . Loading the client private key %s...", name );
fflush( stdout );
- ret = pk_parse_keyfile( &pk, name, NULL );
+ ret = mbedtls_pk_parse_keyfile( &pk, name, NULL );
if( ret != 0 )
{
- polarssl_printf( " failed\n ! pk_parse_keyfile returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned %d\n\n", ret );
goto exit;
}
- polarssl_printf( " ok\n" );
+ mbedtls_printf( " ok\n" );
/*
* 1.6. Verify certificate validity with private key
*/
- polarssl_printf( " . Verify the client certificate with private key..." );
+ mbedtls_printf( " . Verify the client certificate with private key..." );
fflush( stdout );
/* EC NOT IMPLEMENTED YET */
- if( ! pk_can_do( &clicert.pk, POLARSSL_PK_RSA ) )
+ if( ! mbedtls_pk_can_do( &clicert.pk, MBEDTLS_PK_RSA ) )
{
- polarssl_printf( " failed\n ! certificate's key is not RSA\n\n" );
- ret = POLARSSL_ERR_X509_FEATURE_UNAVAILABLE;
+ mbedtls_printf( " failed\n ! certificate's key is not RSA\n\n" );
+ ret = MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE;
goto exit;
}
- ret = mpi_cmp_mpi(&pk_rsa( pk )->N, &pk_rsa( clicert.pk )->N);
+ ret = mbedtls_mpi_cmp_mpi(&mbedtls_pk_rsa( pk )->N, &mbedtls_pk_rsa( clicert.pk )->N);
if( ret != 0 )
{
- polarssl_printf( " failed\n ! mpi_cmp_mpi for N returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_mpi_cmp_mpi for N returned %d\n\n", ret );
goto exit;
}
- ret = mpi_cmp_mpi(&pk_rsa( pk )->E, &pk_rsa( clicert.pk )->E);
+ ret = mbedtls_mpi_cmp_mpi(&mbedtls_pk_rsa( pk )->E, &mbedtls_pk_rsa( clicert.pk )->E);
if( ret != 0 )
{
- polarssl_printf( " failed\n ! mpi_cmp_mpi for E returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_mpi_cmp_mpi for E returned %d\n\n", ret );
goto exit;
}
- ret = rsa_check_privkey( pk_rsa( pk ) );
+ ret = mbedtls_rsa_check_privkey( mbedtls_pk_rsa( pk ) );
if( ret != 0 )
{
- polarssl_printf( " failed\n ! rsa_check_privkey returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_rsa_check_privkey returned %d\n\n", ret );
goto exit;
}
- polarssl_printf( " ok\n" );
+ mbedtls_printf( " ok\n" );
- x509_crt_free( &clicert );
- pk_free( &pk );
+ mbedtls_x509_crt_free( &clicert );
+ mbedtls_pk_free( &pk );
}
exit:
- x509_crt_free( &cacert );
- x509_crl_free( &crl );
+ mbedtls_x509_crt_free( &cacert );
+ mbedtls_x509_crl_free( &crl );
#if defined(_WIN32)
- polarssl_printf( " + Press Enter to exit this program.\n" );
+ mbedtls_printf( " + Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
return( ret );
}
-#endif /* POLARSSL_RSA_C && POLARSSL_X509_CRT_PARSE_C && POLARSSL_FS_IO &&
- POLARSSL_X509_CRL_PARSE_C */
+#endif /* MBEDTLS_RSA_C && MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_FS_IO &&
+ MBEDTLS_X509_CRL_PARSE_C */
diff --git a/programs/test/udp_proxy.c b/programs/test/udp_proxy.c
index f5faa29..28b5eaa 100644
--- a/programs/test/udp_proxy.c
+++ b/programs/test/udp_proxy.c
@@ -20,23 +20,23 @@
* 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_PLATFORM_C)
+#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
-#define polarssl_printf printf
+#define mbedtls_printf printf
#endif
-#if !defined(POLARSSL_NET_C)
+#if !defined(MBEDTLS_NET_C)
#include <stdio.h>
int main( void )
{
- polarssl_printf( "POLARSSL_NET_C not defined.\n" );
+ mbedtls_printf( "MBEDTLS_NET_C not defined.\n" );
return( 0 );
}
#else
@@ -129,11 +129,11 @@
static void exit_usage( const char *name, const char *value )
{
if( value == NULL )
- polarssl_printf( " unknown option or missing value: %s\n", name );
+ mbedtls_printf( " unknown option or missing value: %s\n", name );
else
- polarssl_printf( " option %s: illegal value: %s\n", name, value );
+ mbedtls_printf( " option %s: illegal value: %s\n", name, value );
- polarssl_printf( USAGE );
+ mbedtls_printf( USAGE );
exit( 1 );
}
@@ -235,10 +235,10 @@
if( len < 1 ) return( "Invalid" );
switch( msg[0] )
{
- case SSL_MSG_CHANGE_CIPHER_SPEC: return( "ChangeCipherSpec" );
- case SSL_MSG_ALERT: return( "Alert" );
- case SSL_MSG_APPLICATION_DATA: return( "ApplicationData" );
- case SSL_MSG_HANDSHAKE: break; /* See below */
+ case MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC: return( "ChangeCipherSpec" );
+ case MBEDTLS_SSL_MSG_ALERT: return( "Alert" );
+ case MBEDTLS_SSL_MSG_APPLICATION_DATA: return( "ApplicationData" );
+ case MBEDTLS_SSL_MSG_HANDSHAKE: break; /* See below */
default: return( "Unknown" );
}
@@ -253,18 +253,18 @@
switch( msg[13] )
{
- case SSL_HS_HELLO_REQUEST: return( "HelloRequest" );
- case SSL_HS_CLIENT_HELLO: return( "ClientHello" );
- case SSL_HS_SERVER_HELLO: return( "ServerHello" );
- case SSL_HS_HELLO_VERIFY_REQUEST: return( "HelloVerifyRequest" );
- case SSL_HS_NEW_SESSION_TICKET: return( "NewSessionTicket" );
- case SSL_HS_CERTIFICATE: return( "Certificate" );
- case SSL_HS_SERVER_KEY_EXCHANGE: return( "ServerKeyExchange" );
- case SSL_HS_CERTIFICATE_REQUEST: return( "CertificateRequest" );
- case SSL_HS_SERVER_HELLO_DONE: return( "ServerHelloDone" );
- case SSL_HS_CERTIFICATE_VERIFY: return( "CertificateVerify" );
- case SSL_HS_CLIENT_KEY_EXCHANGE: return( "ClientKeyExchange" );
- case SSL_HS_FINISHED: return( "Finished" );
+ case MBEDTLS_SSL_HS_HELLO_REQUEST: return( "HelloRequest" );
+ case MBEDTLS_SSL_HS_CLIENT_HELLO: return( "ClientHello" );
+ case MBEDTLS_SSL_HS_SERVER_HELLO: return( "ServerHello" );
+ case MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST: return( "HelloVerifyRequest" );
+ case MBEDTLS_SSL_HS_NEW_SESSION_TICKET: return( "NewSessionTicket" );
+ case MBEDTLS_SSL_HS_CERTIFICATE: return( "Certificate" );
+ case MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE: return( "ServerKeyExchange" );
+ case MBEDTLS_SSL_HS_CERTIFICATE_REQUEST: return( "CertificateRequest" );
+ case MBEDTLS_SSL_HS_SERVER_HELLO_DONE: return( "ServerHelloDone" );
+ case MBEDTLS_SSL_HS_CERTIFICATE_VERIFY: return( "CertificateVerify" );
+ case MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE: return( "ClientKeyExchange" );
+ case MBEDTLS_SSL_HS_FINISHED: return( "Finished" );
default: return( "Unknown handshake" );
}
}
@@ -303,10 +303,10 @@
void print_packet( const packet *p, const char *why )
{
if( why == NULL )
- polarssl_printf( " %05lu %s %s (%u bytes)\n",
+ mbedtls_printf( " %05lu %s %s (%u bytes)\n",
ellapsed_time(), p->way, p->type, p->len );
else
- polarssl_printf( " %s %s (%u bytes): %s\n",
+ mbedtls_printf( " %s %s (%u bytes): %s\n",
p->way, p->type, p->len, why );
fflush( stdout );
}
@@ -325,17 +325,17 @@
++buf[p->len - 1];
print_packet( p, "corrupted" );
- if( ( ret = net_send( &dst, buf, p->len ) ) <= 0 )
+ if( ( ret = mbedtls_net_send( &dst, buf, p->len ) ) <= 0 )
{
- polarssl_printf( " ! net_send returned %d\n", ret );
+ mbedtls_printf( " ! mbedtls_net_send returned %d\n", ret );
return( ret );
}
}
print_packet( p, why );
- if( ( ret = net_send( &dst, p->buf, p->len ) ) <= 0 )
+ if( ( ret = mbedtls_net_send( &dst, p->buf, p->len ) ) <= 0 )
{
- polarssl_printf( " ! net_send returned %d\n", ret );
+ mbedtls_printf( " ! mbedtls_net_send returned %d\n", ret );
return( ret );
}
@@ -346,9 +346,9 @@
{
print_packet( p, "duplicated" );
- if( ( ret = net_send( &dst, p->buf, p->len ) ) <= 0 )
+ if( ( ret = mbedtls_net_send( &dst, p->buf, p->len ) ) <= 0 )
{
- polarssl_printf( " ! net_send returned %d\n", ret );
+ mbedtls_printf( " ! mbedtls_net_send returned %d\n", ret );
return( ret );
}
}
@@ -407,9 +407,9 @@
size_t id;
/* receive packet */
- if( ( ret = net_recv( &src, cur.buf, sizeof( cur.buf ) ) ) <= 0 )
+ if( ( ret = mbedtls_net_recv( &src, cur.buf, sizeof( cur.buf ) ) ) <= 0 )
{
- polarssl_printf( " ! net_recv returned %d\n", ret );
+ mbedtls_printf( " ! mbedtls_net_recv returned %d\n", ret );
return( ret );
}
@@ -490,7 +490,7 @@
if( opt.seed == 0 )
{
opt.seed = time( NULL );
- polarssl_printf( " . Pseudo-random seed: %u\n", opt.seed );
+ mbedtls_printf( " . Pseudo-random seed: %u\n", opt.seed );
}
srand( opt.seed );
@@ -498,63 +498,63 @@
/*
* 0. "Connect" to the server
*/
- polarssl_printf( " . Connect to server on UDP/%s/%d ...",
+ mbedtls_printf( " . Connect to server on UDP/%s/%d ...",
opt.server_addr, opt.server_port );
fflush( stdout );
- if( ( ret = net_connect( &server_fd, opt.server_addr, opt.server_port,
- NET_PROTO_UDP ) ) != 0 )
+ if( ( ret = mbedtls_net_connect( &server_fd, opt.server_addr, opt.server_port,
+ MBEDTLS_NET_PROTO_UDP ) ) != 0 )
{
- polarssl_printf( " failed\n ! net_connect returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_net_connect returned %d\n\n", ret );
goto exit;
}
- polarssl_printf( " ok\n" );
+ mbedtls_printf( " ok\n" );
/*
* 1. Setup the "listening" UDP socket
*/
- polarssl_printf( " . Bind on UDP/%s/%d ...",
+ mbedtls_printf( " . Bind on UDP/%s/%d ...",
opt.listen_addr, opt.listen_port );
fflush( stdout );
- if( ( ret = net_bind( &listen_fd, opt.listen_addr, opt.listen_port,
- NET_PROTO_UDP ) ) != 0 )
+ if( ( ret = mbedtls_net_bind( &listen_fd, opt.listen_addr, opt.listen_port,
+ MBEDTLS_NET_PROTO_UDP ) ) != 0 )
{
- polarssl_printf( " failed\n ! net_bind returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_net_bind returned %d\n\n", ret );
goto exit;
}
- polarssl_printf( " ok\n" );
+ mbedtls_printf( " ok\n" );
/*
* 2. Wait until a client connects
*/
accept:
- polarssl_printf( " . Waiting for a remote connection ..." );
+ mbedtls_printf( " . Waiting for a remote connection ..." );
fflush( stdout );
- if( ( ret = net_accept( listen_fd, &client_fd, NULL ) ) != 0 )
+ if( ( ret = mbedtls_net_accept( listen_fd, &client_fd, NULL ) ) != 0 )
{
- polarssl_printf( " failed\n ! net_accept returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_net_accept returned %d\n\n", ret );
goto exit;
}
- polarssl_printf( " ok\n" );
+ mbedtls_printf( " ok\n" );
fflush( stdout );
- polarssl_printf( " . Re-bind on UDP/%s/%d ...",
+ mbedtls_printf( " . Re-bind on UDP/%s/%d ...",
opt.listen_addr, opt.listen_port );
fflush( stdout );
- if( ( ret = net_bind( &listen_fd, opt.listen_addr, opt.listen_port,
- NET_PROTO_UDP ) ) != 0 )
+ if( ( ret = mbedtls_net_bind( &listen_fd, opt.listen_addr, opt.listen_port,
+ MBEDTLS_NET_PROTO_UDP ) ) != 0 )
{
- polarssl_printf( " failed\n ! net_bind returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_net_bind returned %d\n\n", ret );
goto exit;
}
- polarssl_printf( " ok\n" );
+ mbedtls_printf( " ok\n" );
/*
* 3. Forward packets forever (kill the process to terminate it)
@@ -602,28 +602,28 @@
exit:
-#ifdef POLARSSL_ERROR_C
+#ifdef MBEDTLS_ERROR_C
if( ret != 0 )
{
char error_buf[100];
- polarssl_strerror( ret, error_buf, 100 );
- polarssl_printf( "Last error was: -0x%04X - %s\n\n", - ret, error_buf );
+ mbedtls_strerror( ret, error_buf, 100 );
+ mbedtls_printf( "Last error was: -0x%04X - %s\n\n", - ret, error_buf );
fflush( stdout );
}
#endif
if( client_fd != -1 )
- net_close( client_fd );
+ mbedtls_net_close( client_fd );
if( listen_fd != -1 )
- net_close( listen_fd );
+ mbedtls_net_close( listen_fd );
#if defined(_WIN32)
- polarssl_printf( " Press Enter to exit this program.\n" );
+ mbedtls_printf( " Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif
return( ret != 0 );
}
-#endif /* POLARSSL_NET_C */
+#endif /* MBEDTLS_NET_C */