| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include <time.h> | 7 #include <time.h> |
| 8 #include "../../../include/fpdfapi/fpdf_parser.h" | 8 #include "../../../include/fpdfapi/fpdf_parser.h" |
| 9 #include "../../../include/fdrm/fx_crypt.h" | 9 #include "../../../include/fdrm/fx_crypt.h" |
| 10 const FX_BYTE defpasscode[32] = { | 10 const FX_BYTE defpasscode[32] = { |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 FX_DWORD copy_len = key_len; | 453 FX_DWORD copy_len = key_len; |
| 454 if (copy_len > sizeof(digest)) { | 454 if (copy_len > sizeof(digest)) { |
| 455 copy_len = sizeof(digest); | 455 copy_len = sizeof(digest); |
| 456 } | 456 } |
| 457 FXSYS_memcpy32(enckey, digest, copy_len); | 457 FXSYS_memcpy32(enckey, digest, copy_len); |
| 458 int okeylen = okey.GetLength(); | 458 int okeylen = okey.GetLength(); |
| 459 if (okeylen > 32) { | 459 if (okeylen > 32) { |
| 460 okeylen = 32; | 460 okeylen = 32; |
| 461 } | 461 } |
| 462 FX_BYTE okeybuf[64]; | 462 FX_BYTE okeybuf[64]; |
| 463 FXSYS_memset32(okeybuf, 0, sizeof(okeybuf)); |
| 463 FXSYS_memcpy32(okeybuf, (FX_LPCSTR)okey, okeylen); | 464 FXSYS_memcpy32(okeybuf, (FX_LPCSTR)okey, okeylen); |
| 464 if (m_Revision == 2) { | 465 if (m_Revision == 2) { |
| 465 CRYPT_ArcFourCryptBlock(okeybuf, okeylen, enckey, key_len); | 466 CRYPT_ArcFourCryptBlock(okeybuf, okeylen, enckey, key_len); |
| 466 } else { | 467 } else { |
| 467 for (int i = 19; i >= 0; i --) { | 468 for (int i = 19; i >= 0; i --) { |
| 468 FX_BYTE tempkey[32]; | 469 FX_BYTE tempkey[32]; |
| 469 for (int j = 0; j < m_KeyLen; j ++) { | 470 for (int j = 0; j < m_KeyLen; j ++) { |
| 470 tempkey[j] = enckey[j] ^ i; | 471 tempkey[j] = enckey[j] ^ i; |
| 471 } | 472 } |
| 472 CRYPT_ArcFourCryptBlock(okeybuf, okeylen, tempkey, key_len); | 473 CRYPT_ArcFourCryptBlock(okeybuf, okeylen, tempkey, key_len); |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 m_pAESContext = NULL; | 949 m_pAESContext = NULL; |
| 949 m_Cipher = FXCIPHER_NONE; | 950 m_Cipher = FXCIPHER_NONE; |
| 950 m_KeyLen = 0; | 951 m_KeyLen = 0; |
| 951 } | 952 } |
| 952 CPDF_StandardCryptoHandler::~CPDF_StandardCryptoHandler() | 953 CPDF_StandardCryptoHandler::~CPDF_StandardCryptoHandler() |
| 953 { | 954 { |
| 954 if (m_pAESContext) { | 955 if (m_pAESContext) { |
| 955 FX_Free(m_pAESContext); | 956 FX_Free(m_pAESContext); |
| 956 } | 957 } |
| 957 } | 958 } |
| OLD | NEW |