From 097c7bb05b68979744fe6c967cda25a8d62c3dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 18 Jun 2015 16:43:38 +0200 Subject: [PATCH] Rename relevant global symbols from size to bitlen Just applying rename.pl with this file: mbedtls_cipher_get_key_size mbedtls_cipher_get_key_bitlen mbedtls_pk_get_size mbedtls_pk_get_bitlen MBEDTLS_BLOWFISH_MIN_KEY MBEDTLS_BLOWFISH_MIN_KEY_BITS MBEDTLS_BLOWFISH_MAX_KEY MBEDTLS_BLOWFISH_MAX_KEY_BITS --- include/mbedtls/blowfish.h | 4 ++-- include/mbedtls/cipher.h | 2 +- include/mbedtls/compat-1.3.h | 8 ++++---- include/mbedtls/pk.h | 4 ++-- library/blowfish.c | 2 +- library/pk.c | 2 +- library/ssl_ticket.c | 2 +- library/x509_crt.c | 4 ++-- library/x509_csr.c | 2 +- scripts/data_files/rename-1.3-2.0.txt | 8 ++++---- tests/suites/test_suite_pk.function | 4 ++-- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/mbedtls/blowfish.h b/include/mbedtls/blowfish.h index 74bbe2665..a829d80d9 100644 --- a/include/mbedtls/blowfish.h +++ b/include/mbedtls/blowfish.h @@ -35,8 +35,8 @@ #define MBEDTLS_BLOWFISH_ENCRYPT 1 #define MBEDTLS_BLOWFISH_DECRYPT 0 -#define MBEDTLS_BLOWFISH_MAX_KEY 448 -#define MBEDTLS_BLOWFISH_MIN_KEY 32 +#define MBEDTLS_BLOWFISH_MAX_KEY_BITS 448 +#define MBEDTLS_BLOWFISH_MIN_KEY_BITS 32 #define MBEDTLS_BLOWFISH_ROUNDS 16 /**< Rounds to use. When increasing this value, make sure to extend the initialisation vectors */ #define MBEDTLS_BLOWFISH_BLOCKSIZE 8 /* Blowfish uses 64 bit blocks */ diff --git a/include/mbedtls/cipher.h b/include/mbedtls/cipher.h index 9f42f0e44..6710a004f 100644 --- a/include/mbedtls/cipher.h +++ b/include/mbedtls/cipher.h @@ -415,7 +415,7 @@ static inline const char *mbedtls_cipher_get_name( const mbedtls_cipher_context_ * MBEDTLS_KEY_LENGTH_NONE if ctx has not been * initialised. */ -static inline int mbedtls_cipher_get_key_size( const mbedtls_cipher_context_t *ctx ) +static inline int mbedtls_cipher_get_key_bitlen( const mbedtls_cipher_context_t *ctx ) { if( NULL == ctx || NULL == ctx->cipher_info ) return MBEDTLS_KEY_LENGTH_NONE; diff --git a/include/mbedtls/compat-1.3.h b/include/mbedtls/compat-1.3.h index 0af0a9eb5..8b0342a31 100644 --- a/include/mbedtls/compat-1.3.h +++ b/include/mbedtls/compat-1.3.h @@ -709,8 +709,8 @@ #define BLOWFISH_BLOCKSIZE MBEDTLS_BLOWFISH_BLOCKSIZE #define BLOWFISH_DECRYPT MBEDTLS_BLOWFISH_DECRYPT #define BLOWFISH_ENCRYPT MBEDTLS_BLOWFISH_ENCRYPT -#define BLOWFISH_MAX_KEY MBEDTLS_BLOWFISH_MAX_KEY -#define BLOWFISH_MIN_KEY MBEDTLS_BLOWFISH_MIN_KEY +#define BLOWFISH_MAX_KEY MBEDTLS_BLOWFISH_MAX_KEY_BITS +#define BLOWFISH_MIN_KEY MBEDTLS_BLOWFISH_MIN_KEY_BITS #define BLOWFISH_ROUNDS MBEDTLS_BLOWFISH_ROUNDS #define CAMELLIA_DECRYPT MBEDTLS_CAMELLIA_DECRYPT #define CAMELLIA_ENCRYPT MBEDTLS_CAMELLIA_ENCRYPT @@ -1855,7 +1855,7 @@ #define cipher_get_block_size mbedtls_cipher_get_block_size #define cipher_get_cipher_mode mbedtls_cipher_get_cipher_mode #define cipher_get_iv_size mbedtls_cipher_get_iv_size -#define cipher_get_key_size mbedtls_cipher_get_key_size +#define cipher_get_key_size mbedtls_cipher_get_key_bitlen #define cipher_get_name mbedtls_cipher_get_name #define cipher_get_operation mbedtls_cipher_get_operation #define cipher_get_type mbedtls_cipher_get_type @@ -2219,7 +2219,7 @@ #define pk_free mbedtls_pk_free #define pk_get_len mbedtls_pk_get_len #define pk_get_name mbedtls_pk_get_name -#define pk_get_size mbedtls_pk_get_size +#define pk_get_size mbedtls_pk_get_bitlen #define pk_get_type mbedtls_pk_get_type #define pk_info_from_type mbedtls_pk_info_from_type #define pk_info_t mbedtls_pk_info_t diff --git a/include/mbedtls/pk.h b/include/mbedtls/pk.h index ffd06dd33..1e2a29343 100644 --- a/include/mbedtls/pk.h +++ b/include/mbedtls/pk.h @@ -229,7 +229,7 @@ int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key, * * \return Key size in bits, or 0 on error */ -size_t mbedtls_pk_get_size( const mbedtls_pk_context *ctx ); +size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx ); /** * \brief Get the length in bytes of the underlying key @@ -239,7 +239,7 @@ size_t mbedtls_pk_get_size( const mbedtls_pk_context *ctx ); */ static inline size_t mbedtls_pk_get_len( const mbedtls_pk_context *ctx ) { - return( ( mbedtls_pk_get_size( ctx ) + 7 ) / 8 ); + return( ( mbedtls_pk_get_bitlen( ctx ) + 7 ) / 8 ); } /** diff --git a/library/blowfish.c b/library/blowfish.c index baa339304..767d141a3 100644 --- a/library/blowfish.c +++ b/library/blowfish.c @@ -178,7 +178,7 @@ int mbedtls_blowfish_setkey( mbedtls_blowfish_context *ctx, const unsigned char unsigned int i, j, k; uint32_t data, datal, datar; - if( keybits < MBEDTLS_BLOWFISH_MIN_KEY || keybits > MBEDTLS_BLOWFISH_MAX_KEY || + if( keybits < MBEDTLS_BLOWFISH_MIN_KEY_BITS || keybits > MBEDTLS_BLOWFISH_MAX_KEY_BITS || ( keybits % 8 ) ) { return( MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH ); diff --git a/library/pk.c b/library/pk.c index 5a838557e..b5810b5fe 100644 --- a/library/pk.c +++ b/library/pk.c @@ -327,7 +327,7 @@ int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_conte /* * Get key size in bits */ -size_t mbedtls_pk_get_size( const mbedtls_pk_context *ctx ) +size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx ) { if( ctx == NULL || ctx->pk_info == NULL ) return( 0 ); diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c index 3c7dd271e..94795f468 100644 --- a/library/ssl_ticket.c +++ b/library/ssl_ticket.c @@ -81,7 +81,7 @@ static int ssl_ticket_gen_key( mbedtls_ssl_ticket_context *ctx, /* With GCM and CCM, same context can encrypt & decrypt */ ret = mbedtls_cipher_setkey( &key->ctx, buf, - mbedtls_cipher_get_key_size( &key->ctx ), + mbedtls_cipher_get_key_bitlen( &key->ctx ), MBEDTLS_ENCRYPT ); mbedtls_zeroize( buf, sizeof( buf ) ); diff --git a/library/x509_crt.c b/library/x509_crt.c index bedc6e98f..7cb5b4472 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -180,7 +180,7 @@ static int x509_profile_check_key( const mbedtls_x509_crt_profile *profile, #if defined(MBEDTLS_RSA_C) if( pk_alg == MBEDTLS_PK_RSA || pk_alg == MBEDTLS_PK_RSASSA_PSS ) { - if( mbedtls_pk_get_size( pk ) >= profile->rsa_min_bitlen ) + if( mbedtls_pk_get_bitlen( pk ) >= profile->rsa_min_bitlen ) return( 0 ); return( -1 ); @@ -1438,7 +1438,7 @@ int mbedtls_x509_crt_info( char *buf, size_t size, const char *prefix, } ret = mbedtls_snprintf( p, n, "\n%s%-" BC "s: %d bits", prefix, key_size_str, - (int) mbedtls_pk_get_size( &crt->pk ) ); + (int) mbedtls_pk_get_bitlen( &crt->pk ) ); SAFE_SNPRINTF(); /* diff --git a/library/x509_csr.c b/library/x509_csr.c index d8ed04a9d..18ace678d 100644 --- a/library/x509_csr.c +++ b/library/x509_csr.c @@ -418,7 +418,7 @@ int mbedtls_x509_csr_info( char *buf, size_t size, const char *prefix, } ret = mbedtls_snprintf( p, n, "\n%s%-" BC "s: %d bits\n", prefix, key_size_str, - (int) mbedtls_pk_get_size( &csr->pk ) ); + (int) mbedtls_pk_get_bitlen( &csr->pk ) ); SAFE_SNPRINTF(); return( (int) ( size - n ) ); diff --git a/scripts/data_files/rename-1.3-2.0.txt b/scripts/data_files/rename-1.3-2.0.txt index bfe2eb2d7..3f773e3cd 100644 --- a/scripts/data_files/rename-1.3-2.0.txt +++ b/scripts/data_files/rename-1.3-2.0.txt @@ -37,8 +37,8 @@ BADCRL_NOT_TRUSTED MBEDTLS_X509_BADCRL_NOT_TRUSTED BLOWFISH_BLOCKSIZE MBEDTLS_BLOWFISH_BLOCKSIZE BLOWFISH_DECRYPT MBEDTLS_BLOWFISH_DECRYPT BLOWFISH_ENCRYPT MBEDTLS_BLOWFISH_ENCRYPT -BLOWFISH_MAX_KEY MBEDTLS_BLOWFISH_MAX_KEY -BLOWFISH_MIN_KEY MBEDTLS_BLOWFISH_MIN_KEY +BLOWFISH_MAX_KEY MBEDTLS_BLOWFISH_MAX_KEY_BITS +BLOWFISH_MIN_KEY MBEDTLS_BLOWFISH_MIN_KEY_BITS BLOWFISH_ROUNDS MBEDTLS_BLOWFISH_ROUNDS CAMELLIA_DECRYPT MBEDTLS_CAMELLIA_DECRYPT CAMELLIA_ENCRYPT MBEDTLS_CAMELLIA_ENCRYPT @@ -1390,7 +1390,7 @@ cipher_free_ctx mbedtls_cipher_free_ctx cipher_get_block_size mbedtls_cipher_get_block_size cipher_get_cipher_mode mbedtls_cipher_get_cipher_mode cipher_get_iv_size mbedtls_cipher_get_iv_size -cipher_get_key_size mbedtls_cipher_get_key_size +cipher_get_key_size mbedtls_cipher_get_key_bitlen cipher_get_name mbedtls_cipher_get_name cipher_get_operation mbedtls_cipher_get_operation cipher_get_type mbedtls_cipher_get_type @@ -1752,7 +1752,7 @@ pk_encrypt mbedtls_pk_encrypt pk_free mbedtls_pk_free pk_get_len mbedtls_pk_get_len pk_get_name mbedtls_pk_get_name -pk_get_size mbedtls_pk_get_size +pk_get_size mbedtls_pk_get_bitlen pk_get_type mbedtls_pk_get_type pk_info_from_type mbedtls_pk_info_from_type pk_info_t mbedtls_pk_info_t diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function index aab26f4bc..08a262346 100644 --- a/tests/suites/test_suite_pk.function +++ b/tests/suites/test_suite_pk.function @@ -75,7 +75,7 @@ void pk_utils( int type, int size, int len, char *name ) TEST_ASSERT( (int) mbedtls_pk_get_type( &pk ) == type ); TEST_ASSERT( mbedtls_pk_can_do( &pk, type ) ); - TEST_ASSERT( mbedtls_pk_get_size( &pk ) == (unsigned) size ); + TEST_ASSERT( mbedtls_pk_get_bitlen( &pk ) == (unsigned) size ); TEST_ASSERT( mbedtls_pk_get_len( &pk ) == (unsigned) len ); TEST_ASSERT( strcmp( mbedtls_pk_get_name( &pk), name ) == 0 ); @@ -453,7 +453,7 @@ void pk_rsa_alt( ) /* Test administrative functions */ TEST_ASSERT( mbedtls_pk_can_do( &alt, MBEDTLS_PK_RSA ) ); - TEST_ASSERT( mbedtls_pk_get_size( &alt ) == RSA_KEY_SIZE ); + TEST_ASSERT( mbedtls_pk_get_bitlen( &alt ) == RSA_KEY_SIZE ); TEST_ASSERT( mbedtls_pk_get_len( &alt ) == RSA_KEY_LEN ); TEST_ASSERT( mbedtls_pk_get_type( &alt ) == MBEDTLS_PK_RSA_ALT ); TEST_ASSERT( strcmp( mbedtls_pk_get_name( &alt ), "RSA-alt" ) == 0 );