mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 00:45:39 +00:00
Added support for custom labels when using rsa_rsaes_oaep_encrypt() or rsa_rsaes_oaep_decrypt()
This commit is contained in:
parent
b386913f8b
commit
a43231c5a5
|
@ -11,6 +11,8 @@ Changes
|
||||||
* Internally split up rsa_pkcs1_encrypt(), rsa_pkcs1_decrypt(),
|
* Internally split up rsa_pkcs1_encrypt(), rsa_pkcs1_decrypt(),
|
||||||
rsa_pkcs1_sign() and rsa_pkcs1_verify() to separate PKCS#1 v1.5 and
|
rsa_pkcs1_sign() and rsa_pkcs1_verify() to separate PKCS#1 v1.5 and
|
||||||
PKCS#1 v2.1 functions
|
PKCS#1 v2.1 functions
|
||||||
|
* Added support for custom labels when using rsa_rsaes_oaep_encrypt()
|
||||||
|
or rsa_rsaes_oaep_decrypt()
|
||||||
|
|
||||||
Security
|
Security
|
||||||
* Removed further timing differences during SSL message decryption in
|
* Removed further timing differences during SSL message decryption in
|
||||||
|
|
|
@ -309,6 +309,8 @@ int rsa_rsaes_pkcs1_v15_encrypt( rsa_context *ctx,
|
||||||
* \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding)
|
* \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding)
|
||||||
* \param p_rng RNG parameter
|
* \param p_rng RNG parameter
|
||||||
* \param mode RSA_PUBLIC or RSA_PRIVATE
|
* \param mode RSA_PUBLIC or RSA_PRIVATE
|
||||||
|
* \param label buffer holding the custom label to use
|
||||||
|
* \param label_len contains the label length
|
||||||
* \param ilen contains the plaintext length
|
* \param ilen contains the plaintext length
|
||||||
* \param input buffer holding the data to be encrypted
|
* \param input buffer holding the data to be encrypted
|
||||||
* \param output buffer that will hold the ciphertext
|
* \param output buffer that will hold the ciphertext
|
||||||
|
@ -321,7 +323,9 @@ int rsa_rsaes_pkcs1_v15_encrypt( rsa_context *ctx,
|
||||||
int rsa_rsaes_oaep_encrypt( rsa_context *ctx,
|
int rsa_rsaes_oaep_encrypt( rsa_context *ctx,
|
||||||
int (*f_rng)(void *, unsigned char *, size_t),
|
int (*f_rng)(void *, unsigned char *, size_t),
|
||||||
void *p_rng,
|
void *p_rng,
|
||||||
int mode, size_t ilen,
|
int mode,
|
||||||
|
const unsigned char *label, size_t label_len,
|
||||||
|
size_t ilen,
|
||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
unsigned char *output );
|
unsigned char *output );
|
||||||
|
|
||||||
|
@ -376,6 +380,8 @@ int rsa_rsaes_pkcs1_v15_decrypt( rsa_context *ctx,
|
||||||
*
|
*
|
||||||
* \param ctx RSA context
|
* \param ctx RSA context
|
||||||
* \param mode RSA_PUBLIC or RSA_PRIVATE
|
* \param mode RSA_PUBLIC or RSA_PRIVATE
|
||||||
|
* \param label buffer holding the custom label to use
|
||||||
|
* \param label_len contains the label length
|
||||||
* \param olen will contain the plaintext length
|
* \param olen will contain the plaintext length
|
||||||
* \param input buffer holding the encrypted data
|
* \param input buffer holding the encrypted data
|
||||||
* \param output buffer that will hold the plaintext
|
* \param output buffer that will hold the plaintext
|
||||||
|
@ -388,7 +394,9 @@ int rsa_rsaes_pkcs1_v15_decrypt( rsa_context *ctx,
|
||||||
* an error is thrown.
|
* an error is thrown.
|
||||||
*/
|
*/
|
||||||
int rsa_rsaes_oaep_decrypt( rsa_context *ctx,
|
int rsa_rsaes_oaep_decrypt( rsa_context *ctx,
|
||||||
int mode, size_t *olen,
|
int mode,
|
||||||
|
const unsigned char *label, size_t label_len,
|
||||||
|
size_t *olen,
|
||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
unsigned char *output,
|
unsigned char *output,
|
||||||
size_t output_max_len );
|
size_t output_max_len );
|
||||||
|
|
|
@ -368,7 +368,9 @@ static void mgf_mask( unsigned char *dst, size_t dlen, unsigned char *src, size_
|
||||||
int rsa_rsaes_oaep_encrypt( rsa_context *ctx,
|
int rsa_rsaes_oaep_encrypt( rsa_context *ctx,
|
||||||
int (*f_rng)(void *, unsigned char *, size_t),
|
int (*f_rng)(void *, unsigned char *, size_t),
|
||||||
void *p_rng,
|
void *p_rng,
|
||||||
int mode, size_t ilen,
|
int mode,
|
||||||
|
const unsigned char *label, size_t label_len,
|
||||||
|
size_t ilen,
|
||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
unsigned char *output )
|
unsigned char *output )
|
||||||
{
|
{
|
||||||
|
@ -406,7 +408,7 @@ int rsa_rsaes_oaep_encrypt( rsa_context *ctx,
|
||||||
|
|
||||||
// Construct DB
|
// Construct DB
|
||||||
//
|
//
|
||||||
md( md_info, p, 0, p );
|
md( md_info, label, label_len, p );
|
||||||
p += hlen;
|
p += hlen;
|
||||||
p += olen - 2 * hlen - 2 - ilen;
|
p += olen - 2 * hlen - 2 - ilen;
|
||||||
*p++ = 1;
|
*p++ = 1;
|
||||||
|
@ -525,7 +527,9 @@ int rsa_pkcs1_encrypt( rsa_context *ctx,
|
||||||
* Implementation of the PKCS#1 v2.1 RSAES-OAEP-DECRYPT function
|
* Implementation of the PKCS#1 v2.1 RSAES-OAEP-DECRYPT function
|
||||||
*/
|
*/
|
||||||
int rsa_rsaes_oaep_decrypt( rsa_context *ctx,
|
int rsa_rsaes_oaep_decrypt( rsa_context *ctx,
|
||||||
int mode, size_t *olen,
|
int mode,
|
||||||
|
const unsigned char *label, size_t label_len,
|
||||||
|
size_t *olen,
|
||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
unsigned char *output,
|
unsigned char *output,
|
||||||
size_t output_max_len )
|
size_t output_max_len )
|
||||||
|
@ -569,7 +573,7 @@ int rsa_rsaes_oaep_decrypt( rsa_context *ctx,
|
||||||
|
|
||||||
// Generate lHash
|
// Generate lHash
|
||||||
//
|
//
|
||||||
md( md_info, lhash, 0, lhash );
|
md( md_info, label, label_len, lhash );
|
||||||
|
|
||||||
// seed: Apply seedMask to maskedSeed
|
// seed: Apply seedMask to maskedSeed
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue