Coverage Report

Created: 2024-09-08 06:06

/src/qpdf/libqpdf/qpdf/Pl_SHA2.hh
Line
Count
Source
1
#ifndef PL_SHA2_HH
2
#define PL_SHA2_HH
3
4
// Bits must be a supported number of bits, currently only 256, 384, or 512.  Passing 0 as bits
5
// leaves the pipeline uncommitted, in which case resetBits must be called before the pipeline is
6
// used. If a next is provided, this pipeline sends its output to its successor unmodified.  After
7
// calling finish, the SHA2 checksum of the data that passed through the pipeline is available.
8
9
// This pipeline is reusable; i.e., it is safe to call write() after calling finish().  The first
10
// call to write() after a call to finish() initializes a new SHA2 object.  resetBits may also be
11
// called between finish and the next call to write.
12
13
#include <qpdf/Pipeline.hh>
14
#include <qpdf/QPDFCryptoImpl.hh>
15
#include <memory>
16
17
class Pl_SHA2: public Pipeline
18
{
19
  public:
20
    Pl_SHA2(int bits = 0, Pipeline* next = nullptr);
21
1.23M
    ~Pl_SHA2() override = default;
22
    void write(unsigned char const*, size_t) override;
23
    void finish() override;
24
    void resetBits(int bits);
25
    std::string getHexDigest();
26
    std::string getRawDigest();
27
28
  private:
29
    bool in_progress;
30
    std::shared_ptr<QPDFCryptoImpl> crypto;
31
};
32
33
#endif // PL_SHA2_HH