The Great Renaming

A simple execution of tmp/invoke-rename.pl
diff --git a/library/cipher_wrap.c b/library/cipher_wrap.c
index 4478cc8..ebc3c4f 100644
--- a/library/cipher_wrap.c
+++ b/library/cipher_wrap.c
@@ -24,164 +24,164 @@
  *  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_CIPHER_C)
+#if defined(MBEDTLS_CIPHER_C)
 
 #include "mbedtls/cipher_wrap.h"
 
-#if defined(POLARSSL_AES_C)
+#if defined(MBEDTLS_AES_C)
 #include "mbedtls/aes.h"
 #endif
 
-#if defined(POLARSSL_ARC4_C)
+#if defined(MBEDTLS_ARC4_C)
 #include "mbedtls/arc4.h"
 #endif
 
-#if defined(POLARSSL_CAMELLIA_C)
+#if defined(MBEDTLS_CAMELLIA_C)
 #include "mbedtls/camellia.h"
 #endif
 
-#if defined(POLARSSL_DES_C)
+#if defined(MBEDTLS_DES_C)
 #include "mbedtls/des.h"
 #endif
 
-#if defined(POLARSSL_BLOWFISH_C)
+#if defined(MBEDTLS_BLOWFISH_C)
 #include "mbedtls/blowfish.h"
 #endif
 
-#if defined(POLARSSL_GCM_C)
+#if defined(MBEDTLS_GCM_C)
 #include "mbedtls/gcm.h"
 #endif
 
-#if defined(POLARSSL_CCM_C)
+#if defined(MBEDTLS_CCM_C)
 #include "mbedtls/ccm.h"
 #endif
 
-#if defined(POLARSSL_CIPHER_NULL_CIPHER)
+#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
 #include <string.h>
 #endif
 
-#if defined(POLARSSL_PLATFORM_C)
+#if defined(MBEDTLS_PLATFORM_C)
 #include "mbedtls/platform.h"
 #else
 #include <stdlib.h>
-#define polarssl_malloc     malloc
-#define polarssl_free       free
+#define mbedtls_malloc     malloc
+#define mbedtls_free       free
 #endif
 
-#if defined(POLARSSL_GCM_C)
+#if defined(MBEDTLS_GCM_C)
 /* shared by all GCM ciphers */
 static void *gcm_ctx_alloc( void )
 {
-    return polarssl_malloc( sizeof( gcm_context ) );
+    return mbedtls_malloc( sizeof( mbedtls_gcm_context ) );
 }
 
 static void gcm_ctx_free( void *ctx )
 {
-    gcm_free( ctx );
-    polarssl_free( ctx );
+    mbedtls_gcm_free( ctx );
+    mbedtls_free( ctx );
 }
-#endif /* POLARSSL_GCM_C */
+#endif /* MBEDTLS_GCM_C */
 
-#if defined(POLARSSL_CCM_C)
+#if defined(MBEDTLS_CCM_C)
 /* shared by all CCM ciphers */
 static void *ccm_ctx_alloc( void )
 {
-    return polarssl_malloc( sizeof( ccm_context ) );
+    return mbedtls_malloc( sizeof( mbedtls_ccm_context ) );
 }
 
 static void ccm_ctx_free( void *ctx )
 {
-    ccm_free( ctx );
-    polarssl_free( ctx );
+    mbedtls_ccm_free( ctx );
+    mbedtls_free( ctx );
 }
-#endif /* POLARSSL_CCM_C */
+#endif /* MBEDTLS_CCM_C */
 
-#if defined(POLARSSL_AES_C)
+#if defined(MBEDTLS_AES_C)
 
-static int aes_crypt_ecb_wrap( void *ctx, operation_t operation,
+static int aes_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
         const unsigned char *input, unsigned char *output )
 {
-    return aes_crypt_ecb( (aes_context *) ctx, operation, input, output );
+    return mbedtls_aes_crypt_ecb( (mbedtls_aes_context *) ctx, operation, input, output );
 }
 
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-static int aes_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+static int aes_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
         unsigned char *iv, const unsigned char *input, unsigned char *output )
 {
-    return aes_crypt_cbc( (aes_context *) ctx, operation, length, iv, input,
+    return mbedtls_aes_crypt_cbc( (mbedtls_aes_context *) ctx, operation, length, iv, input,
                           output );
 }
-#endif /* POLARSSL_CIPHER_MODE_CBC */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
 
-#if defined(POLARSSL_CIPHER_MODE_CFB)
-static int aes_crypt_cfb128_wrap( void *ctx, operation_t operation,
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
+static int aes_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation,
         size_t length, size_t *iv_off, unsigned char *iv,
         const unsigned char *input, unsigned char *output )
 {
-    return aes_crypt_cfb128( (aes_context *) ctx, operation, length, iv_off, iv,
+    return mbedtls_aes_crypt_cfb128( (mbedtls_aes_context *) ctx, operation, length, iv_off, iv,
                              input, output );
 }
-#endif /* POLARSSL_CIPHER_MODE_CFB */
+#endif /* MBEDTLS_CIPHER_MODE_CFB */
 
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
 static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
         unsigned char *nonce_counter, unsigned char *stream_block,
         const unsigned char *input, unsigned char *output )
 {
-    return aes_crypt_ctr( (aes_context *) ctx, length, nc_off, nonce_counter,
+    return mbedtls_aes_crypt_ctr( (mbedtls_aes_context *) ctx, length, nc_off, nonce_counter,
                           stream_block, input, output );
 }
-#endif /* POLARSSL_CIPHER_MODE_CTR */
+#endif /* MBEDTLS_CIPHER_MODE_CTR */
 
 static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key,
                                 unsigned int key_length )
 {
-    return aes_setkey_dec( (aes_context *) ctx, key, key_length );
+    return mbedtls_aes_setkey_dec( (mbedtls_aes_context *) ctx, key, key_length );
 }
 
 static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key,
                                 unsigned int key_length )
 {
-    return aes_setkey_enc( (aes_context *) ctx, key, key_length );
+    return mbedtls_aes_setkey_enc( (mbedtls_aes_context *) ctx, key, key_length );
 }
 
 static void * aes_ctx_alloc( void )
 {
-    aes_context *aes = polarssl_malloc( sizeof( aes_context ) );
+    mbedtls_aes_context *aes = mbedtls_malloc( sizeof( mbedtls_aes_context ) );
 
     if( aes == NULL )
         return( NULL );
 
-    aes_init( aes );
+    mbedtls_aes_init( aes );
 
     return( aes );
 }
 
 static void aes_ctx_free( void *ctx )
 {
-    aes_free( (aes_context *) ctx );
-    polarssl_free( ctx );
+    mbedtls_aes_free( (mbedtls_aes_context *) ctx );
+    mbedtls_free( ctx );
 }
 
