mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibCrypto: Optimize UnsignedBigInteger import_data/export_data
No need to do complicated math to import or export numbers, just convert the byte stream to words and vice versa.
This commit is contained in:
parent
08221139a5
commit
3fdacef07f
2 changed files with 47 additions and 28 deletions
|
@ -46,12 +46,17 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
explicit UnsignedBigInteger(const u8* ptr, size_t length);
|
||||
|
||||
UnsignedBigInteger() { }
|
||||
|
||||
static UnsignedBigInteger create_invalid();
|
||||
|
||||
static UnsignedBigInteger import_data(const AK::StringView& data) { return import_data((const u8*)data.characters_without_null_termination(), data.length()); }
|
||||
static UnsignedBigInteger import_data(const u8* ptr, size_t length);
|
||||
static UnsignedBigInteger import_data(const u8* ptr, size_t length)
|
||||
{
|
||||
return UnsignedBigInteger(ptr, length);
|
||||
}
|
||||
|
||||
size_t export_data(AK::ByteBuffer& data) const;
|
||||
size_t export_data(const u8* ptr, size_t length) const
|
||||
|
@ -129,7 +134,7 @@ struct UnsignedDivisionResult {
|
|||
}
|
||||
|
||||
inline const LogStream&
|
||||
operator<<(const LogStream& stream, const Crypto::UnsignedBigInteger value)
|
||||
operator<<(const LogStream& stream, const Crypto::UnsignedBigInteger& value)
|
||||
{
|
||||
if (value.is_invalid()) {
|
||||
stream << "Invalid BigInt";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue