Rm mbedtls_ prefix form static functions

- prefix is no necessary for static ids and makes lines longer
- most often omitted (even though we're not fully consistent)
This commit is contained in:
Manuel Pégourié-Gonnard 2018-05-24 16:52:19 +02:00
parent c22e61a081
commit 9620f9b99e
3 changed files with 36 additions and 43 deletions

View File

@ -76,11 +76,11 @@
* \param c The index of 'c' in the state.
* \param d The index of 'd' in the state.
*/
static inline void mbedtls_chacha20_quarter_round( uint32_t state[16],
size_t a,
size_t b,
size_t c,
size_t d )
static inline void chacha20_quarter_round( uint32_t state[16],
size_t a,
size_t b,
size_t c,
size_t d )
{
/* a += b; d ^= a; d <<<= 16; */
state[a] += state[b];
@ -111,17 +111,17 @@ static inline void mbedtls_chacha20_quarter_round( uint32_t state[16],
*
* \param state The ChaCha20 state to update.
*/
static void mbedtls_chacha20_inner_block( uint32_t state[16] )
static void chacha20_inner_block( uint32_t state[16] )
{
mbedtls_chacha20_quarter_round( state, 0, 4, 8, 12 );
mbedtls_chacha20_quarter_round( state, 1, 5, 9, 13 );
mbedtls_chacha20_quarter_round( state, 2, 6, 10, 14 );
mbedtls_chacha20_quarter_round( state, 3, 7, 11, 15 );
chacha20_quarter_round( state, 0, 4, 8, 12 );
chacha20_quarter_round( state, 1, 5, 9, 13 );
chacha20_quarter_round( state, 2, 6, 10, 14 );
chacha20_quarter_round( state, 3, 7, 11, 15 );
mbedtls_chacha20_quarter_round( state, 0, 5, 10, 15 );
mbedtls_chacha20_quarter_round( state, 1, 6, 11, 12 );
mbedtls_chacha20_quarter_round( state, 2, 7, 8, 13 );
mbedtls_chacha20_quarter_round( state, 3, 4, 9, 14 );
chacha20_quarter_round( state, 0, 5, 10, 15 );
chacha20_quarter_round( state, 1, 6, 11, 12 );
chacha20_quarter_round( state, 2, 7, 8, 13 );
chacha20_quarter_round( state, 3, 4, 9, 14 );
}
/**
@ -131,9 +131,9 @@ static void mbedtls_chacha20_inner_block( uint32_t state[16] )
* \param working_state This state is used as a temporary working area.
* \param keystream Generated keystream bytes are written to this buffer.
*/
static void mbedtls_chacha20_block( const uint32_t initial_state[16],
uint32_t working_state[16],
unsigned char keystream[64] )
static void chacha20_block( const uint32_t initial_state[16],
uint32_t working_state[16],
unsigned char keystream[64] )
{
size_t i;
size_t offset;
@ -143,9 +143,7 @@ static void mbedtls_chacha20_block( const uint32_t initial_state[16],
CHACHA20_BLOCK_SIZE_BYTES );
for ( i = 0U; i < 10U; i++ )
{
mbedtls_chacha20_inner_block( working_state );
}
chacha20_inner_block( working_state );
working_state[0] += initial_state[0];
working_state[1] += initial_state[1];
@ -281,7 +279,7 @@ int mbedtls_chacha20_update( mbedtls_chacha20_context *ctx,
while ( size >= CHACHA20_BLOCK_SIZE_BYTES )
{
/* Generate new keystream block and increment counter */
mbedtls_chacha20_block( ctx->initial_state, ctx->working_state, ctx->keystream8 );
chacha20_block( ctx->initial_state, ctx->working_state, ctx->keystream8 );
ctx->initial_state[CHACHA20_CTR_INDEX]++;
for ( i = 0U; i < 64U; i += 8U )
@ -304,7 +302,7 @@ int mbedtls_chacha20_update( mbedtls_chacha20_context *ctx,
if ( size > 0U )
{
/* Generate new keystream block and increment counter */
mbedtls_chacha20_block( ctx->initial_state, ctx->working_state, ctx->keystream8 );
chacha20_block( ctx->initial_state, ctx->working_state, ctx->keystream8 );
ctx->initial_state[CHACHA20_CTR_INDEX]++;
for ( i = 0U; i < size; i++)

View File

@ -54,7 +54,7 @@
*
* \param ctx The ChaCha20-Poly1305 context.
*/
static void mbedtls_chachapoly_pad_aad( mbedtls_chachapoly_context *ctx )
static void chachapoly_pad_aad( mbedtls_chachapoly_context *ctx )
{
uint32_t partial_block_len = (uint32_t) ( ctx->aad_len % 16U );
unsigned char zeroes[15];
@ -73,7 +73,7 @@ static void mbedtls_chachapoly_pad_aad( mbedtls_chachapoly_context *ctx )
*
* \param ctx The ChaCha20-Poly1305 context.
*/
static void mbedtls_chachapoly_pad_ciphertext( mbedtls_chachapoly_context *ctx )
static void chachapoly_pad_ciphertext( mbedtls_chachapoly_context *ctx )
{
uint32_t partial_block_len = (uint32_t) ( ctx->ciphertext_len % 16U );
unsigned char zeroes[15];
@ -218,7 +218,7 @@ int mbedtls_chachapoly_update( mbedtls_chachapoly_context *ctx,
{
ctx->state = CHACHAPOLY_STATE_CIPHERTEXT;
mbedtls_chachapoly_pad_aad( ctx );
chachapoly_pad_aad( ctx );
}
ctx->ciphertext_len += len;
@ -257,11 +257,11 @@ int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx,
if ( ctx->state == CHACHAPOLY_STATE_AAD )
{
mbedtls_chachapoly_pad_aad( ctx );
chachapoly_pad_aad( ctx );
}
else if ( ctx->state == CHACHAPOLY_STATE_CIPHERTEXT )
{
mbedtls_chachapoly_pad_ciphertext( ctx );
chachapoly_pad_ciphertext( ctx );
}
ctx->state = CHACHAPOLY_STATE_FINISHED;

View File

@ -64,10 +64,10 @@
* to the input data before calling this function.
* Otherwise, set this parameter to 1.
*/
static void mbedtls_poly1305_process( mbedtls_poly1305_context *ctx,
size_t nblocks,
const unsigned char *input,
uint32_t needs_padding )
static void poly1305_process( mbedtls_poly1305_context *ctx,
size_t nblocks,
const unsigned char *input,
uint32_t needs_padding )
{
uint64_t d0, d1, d2, d3;
uint32_t acc0, acc1, acc2, acc3, acc4;
@ -167,8 +167,8 @@ static void mbedtls_poly1305_process( mbedtls_poly1305_context *ctx,
* \param mac The buffer to where the MAC is written. Must be
* big enough to contain the 16-byte MAC.
*/
static void mbedtls_poly1305_compute_mac( const mbedtls_poly1305_context *ctx,
unsigned char mac[16] )
static void poly1305_compute_mac( const mbedtls_poly1305_context *ctx,
unsigned char mac[16] )
{
uint64_t d;
uint32_t g0, g1, g2, g3, g4;
@ -330,10 +330,7 @@ int mbedtls_poly1305_update( mbedtls_poly1305_context *ctx,
ctx->queue_len = 0U;
mbedtls_poly1305_process( ctx,
1U,
ctx->queue,
1U ); /* add padding bit */
poly1305_process( ctx, 1U, ctx->queue, 1U ); /* add padding bit */
offset += queue_free_len;
remaining -= queue_free_len;
@ -344,7 +341,7 @@ int mbedtls_poly1305_update( mbedtls_poly1305_context *ctx,
{
nblocks = remaining / POLY1305_BLOCK_SIZE_BYTES;
mbedtls_poly1305_process( ctx, nblocks, &input[offset], 1U );
poly1305_process( ctx, nblocks, &input[offset], 1U );
offset += nblocks * POLY1305_BLOCK_SIZE_BYTES;
remaining %= POLY1305_BLOCK_SIZE_BYTES;
@ -380,13 +377,11 @@ int mbedtls_poly1305_finish( mbedtls_poly1305_context *ctx,
0,
POLY1305_BLOCK_SIZE_BYTES - ctx->queue_len );
mbedtls_poly1305_process( ctx,
1U, /* Process 1 block */
ctx->queue,
0U ); /* Don't add padding bit (it was just added above) */
poly1305_process( ctx, 1U, /* Process 1 block */
ctx->queue, 0U ); /* Don't add padding bit (it was just added above) */
}
mbedtls_poly1305_compute_mac( ctx, mac );
poly1305_compute_mac( ctx, mac );
return( 0 );
}