-static const cipher_base_t aes_info = {
-    POLARSSL_CIPHER_ID_AES,
+static const mbedtls_cipher_base_t aes_info = {
+    MBEDTLS_CIPHER_ID_AES,
     aes_crypt_ecb_wrap,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     aes_crypt_cbc_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     aes_crypt_cfb128_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     aes_crypt_ctr_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     NULL,
 #endif
     aes_setkey_enc_wrap,
@@ -190,9 +190,9 @@
     aes_ctx_free
 };
 
-static const cipher_info_t aes_128_ecb_info = {
-    POLARSSL_CIPHER_AES_128_ECB,
-    POLARSSL_MODE_ECB,
+static const mbedtls_cipher_info_t aes_128_ecb_info = {
+    MBEDTLS_CIPHER_AES_128_ECB,
+    MBEDTLS_MODE_ECB,
     128,
     "AES-128-ECB",
     16,
@@ -201,9 +201,9 @@
     &aes_info
 };
 
-static const cipher_info_t aes_192_ecb_info = {
-    POLARSSL_CIPHER_AES_192_ECB,
-    POLARSSL_MODE_ECB,
+static const mbedtls_cipher_info_t aes_192_ecb_info = {
+    MBEDTLS_CIPHER_AES_192_ECB,
+    MBEDTLS_MODE_ECB,
     192,
     "AES-192-ECB",
     16,
@@ -212,9 +212,9 @@
     &aes_info
 };
 
-static const cipher_info_t aes_256_ecb_info = {
-    POLARSSL_CIPHER_AES_256_ECB,
-    POLARSSL_MODE_ECB,
+static const mbedtls_cipher_info_t aes_256_ecb_info = {
+    MBEDTLS_CIPHER_AES_256_ECB,
+    MBEDTLS_MODE_ECB,
     256,
     "AES-256-ECB",
     16,
@@ -223,10 +223,10 @@
     &aes_info
 };
 
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-static const cipher_info_t aes_128_cbc_info = {
-    POLARSSL_CIPHER_AES_128_CBC,
-    POLARSSL_MODE_CBC,
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+static const mbedtls_cipher_info_t aes_128_cbc_info = {
+    MBEDTLS_CIPHER_AES_128_CBC,
+    MBEDTLS_MODE_CBC,
     128,
     "AES-128-CBC",
     16,
@@ -235,9 +235,9 @@
     &aes_info
 };
 
-static const cipher_info_t aes_192_cbc_info = {
-    POLARSSL_CIPHER_AES_192_CBC,
-    POLARSSL_MODE_CBC,
+static const mbedtls_cipher_info_t aes_192_cbc_info = {
+    MBEDTLS_CIPHER_AES_192_CBC,
+    MBEDTLS_MODE_CBC,
     192,
     "AES-192-CBC",
     16,
@@ -246,9 +246,9 @@
     &aes_info
 };
 
-static const cipher_info_t aes_256_cbc_info = {
-    POLARSSL_CIPHER_AES_256_CBC,
-    POLARSSL_MODE_CBC,
+static const mbedtls_cipher_info_t aes_256_cbc_info = {
+    MBEDTLS_CIPHER_AES_256_CBC,
+    MBEDTLS_MODE_CBC,
     256,
     "AES-256-CBC",
     16,
@@ -256,12 +256,12 @@
     16,
     &aes_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CBC */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
 
-#if defined(POLARSSL_CIPHER_MODE_CFB)
-static const cipher_info_t aes_128_cfb128_info = {
-    POLARSSL_CIPHER_AES_128_CFB128,
-    POLARSSL_MODE_CFB,
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
+static const mbedtls_cipher_info_t aes_128_cfb128_info = {
+    MBEDTLS_CIPHER_AES_128_CFB128,
+    MBEDTLS_MODE_CFB,
     128,
     "AES-128-CFB128",
     16,
@@ -270,9 +270,9 @@
     &aes_info
 };
 
-static const cipher_info_t aes_192_cfb128_info = {
-    POLARSSL_CIPHER_AES_192_CFB128,
-    POLARSSL_MODE_CFB,
+static const mbedtls_cipher_info_t aes_192_cfb128_info = {
+    MBEDTLS_CIPHER_AES_192_CFB128,
+    MBEDTLS_MODE_CFB,
     192,
     "AES-192-CFB128",
     16,
@@ -281,9 +281,9 @@
     &aes_info
 };
 
-static const cipher_info_t aes_256_cfb128_info = {
-    POLARSSL_CIPHER_AES_256_CFB128,
-    POLARSSL_MODE_CFB,
+static const mbedtls_cipher_info_t aes_256_cfb128_info = {
+    MBEDTLS_CIPHER_AES_256_CFB128,
+    MBEDTLS_MODE_CFB,
     256,
     "AES-256-CFB128",
     16,
@@ -291,12 +291,12 @@
     16,
     &aes_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CFB */
+#endif /* MBEDTLS_CIPHER_MODE_CFB */
 
-#if defined(POLARSSL_CIPHER_MODE_CTR)
-static const cipher_info_t aes_128_ctr_info = {
-    POLARSSL_CIPHER_AES_128_CTR,
-    POLARSSL_MODE_CTR,
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
+static const mbedtls_cipher_info_t aes_128_ctr_info = {
+    MBEDTLS_CIPHER_AES_128_CTR,
+    MBEDTLS_MODE_CTR,
     128,
     "AES-128-CTR",
     16,
@@ -305,9 +305,9 @@
     &aes_info
 };
 
-static const cipher_info_t aes_192_ctr_info = {
-    POLARSSL_CIPHER_AES_192_CTR,
-    POLARSSL_MODE_CTR,
+static const mbedtls_cipher_info_t aes_192_ctr_info = {
+    MBEDTLS_CIPHER_AES_192_CTR,
+    MBEDTLS_MODE_CTR,
     192,
     "AES-192-CTR",
     16,
@@ -316,9 +316,9 @@
     &aes_info
 };
 
-static const cipher_info_t aes_256_ctr_info = {
-    POLARSSL_CIPHER_AES_256_CTR,
-    POLARSSL_MODE_CTR,
+static const mbedtls_cipher_info_t aes_256_ctr_info = {
+    MBEDTLS_CIPHER_AES_256_CTR,
+    MBEDTLS_MODE_CTR,
     256,
     "AES-256-CTR",
     16,
@@ -326,29 +326,29 @@
     16,
     &aes_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CTR */
+#endif /* MBEDTLS_CIPHER_MODE_CTR */
 
-#if defined(POLARSSL_GCM_C)
+#if defined(MBEDTLS_GCM_C)
 static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key,
                                 unsigned int key_length )
 {
-    return gcm_init( (gcm_context *) ctx, POLARSSL_CIPHER_ID_AES,
+    return mbedtls_gcm_init( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_AES,
                      key, key_length );
 }
 
-static const cipher_base_t gcm_aes_info = {
-    POLARSSL_CIPHER_ID_AES,
+static const mbedtls_cipher_base_t gcm_aes_info = {
+    MBEDTLS_CIPHER_ID_AES,
     NULL,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     NULL,
 #endif
     gcm_aes_setkey_wrap,
@@ -357,61 +357,61 @@
     gcm_ctx_free,
 };
 
-static const cipher_info_t aes_128_gcm_info = {
-    POLARSSL_CIPHER_AES_128_GCM,
-    POLARSSL_MODE_GCM,
+static const mbedtls_cipher_info_t aes_128_gcm_info = {
+    MBEDTLS_CIPHER_AES_128_GCM,
+    MBEDTLS_MODE_GCM,
     128,
     "AES-128-GCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &gcm_aes_info
 };
 
-static const cipher_info_t aes_192_gcm_info = {
-    POLARSSL_CIPHER_AES_192_GCM,
-    POLARSSL_MODE_GCM,
+static const mbedtls_cipher_info_t aes_192_gcm_info = {
+    MBEDTLS_CIPHER_AES_192_GCM,
+    MBEDTLS_MODE_GCM,
     192,
     "AES-192-GCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &gcm_aes_info
 };
 
-static const cipher_info_t aes_256_gcm_info = {
-    POLARSSL_CIPHER_AES_256_GCM,
-    POLARSSL_MODE_GCM,
+static const mbedtls_cipher_info_t aes_256_gcm_info = {
+    MBEDTLS_CIPHER_AES_256_GCM,
+    MBEDTLS_MODE_GCM,
     256,
     "AES-256-GCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &gcm_aes_info
 };
-#endif /* POLARSSL_GCM_C */
+#endif /* MBEDTLS_GCM_C */
 
-#if defined(POLARSSL_CCM_C)
+#if defined(MBEDTLS_CCM_C)
 static int ccm_aes_setkey_wrap( void *ctx, const unsigned char *key,
                                 unsigned int key_length )
 {
-    return ccm_init( (ccm_context *) ctx, POLARSSL_CIPHER_ID_AES,
+    return mbedtls_ccm_init( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_AES,
                      key, key_length );
 }
 
-static const cipher_base_t ccm_aes_info = {
-    POLARSSL_CIPHER_ID_AES,
+static const mbedtls_cipher_base_t ccm_aes_info = {
+    MBEDTLS_CIPHER_ID_AES,
     NULL,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     NULL,
 #endif
     ccm_aes_setkey_wrap,
@@ -420,125 +420,125 @@
     ccm_ctx_free,
 };
 
-static const cipher_info_t aes_128_ccm_info = {
-    POLARSSL_CIPHER_AES_128_CCM,
-    POLARSSL_MODE_CCM,
+static const mbedtls_cipher_info_t aes_128_ccm_info = {
+    MBEDTLS_CIPHER_AES_128_CCM,
+    MBEDTLS_MODE_CCM,
     128,
     "AES-128-CCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &ccm_aes_info
 };
 
-static const cipher_info_t aes_192_ccm_info = {
-    POLARSSL_CIPHER_AES_192_CCM,
-    POLARSSL_MODE_CCM,
+static const mbedtls_cipher_info_t aes_192_ccm_info = {
+    MBEDTLS_CIPHER_AES_192_CCM,
+    MBEDTLS_MODE_CCM,
     192,
     "AES-192-CCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &ccm_aes_info
 };
 
-static const cipher_info_t aes_256_ccm_info = {
-    POLARSSL_CIPHER_AES_256_CCM,
-    POLARSSL_MODE_CCM,
+static const mbedtls_cipher_info_t aes_256_ccm_info = {
+    MBEDTLS_CIPHER_AES_256_CCM,
+    MBEDTLS_MODE_CCM,
     256,
     "AES-256-CCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &ccm_aes_info
 };
-#endif /* POLARSSL_CCM_C */
+#endif /* MBEDTLS_CCM_C */
 
-#endif /* POLARSSL_AES_C */
+#endif /* MBEDTLS_AES_C */
 
-#if defined(POLARSSL_CAMELLIA_C)
+#if defined(MBEDTLS_CAMELLIA_C)
 
-static int camellia_crypt_ecb_wrap( void *ctx, operation_t operation,
+static int camellia_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
         const unsigned char *input, unsigned char *output )
 {
-    return camellia_crypt_ecb( (camellia_context *) ctx, operation, input,
+    return mbedtls_camellia_crypt_ecb( (mbedtls_camellia_context *) ctx, operation, input,
                                output );
 }
 
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-static int camellia_crypt_cbc_wrap( void *ctx, operation_t operation,
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+static int camellia_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
         size_t length, unsigned char *iv,
         const unsigned char *input, unsigned char *output )
 {
-    return camellia_crypt_cbc( (camellia_context *) ctx, operation, length, iv,
+    return mbedtls_camellia_crypt_cbc( (mbedtls_camellia_context *) ctx, operation, length, iv,
                                input, output );
 }
-#endif /* POLARSSL_CIPHER_MODE_CBC */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
 
-#if defined(POLARSSL_CIPHER_MODE_CFB)
-static int camellia_crypt_cfb128_wrap( void *ctx, operation_t operation,
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
+static int camellia_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation,
         size_t length, size_t *iv_off, unsigned char *iv,
         const unsigned char *input, unsigned char *output )
 {
-    return camellia_crypt_cfb128( (camellia_context *) ctx, operation, length,
+    return mbedtls_camellia_crypt_cfb128( (mbedtls_camellia_context *) ctx, operation, length,
                                   iv_off, iv, input, output );
 }
-#endif /* POLARSSL_CIPHER_MODE_CFB */
+#endif /* MBEDTLS_CIPHER_MODE_CFB */
 
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
 static int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
         unsigned char *nonce_counter, unsigned char *stream_block,
         const unsigned char *input, unsigned char *output )
 {
-    return camellia_crypt_ctr( (camellia_context *) ctx, length, nc_off,
+    return mbedtls_camellia_crypt_ctr( (mbedtls_camellia_context *) ctx, length, nc_off,
                                nonce_counter, stream_block, input, output );
 }
-#endif /* POLARSSL_CIPHER_MODE_CTR */
+#endif /* MBEDTLS_CIPHER_MODE_CTR */
 
 static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key,
                                      unsigned int key_length )
 {
-    return camellia_setkey_dec( (camellia_context *) ctx, key, key_length );
+    return mbedtls_camellia_setkey_dec( (mbedtls_camellia_context *) ctx, key, key_length );
 }
 
 static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key,
                                      unsigned int key_length )
 {
-    return camellia_setkey_enc( (camellia_context *) ctx, key, key_length );
+    return mbedtls_camellia_setkey_enc( (mbedtls_camellia_context *) ctx, key, key_length );
 }
 
 static void * camellia_ctx_alloc( void )
 {
-    camellia_context *ctx;
-    ctx = polarssl_malloc( sizeof( camellia_context ) );
+    mbedtls_camellia_context *ctx;
+    ctx = mbedtls_malloc( sizeof( mbedtls_camellia_context ) );
 
     if( ctx == NULL )
         return( NULL );
 
-    camellia_init( ctx );
+    mbedtls_camellia_init( ctx );
 
     return( ctx );
 }
 
 static void camellia_ctx_free( void *ctx )
 {
-    camellia_free( (camellia_context *) ctx );
-    polarssl_free( ctx );
+    mbedtls_camellia_free( (mbedtls_camellia_context *) ctx );
+    mbedtls_free( ctx );
 }
 
-static const cipher_base_t camellia_info = {
-    POLARSSL_CIPHER_ID_CAMELLIA,
+static const mbedtls_cipher_base_t camellia_info = {
+    MBEDTLS_CIPHER_ID_CAMELLIA,
     camellia_crypt_ecb_wrap,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     camellia_crypt_cbc_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     camellia_crypt_cfb128_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     camellia_crypt_ctr_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     NULL,
 #endif
     camellia_setkey_enc_wrap,
@@ -547,9 +547,9 @@
     camellia_ctx_free
 };
 
-static const cipher_info_t camellia_128_ecb_info = {
-    POLARSSL_CIPHER_CAMELLIA_128_ECB,
-    POLARSSL_MODE_ECB,
+static const mbedtls_cipher_info_t camellia_128_ecb_info = {
+    MBEDTLS_CIPHER_CAMELLIA_128_ECB,
+    MBEDTLS_MODE_ECB,
     128,
     "CAMELLIA-128-ECB",
     16,
@@ -558,9 +558,9 @@
     &camellia_info
 };
 
-static const cipher_info_t camellia_192_ecb_info = {
-    POLARSSL_CIPHER_CAMELLIA_192_ECB,
-    POLARSSL_MODE_ECB,
+static const mbedtls_cipher_info_t camellia_192_ecb_info = {
+    MBEDTLS_CIPHER_CAMELLIA_192_ECB,
+    MBEDTLS_MODE_ECB,
     192,
     "CAMELLIA-192-ECB",
     16,
@@ -569,9 +569,9 @@
     &camellia_info
 };
 
-static const cipher_info_t camellia_256_ecb_info = {
-    POLARSSL_CIPHER_CAMELLIA_256_ECB,
-    POLARSSL_MODE_ECB,
+static const mbedtls_cipher_info_t camellia_256_ecb_info = {
+    MBEDTLS_CIPHER_CAMELLIA_256_ECB,
+    MBEDTLS_MODE_ECB,
     256,
     "CAMELLIA-256-ECB",
     16,
@@ -580,10 +580,10 @@
     &camellia_info
 };
 
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-static const cipher_info_t camellia_128_cbc_info = {
-    POLARSSL_CIPHER_CAMELLIA_128_CBC,
-    POLARSSL_MODE_CBC,
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+static const mbedtls_cipher_info_t camellia_128_cbc_info = {
+    MBEDTLS_CIPHER_CAMELLIA_128_CBC,
+    MBEDTLS_MODE_CBC,
     128,
     "CAMELLIA-128-CBC",
     16,
@@ -592,9 +592,9 @@
     &camellia_info
 };
 
-static const cipher_info_t camellia_192_cbc_info = {
-    POLARSSL_CIPHER_CAMELLIA_192_CBC,
-    POLARSSL_MODE_CBC,
+static const mbedtls_cipher_info_t camellia_192_cbc_info = {
+    MBEDTLS_CIPHER_CAMELLIA_192_CBC,
+    MBEDTLS_MODE_CBC,
     192,
     "CAMELLIA-192-CBC",
     16,
@@ -603,9 +603,9 @@
     &camellia_info
 };
 
-static const cipher_info_t camellia_256_cbc_info = {
-    POLARSSL_CIPHER_CAMELLIA_256_CBC,
-    POLARSSL_MODE_CBC,
+static const mbedtls_cipher_info_t camellia_256_cbc_info = {
+    MBEDTLS_CIPHER_CAMELLIA_256_CBC,
+    MBEDTLS_MODE_CBC,
     256,
     "CAMELLIA-256-CBC",
     16,
@@ -613,12 +613,12 @@
     16,
     &camellia_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CBC */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
 
-#if defined(POLARSSL_CIPHER_MODE_CFB)
-static const cipher_info_t camellia_128_cfb128_info = {
-    POLARSSL_CIPHER_CAMELLIA_128_CFB128,
-    POLARSSL_MODE_CFB,
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
+static const mbedtls_cipher_info_t camellia_128_cfb128_info = {
+    MBEDTLS_CIPHER_CAMELLIA_128_CFB128,
+    MBEDTLS_MODE_CFB,
     128,
     "CAMELLIA-128-CFB128",
     16,
@@ -627,9 +627,9 @@
     &camellia_info
 };
 
-static const cipher_info_t camellia_192_cfb128_info = {
-    POLARSSL_CIPHER_CAMELLIA_192_CFB128,
-    POLARSSL_MODE_CFB,
+static const mbedtls_cipher_info_t camellia_192_cfb128_info = {
+    MBEDTLS_CIPHER_CAMELLIA_192_CFB128,
+    MBEDTLS_MODE_CFB,
     192,
     "CAMELLIA-192-CFB128",
     16,
@@ -638,9 +638,9 @@
     &camellia_info
 };
 
-static const cipher_info_t camellia_256_cfb128_info = {
-    POLARSSL_CIPHER_CAMELLIA_256_CFB128,
-    POLARSSL_MODE_CFB,
+static const mbedtls_cipher_info_t camellia_256_cfb128_info = {
+    MBEDTLS_CIPHER_CAMELLIA_256_CFB128,
+    MBEDTLS_MODE_CFB,
     256,
     "CAMELLIA-256-CFB128",
     16,
@@ -648,12 +648,12 @@
     16,
     &camellia_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CFB */
+#endif /* MBEDTLS_CIPHER_MODE_CFB */
 
-#if defined(POLARSSL_CIPHER_MODE_CTR)
-static const cipher_info_t camellia_128_ctr_info = {
-    POLARSSL_CIPHER_CAMELLIA_128_CTR,
-    POLARSSL_MODE_CTR,
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
+static const mbedtls_cipher_info_t camellia_128_ctr_info = {
+    MBEDTLS_CIPHER_CAMELLIA_128_CTR,
+    MBEDTLS_MODE_CTR,
     128,
     "CAMELLIA-128-CTR",
     16,
@@ -662,9 +662,9 @@
     &camellia_info
 };
 
-static const cipher_info_t camellia_192_ctr_info = {
-    POLARSSL_CIPHER_CAMELLIA_192_CTR,
-    POLARSSL_MODE_CTR,
+static const mbedtls_cipher_info_t camellia_192_ctr_info = {
+    MBEDTLS_CIPHER_CAMELLIA_192_CTR,
+    MBEDTLS_MODE_CTR,
     192,
     "CAMELLIA-192-CTR",
     16,
@@ -673,9 +673,9 @@
     &camellia_info
 };
 
-static const cipher_info_t camellia_256_ctr_info = {
-    POLARSSL_CIPHER_CAMELLIA_256_CTR,
-    POLARSSL_MODE_CTR,
+static const mbedtls_cipher_info_t camellia_256_ctr_info = {
+    MBEDTLS_CIPHER_CAMELLIA_256_CTR,
+    MBEDTLS_MODE_CTR,
     256,
     "CAMELLIA-256-CTR",
     16,
@@ -683,29 +683,29 @@
     16,
     &camellia_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CTR */
+#endif /* MBEDTLS_CIPHER_MODE_CTR */
 
-#if defined(POLARSSL_GCM_C)
+#if defined(MBEDTLS_GCM_C)
 static int gcm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
                                      unsigned int key_length )
 {
-    return gcm_init( (gcm_context *) ctx, POLARSSL_CIPHER_ID_CAMELLIA,
+    return mbedtls_gcm_init( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA,
                      key, key_length );
 }
 
-static const cipher_base_t gcm_camellia_info = {
-    POLARSSL_CIPHER_ID_CAMELLIA,
+static const mbedtls_cipher_base_t gcm_camellia_info = {
+    MBEDTLS_CIPHER_ID_CAMELLIA,
     NULL,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     NULL,
 #endif
     gcm_camellia_setkey_wrap,
@@ -714,61 +714,61 @@
     gcm_ctx_free,
 };
 
-static const cipher_info_t camellia_128_gcm_info = {
-    POLARSSL_CIPHER_CAMELLIA_128_GCM,
-    POLARSSL_MODE_GCM,
+static const mbedtls_cipher_info_t camellia_128_gcm_info = {
+    MBEDTLS_CIPHER_CAMELLIA_128_GCM,
+    MBEDTLS_MODE_GCM,
     128,
     "CAMELLIA-128-GCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &gcm_camellia_info
 };
 
-static const cipher_info_t camellia_192_gcm_info = {
-    POLARSSL_CIPHER_CAMELLIA_192_GCM,
-    POLARSSL_MODE_GCM,
+static const mbedtls_cipher_info_t camellia_192_gcm_info = {
+    MBEDTLS_CIPHER_CAMELLIA_192_GCM,
+    MBEDTLS_MODE_GCM,
     192,
     "CAMELLIA-192-GCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &gcm_camellia_info
 };
 
-static const cipher_info_t camellia_256_gcm_info = {
-    POLARSSL_CIPHER_CAMELLIA_256_GCM,
-    POLARSSL_MODE_GCM,
+static const mbedtls_cipher_info_t camellia_256_gcm_info = {
+    MBEDTLS_CIPHER_CAMELLIA_256_GCM,
+    MBEDTLS_MODE_GCM,
     256,
     "CAMELLIA-256-GCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &gcm_camellia_info
 };
-#endif /* POLARSSL_GCM_C */
+#endif /* MBEDTLS_GCM_C */
 
-#if defined(POLARSSL_CCM_C)
+#if defined(MBEDTLS_CCM_C)
 static int ccm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
                                      unsigned int key_length )
 {
-    return ccm_init( (ccm_context *) ctx, POLARSSL_CIPHER_ID_CAMELLIA,
+    return mbedtls_ccm_init( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA,
                      key, key_length );
 }
 
-static const cipher_base_t ccm_camellia_info = {
-    POLARSSL_CIPHER_ID_CAMELLIA,
+static const mbedtls_cipher_base_t ccm_camellia_info = {
+    MBEDTLS_CIPHER_ID_CAMELLIA,
     NULL,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     NULL,
 #endif
     ccm_camellia_setkey_wrap,
@@ -777,82 +777,82 @@
     ccm_ctx_free,
 };
 
-static const cipher_info_t camellia_128_ccm_info = {
-    POLARSSL_CIPHER_CAMELLIA_128_CCM,
-    POLARSSL_MODE_CCM,
+static const mbedtls_cipher_info_t camellia_128_ccm_info = {
+    MBEDTLS_CIPHER_CAMELLIA_128_CCM,
+    MBEDTLS_MODE_CCM,
     128,
     "CAMELLIA-128-CCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &ccm_camellia_info
 };
 
-static const cipher_info_t camellia_192_ccm_info = {
-    POLARSSL_CIPHER_CAMELLIA_192_CCM,
-    POLARSSL_MODE_CCM,
+static const mbedtls_cipher_info_t camellia_192_ccm_info = {
+    MBEDTLS_CIPHER_CAMELLIA_192_CCM,
+    MBEDTLS_MODE_CCM,
     192,
     "CAMELLIA-192-CCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &ccm_camellia_info
 };
 
-static const cipher_info_t camellia_256_ccm_info = {
-    POLARSSL_CIPHER_CAMELLIA_256_CCM,
-    POLARSSL_MODE_CCM,
+static const mbedtls_cipher_info_t camellia_256_ccm_info = {
+    MBEDTLS_CIPHER_CAMELLIA_256_CCM,
+    MBEDTLS_MODE_CCM,
     256,
     "CAMELLIA-256-CCM",
     12,
-    POLARSSL_CIPHER_VARIABLE_IV_LEN,
+    MBEDTLS_CIPHER_VARIABLE_IV_LEN,
     16,
     &ccm_camellia_info
 };
-#endif /* POLARSSL_CCM_C */
+#endif /* MBEDTLS_CCM_C */
 
-#endif /* POLARSSL_CAMELLIA_C */
+#endif /* MBEDTLS_CAMELLIA_C */
 
-#if defined(POLARSSL_DES_C)
+#if defined(MBEDTLS_DES_C)
 
-static int des_crypt_ecb_wrap( void *ctx, operation_t operation,
+static int des_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
         const unsigned char *input, unsigned char *output )
 {
     ((void) operation);
-    return des_crypt_ecb( (des_context *) ctx, input, output );
+    return mbedtls_des_crypt_ecb( (mbedtls_des_context *) ctx, input, output );
 }
 
-static int des3_crypt_ecb_wrap( void *ctx, operation_t operation,
+static int des3_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
         const unsigned char *input, unsigned char *output )
 {
     ((void) operation);
-    return des3_crypt_ecb( (des3_context *) ctx, input, output );
+    return mbedtls_des3_crypt_ecb( (mbedtls_des3_context *) ctx, input, output );
 }
 
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-static int des_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+static int des_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
         unsigned char *iv, const unsigned char *input, unsigned char *output )
 {
-    return des_crypt_cbc( (des_context *) ctx, operation, length, iv, input,
+    return mbedtls_des_crypt_cbc( (mbedtls_des_context *) ctx, operation, length, iv, input,
                           output );
 }
-#endif /* POLARSSL_CIPHER_MODE_CBC */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
 
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-static int des3_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+static int des3_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
         unsigned char *iv, const unsigned char *input, unsigned char *output )
 {
-    return des3_crypt_cbc( (des3_context *) ctx, operation, length, iv, input,
+    return mbedtls_des3_crypt_cbc( (mbedtls_des3_context *) ctx, operation, length, iv, input,
                            output );
 }
-#endif /* POLARSSL_CIPHER_MODE_CBC */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
 
 static int des_setkey_dec_wrap( void *ctx, const unsigned char *key,
                                 unsigned int key_length )
 {
     ((void) key_length);
 
-    return des_setkey_dec( (des_context *) ctx, key );
+    return mbedtls_des_setkey_dec( (mbedtls_des_context *) ctx, key );
 }
 
 static int des_setkey_enc_wrap( void *ctx, const unsigned char *key,
@@ -860,7 +860,7 @@
 {
     ((void) key_length);
 
-    return des_setkey_enc( (des_context *) ctx, key );
+    return mbedtls_des_setkey_enc( (mbedtls_des_context *) ctx, key );
 }
 
 static int des3_set2key_dec_wrap( void *ctx, const unsigned char *key,
@@ -868,7 +868,7 @@
 {
     ((void) key_length);
 
-    return des3_set2key_dec( (des3_context *) ctx, key );
+    return mbedtls_des3_set2key_dec( (mbedtls_des3_context *) ctx, key );
 }
 
 static int des3_set2key_enc_wrap( void *ctx, const unsigned char *key,
@@ -876,7 +876,7 @@
 {
     ((void) key_length);
 
-    return des3_set2key_enc( (des3_context *) ctx, key );
+    return mbedtls_des3_set2key_enc( (mbedtls_des3_context *) ctx, key );
 }
 
 static int des3_set3key_dec_wrap( void *ctx, const unsigned char *key,
@@ -884,7 +884,7 @@
 {
     ((void) key_length);
 
-    return des3_set3key_dec( (des3_context *) ctx, key );
+    return mbedtls_des3_set3key_dec( (mbedtls_des3_context *) ctx, key );
 }
 
 static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key,
@@ -892,59 +892,59 @@
 {
     ((void) key_length);
 
-    return des3_set3key_enc( (des3_context *) ctx, key );
+    return mbedtls_des3_set3key_enc( (mbedtls_des3_context *) ctx, key );
 }
 
 static void * des_ctx_alloc( void )
 {
-    des_context *des = polarssl_malloc( sizeof( des_context ) );
+    mbedtls_des_context *des = mbedtls_malloc( sizeof( mbedtls_des_context ) );
 
     if( des == NULL )
         return( NULL );
 
-    des_init( des );
+    mbedtls_des_init( des );
 
     return( des );
 }
 
 static void des_ctx_free( void *ctx )
 {
-    des_free( (des_context *) ctx );
-    polarssl_free( ctx );
+    mbedtls_des_free( (mbedtls_des_context *) ctx );
+    mbedtls_free( ctx );
 }
 
 static void * des3_ctx_alloc( void )
 {
-    des3_context *des3;
-    des3 = polarssl_malloc( sizeof( des3_context ) );
+    mbedtls_des3_context *des3;
+    des3 = mbedtls_malloc( sizeof( mbedtls_des3_context ) );
 
     if( des3 == NULL )
         return( NULL );
 
-    des3_init( des3 );
+    mbedtls_des3_init( des3 );
 
     return( des3 );
 }
 
 static void des3_ctx_free( void *ctx )
 {
-    des3_free( (des3_context *) ctx );
-    polarssl_free( ctx );
+    mbedtls_des3_free( (mbedtls_des3_context *) ctx );
+    mbedtls_free( ctx );
 }
 
-static const cipher_base_t des_info = {
-    POLARSSL_CIPHER_ID_DES,
+static const mbedtls_cipher_base_t des_info = {
+    MBEDTLS_CIPHER_ID_DES,
     des_crypt_ecb_wrap,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     des_crypt_cbc_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     NULL,
 #endif
     des_setkey_enc_wrap,
@@ -953,10 +953,10 @@
     des_ctx_free
 };
 
-static const cipher_info_t des_ecb_info = {
-    POLARSSL_CIPHER_DES_ECB,
-    POLARSSL_MODE_ECB,
-    POLARSSL_KEY_LENGTH_DES,
+static const mbedtls_cipher_info_t des_ecb_info = {
+    MBEDTLS_CIPHER_DES_ECB,
+    MBEDTLS_MODE_ECB,
+    MBEDTLS_KEY_LENGTH_DES,
     "DES-ECB",
     8,
     0,
@@ -964,32 +964,32 @@
     &des_info
 };
 
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-static const cipher_info_t des_cbc_info = {
-    POLARSSL_CIPHER_DES_CBC,
-    POLARSSL_MODE_CBC,
-    POLARSSL_KEY_LENGTH_DES,
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+static const mbedtls_cipher_info_t des_cbc_info = {
+    MBEDTLS_CIPHER_DES_CBC,
+    MBEDTLS_MODE_CBC,
+    MBEDTLS_KEY_LENGTH_DES,
     "DES-CBC",
     8,
     0,
     8,
     &des_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CBC */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
 
-static const cipher_base_t des_ede_info = {
-    POLARSSL_CIPHER_ID_DES,
+static const mbedtls_cipher_base_t des_ede_info = {
+    MBEDTLS_CIPHER_ID_DES,
     des3_crypt_ecb_wrap,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     des3_crypt_cbc_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     NULL,
 #endif
     des3_set2key_enc_wrap,
@@ -998,10 +998,10 @@
     des3_ctx_free
 };
 
-static const cipher_info_t des_ede_ecb_info = {
-    POLARSSL_CIPHER_DES_EDE_ECB,
-    POLARSSL_MODE_ECB,
-    POLARSSL_KEY_LENGTH_DES_EDE,
+static const mbedtls_cipher_info_t des_ede_ecb_info = {
+    MBEDTLS_CIPHER_DES_EDE_ECB,
+    MBEDTLS_MODE_ECB,
+    MBEDTLS_KEY_LENGTH_DES_EDE,
     "DES-EDE-ECB",
     8,
     0,
@@ -1009,32 +1009,32 @@
     &des_ede_info
 };
 
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-static const cipher_info_t des_ede_cbc_info = {
-    POLARSSL_CIPHER_DES_EDE_CBC,
-    POLARSSL_MODE_CBC,
-    POLARSSL_KEY_LENGTH_DES_EDE,
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+static const mbedtls_cipher_info_t des_ede_cbc_info = {
+    MBEDTLS_CIPHER_DES_EDE_CBC,
+    MBEDTLS_MODE_CBC,
+    MBEDTLS_KEY_LENGTH_DES_EDE,
     "DES-EDE-CBC",
     8,
     0,
     8,
     &des_ede_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CBC */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
 
-static const cipher_base_t des_ede3_info = {
-    POLARSSL_CIPHER_ID_DES,
+static const mbedtls_cipher_base_t des_ede3_info = {
+    MBEDTLS_CIPHER_ID_DES,
     des3_crypt_ecb_wrap,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     des3_crypt_cbc_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     NULL,
 #endif
     des3_set3key_enc_wrap,
@@ -1043,107 +1043,107 @@
     des3_ctx_free
 };
 
-static const cipher_info_t des_ede3_ecb_info = {
-    POLARSSL_CIPHER_DES_EDE3_ECB,
-    POLARSSL_MODE_ECB,
-    POLARSSL_KEY_LENGTH_DES_EDE3,
+static const mbedtls_cipher_info_t des_ede3_ecb_info = {
+    MBEDTLS_CIPHER_DES_EDE3_ECB,
+    MBEDTLS_MODE_ECB,
+    MBEDTLS_KEY_LENGTH_DES_EDE3,
     "DES-EDE3-ECB",
     8,
     0,
     8,
     &des_ede3_info
 };
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-static const cipher_info_t des_ede3_cbc_info = {
-    POLARSSL_CIPHER_DES_EDE3_CBC,
-    POLARSSL_MODE_CBC,
-    POLARSSL_KEY_LENGTH_DES_EDE3,
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+static const mbedtls_cipher_info_t des_ede3_cbc_info = {
+    MBEDTLS_CIPHER_DES_EDE3_CBC,
+    MBEDTLS_MODE_CBC,
+    MBEDTLS_KEY_LENGTH_DES_EDE3,
     "DES-EDE3-CBC",
     8,
     0,
     8,
     &des_ede3_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CBC */
-#endif /* POLARSSL_DES_C */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
+#endif /* MBEDTLS_DES_C */
 
-#if defined(POLARSSL_BLOWFISH_C)
+#if defined(MBEDTLS_BLOWFISH_C)
 
-static int blowfish_crypt_ecb_wrap( void *ctx, operation_t operation,
+static int blowfish_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
         const unsigned char *input, unsigned char *output )
 {
-    return blowfish_crypt_ecb( (blowfish_context *) ctx, operation, input,
+    return mbedtls_blowfish_crypt_ecb( (mbedtls_blowfish_context *) ctx, operation, input,
                                output );
 }
 
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-static int blowfish_crypt_cbc_wrap( void *ctx, operation_t operation,
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+static int blowfish_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
         size_t length, unsigned char *iv, const unsigned char *input,
         unsigned char *output )
 {
-    return blowfish_crypt_cbc( (blowfish_context *) ctx, operation, length, iv,
+    return mbedtls_blowfish_crypt_cbc( (mbedtls_blowfish_context *) ctx, operation, length, iv,
                                input, output );
 }
-#endif /* POLARSSL_CIPHER_MODE_CBC */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
 
-#if defined(POLARSSL_CIPHER_MODE_CFB)
-static int blowfish_crypt_cfb64_wrap( void *ctx, operation_t operation,
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
+static int blowfish_crypt_cfb64_wrap( void *ctx, mbedtls_operation_t operation,
         size_t length, size_t *iv_off, unsigned char *iv,
         const unsigned char *input, unsigned char *output )
 {
-    return blowfish_crypt_cfb64( (blowfish_context *) ctx, operation, length,
+    return mbedtls_blowfish_crypt_cfb64( (mbedtls_blowfish_context *) ctx, operation, length,
                                  iv_off, iv, input, output );
 }
-#endif /* POLARSSL_CIPHER_MODE_CFB */
+#endif /* MBEDTLS_CIPHER_MODE_CFB */
 
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
 static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
         unsigned char *nonce_counter, unsigned char *stream_block,
         const unsigned char *input, unsigned char *output )
 {
-    return blowfish_crypt_ctr( (blowfish_context *) ctx, length, nc_off,
+    return mbedtls_blowfish_crypt_ctr( (mbedtls_blowfish_context *) ctx, length, nc_off,
                                nonce_counter, stream_block, input, output );
 }
-#endif /* POLARSSL_CIPHER_MODE_CTR */
+#endif /* MBEDTLS_CIPHER_MODE_CTR */
 
 static int blowfish_setkey_wrap( void *ctx, const unsigned char *key,
                                  unsigned int key_length )
 {
-    return blowfish_setkey( (blowfish_context *) ctx, key, key_length );
+    return mbedtls_blowfish_setkey( (mbedtls_blowfish_context *) ctx, key, key_length );
 }
 
 static void * blowfish_ctx_alloc( void )
 {
-    blowfish_context *ctx;
-    ctx = polarssl_malloc( sizeof( blowfish_context ) );
+    mbedtls_blowfish_context *ctx;
+    ctx = mbedtls_malloc( sizeof( mbedtls_blowfish_context ) );
 
     if( ctx == NULL )
         return( NULL );
 
-    blowfish_init( ctx );
+    mbedtls_blowfish_init( ctx );
 
     return( ctx );
 }
 
 static void blowfish_ctx_free( void *ctx )
 {
-    blowfish_free( (blowfish_context *) ctx );
-    polarssl_free( ctx );
+    mbedtls_blowfish_free( (mbedtls_blowfish_context *) ctx );
+    mbedtls_free( ctx );
 }
 
-static const cipher_base_t blowfish_info = {
-    POLARSSL_CIPHER_ID_BLOWFISH,
+static const mbedtls_cipher_base_t blowfish_info = {
+    MBEDTLS_CIPHER_ID_BLOWFISH,
     blowfish_crypt_ecb_wrap,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     blowfish_crypt_cbc_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     blowfish_crypt_cfb64_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     blowfish_crypt_ctr_wrap,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     NULL,
 #endif
     blowfish_setkey_wrap,
@@ -1152,63 +1152,63 @@
     blowfish_ctx_free
 };
 
-static const cipher_info_t blowfish_ecb_info = {
-    POLARSSL_CIPHER_BLOWFISH_ECB,
-    POLARSSL_MODE_ECB,
+static const mbedtls_cipher_info_t blowfish_ecb_info = {
+    MBEDTLS_CIPHER_BLOWFISH_ECB,
+    MBEDTLS_MODE_ECB,
     128,
     "BLOWFISH-ECB",
     8,
-    POLARSSL_CIPHER_VARIABLE_KEY_LEN,
+    MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
     8,
     &blowfish_info
 };
 
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-static const cipher_info_t blowfish_cbc_info = {
-    POLARSSL_CIPHER_BLOWFISH_CBC,
-    POLARSSL_MODE_CBC,
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+static const mbedtls_cipher_info_t blowfish_cbc_info = {
+    MBEDTLS_CIPHER_BLOWFISH_CBC,
+    MBEDTLS_MODE_CBC,
     128,
     "BLOWFISH-CBC",
     8,
-    POLARSSL_CIPHER_VARIABLE_KEY_LEN,
+    MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
     8,
     &blowfish_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CBC */
+#endif /* MBEDTLS_CIPHER_MODE_CBC */
 
-#if defined(POLARSSL_CIPHER_MODE_CFB)
-static const cipher_info_t blowfish_cfb64_info = {
-    POLARSSL_CIPHER_BLOWFISH_CFB64,
-    POLARSSL_MODE_CFB,
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
+static const mbedtls_cipher_info_t blowfish_cfb64_info = {
+    MBEDTLS_CIPHER_BLOWFISH_CFB64,
+    MBEDTLS_MODE_CFB,
     128,
     "BLOWFISH-CFB64",
     8,
-    POLARSSL_CIPHER_VARIABLE_KEY_LEN,
+    MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
     8,
     &blowfish_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CFB */
+#endif /* MBEDTLS_CIPHER_MODE_CFB */
 
-#if defined(POLARSSL_CIPHER_MODE_CTR)
-static const cipher_info_t blowfish_ctr_info = {
-    POLARSSL_CIPHER_BLOWFISH_CTR,
-    POLARSSL_MODE_CTR,
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
+static const mbedtls_cipher_info_t blowfish_ctr_info = {
+    MBEDTLS_CIPHER_BLOWFISH_CTR,
+    MBEDTLS_MODE_CTR,
     128,
     "BLOWFISH-CTR",
     8,
-    POLARSSL_CIPHER_VARIABLE_KEY_LEN,
+    MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
     8,
     &blowfish_info
 };
-#endif /* POLARSSL_CIPHER_MODE_CTR */
-#endif /* POLARSSL_BLOWFISH_C */
+#endif /* MBEDTLS_CIPHER_MODE_CTR */
+#endif /* MBEDTLS_BLOWFISH_C */
 
-#if defined(POLARSSL_ARC4_C)
+#if defined(MBEDTLS_ARC4_C)
 static int arc4_crypt_stream_wrap( void *ctx, size_t length,
                                    const unsigned char *input,
                                    unsigned char *output )
 {
-    return( arc4_crypt( (arc4_context *) ctx, length, input, output ) );
+    return( mbedtls_arc4_crypt( (mbedtls_arc4_context *) ctx, length, input, output ) );
 }
 
 static int arc4_setkey_wrap( void *ctx, const unsigned char *key,
@@ -1216,44 +1216,44 @@
 {
     /* we get key_length in bits, arc4 expects it in bytes */
     if( key_length % 8 != 0 )
-        return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
+        return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
 
-    arc4_setup( (arc4_context *) ctx, key, key_length / 8 );
+    mbedtls_arc4_setup( (mbedtls_arc4_context *) ctx, key, key_length / 8 );
     return( 0 );
 }
 
 static void * arc4_ctx_alloc( void )
 {
-    arc4_context *ctx;
-    ctx = polarssl_malloc( sizeof( arc4_context ) );
+    mbedtls_arc4_context *ctx;
+    ctx = mbedtls_malloc( sizeof( mbedtls_arc4_context ) );
 
     if( ctx == NULL )
         return( NULL );
 
-    arc4_init( ctx );
+    mbedtls_arc4_init( ctx );
 
     return( ctx );
 }
 
 static void arc4_ctx_free( void *ctx )
 {
-    arc4_free( (arc4_context *) ctx );
-    polarssl_free( ctx );
+    mbedtls_arc4_free( (mbedtls_arc4_context *) ctx );
+    mbedtls_free( ctx );
 }
 
-static const cipher_base_t arc4_base_info = {
-    POLARSSL_CIPHER_ID_ARC4,
+static const mbedtls_cipher_base_t arc4_base_info = {
+    MBEDTLS_CIPHER_ID_ARC4,
     NULL,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     arc4_crypt_stream_wrap,
 #endif
     arc4_setkey_wrap,
@@ -1262,9 +1262,9 @@
     arc4_ctx_free
 };
 
-static const cipher_info_t arc4_128_info = {
-    POLARSSL_CIPHER_ARC4_128,
-    POLARSSL_MODE_STREAM,
+static const mbedtls_cipher_info_t arc4_128_info = {
+    MBEDTLS_CIPHER_ARC4_128,
+    MBEDTLS_MODE_STREAM,
     128,
     "ARC4-128",
     0,
@@ -1272,9 +1272,9 @@
     1,
     &arc4_base_info
 };
-#endif /* POLARSSL_ARC4_C */
+#endif /* MBEDTLS_ARC4_C */
 
-#if defined(POLARSSL_CIPHER_NULL_CIPHER)
+#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
 static int null_crypt_stream( void *ctx, size_t length,
                               const unsigned char *input,
                               unsigned char *output )
@@ -1304,19 +1304,19 @@
     ((void) ctx);
 }
 
-static const cipher_base_t null_base_info = {
-    POLARSSL_CIPHER_ID_NULL,
+static const mbedtls_cipher_base_t null_base_info = {
+    MBEDTLS_CIPHER_ID_NULL,
     NULL,
-#if defined(POLARSSL_CIPHER_MODE_CBC)
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
     NULL,
 #endif
-#if defined(POLARSSL_CIPHER_MODE_STREAM)
+#if defined(MBEDTLS_CIPHER_MODE_STREAM)
     null_crypt_stream,
 #endif
     null_setkey,
@@ -1325,9 +1325,9 @@
     null_ctx_free
 };
 
-static const cipher_info_t null_cipher_info = {
-    POLARSSL_CIPHER_NULL,
-    POLARSSL_MODE_STREAM,
+static const mbedtls_cipher_info_t null_cipher_info = {
+    MBEDTLS_CIPHER_NULL,
+    MBEDTLS_MODE_STREAM,
     0,
     "NULL",
     0,
@@ -1335,108 +1335,108 @@
     1,
     &null_base_info
 };
-#endif /* defined(POLARSSL_CIPHER_NULL_CIPHER) */
+#endif /* defined(MBEDTLS_CIPHER_NULL_CIPHER) */
 
-const cipher_definition_t cipher_definitions[] =
+const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] =
 {
-#if defined(POLARSSL_AES_C)
-    { POLARSSL_CIPHER_AES_128_ECB,          &aes_128_ecb_info },
-    { POLARSSL_CIPHER_AES_192_ECB,          &aes_192_ecb_info },
-    { POLARSSL_CIPHER_AES_256_ECB,          &aes_256_ecb_info },
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-    { POLARSSL_CIPHER_AES_128_CBC,          &aes_128_cbc_info },
-    { POLARSSL_CIPHER_AES_192_CBC,          &aes_192_cbc_info },
-    { POLARSSL_CIPHER_AES_256_CBC,          &aes_256_cbc_info },
+#if defined(MBEDTLS_AES_C)
+    { MBEDTLS_CIPHER_AES_128_ECB,          &aes_128_ecb_info },
+    { MBEDTLS_CIPHER_AES_192_ECB,          &aes_192_ecb_info },
+    { MBEDTLS_CIPHER_AES_256_ECB,          &aes_256_ecb_info },
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+    { MBEDTLS_CIPHER_AES_128_CBC,          &aes_128_cbc_info },
+    { MBEDTLS_CIPHER_AES_192_CBC,          &aes_192_cbc_info },
+    { MBEDTLS_CIPHER_AES_256_CBC,          &aes_256_cbc_info },
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
-    { POLARSSL_CIPHER_AES_128_CFB128,       &aes_128_cfb128_info },
-    { POLARSSL_CIPHER_AES_192_CFB128,       &aes_192_cfb128_info },
-    { POLARSSL_CIPHER_AES_256_CFB128,       &aes_256_cfb128_info },
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
+    { MBEDTLS_CIPHER_AES_128_CFB128,       &aes_128_cfb128_info },
+    { MBEDTLS_CIPHER_AES_192_CFB128,       &aes_192_cfb128_info },
+    { MBEDTLS_CIPHER_AES_256_CFB128,       &aes_256_cfb128_info },
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
-    { POLARSSL_CIPHER_AES_128_CTR,          &aes_128_ctr_info },
-    { POLARSSL_CIPHER_AES_192_CTR,          &aes_192_ctr_info },
-    { POLARSSL_CIPHER_AES_256_CTR,          &aes_256_ctr_info },
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
+    { MBEDTLS_CIPHER_AES_128_CTR,          &aes_128_ctr_info },
+    { MBEDTLS_CIPHER_AES_192_CTR,          &aes_192_ctr_info },
+    { MBEDTLS_CIPHER_AES_256_CTR,          &aes_256_ctr_info },
 #endif
-#if defined(POLARSSL_GCM_C)
-    { POLARSSL_CIPHER_AES_128_GCM,          &aes_128_gcm_info },
-    { POLARSSL_CIPHER_AES_192_GCM,          &aes_192_gcm_info },
-    { POLARSSL_CIPHER_AES_256_GCM,          &aes_256_gcm_info },
+#if defined(MBEDTLS_GCM_C)
+    { MBEDTLS_CIPHER_AES_128_GCM,          &aes_128_gcm_info },
+    { MBEDTLS_CIPHER_AES_192_GCM,          &aes_192_gcm_info },
+    { MBEDTLS_CIPHER_AES_256_GCM,          &aes_256_gcm_info },
 #endif
-#if defined(POLARSSL_CCM_C)
-    { POLARSSL_CIPHER_AES_128_CCM,          &aes_128_ccm_info },
-    { POLARSSL_CIPHER_AES_192_CCM,          &aes_192_ccm_info },
-    { POLARSSL_CIPHER_AES_256_CCM,          &aes_256_ccm_info },
+#if defined(MBEDTLS_CCM_C)
+    { MBEDTLS_CIPHER_AES_128_CCM,          &aes_128_ccm_info },
+    { MBEDTLS_CIPHER_AES_192_CCM,          &aes_192_ccm_info },
+    { MBEDTLS_CIPHER_AES_256_CCM,          &aes_256_ccm_info },
 #endif
-#endif /* POLARSSL_AES_C */
+#endif /* MBEDTLS_AES_C */
 
-#if defined(POLARSSL_ARC4_C)
-    { POLARSSL_CIPHER_ARC4_128,             &arc4_128_info },
+#if defined(MBEDTLS_ARC4_C)
+    { MBEDTLS_CIPHER_ARC4_128,             &arc4_128_info },
 #endif
 
-#if defined(POLARSSL_BLOWFISH_C)
-    { POLARSSL_CIPHER_BLOWFISH_ECB,         &blowfish_ecb_info },
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-    { POLARSSL_CIPHER_BLOWFISH_CBC,         &blowfish_cbc_info },
+#if defined(MBEDTLS_BLOWFISH_C)
+    { MBEDTLS_CIPHER_BLOWFISH_ECB,         &blowfish_ecb_info },
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+    { MBEDTLS_CIPHER_BLOWFISH_CBC,         &blowfish_cbc_info },
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
-    { POLARSSL_CIPHER_BLOWFISH_CFB64,       &blowfish_cfb64_info },
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
+    { MBEDTLS_CIPHER_BLOWFISH_CFB64,       &blowfish_cfb64_info },
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
-    { POLARSSL_CIPHER_BLOWFISH_CTR,         &blowfish_ctr_info },
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
+    { MBEDTLS_CIPHER_BLOWFISH_CTR,         &blowfish_ctr_info },
 #endif
-#endif /* POLARSSL_BLOWFISH_C */
+#endif /* MBEDTLS_BLOWFISH_C */
 
-#if defined(POLARSSL_CAMELLIA_C)
-    { POLARSSL_CIPHER_CAMELLIA_128_ECB,     &camellia_128_ecb_info },
-    { POLARSSL_CIPHER_CAMELLIA_192_ECB,     &camellia_192_ecb_info },
-    { POLARSSL_CIPHER_CAMELLIA_256_ECB,     &camellia_256_ecb_info },
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-    { POLARSSL_CIPHER_CAMELLIA_128_CBC,     &camellia_128_cbc_info },
-    { POLARSSL_CIPHER_CAMELLIA_192_CBC,     &camellia_192_cbc_info },
-    { POLARSSL_CIPHER_CAMELLIA_256_CBC,     &camellia_256_cbc_info },
+#if defined(MBEDTLS_CAMELLIA_C)
+    { MBEDTLS_CIPHER_CAMELLIA_128_ECB,     &camellia_128_ecb_info },
+    { MBEDTLS_CIPHER_CAMELLIA_192_ECB,     &camellia_192_ecb_info },
+    { MBEDTLS_CIPHER_CAMELLIA_256_ECB,     &camellia_256_ecb_info },
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+    { MBEDTLS_CIPHER_CAMELLIA_128_CBC,     &camellia_128_cbc_info },
+    { MBEDTLS_CIPHER_CAMELLIA_192_CBC,     &camellia_192_cbc_info },
+    { MBEDTLS_CIPHER_CAMELLIA_256_CBC,     &camellia_256_cbc_info },
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CFB)
-    { POLARSSL_CIPHER_CAMELLIA_128_CFB128,  &camellia_128_cfb128_info },
-    { POLARSSL_CIPHER_CAMELLIA_192_CFB128,  &camellia_192_cfb128_info },
-    { POLARSSL_CIPHER_CAMELLIA_256_CFB128,  &camellia_256_cfb128_info },
+#if defined(MBEDTLS_CIPHER_MODE_CFB)
+    { MBEDTLS_CIPHER_CAMELLIA_128_CFB128,  &camellia_128_cfb128_info },
+    { MBEDTLS_CIPHER_CAMELLIA_192_CFB128,  &camellia_192_cfb128_info },
+    { MBEDTLS_CIPHER_CAMELLIA_256_CFB128,  &camellia_256_cfb128_info },
 #endif
-#if defined(POLARSSL_CIPHER_MODE_CTR)
-    { POLARSSL_CIPHER_CAMELLIA_128_CTR,     &camellia_128_ctr_info },
-    { POLARSSL_CIPHER_CAMELLIA_192_CTR,     &camellia_192_ctr_info },
-    { POLARSSL_CIPHER_CAMELLIA_256_CTR,     &camellia_256_ctr_info },
+#if defined(MBEDTLS_CIPHER_MODE_CTR)
+    { MBEDTLS_CIPHER_CAMELLIA_128_CTR,     &camellia_128_ctr_info },
+    { MBEDTLS_CIPHER_CAMELLIA_192_CTR,     &camellia_192_ctr_info },
+    { MBEDTLS_CIPHER_CAMELLIA_256_CTR,     &camellia_256_ctr_info },
 #endif
-#if defined(POLARSSL_GCM_C)
-    { POLARSSL_CIPHER_CAMELLIA_128_GCM,     &camellia_128_gcm_info },
-    { POLARSSL_CIPHER_CAMELLIA_192_GCM,     &camellia_192_gcm_info },
-    { POLARSSL_CIPHER_CAMELLIA_256_GCM,     &camellia_256_gcm_info },
+#if defined(MBEDTLS_GCM_C)
+    { MBEDTLS_CIPHER_CAMELLIA_128_GCM,     &camellia_128_gcm_info },
+    { MBEDTLS_CIPHER_CAMELLIA_192_GCM,     &camellia_192_gcm_info },
+    { MBEDTLS_CIPHER_CAMELLIA_256_GCM,     &camellia_256_gcm_info },
 #endif
-#if defined(POLARSSL_CCM_C)
-    { POLARSSL_CIPHER_CAMELLIA_128_CCM,     &camellia_128_ccm_info },
-    { POLARSSL_CIPHER_CAMELLIA_192_CCM,     &camellia_192_ccm_info },
-    { POLARSSL_CIPHER_CAMELLIA_256_CCM,     &camellia_256_ccm_info },
+#if defined(MBEDTLS_CCM_C)
+    { MBEDTLS_CIPHER_CAMELLIA_128_CCM,     &camellia_128_ccm_info },
+    { MBEDTLS_CIPHER_CAMELLIA_192_CCM,     &camellia_192_ccm_info },
+    { MBEDTLS_CIPHER_CAMELLIA_256_CCM,     &camellia_256_ccm_info },
 #endif
-#endif /* POLARSSL_CAMELLIA_C */
+#endif /* MBEDTLS_CAMELLIA_C */
 
-#if defined(POLARSSL_DES_C)
-    { POLARSSL_CIPHER_DES_ECB,              &des_ecb_info },
-    { POLARSSL_CIPHER_DES_EDE_ECB,          &des_ede_ecb_info },
-    { POLARSSL_CIPHER_DES_EDE3_ECB,         &des_ede3_ecb_info },
-#if defined(POLARSSL_CIPHER_MODE_CBC)
-    { POLARSSL_CIPHER_DES_CBC,              &des_cbc_info },
-    { POLARSSL_CIPHER_DES_EDE_CBC,          &des_ede_cbc_info },
-    { POLARSSL_CIPHER_DES_EDE3_CBC,         &des_ede3_cbc_info },
+#if defined(MBEDTLS_DES_C)
+    { MBEDTLS_CIPHER_DES_ECB,              &des_ecb_info },
+    { MBEDTLS_CIPHER_DES_EDE_ECB,          &des_ede_ecb_info },
+    { MBEDTLS_CIPHER_DES_EDE3_ECB,         &des_ede3_ecb_info },
+#if defined(MBEDTLS_CIPHER_MODE_CBC)
+    { MBEDTLS_CIPHER_DES_CBC,              &des_cbc_info },
+    { MBEDTLS_CIPHER_DES_EDE_CBC,          &des_ede_cbc_info },
+    { MBEDTLS_CIPHER_DES_EDE3_CBC,         &des_ede3_cbc_info },
 #endif
-#endif /* POLARSSL_DES_C */
+#endif /* MBEDTLS_DES_C */
 
-#if defined(POLARSSL_CIPHER_NULL_CIPHER)
-    { POLARSSL_CIPHER_NULL,                 &null_cipher_info },
-#endif /* POLARSSL_CIPHER_NULL_CIPHER */
+#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
+    { MBEDTLS_CIPHER_NULL,                 &null_cipher_info },
+#endif /* MBEDTLS_CIPHER_NULL_CIPHER */
 
-    { POLARSSL_CIPHER_NONE, NULL }
+    { MBEDTLS_CIPHER_NONE, NULL }
 };
 
-#define NUM_CIPHERS sizeof cipher_definitions / sizeof cipher_definitions[0]
-int supported_ciphers[NUM_CIPHERS];
+#define NUM_CIPHERS sizeof mbedtls_cipher_definitions / sizeof mbedtls_cipher_definitions[0]
+int mbedtls_cipher_supported[NUM_CIPHERS];
 
-#endif /* POLARSSL_CIPHER_C */
+#endif /* MBEDTLS_CIPHER_C */