From 342f692c3dc91d75b08bbb1b7e9b5d3bb278ee60 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 16 Oct 2025 04:24:39 +0000 Subject: [PATCH] fix comp errors Signed-off-by: lizzie --- src/core/crypto/xts_encryption_layer.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/core/crypto/xts_encryption_layer.cpp b/src/core/crypto/xts_encryption_layer.cpp index 25ca34c43d..240f930c57 100644 --- a/src/core/crypto/xts_encryption_layer.cpp +++ b/src/core/crypto/xts_encryption_layer.cpp @@ -46,16 +46,15 @@ std::size_t XTSEncryptionLayer::Read(u8* data, std::size_t length, std::size_t o if (length > 0) { // Process aligned middle inplace, in sector sized multiples. - while (length >= sector_size) { - const std::size_t req = (length / sector_size) * sector_size; + while (length >= XTS_SECTOR_SIZE) { + const std::size_t req = (length / XTS_SECTOR_SIZE) * XTS_SECTOR_SIZE; const std::size_t got = base->Read(data, req, offset); if (got == 0) { return total_read; } - const std::size_t got_rounded = got - (got % sector_size); + const std::size_t got_rounded = got - (got % XTS_SECTOR_SIZE); if (got_rounded > 0) { - cipher.XTSTranscode(data, got_rounded, data, offset / sector_size, sector_size, - Op::Decrypt); + cipher.XTSTranscode(data, got_rounded, data, offset / XTS_SECTOR_SIZE, XTS_SECTOR_SIZE, Op::Decrypt); data += got_rounded; offset += got_rounded; length -= got_rounded; @@ -69,13 +68,13 @@ std::size_t XTSEncryptionLayer::Read(u8* data, std::size_t length, std::size_t o // Handle tail within a sector, if any. if (length > 0) { std::array block{}; - const std::size_t got = base->Read(block.data(), sector_size, offset); + const std::size_t got = base->Read(block.data(), XTS_SECTOR_SIZE, offset); if (got > 0) { - if (got < sector_size) { - std::memset(block.data() + got, 0, sector_size - got); + if (got < XTS_SECTOR_SIZE) { + std::memset(block.data() + got, 0, XTS_SECTOR_SIZE - got); } - cipher.XTSTranscode(block.data(), sector_size, block.data(), - offset / sector_size, sector_size, Op::Decrypt); + cipher.XTSTranscode(block.data(), XTS_SECTOR_SIZE, block.data(), + offset / XTS_SECTOR_SIZE, XTS_SECTOR_SIZE, Op::Decrypt); const std::size_t to_copy = std::min(length, got); std::memcpy(data, block.data(), to_copy); total_read += to_copy;