| 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 "xfa/fxfa/include/xfa_checksum.h" | 7 #include "xfa/fxfa/include/xfa_checksum.h" |
| 8 | 8 |
| 9 #include "core/fdrm/crypto/include/fx_crypt.h" | 9 #include "core/fdrm/crypto/include/fx_crypt.h" |
| 10 #include "xfa/fgas/crt/fgas_algorithm.h" | 10 #include "xfa/fgas/crt/fgas_algorithm.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 CXFA_ChecksumContext::CXFA_ChecksumContext() | 128 CXFA_ChecksumContext::CXFA_ChecksumContext() |
| 129 : m_pSAXReader(NULL), m_pByteContext(NULL) {} | 129 : m_pSAXReader(NULL), m_pByteContext(NULL) {} |
| 130 CXFA_ChecksumContext::~CXFA_ChecksumContext() { | 130 CXFA_ChecksumContext::~CXFA_ChecksumContext() { |
| 131 FinishChecksum(); | 131 FinishChecksum(); |
| 132 } | 132 } |
| 133 FX_BOOL CXFA_ChecksumContext::StartChecksum() { | 133 FX_BOOL CXFA_ChecksumContext::StartChecksum() { |
| 134 FinishChecksum(); | 134 FinishChecksum(); |
| 135 m_pByteContext = FX_Alloc(uint8_t, 128); | 135 m_pByteContext = FX_Alloc(uint8_t, 128); |
| 136 CRYPT_SHA1Start(m_pByteContext); | 136 CRYPT_SHA1Start(m_pByteContext); |
| 137 m_bsChecksum.Empty(); | 137 m_bsChecksum.clear(); |
| 138 m_pSAXReader = FX_SAXReader_Create(); | 138 m_pSAXReader = FX_SAXReader_Create(); |
| 139 return m_pSAXReader != NULL; | 139 return m_pSAXReader != NULL; |
| 140 } | 140 } |
| 141 FX_BOOL CXFA_ChecksumContext::UpdateChecksum(IFX_FileRead* pSrcFile, | 141 FX_BOOL CXFA_ChecksumContext::UpdateChecksum(IFX_FileRead* pSrcFile, |
| 142 FX_FILESIZE offset, | 142 FX_FILESIZE offset, |
| 143 size_t size) { | 143 size_t size) { |
| 144 if (m_pSAXReader == NULL) { | 144 if (m_pSAXReader == NULL) { |
| 145 return FALSE; | 145 return FALSE; |
| 146 } | 146 } |
| 147 if (pSrcFile == NULL) { | 147 if (pSrcFile == NULL) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 void CXFA_ChecksumContext::GetChecksum(CFX_ByteString& bsChecksum) { | 181 void CXFA_ChecksumContext::GetChecksum(CFX_ByteString& bsChecksum) { |
| 182 bsChecksum = m_bsChecksum; | 182 bsChecksum = m_bsChecksum; |
| 183 } | 183 } |
| 184 void CXFA_ChecksumContext::Update(const CFX_ByteStringC& bsText) { | 184 void CXFA_ChecksumContext::Update(const CFX_ByteStringC& bsText) { |
| 185 if (m_pByteContext) { | 185 if (m_pByteContext) { |
| 186 CRYPT_SHA1Update(m_pByteContext, bsText.raw_str(), bsText.GetLength()); | 186 CRYPT_SHA1Update(m_pByteContext, bsText.raw_str(), bsText.GetLength()); |
| 187 } | 187 } |
| 188 } | 188 } |
| OLD | NEW |