mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-06 14:38:57 +01:00
Added more constant-time code and removed biases in the prime number generation routines.
This commit is contained in:
parent
02ba5785bf
commit
b99183dfc6
2 changed files with 32 additions and 19 deletions
|
|
@ -761,7 +761,7 @@ int rsa_rsaes_oaep_decrypt( rsa_context *ctx,
|
|||
for( i = 0; i < ilen - 2 * hlen - 2; i++ )
|
||||
{
|
||||
pad_done |= p[i];
|
||||
pad_len += ( pad_done == 0 );
|
||||
pad_len += ((pad_done | (unsigned char)-pad_done) >> 7) ^ 1;
|
||||
}
|
||||
|
||||
p += pad_len;
|
||||
|
|
@ -835,8 +835,8 @@ int rsa_rsaes_pkcs1_v15_decrypt( rsa_context *ctx,
|
|||
* (minus one, for the 00 byte) */
|
||||
for( i = 0; i < ilen - 3; i++ )
|
||||
{
|
||||
pad_done |= ( p[i] == 0 );
|
||||
pad_count += ( pad_done == 0 );
|
||||
pad_done |= ((p[i] | (unsigned char)-p[i]) >> 7) ^ 1;
|
||||
pad_count += ((pad_done | (unsigned char)-pad_done) >> 7) ^ 1;
|
||||
}
|
||||
|
||||
p += pad_count;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue