mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 08:16:33 +01:00
- 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:
parent
fea43a2501
commit
9dcc32236b
16 changed files with 1884 additions and 123 deletions
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue