mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibCrypto: Ensure that EME padding does not contain zeros
With this fix, we can now reliably open TLS connections!
This commit is contained in:
parent
05e2c7d9cf
commit
e015ffd5f0
Notes:
sideshowbarker
2024-07-19 07:04:34 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/e015ffd5f08 Pull-request: https://github.com/SerenityOS/serenity/pull/1661 Reviewed-by: https://github.com/Dexesttp Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/itamar8910
1 changed files with 6 additions and 0 deletions
|
@ -233,6 +233,12 @@ void RSA_PKCS1_EME::encrypt(const ByteBuffer& in, ByteBuffer& out)
|
|||
u8 ps[ps_length];
|
||||
|
||||
arc4random_buf(ps, ps_length);
|
||||
// since arc4random can create zeros (shocking!)
|
||||
// we have to go through and un-zero the zeros
|
||||
for (size_t i = 0; i < ps_length; ++i)
|
||||
if (!ps[i])
|
||||
ps[i] = 0xfe;
|
||||
|
||||
u8 paddings[] { 0x00, 0x02 };
|
||||
|
||||
out.overwrite(0, paddings, 2);
|
||||
|
|
Loading…
Reference in a new issue