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/app/xfa_checksum.h" | 7 #include "xfa/include/fxfa/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" |
11 | 11 |
12 CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext) | 12 CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext) |
13 : m_pContext(pContext) { | 13 : m_pContext(pContext) { |
14 FXSYS_assert(m_pContext); | 14 FXSYS_assert(m_pContext); |
15 } | 15 } |
16 CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {} | 16 CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {} |
17 void* CXFA_SAXReaderHandler::OnTagEnter(const CFX_ByteStringC& bsTagName, | 17 void* CXFA_SAXReaderHandler::OnTagEnter(const CFX_ByteStringC& bsTagName, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if (bUpdata) { | 117 if (bUpdata) { |
118 break; | 118 break; |
119 } | 119 } |
120 } | 120 } |
121 } | 121 } |
122 if (bUpdata) { | 122 if (bUpdata) { |
123 m_pContext->Update(CFX_ByteStringC(pBuffer, iLength)); | 123 m_pContext->Update(CFX_ByteStringC(pBuffer, iLength)); |
124 } | 124 } |
125 m_SAXContext.m_TextBuf.Clear(); | 125 m_SAXContext.m_TextBuf.Clear(); |
126 } | 126 } |
127 IXFA_ChecksumContext* XFA_Checksum_Create() { | 127 |
128 return new CXFA_ChecksumContext; | |
129 } | |
130 CXFA_ChecksumContext::CXFA_ChecksumContext() | 128 CXFA_ChecksumContext::CXFA_ChecksumContext() |
131 : m_pSAXReader(NULL), m_pByteContext(NULL) {} | 129 : m_pSAXReader(NULL), m_pByteContext(NULL) {} |
132 CXFA_ChecksumContext::~CXFA_ChecksumContext() { | 130 CXFA_ChecksumContext::~CXFA_ChecksumContext() { |
133 FinishChecksum(); | 131 FinishChecksum(); |
134 } | 132 } |
135 FX_BOOL CXFA_ChecksumContext::StartChecksum() { | 133 FX_BOOL CXFA_ChecksumContext::StartChecksum() { |
136 FinishChecksum(); | 134 FinishChecksum(); |
137 m_pByteContext = FX_Alloc(uint8_t, 128); | 135 m_pByteContext = FX_Alloc(uint8_t, 128); |
138 CRYPT_SHA1Start(m_pByteContext); | 136 CRYPT_SHA1Start(m_pByteContext); |
139 m_bsChecksum.Empty(); | 137 m_bsChecksum.Empty(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 179 } |
182 } | 180 } |
183 void CXFA_ChecksumContext::GetChecksum(CFX_ByteString& bsChecksum) { | 181 void CXFA_ChecksumContext::GetChecksum(CFX_ByteString& bsChecksum) { |
184 bsChecksum = m_bsChecksum; | 182 bsChecksum = m_bsChecksum; |
185 } | 183 } |
186 void CXFA_ChecksumContext::Update(const CFX_ByteStringC& bsText) { | 184 void CXFA_ChecksumContext::Update(const CFX_ByteStringC& bsText) { |
187 if (m_pByteContext) { | 185 if (m_pByteContext) { |
188 CRYPT_SHA1Update(m_pByteContext, bsText.GetPtr(), bsText.GetLength()); | 186 CRYPT_SHA1Update(m_pByteContext, bsText.GetPtr(), bsText.GetLength()); |
189 } | 187 } |
190 } | 188 } |
OLD | NEW |