Home | History | Annotate | Download | only in fxcrt
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #ifndef CORE_FXCRT_CFX_CHECKSUMCONTEXT_H_
      8 #define CORE_FXCRT_CFX_CHECKSUMCONTEXT_H_
      9 
     10 #include <memory>
     11 
     12 #include "core/fdrm/crypto/fx_crypt.h"
     13 #include "core/fxcrt/xml/cfx_saxreader.h"
     14 
     15 class CFX_ChecksumContext {
     16  public:
     17   CFX_ChecksumContext();
     18   ~CFX_ChecksumContext();
     19 
     20   void StartChecksum();
     21   void Update(const ByteStringView& bsText);
     22   bool UpdateChecksum(const RetainPtr<IFX_SeekableReadStream>& pSrcFile,
     23                       FX_FILESIZE offset = 0,
     24                       size_t size = 0);
     25   void FinishChecksum();
     26   ByteString GetChecksum() const;
     27 
     28  private:
     29   std::unique_ptr<CFX_SAXReader> m_pSAXReader;
     30   std::unique_ptr<CRYPT_sha1_context> m_pByteContext;
     31   ByteString m_bsChecksum;
     32 };
     33 
     34 #endif  // CORE_FXCRT_CFX_CHECKSUMCONTEXT_H_
     35