Use safer names for macros

This commit is contained in:
Manuel Pégourié-Gonnard 2014-01-30 19:36:22 +01:00
parent 6e897c2a59
commit efc8d8078b
2 changed files with 17 additions and 17 deletions

View file

@ -37,13 +37,13 @@
#define POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG -0x0038 /**< Input too large (Entropy + additional). */
#define POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR -0x003A /**< Read/write error in file. */
#define HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */
#define HMAC_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */
#define HMAC_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */
#define HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */
#define POLARSSL_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */
#define POLARSSL_HMAC_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */
#define POLARSSL_HMAC_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */
#define POLARSSL_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */
#define HMAC_DRBG_PR_OFF 0 /**< No prediction resistance */
#define HMAC_DRBG_PR_ON 1 /**< Prediction resistance enabled */
#define POLARSSL_HMAC_DRBG_PR_OFF 0 /**< No prediction resistance */
#define POLARSSL_HMAC_DRBG_PR_ON 1 /**< Prediction resistance enabled */
#ifdef __cplusplus
extern "C" {
@ -125,7 +125,7 @@ int hmac_drbg_init_buf( hmac_drbg_context *ctx,
* Only use this if you have ample supply of good entropy!
*
* \param ctx HMAC_DRBG context
* \param resistance HMAC_DRBG_PR_ON or HMAC_DRBG_PR_OFF
* \param resistance POLARSSL_HMAC_DRBG_PR_ON or POLARSSL_HMAC_DRBG_PR_OFF
*/
void hmac_drbg_set_prediction_resistance( hmac_drbg_context *ctx,
int resistance );
@ -143,7 +143,7 @@ void hmac_drbg_set_entropy_len( hmac_drbg_context *ctx,
/**
* \brief Set the reseed interval
* (Default: HMAC_DRBG_RESEED_INTERVAL)
* (Default: POLARSSL_HMAC_DRBG_RESEED_INTERVAL)
*
* \param ctx HMAC_DRBG context
* \param interval Reseed interval

View file

@ -90,17 +90,17 @@ int hmac_drbg_init_buf( hmac_drbg_context *ctx,
int hmac_drbg_reseed( hmac_drbg_context *ctx,
const unsigned char *additional, size_t len )
{
unsigned char seed[HMAC_DRBG_MAX_SEED_INPUT];
unsigned char seed[POLARSSL_HMAC_DRBG_MAX_SEED_INPUT];
size_t seedlen;
/* III. Check input length */
if( len > HMAC_DRBG_MAX_INPUT ||
ctx->entropy_len + len > HMAC_DRBG_MAX_SEED_INPUT )
if( len > POLARSSL_HMAC_DRBG_MAX_INPUT ||
ctx->entropy_len + len > POLARSSL_HMAC_DRBG_MAX_SEED_INPUT )
{
return( POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG );
}
memset( seed, 0, HMAC_DRBG_MAX_SEED_INPUT );
memset( seed, 0, POLARSSL_HMAC_DRBG_MAX_SEED_INPUT );
/* IV. Gather entropy_len bytes of entropy for the seed */
if( ctx->f_entropy( ctx->p_entropy, seed, ctx->entropy_len ) != 0 )
@ -150,7 +150,7 @@ int hmac_drbg_init( hmac_drbg_context *ctx,
ctx->f_entropy = f_entropy;
ctx->p_entropy = p_entropy;
ctx->reseed_interval = HMAC_DRBG_RESEED_INTERVAL;
ctx->reseed_interval = POLARSSL_HMAC_DRBG_RESEED_INTERVAL;
/*
* See SP800-57 5.6.1 (p. 65-66) for the security strength provided by
@ -217,16 +217,16 @@ int hmac_drbg_random_with_add( void *p_rng,
unsigned char *out = output;
/* II. Check request length */
if( out_len > HMAC_DRBG_MAX_REQUEST )
if( out_len > POLARSSL_HMAC_DRBG_MAX_REQUEST )
return( POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG );
/* III. Check input length */
if( add_len > HMAC_DRBG_MAX_INPUT )
if( add_len > POLARSSL_HMAC_DRBG_MAX_INPUT )
return( POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG );
/* 1. (aka VII and IX) Check reseed counter and PR */
if( ctx->f_entropy != NULL &&
( ctx->prediction_resistance == HMAC_DRBG_PR_ON ||
if( ctx->f_entropy != NULL && /* For no-reseeding instances */
( ctx->prediction_resistance == POLARSSL_HMAC_DRBG_PR_ON ||
ctx->reseed_counter > ctx->reseed_interval ) )
{
if( ( ret = hmac_drbg_reseed( ctx, additional, add_len ) ) != 0 )