Commit abb67446 authored by Manuel Pégourié-Gonnard's avatar Manuel Pégourié-Gonnard
Browse files

Rename md_init_ctx() to md_setup()

parent d4b91732
......@@ -12,7 +12,7 @@
* for authentication, which is a message integrity control.
*
* All hash algorithms can be accessed via the generic MD layer (see
* \c md_init_ctx())
* \c md_setup())
*
* The following hashing-algorithms are provided:
* - MD2, MD4, MD5 128-bit one-way hash functions by Ron Rivest.
......
......@@ -140,7 +140,7 @@ void md_free( md_context_t *ctx );
* parameter failure, \c POLARSSL_ERR_MD_ALLOC_FAILED if
* allocation of the digest-specific context failed.
*/
int md_init_ctx( md_context_t *ctx, const md_info_t *md_info, int hmac );
int md_setup( md_context_t *ctx, const md_info_t *md_info, int hmac );
/**
* \brief Returns the size of the message digest output.
......
......@@ -97,7 +97,7 @@ int hmac_drbg_init_buf( hmac_drbg_context *ctx,
md_init( &ctx->md_ctx );
if( ( ret = md_init_ctx( &ctx->md_ctx, md_info, 1 ) ) != 0 )
if( ( ret = md_setup( &ctx->md_ctx, md_info, 1 ) ) != 0 )
return( ret );
/*
......@@ -171,7 +171,7 @@ int hmac_drbg_init( hmac_drbg_context *ctx,
md_init( &ctx->md_ctx );
if( ( ret = md_init_ctx( &ctx->md_ctx, md_info, 1 ) ) != 0 )
if( ( ret = md_setup( &ctx->md_ctx, md_info, 1 ) ) != 0 )
return( ret );
md_size = md_get_size( md_info );
......
......@@ -199,7 +199,7 @@ void md_free( md_context_t *ctx )
polarssl_zeroize( ctx, sizeof( md_context_t ) );
}
int md_init_ctx( md_context_t *ctx, const md_info_t *md_info, int hmac )
int md_setup( md_context_t *ctx, const md_info_t *md_info, int hmac )
{
if( md_info == NULL || ctx == NULL )
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
......@@ -381,7 +381,7 @@ int md_hmac( const md_info_t *md_info, const unsigned char *key, size_t keylen,
md_init( &ctx );
if( ( ret = md_init_ctx( &ctx, md_info, 1 ) ) != 0 )
if( ( ret = md_setup( &ctx, md_info, 1 ) ) != 0 )
return( ret );
md_hmac_starts( &ctx, key, keylen );
......
......@@ -268,7 +268,7 @@ int pkcs12_derivation( unsigned char *data, size_t datalen,
md_init( &md_ctx );
if( ( ret = md_init_ctx( &md_ctx, md_info, 0 ) ) != 0 )
if( ( ret = md_setup( &md_ctx, md_info, 0 ) ) != 0 )
return( ret );
hlen = md_get_size( md_info );
......
......@@ -189,7 +189,7 @@ int pkcs5_pbes2( const asn1_buf *pbe_params, int mode,
memcpy( iv, enc_scheme_params.p, enc_scheme_params.len );
if( ( ret = md_init_ctx( &md_ctx, md_info, 1 ) ) != 0 )
if( ( ret = md_setup( &md_ctx, md_info, 1 ) ) != 0 )
goto exit;
if( ( ret = pkcs5_pbkdf2_hmac( &md_ctx, pwd, pwdlen, salt.p, salt.len,
......@@ -365,7 +365,7 @@ int pkcs5_self_test( int verbose )
goto exit;
}
if( ( ret = md_init_ctx( &sha1_ctx, info_sha1, 1 ) ) != 0 )
if( ( ret = md_setup( &sha1_ctx, info_sha1, 1 ) ) != 0 )
{
ret = 1;
goto exit;
......
......@@ -556,7 +556,7 @@ int rsa_rsaes_oaep_encrypt( rsa_context *ctx,
memcpy( p, input, ilen );
md_init( &md_ctx );
md_init_ctx( &md_ctx, md_info, 0 );
md_setup( &md_ctx, md_info, 0 );
// maskedDB: Apply dbMask to DB
//
......@@ -725,7 +725,7 @@ int rsa_rsaes_oaep_decrypt( rsa_context *ctx,
hlen = md_get_size( md_info );
md_init( &md_ctx );
md_init_ctx( &md_ctx, md_info, 0 );
md_setup( &md_ctx, md_info, 0 );
/* Generate lHash */
md( md_info, label, label_len, lhash );
......@@ -969,7 +969,7 @@ int rsa_rsassa_pss_sign( rsa_context *ctx,
p += slen;
md_init( &md_ctx );
md_init_ctx( &md_ctx, md_info, 0 );
md_setup( &md_ctx, md_info, 0 );
// Generate H = Hash( M' )
//
......@@ -1201,7 +1201,7 @@ int rsa_rsassa_pss_verify_ext( rsa_context *ctx,
return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
md_init( &md_ctx );
md_init_ctx( &md_ctx, md_info, 0 );
md_setup( &md_ctx, md_info, 0 );
mgf_mask( p, siglen - hlen - 1, p + siglen - hlen - 1, hlen, &md_ctx );
......
......@@ -2172,10 +2172,10 @@ static int ssl_parse_server_key_exchange( ssl_context *ssl )
* ServerDHParams params;
* };
*/
if( ( ret = md_init_ctx( &ctx,
if( ( ret = md_setup( &ctx,
md_info_from_type( md_alg ), 0 ) ) != 0 )
{
SSL_DEBUG_RET( 1, "md_init_ctx", ret );
SSL_DEBUG_RET( 1, "md_setup", ret );
return( ret );
}
......
......@@ -104,7 +104,7 @@ int ssl_cookie_setup( ssl_cookie_ctx *ctx,
if( ( ret = f_rng( p_rng, key, sizeof( key ) ) ) != 0 )
return( ret );
ret = md_init_ctx( &ctx->hmac_ctx, md_info_from_type( COOKIE_MD ), 1 );
ret = md_setup( &ctx->hmac_ctx, md_info_from_type( COOKIE_MD ), 1 );
if( ret != 0 )
return( ret );
......
......@@ -3073,9 +3073,9 @@ curve_matching_done:
* ServerDHParams params;
* };
*/
if( ( ret = md_init_ctx( &ctx, md_info, 0 ) ) != 0 )
if( ( ret = md_setup( &ctx, md_info, 0 ) ) != 0 )
{
SSL_DEBUG_RET( 1, "md_init_ctx", ret );
SSL_DEBUG_RET( 1, "md_setup", ret );
return( ret );
}
......
......@@ -658,10 +658,10 @@ int ssl_derive_keys( ssl_context *ssl )
int ret;
/* Initialize HMAC contexts */
if( ( ret = md_init_ctx( &transform->md_ctx_enc, md_info, 1 ) ) != 0 ||
( ret = md_init_ctx( &transform->md_ctx_dec, md_info, 1 ) ) != 0 )
if( ( ret = md_setup( &transform->md_ctx_enc, md_info, 1 ) ) != 0 ||
( ret = md_setup( &transform->md_ctx_dec, md_info, 1 ) ) != 0 )
{
SSL_DEBUG_RET( 1, "md_init_ctx", ret );
SSL_DEBUG_RET( 1, "md_setup", ret );
return( ret );
}
......
......@@ -101,10 +101,10 @@ int main( int argc, char *argv[] )
aes_init( &aes_ctx );
md_init( &sha_ctx );
ret = md_init_ctx( &sha_ctx, md_info_from_type( POLARSSL_MD_SHA256 ), 1 );
ret = md_setup( &sha_ctx, md_info_from_type( POLARSSL_MD_SHA256 ), 1 );
if( ret != 0 )
{
polarssl_printf( " ! md_init_ctx() returned -0x%04x\n", -ret );
polarssl_printf( " ! md_setup() returned -0x%04x\n", -ret );
goto exit;
}
......
......@@ -185,7 +185,7 @@ int main( int argc, char *argv[] )
polarssl_fprintf( stderr, "Message Digest '%s' not found\n", argv[5] );
goto exit;
}
md_init_ctx( &md_ctx, md_info, 1 );
md_setup( &md_ctx, md_info, 1 );
/*
* Read the secret key and clean the command line.
......
......@@ -204,7 +204,7 @@ int main( int argc, char *argv[] )
polarssl_fprintf( stderr, "Message Digest '%s' not found\n", argv[1] );
return( 1 );
}
if( md_init_ctx( &md_ctx, md_info, 0 ) )
if( md_setup( &md_ctx, md_info, 0 ) )
{
polarssl_fprintf( stderr, "Failed to initialize context.\n" );
return( 1 );
......
......@@ -29,7 +29,7 @@ void md_process( )
{
info = md_info_from_type( *md_type_ptr );
TEST_ASSERT( info != NULL );
TEST_ASSERT( md_init_ctx( &ctx, info, 0 ) == 0 );
TEST_ASSERT( md_setup( &ctx, info, 0 ) == 0 );
TEST_ASSERT( md_process( &ctx, buf ) == 0 );
md_free( &ctx );
}
......@@ -54,8 +54,8 @@ void md_null_args( )
TEST_ASSERT( md_info_from_string( NULL ) == NULL );
TEST_ASSERT( md_init_ctx( &ctx, NULL, 0 ) == POLARSSL_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( md_init_ctx( NULL, info, 0 ) == POLARSSL_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( md_setup( &ctx, NULL, 0 ) == POLARSSL_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( md_setup( NULL, info, 0 ) == POLARSSL_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( md_starts( NULL ) == POLARSSL_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( md_starts( &ctx ) == POLARSSL_ERR_MD_BAD_INPUT_DATA );
......@@ -195,7 +195,7 @@ void md_text_multi( char *text_md_name, char *text_src_string,
strncpy( (char *) md_name, text_md_name, sizeof(md_name) - 1 );
md_info = md_info_from_string(md_name);
TEST_ASSERT( md_info != NULL );
TEST_ASSERT ( 0 == md_init_ctx( &ctx, md_info, 0 ) );
TEST_ASSERT ( 0 == md_setup( &ctx, md_info, 0 ) );
TEST_ASSERT ( 0 == md_starts( &ctx ) );
TEST_ASSERT ( ctx.md_ctx != NULL );
......@@ -233,7 +233,7 @@ void md_hex_multi( char *text_md_name, char *hex_src_string,
strncpy( (char *) md_name, text_md_name, sizeof(md_name) - 1 );
md_info = md_info_from_string(md_name);
TEST_ASSERT( md_info != NULL );
TEST_ASSERT ( 0 == md_init_ctx( &ctx, md_info, 0 ) );
TEST_ASSERT ( 0 == md_setup( &ctx, md_info, 0 ) );
src_len = unhexify( src_str, hex_src_string );
......@@ -307,7 +307,7 @@ void md_hmac_multi( char *text_md_name, int trunc_size, char *hex_key_string,
strncpy( (char *) md_name, text_md_name, sizeof(md_name) - 1 );
md_info = md_info_from_string( md_name );
TEST_ASSERT( md_info != NULL );
TEST_ASSERT ( 0 == md_init_ctx( &ctx, md_info, 1 ) );
TEST_ASSERT ( 0 == md_setup( &ctx, md_info, 1 ) );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
......
......@@ -36,7 +36,7 @@ void pbkdf2_hmac( int hash, char *hex_password_string,
TEST_ASSERT( info != NULL );
if( info == NULL )
return;
TEST_ASSERT( md_init_ctx( &ctx, info, 1 ) == 0 );
TEST_ASSERT( md_setup( &ctx, info, 1 ) == 0 );
TEST_ASSERT( pkcs5_pbkdf2_hmac( &ctx, pw_str, pw_len, salt_str, salt_len,
it_cnt, key_len, key ) == 0 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment