Remove always-false arg from CPDF_CryptoHandler::CryptStart().
Then inline into its only caller, DecryptStart().
Change-Id: I8ba573419dc6806304fd47754205fdd23c8d5cd4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/86371
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.cpp b/core/fpdfapi/parser/cpdf_crypto_handler.cpp
index 9fa9b65..4fa74d3 100644
--- a/core/fpdfapi/parser/cpdf_crypto_handler.cpp
+++ b/core/fpdfapi/parser/cpdf_crypto_handler.cpp
@@ -108,23 +108,15 @@
uint8_t m_Block[16];
};
-void* CPDF_CryptoHandler::CryptStart(uint32_t objnum,
- uint32_t gennum,
- bool bEncrypt) {
- if (m_Cipher == Cipher::kNone) {
+void* CPDF_CryptoHandler::DecryptStart(uint32_t objnum, uint32_t gennum) {
+ if (m_Cipher == Cipher::kNone)
return this;
- }
+
if (m_Cipher == Cipher::kAES && m_KeyLen == 32) {
AESCryptContext* pContext = FX_Alloc(AESCryptContext, 1);
pContext->m_bIV = true;
pContext->m_BlockOffset = 0;
CRYPT_AESSetKey(&pContext->m_Context, m_EncryptKey, 32);
- if (bEncrypt) {
- for (int i = 0; i < 16; i++) {
- pContext->m_Block[i] = (uint8_t)rand();
- }
- CRYPT_AESSetIV(&pContext->m_Context, pContext->m_Block);
- }
return pContext;
}
uint8_t key1[48];
@@ -143,12 +135,6 @@
pContext->m_bIV = true;
pContext->m_BlockOffset = 0;
CRYPT_AESSetKey(&pContext->m_Context, realkey, 16);
- if (bEncrypt) {
- for (int i = 0; i < 16; i++) {
- pContext->m_Block[i] = (uint8_t)rand();
- }
- CRYPT_AESSetIV(&pContext->m_Context, pContext->m_Block);
- }
return pContext;
}
CRYPT_rc4_context* pContext = FX_Alloc(CRYPT_rc4_context, 1);
@@ -262,9 +248,6 @@
return ByteString(dest_buf.GetBuffer(), dest_buf.GetSize());
}
-void* CPDF_CryptoHandler::DecryptStart(uint32_t objnum, uint32_t gennum) {
- return CryptStart(objnum, gennum, false);
-}
uint32_t CPDF_CryptoHandler::DecryptGetSize(uint32_t src_size) {
return m_Cipher == Cipher::kAES ? src_size - 16 : src_size;
}
diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.h b/core/fpdfapi/parser/cpdf_crypto_handler.h
index 58410c5..dd04034 100644
--- a/core/fpdfapi/parser/cpdf_crypto_handler.h
+++ b/core/fpdfapi/parser/cpdf_crypto_handler.h
@@ -62,7 +62,6 @@
pdfium::span<const uint8_t> source,
uint8_t* dest_buf,
uint32_t& dest_size) const;
- void* CryptStart(uint32_t objnum, uint32_t gennum, bool bEncrypt);
bool CryptStream(void* context,
pdfium::span<const uint8_t> source,
CFX_BinaryBuf& dest_buf,