mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibCrypto: Do not trim leading zeros in export_data by default
This fixes the issue with the exported data having a leading zero, causing RSA::encrypt to trim the block down, and ruining the encryption. Fixes #2691 :^)
This commit is contained in:
committed by
Andreas Kling
parent
180207062c
commit
b00ffc860b
Notes:
sideshowbarker
2024-07-19 04:26:38 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/b00ffc860b9 Pull-request: https://github.com/SerenityOS/serenity/pull/2929 Issue: https://github.com/SerenityOS/serenity/issues/2691
@@ -36,11 +36,15 @@ SignedBigInteger SignedBigInteger::import_data(const u8* ptr, size_t length)
|
||||
return { move(unsigned_data), sign };
|
||||
}
|
||||
|
||||
size_t SignedBigInteger::export_data(Bytes data) const
|
||||
size_t SignedBigInteger::export_data(Bytes data, bool remove_leading_zeros) const
|
||||
{
|
||||
// FIXME: Support this:
|
||||
// m <0XX> -> m <XX> (if remove_leading_zeros)
|
||||
ASSERT(!remove_leading_zeros);
|
||||
|
||||
data[0] = m_sign;
|
||||
auto bytes_view = data.slice(1, data.size() - 1);
|
||||
return m_unsigned_data.export_data(bytes_view) + 1;
|
||||
return m_unsigned_data.export_data(bytes_view, remove_leading_zeros) + 1;
|
||||
}
|
||||
|
||||
SignedBigInteger SignedBigInteger::from_base10(StringView str)
|
||||
|
||||
Reference in New Issue
Block a user