The Great Renaming

A simple execution of tmp/invoke-rename.pl
This commit is contained in:
Manuel Pégourié-Gonnard 2015-04-08 12:49:31 +02:00
parent b5904d25ef
commit 2cf5a7c98e
291 changed files with 36012 additions and 36012 deletions
library

View file

@ -20,35 +20,35 @@
* 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_PK_C)
#if defined(MBEDTLS_PK_C)
#include "mbedtls/pk.h"
#include "mbedtls/pk_wrap.h"
#if defined(POLARSSL_RSA_C)
#if defined(MBEDTLS_RSA_C)
#include "mbedtls/rsa.h"
#endif
#if defined(POLARSSL_ECP_C)
#if defined(MBEDTLS_ECP_C)
#include "mbedtls/ecp.h"
#endif
#if defined(POLARSSL_ECDSA_C)
#if defined(MBEDTLS_ECDSA_C)
#include "mbedtls/ecdsa.h"
#endif
/* Implementation that should never be optimized out by the compiler */
static void polarssl_zeroize( void *v, size_t n ) {
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
}
/*
* Initialise a pk_context
* Initialise a mbedtls_pk_context
*/
void pk_init( pk_context *ctx )
void mbedtls_pk_init( mbedtls_pk_context *ctx )
{
if( ctx == NULL )
return;
@ -58,39 +58,39 @@ void pk_init( pk_context *ctx )
}
/*
* Free (the components of) a pk_context
* Free (the components of) a mbedtls_pk_context
*/
void pk_free( pk_context *ctx )
void mbedtls_pk_free( mbedtls_pk_context *ctx )
{
if( ctx == NULL || ctx->pk_info == NULL )
return;
ctx->pk_info->ctx_free_func( ctx->pk_ctx );
polarssl_zeroize( ctx, sizeof( pk_context ) );
mbedtls_zeroize( ctx, sizeof( mbedtls_pk_context ) );
}
/*
* Get pk_info structure from type
*/
const pk_info_t * pk_info_from_type( pk_type_t pk_type )
const mbedtls_pk_info_t * mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type )
{
switch( pk_type ) {
#if defined(POLARSSL_RSA_C)
case POLARSSL_PK_RSA:
return( &rsa_info );
#if defined(MBEDTLS_RSA_C)
case MBEDTLS_PK_RSA:
return( &mbedtls_rsa_info );
#endif
#if defined(POLARSSL_ECP_C)
case POLARSSL_PK_ECKEY:
return( &eckey_info );
case POLARSSL_PK_ECKEY_DH:
return( &eckeydh_info );
#if defined(MBEDTLS_ECP_C)
case MBEDTLS_PK_ECKEY:
return( &mbedtls_eckey_info );
case MBEDTLS_PK_ECKEY_DH:
return( &mbedtls_eckeydh_info );
#endif
#if defined(POLARSSL_ECDSA_C)
case POLARSSL_PK_ECDSA:
return( &ecdsa_info );
#if defined(MBEDTLS_ECDSA_C)
case MBEDTLS_PK_ECDSA:
return( &mbedtls_ecdsa_info );
#endif
/* POLARSSL_PK_RSA_ALT omitted on purpose */
/* MBEDTLS_PK_RSA_ALT omitted on purpose */
default:
return( NULL );
}
@ -99,40 +99,40 @@ const pk_info_t * pk_info_from_type( pk_type_t pk_type )
/*
* Initialise context
*/
int pk_init_ctx( pk_context *ctx, const pk_info_t *info )
int mbedtls_pk_init_ctx( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info )
{
if( ctx == NULL || info == NULL || ctx->pk_info != NULL )
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL )
return( POLARSSL_ERR_PK_MALLOC_FAILED );
return( MBEDTLS_ERR_PK_MALLOC_FAILED );
ctx->pk_info = info;
return( 0 );
}
#if defined(POLARSSL_PK_RSA_ALT_SUPPORT)
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
/*
* Initialize an RSA-alt context
*/
int pk_init_ctx_rsa_alt( pk_context *ctx, void * key,
pk_rsa_alt_decrypt_func decrypt_func,
pk_rsa_alt_sign_func sign_func,
pk_rsa_alt_key_len_func key_len_func )
int mbedtls_pk_init_ctx_rsa_alt( mbedtls_pk_context *ctx, void * key,
mbedtls_pk_rsa_alt_decrypt_func decrypt_func,
mbedtls_pk_rsa_alt_sign_func sign_func,
mbedtls_pk_rsa_alt_key_len_func key_len_func )
{
rsa_alt_context *rsa_alt;
const pk_info_t *info = &rsa_alt_info;
mbedtls_rsa_alt_context *rsa_alt;
const mbedtls_pk_info_t *info = &mbedtls_rsa_alt_info;
if( ctx == NULL || ctx->pk_info != NULL )
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL )
return( POLARSSL_ERR_PK_MALLOC_FAILED );
return( MBEDTLS_ERR_PK_MALLOC_FAILED );
ctx->pk_info = info;
rsa_alt = (rsa_alt_context *) ctx->pk_ctx;
rsa_alt = (mbedtls_rsa_alt_context *) ctx->pk_ctx;
rsa_alt->key = key;
rsa_alt->decrypt_func = decrypt_func;
@ -141,12 +141,12 @@ int pk_init_ctx_rsa_alt( pk_context *ctx, void * key,
return( 0 );
}
#endif /* POLARSSL_PK_RSA_ALT_SUPPORT */
#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */
/*
* Tell if a PK can do the operations of the given type
*/
int pk_can_do( const pk_context *ctx, pk_type_t type )
int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type )
{
/* null or NONE context can't do anything */
if( ctx == NULL || ctx->pk_info == NULL )
@ -156,35 +156,35 @@ int pk_can_do( const pk_context *ctx, pk_type_t type )
}
/*
* Helper for pk_sign and pk_verify
* Helper for mbedtls_pk_sign and mbedtls_pk_verify
*/
static inline int pk_hashlen_helper( md_type_t md_alg, size_t *hash_len )
static inline int pk_hashlen_helper( mbedtls_md_type_t md_alg, size_t *hash_len )
{
const md_info_t *md_info;
const mbedtls_md_info_t *md_info;
if( *hash_len != 0 )
return( 0 );
if( ( md_info = md_info_from_type( md_alg ) ) == NULL )
if( ( md_info = mbedtls_md_info_from_type( md_alg ) ) == NULL )
return( -1 );
*hash_len = md_get_size( md_info );
*hash_len = mbedtls_md_get_size( md_info );
return( 0 );
}
/*
* Verify a signature
*/
int pk_verify( pk_context *ctx, md_type_t md_alg,
int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
const unsigned char *sig, size_t sig_len )
{
if( ctx == NULL || ctx->pk_info == NULL ||
pk_hashlen_helper( md_alg, &hash_len ) != 0 )
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
if( ctx->pk_info->verify_func == NULL )
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
return( ctx->pk_info->verify_func( ctx->pk_ctx, md_alg, hash, hash_len,
sig, sig_len ) );
@ -193,33 +193,33 @@ int pk_verify( pk_context *ctx, md_type_t md_alg,
/*
* Verify a signature with options
*/
int pk_verify_ext( pk_type_t type, const void *options,
pk_context *ctx, md_type_t md_alg,
int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options,
mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
const unsigned char *sig, size_t sig_len )
{
if( ctx == NULL || ctx->pk_info == NULL )
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
if( ! pk_can_do( ctx, type ) )
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
if( ! mbedtls_pk_can_do( ctx, type ) )
return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
if( type == POLARSSL_PK_RSASSA_PSS )
if( type == MBEDTLS_PK_RSASSA_PSS )
{
#if defined(POLARSSL_RSA_C) && defined(POLARSSL_PKCS1_V21)
#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_PKCS1_V21)
int ret;
const pk_rsassa_pss_options *pss_opts;
const mbedtls_pk_rsassa_pss_options *pss_opts;
if( options == NULL )
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
pss_opts = (const pk_rsassa_pss_options *) options;
pss_opts = (const mbedtls_pk_rsassa_pss_options *) options;
if( sig_len < pk_get_len( ctx ) )
return( POLARSSL_ERR_RSA_VERIFY_FAILED );
if( sig_len < mbedtls_pk_get_len( ctx ) )
return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
ret = rsa_rsassa_pss_verify_ext( pk_rsa( *ctx ),
NULL, NULL, RSA_PUBLIC,
ret = mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_pk_rsa( *ctx ),
NULL, NULL, MBEDTLS_RSA_PUBLIC,
md_alg, (unsigned int) hash_len, hash,
pss_opts->mgf1_hash_id,
pss_opts->expected_salt_len,
@ -227,36 +227,36 @@ int pk_verify_ext( pk_type_t type, const void *options,
if( ret != 0 )
return( ret );
if( sig_len > pk_get_len( ctx ) )
return( POLARSSL_ERR_PK_SIG_LEN_MISMATCH );
if( sig_len > mbedtls_pk_get_len( ctx ) )
return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH );
return( 0 );
#else
return( POLARSSL_ERR_PK_FEATURE_UNAVAILABLE );
return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
#endif
}
/* General case: no options */
if( options != NULL )
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
return( pk_verify( ctx, md_alg, hash, hash_len, sig, sig_len ) );
return( mbedtls_pk_verify( ctx, md_alg, hash, hash_len, sig, sig_len ) );
}
/*
* Make a signature
*/
int pk_sign( pk_context *ctx, md_type_t md_alg,
int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
unsigned char *sig, size_t *sig_len,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
if( ctx == NULL || ctx->pk_info == NULL ||
pk_hashlen_helper( md_alg, &hash_len ) != 0 )
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
if( ctx->pk_info->sign_func == NULL )
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
return( ctx->pk_info->sign_func( ctx->pk_ctx, md_alg, hash, hash_len,
sig, sig_len, f_rng, p_rng ) );
@ -265,16 +265,16 @@ int pk_sign( pk_context *ctx, md_type_t md_alg,
/*
* Decrypt message
*/
int pk_decrypt( pk_context *ctx,
int mbedtls_pk_decrypt( mbedtls_pk_context *ctx,
const unsigned char *input, size_t ilen,
unsigned char *output, size_t *olen, size_t osize,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
if( ctx == NULL || ctx->pk_info == NULL )
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
if( ctx->pk_info->decrypt_func == NULL )
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
return( ctx->pk_info->decrypt_func( ctx->pk_ctx, input, ilen,
output, olen, osize, f_rng, p_rng ) );
@ -283,16 +283,16 @@ int pk_decrypt( pk_context *ctx,
/*
* Encrypt message
*/
int pk_encrypt( pk_context *ctx,
int mbedtls_pk_encrypt( mbedtls_pk_context *ctx,
const unsigned char *input, size_t ilen,
unsigned char *output, size_t *olen, size_t osize,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
if( ctx == NULL || ctx->pk_info == NULL )
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
if( ctx->pk_info->encrypt_func == NULL )
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
return( ctx->pk_info->encrypt_func( ctx->pk_ctx, input, ilen,
output, olen, osize, f_rng, p_rng ) );
@ -301,24 +301,24 @@ int pk_encrypt( pk_context *ctx,
/*
* Check public-private key pair
*/
int pk_check_pair( const pk_context *pub, const pk_context *prv )
int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_context *prv )
{
if( pub == NULL || pub->pk_info == NULL ||
prv == NULL || prv->pk_info == NULL ||
prv->pk_info->check_pair_func == NULL )
{
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
}
if( prv->pk_info->type == POLARSSL_PK_RSA_ALT )
if( prv->pk_info->type == MBEDTLS_PK_RSA_ALT )
{
if( pub->pk_info->type != POLARSSL_PK_RSA )
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
if( pub->pk_info->type != MBEDTLS_PK_RSA )
return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
}
else
{
if( pub->pk_info != prv->pk_info )
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
}
return( prv->pk_info->check_pair_func( pub->pk_ctx, prv->pk_ctx ) );
@ -327,7 +327,7 @@ int pk_check_pair( const pk_context *pub, const pk_context *prv )
/*
* Get key size in bits
*/
size_t pk_get_size( const pk_context *ctx )
size_t mbedtls_pk_get_size( const mbedtls_pk_context *ctx )
{
if( ctx == NULL || ctx->pk_info == NULL )
return( 0 );
@ -338,13 +338,13 @@ size_t pk_get_size( const pk_context *ctx )
/*
* Export debug information
*/
int pk_debug( const pk_context *ctx, pk_debug_item *items )
int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items )
{
if( ctx == NULL || ctx->pk_info == NULL )
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
if( ctx->pk_info->debug_func == NULL )
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
ctx->pk_info->debug_func( ctx->pk_ctx, items );
return( 0 );
@ -353,7 +353,7 @@ int pk_debug( const pk_context *ctx, pk_debug_item *items )
/*
* Access the PK type name
*/
const char *pk_get_name( const pk_context *ctx )
const char *mbedtls_pk_get_name( const mbedtls_pk_context *ctx )
{
if( ctx == NULL || ctx->pk_info == NULL )
return( "invalid PK" );
@ -364,12 +364,12 @@ const char *pk_get_name( const pk_context *ctx )
/*
* Access the PK type
*/
pk_type_t pk_get_type( const pk_context *ctx )
mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx )
{
if( ctx == NULL || ctx->pk_info == NULL )
return( POLARSSL_PK_NONE );
return( MBEDTLS_PK_NONE );
return( ctx->pk_info->type );
}
#endif /* POLARSSL_PK_C */
#endif /* MBEDTLS_PK_C */