1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +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:
AnotherTest 2020-04-24 17:39:58 +04:30 committed by Andreas Kling
parent 05e2c7d9cf
commit e015ffd5f0

View file

@ -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);