1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:57:35 +00:00

LibCrypto: Do a simple copy for buffered GHash bytes

Using a Stream to copy over a single span is kind of overkill.
This commit is contained in:
Tim Schumacher 2023-02-08 17:46:24 +01:00 committed by Linus Groh
parent 220fbcaa7e
commit 7d70f6d7c8

View file

@ -6,7 +6,6 @@
#include <AK/ByteReader.h> #include <AK/ByteReader.h>
#include <AK/Debug.h> #include <AK/Debug.h>
#include <AK/DeprecatedMemoryStream.h>
#include <AK/Types.h> #include <AK/Types.h>
#include <LibCrypto/Authentication/GHash.h> #include <LibCrypto/Authentication/GHash.h>
@ -45,11 +44,9 @@ GHash::TagType GHash::process(ReadonlyBytes aad, ReadonlyBytes cipher)
} }
if (i > buf.size()) { if (i > buf.size()) {
static u8 buffer[16]; u8 buffer[16] = {};
Bytes buffer_bytes { buffer, 16 }; Bytes buffer_bytes { buffer, 16 };
DeprecatedOutputMemoryStream stream { buffer_bytes }; buf.slice(i - 16).copy_to(buffer_bytes);
stream.write(buf.slice(i - 16));
stream.fill_to_end(0);
for (auto j = 0; j < 4; ++j) { for (auto j = 0; j < 4; ++j) {
tag[j] ^= to_u32(buffer_bytes.offset(j * 4)); tag[j] ^= to_u32(buffer_bytes.offset(j * 4));