mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 15:43:20 +00:00
LibCrypto: Convert SignedBigInteger::import_data to accept Bytes
This brings it up to par with UnsignedBigInteger.
This commit is contained in:
parent
b0fdbe3756
commit
110136b862
Notes:
github-actions[bot]
2025-08-05 07:10:20 +00:00
Author: https://github.com/IdanHo
Commit: 110136b862
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5708
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/trflynn89
3 changed files with 5 additions and 6 deletions
|
@ -23,10 +23,10 @@ SignedBigInteger::SignedBigInteger(UnsignedBigInteger&& unsigned_data, bool sign
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SignedBigInteger::SignedBigInteger(u8 const* ptr, size_t length)
|
SignedBigInteger::SignedBigInteger(ReadonlyBytes data)
|
||||||
{
|
{
|
||||||
MP_MUST(mp_init(&m_mp));
|
MP_MUST(mp_init(&m_mp));
|
||||||
MP_MUST(mp_from_sbin(&m_mp, ptr, length));
|
MP_MUST(mp_from_sbin(&m_mp, data.data(), data.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
SignedBigInteger::SignedBigInteger(UnsignedBigInteger const& unsigned_data)
|
SignedBigInteger::SignedBigInteger(UnsignedBigInteger const& unsigned_data)
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
SignedBigInteger(UnsignedBigInteger&& unsigned_data, bool sign);
|
SignedBigInteger(UnsignedBigInteger&& unsigned_data, bool sign);
|
||||||
SignedBigInteger(u8 const* ptr, size_t length);
|
SignedBigInteger(ReadonlyBytes);
|
||||||
|
|
||||||
explicit SignedBigInteger(UnsignedBigInteger const& unsigned_data);
|
explicit SignedBigInteger(UnsignedBigInteger const& unsigned_data);
|
||||||
explicit SignedBigInteger(double value);
|
explicit SignedBigInteger(double value);
|
||||||
|
@ -37,8 +37,7 @@ public:
|
||||||
SignedBigInteger();
|
SignedBigInteger();
|
||||||
~SignedBigInteger();
|
~SignedBigInteger();
|
||||||
|
|
||||||
[[nodiscard]] static SignedBigInteger import_data(StringView data) { return import_data(reinterpret_cast<u8 const*>(data.characters_without_null_termination()), data.length()); }
|
[[nodiscard]] static SignedBigInteger import_data(ReadonlyBytes data) { return SignedBigInteger(data); }
|
||||||
[[nodiscard]] static SignedBigInteger import_data(u8 const* ptr, size_t length) { return SignedBigInteger(ptr, length); }
|
|
||||||
|
|
||||||
[[nodiscard]] Bytes export_data(Bytes) const;
|
[[nodiscard]] Bytes export_data(Bytes) const;
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export)
|
||||||
return JS::Value(global->value().to<double>());
|
return JS::Value(global->value().to<double>());
|
||||||
case Wasm::ValueType::V128: {
|
case Wasm::ValueType::V128: {
|
||||||
auto value = global->value().to<u128>();
|
auto value = global->value().to<u128>();
|
||||||
return JS::BigInt::create(vm, Crypto::SignedBigInteger::import_data(bit_cast<u8 const*>(&value), sizeof(u128)));
|
return JS::BigInt::create(vm, Crypto::SignedBigInteger::import_data(value.bytes()));
|
||||||
}
|
}
|
||||||
case Wasm::ValueType::FunctionReference:
|
case Wasm::ValueType::FunctionReference:
|
||||||
case Wasm::ValueType::ExternReference:
|
case Wasm::ValueType::ExternReference:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue