mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
fix: Crypto buffered hexadecimal encoding
This commit is contained in:
@@ -396,14 +396,14 @@ namespace hex::crypt {
|
||||
|
||||
ON_SCOPE_EXIT { mbedtls_mpi_free(&ctx); };
|
||||
|
||||
// read buffered
|
||||
constexpr static auto BufferSize = 0x100;
|
||||
for (size_t offset = 0; offset < input.size(); offset += BufferSize) {
|
||||
std::string inputPart = input.substr(offset, std::min<size_t>(BufferSize, input.size() - offset));
|
||||
if (mbedtls_mpi_read_string(&ctx, 16, inputPart.c_str()))
|
||||
return {};
|
||||
|
||||
auto size = std::min<size_t>(BufferSize / 2, input.size() - offset);
|
||||
if (mbedtls_mpi_write_binary(&ctx, output.data() + offset / 2, size) != 0)
|
||||
if (mbedtls_mpi_write_binary(&ctx, output.data() + offset / 2, inputPart.size() / 2))
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user