diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-10-03 19:53:38 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-03 19:53:38 +0000 |
commit | bd8855b27b43de3587b2040fee64236bf53a4238 (patch) | |
tree | 7fbb689bf5cfe7374dfd7b2c3ce60a4e33c35f5c /core/fpdfapi | |
parent | 2ff6cd661c0203dcdcc09135bce8bba141037574 (diff) | |
download | pdfium-bd8855b27b43de3587b2040fee64236bf53a4238.tar.xz |
Remove blocklen argument from CRYPT_AESSetKey()
We always pass it as 16. In turn, remove some unused code
to handle the non-16 cases.
Noticed while looking at coverage report.
Change-Id: I93f5f0342537284ce6a2b36a8b477425da3cc872
Reviewed-on: https://pdfium-review.googlesource.com/c/43450
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/parser/cpdf_crypto_handler.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_security_handler.cpp | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.cpp b/core/fpdfapi/parser/cpdf_crypto_handler.cpp index 4f77bc903b..4e24c66a4f 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.cpp +++ b/core/fpdfapi/parser/cpdf_crypto_handler.cpp @@ -72,7 +72,7 @@ void CPDF_CryptoHandler::CryptBlock(bool bEncrypt, } } if (m_Cipher == FXCIPHER_AES) { - CRYPT_AESSetKey(m_pAESContext.get(), 16, + CRYPT_AESSetKey(m_pAESContext.get(), m_KeyLen == 32 ? m_EncryptKey : realkey, m_KeyLen, bEncrypt); if (bEncrypt) { @@ -125,7 +125,7 @@ void* CPDF_CryptoHandler::CryptStart(uint32_t objnum, AESCryptContext* pContext = FX_Alloc(AESCryptContext, 1); pContext->m_bIV = true; pContext->m_BlockOffset = 0; - CRYPT_AESSetKey(&pContext->m_Context, 16, m_EncryptKey, 32, bEncrypt); + CRYPT_AESSetKey(&pContext->m_Context, m_EncryptKey, 32, bEncrypt); if (bEncrypt) { for (int i = 0; i < 16; i++) { pContext->m_Block[i] = (uint8_t)rand(); @@ -151,7 +151,7 @@ void* CPDF_CryptoHandler::CryptStart(uint32_t objnum, AESCryptContext* pContext = FX_Alloc(AESCryptContext, 1); pContext->m_bIV = true; pContext->m_BlockOffset = 0; - CRYPT_AESSetKey(&pContext->m_Context, 16, realkey, 16, bEncrypt); + CRYPT_AESSetKey(&pContext->m_Context, realkey, 16, bEncrypt); if (bEncrypt) { for (int i = 0; i < 16; i++) { pContext->m_Block[i] = (uint8_t)rand(); diff --git a/core/fpdfapi/parser/cpdf_security_handler.cpp b/core/fpdfapi/parser/cpdf_security_handler.cpp index f3d9201cbf..bb2296666a 100644 --- a/core/fpdfapi/parser/cpdf_security_handler.cpp +++ b/core/fpdfapi/parser/cpdf_security_handler.cpp @@ -278,7 +278,7 @@ void Revision6_Hash(const ByteString& password, content.insert(std::end(content), vector, vector + 48); } } - CRYPT_AESSetKey(&aes, 16, key, 16, true); + CRYPT_AESSetKey(&aes, key, 16, true); CRYPT_AESSetIV(&aes, iv); CRYPT_AESEncrypt(&aes, E, content.data(), iBufLen); int iHash = 0; @@ -365,12 +365,12 @@ bool CPDF_SecurityHandler::AES256_CheckPassword(const ByteString& password, CRYPT_aes_context aes; memset(&aes, 0, sizeof(aes)); - CRYPT_AESSetKey(&aes, 16, digest, 32, false); + CRYPT_AESSetKey(&aes, digest, 32, false); uint8_t iv[16]; memset(iv, 0, 16); CRYPT_AESSetIV(&aes, iv); CRYPT_AESDecrypt(&aes, key, ekey.raw_str(), 32); - CRYPT_AESSetKey(&aes, 16, key, 32, false); + CRYPT_AESSetKey(&aes, key, 32, false); CRYPT_AESSetIV(&aes, iv); ByteString perms = m_pEncryptDict->GetStringFor("Perms"); if (perms.IsEmpty()) @@ -676,7 +676,7 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict, } CRYPT_aes_context aes; memset(&aes, 0, sizeof(aes)); - CRYPT_AESSetKey(&aes, 16, digest1, 32, true); + CRYPT_AESSetKey(&aes, digest1, 32, true); uint8_t iv[16]; memset(iv, 0, 16); CRYPT_AESSetIV(&aes, iv); @@ -705,7 +705,7 @@ void CPDF_SecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict, CRYPT_aes_context aes; memset(&aes, 0, sizeof(aes)); - CRYPT_AESSetKey(&aes, 16, key, 32, true); + CRYPT_AESSetKey(&aes, key, 32, true); uint8_t iv[16]; memset(iv, 0, 16); |