mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-03 01:13:37 +00:00
Removes mode param from mbedtls_rsa_pkcs1_encrypt
Removal of the mode parameter from mbedtls_rsa_pkcs1_encrypt function. This change is propagated throughout the codebase and to relevant tests. Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
This commit is contained in:
parent
c32e2b0921
commit
2177277dda
@ -571,12 +571,7 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
|
||||
* operation.
|
||||
*
|
||||
* It is the generic wrapper for performing a PKCS#1 encryption
|
||||
* operation using the \p mode from the context.
|
||||
*
|
||||
* \deprecated It is deprecated and discouraged to call this function
|
||||
* in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library
|
||||
* are likely to remove the \p mode argument and have it
|
||||
* implicitly set to #MBEDTLS_RSA_PUBLIC.
|
||||
* operation.
|
||||
*
|
||||
* \note Alternative implementations of RSA need not support
|
||||
* mode being set to #MBEDTLS_RSA_PRIVATE and might instead
|
||||
@ -584,16 +579,10 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
|
||||
*
|
||||
* \param ctx The initialized RSA context to use.
|
||||
* \param f_rng The RNG to use. It is mandatory for PKCS#1 v2.1 padding
|
||||
* encoding, and for PKCS#1 v1.5 padding encoding when used
|
||||
* with \p mode set to #MBEDTLS_RSA_PUBLIC. For PKCS#1 v1.5
|
||||
* padding encoding and \p mode set to #MBEDTLS_RSA_PRIVATE,
|
||||
* it is used for blinding and should be provided in this
|
||||
* case; see mbedtls_rsa_private() for more.
|
||||
* encoding, and for PKCS#1 v1.5 padding encoding.
|
||||
* \param p_rng The RNG context to be passed to \p f_rng. May be
|
||||
* \c NULL if \p f_rng is \c NULL or if \p f_rng doesn't
|
||||
* need a context argument.
|
||||
* \param mode The mode of operation. This must be either
|
||||
* #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated).
|
||||
* \param ilen The length of the plaintext in Bytes.
|
||||
* \param input The input data to encrypt. This must be a readable
|
||||
* buffer of size \p ilen Bytes. It may be \c NULL if
|
||||
@ -608,7 +597,7 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
|
||||
int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng,
|
||||
int mode, size_t ilen,
|
||||
size_t ilen,
|
||||
const unsigned char *input,
|
||||
unsigned char *output );
|
||||
|
||||
|
@ -149,7 +149,7 @@ static int rsa_encrypt_wrap( void *ctx,
|
||||
if( *olen > osize )
|
||||
return( MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE );
|
||||
|
||||
return( mbedtls_rsa_pkcs1_encrypt( rsa, f_rng, p_rng, MBEDTLS_RSA_PUBLIC,
|
||||
return( mbedtls_rsa_pkcs1_encrypt( rsa, f_rng, p_rng,
|
||||
ilen, input, output ) );
|
||||
}
|
||||
|
||||
|
@ -3064,7 +3064,6 @@ psa_status_t psa_asymmetric_encrypt( mbedtls_svc_key_id_t key,
|
||||
mbedtls_rsa_pkcs1_encrypt( rsa,
|
||||
mbedtls_psa_get_random,
|
||||
MBEDTLS_PSA_RANDOM_STATE,
|
||||
MBEDTLS_RSA_PUBLIC,
|
||||
input_length,
|
||||
input,
|
||||
output ) );
|
||||
|
@ -1317,13 +1317,11 @@ int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
|
||||
int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng,
|
||||
int mode, size_t ilen,
|
||||
size_t ilen,
|
||||
const unsigned char *input,
|
||||
unsigned char *output )
|
||||
{
|
||||
RSA_VALIDATE_RET( ctx != NULL );
|
||||
RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE ||
|
||||
mode == MBEDTLS_RSA_PUBLIC );
|
||||
RSA_VALIDATE_RET( output != NULL );
|
||||
RSA_VALIDATE_RET( ilen == 0 || input != NULL );
|
||||
|
||||
@ -1331,14 +1329,16 @@ int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx,
|
||||
{
|
||||
#if defined(MBEDTLS_PKCS1_V15)
|
||||
case MBEDTLS_RSA_PKCS_V15:
|
||||
return mbedtls_rsa_rsaes_pkcs1_v15_encrypt( ctx, f_rng, p_rng, mode, ilen,
|
||||
input, output );
|
||||
return mbedtls_rsa_rsaes_pkcs1_v15_encrypt( ctx, f_rng, p_rng,
|
||||
MBEDTLS_RSA_PUBLIC, ilen,
|
||||
input, output );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PKCS1_V21)
|
||||
case MBEDTLS_RSA_PKCS_V21:
|
||||
return mbedtls_rsa_rsaes_oaep_encrypt( ctx, f_rng, p_rng, mode, NULL, 0,
|
||||
ilen, input, output );
|
||||
return mbedtls_rsa_rsaes_oaep_encrypt( ctx, f_rng, p_rng,
|
||||
MBEDTLS_RSA_PUBLIC, NULL, 0,
|
||||
ilen, input, output );
|
||||
#endif
|
||||
|
||||
default:
|
||||
@ -2691,7 +2691,7 @@ int mbedtls_rsa_self_test( int verbose )
|
||||
|
||||
memcpy( rsa_plaintext, RSA_PT, PT_LEN );
|
||||
|
||||
if( mbedtls_rsa_pkcs1_encrypt( &rsa, myrand, NULL, MBEDTLS_RSA_PUBLIC,
|
||||
if( mbedtls_rsa_pkcs1_encrypt( &rsa, myrand, NULL,
|
||||
PT_LEN, rsa_plaintext,
|
||||
rsa_ciphertext ) != 0 )
|
||||
{
|
||||
|
@ -143,8 +143,7 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
ret = mbedtls_rsa_pkcs1_encrypt( &rsa, mbedtls_ctr_drbg_random,
|
||||
&ctr_drbg, MBEDTLS_RSA_PUBLIC,
|
||||
strlen( argv[1] ), input, buf );
|
||||
&ctr_drbg, strlen( argv[1] ), input, buf );
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_encrypt returned %d\n\n",
|
||||
|
@ -36,8 +36,8 @@ void pkcs1_rsaes_v15_encrypt( int mod, int radix_N, char * input_N,
|
||||
message_str->x = NULL;
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx,
|
||||
&mbedtls_test_rnd_buffer_rand,
|
||||
&info, MBEDTLS_RSA_PUBLIC,
|
||||
message_str->len, message_str->x,
|
||||
&info, message_str->len,
|
||||
message_str->x,
|
||||
output ) == result );
|
||||
|
||||
if( result == 0 )
|
||||
|
@ -35,8 +35,8 @@ void pkcs1_rsaes_oaep_encrypt( int mod, data_t * input_N, data_t * input_E,
|
||||
message_str->x = NULL;
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx,
|
||||
&mbedtls_test_rnd_buffer_rand,
|
||||
&info, MBEDTLS_RSA_PUBLIC,
|
||||
message_str->len, message_str->x,
|
||||
&info, message_str->len,
|
||||
message_str->x,
|
||||
output ) == result );
|
||||
if( result == 0 )
|
||||
{
|
||||
|
@ -103,17 +103,14 @@ void rsa_invalid_param( )
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_encrypt( NULL, NULL, NULL,
|
||||
MBEDTLS_RSA_PUBLIC,
|
||||
sizeof( buf ), buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_encrypt( &ctx, NULL, NULL,
|
||||
MBEDTLS_RSA_PUBLIC,
|
||||
sizeof( buf ), NULL,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||
mbedtls_rsa_pkcs1_encrypt( &ctx, NULL, NULL,
|
||||
MBEDTLS_RSA_PUBLIC,
|
||||
sizeof( buf ), buf,
|
||||
NULL ) );
|
||||
|
||||
@ -703,8 +700,8 @@ void mbedtls_rsa_pkcs1_encrypt( data_t * message_str, int padding_mode,
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info, MBEDTLS_RSA_PUBLIC,
|
||||
message_str->len, message_str->x,
|
||||
&rnd_info, message_str->len,
|
||||
message_str->x,
|
||||
output ) == result );
|
||||
if( result == 0 )
|
||||
{
|
||||
@ -743,8 +740,8 @@ void rsa_pkcs1_encrypt_bad_rng( data_t * message_str, int padding_mode,
|
||||
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &mbedtls_test_rnd_zero_rand,
|
||||
NULL, MBEDTLS_RSA_PUBLIC,
|
||||
message_str->len, message_str->x,
|
||||
NULL, message_str->len,
|
||||
message_str->x,
|
||||
output ) == result );
|
||||
if( result == 0 )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user