Get rid of FX_GET_32WORD macro.
Replace its usage with a call to fxcrt::GetUInt32MSBFirst(). Use more
span when appropriate.
Change-Id: I73e1b546d86b840103ab0e0a41d10270922f80cc
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/64133
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_security_handler.cpp b/core/fpdfapi/parser/cpdf_security_handler.cpp
index e2ae2c5..ab4873d 100644
--- a/core/fpdfapi/parser/cpdf_security_handler.cpp
+++ b/core/fpdfapi/parser/cpdf_security_handler.cpp
@@ -91,22 +91,15 @@
}
}
-#define FX_GET_32WORD(n, b, i) \
- { \
- (n) = (uint32_t)( \
- ((uint64_t)(b)[(i)] << 24) | ((uint64_t)(b)[(i) + 1] << 16) | \
- ((uint64_t)(b)[(i) + 2] << 8) | ((uint64_t)(b)[(i) + 3])); \
- }
-int BigOrder64BitsMod3(uint8_t* data) {
+int BigOrder64BitsMod3(pdfium::span<const uint8_t> data) {
uint64_t ret = 0;
for (int i = 0; i < 4; ++i) {
- uint32_t value;
- FX_GET_32WORD(value, data, 4 * i);
ret <<= 32;
- ret |= value;
+ ret |= fxcrt::GetUInt32MSBFirst(data);
ret %= 3;
+ data = data.subspan(4);
}
- return (int)ret;
+ return static_cast<int>(ret);
}
void Revision6_Hash(const ByteString& password,
@@ -152,7 +145,7 @@
CRYPT_AESEncrypt(&aes, encrypted_output_span.data(), content.data(),
encrypted_output_span.size());
int iHash = 0;
- switch (BigOrder64BitsMod3(encrypted_output_span.data())) {
+ switch (BigOrder64BitsMod3(encrypted_output_span)) {
case 0:
iHash = 0;
block_size = 32;