- Added support for PKCS#1 v2.1 encoding and thus support for the RSAES-OAEP and RSASSA-PSS operations (enabled by POLARSSL_PKCS1_V21)

This commit is contained in:
Paul Bakker 2011-03-08 14:16:06 +00:00
parent fea43a2501
commit 9dcc32236b
16 changed files with 1884 additions and 123 deletions

View file

@ -55,3 +55,68 @@ void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
len--;
}
}
/**
* This function just returns data from rand().
*
* rng_state shall be NULL.
*/
static int rnd_std_rand( void *rng_state )
{
if( rng_state != NULL )
rng_state = NULL;
return( rand() );
}
/**
* This function only returns zeros
*
* rng_state shall be NULL.
*/
static int rnd_zero_rand( void *rng_state )
{
if( rng_state != NULL )
rng_state = NULL;
return( 0 );
}
typedef struct
{
unsigned char *buf;
int length;
int per_call;
} rnd_info;
/**
* This function returns random based on a buffer it receives.
*
* rng_state shall be a pointer to a rnd_buf structure.
*
* After the buffer is empty it will return rand();
*/
static int rnd_buffer_rand( void *rng_state )
{
rnd_info *info = (rnd_info *) rng_state;
int res;
if( rng_state == NULL )
return( rand() );
res = rand();
if( info->length >= info->per_call )
{
memcpy( &res, info->buf, info->per_call );
info->buf += info->per_call;
info->length -= info->per_call;
}
else if( info->length > 0 )
{
memcpy( &res, info->buf, info->length );
info->length = 0;
}
return( res );
}