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