diff options
author | Jay Berkenbilt <ejb@ql.org> | 2019-11-04 15:55:43 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2019-11-09 14:18:02 +0100 |
commit | bb427bd11774f47f553257cdc0693f77b559654d (patch) | |
tree | 379100926074a82f81f24d0d6cbe41631b71cc50 /libqpdf/qpdf/SHA2_native.hh | |
parent | eadc222ff9087c8dd41a7afced717a65802e849c (diff) | |
download | qpdf-bb427bd11774f47f553257cdc0693f77b559654d.tar.zst |
SHA2: switch to pluggable crypto
Diffstat (limited to 'libqpdf/qpdf/SHA2_native.hh')
-rw-r--r-- | libqpdf/qpdf/SHA2_native.hh | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/libqpdf/qpdf/SHA2_native.hh b/libqpdf/qpdf/SHA2_native.hh index 0748dd0b..17b77765 100644 --- a/libqpdf/qpdf/SHA2_native.hh +++ b/libqpdf/qpdf/SHA2_native.hh @@ -1,43 +1,21 @@ -#ifndef PL_SHA2_HH -#define PL_SHA2_HH +#ifndef SHA2_NATIVE_HH +#define SHA2_NATIVE_HH -// Bits must be a supported number of bits, currently only 256, 384, -// or 512. Passing 0 as bits leaves the pipeline uncommitted, in -// which case resetBits must be called before the pipeline is used. -// If a next is provided, this pipeline sends its output to its -// successor unmodified. After calling finish, the SHA2 checksum of -// the data that passed through the pipeline is available. - -// This pipeline is reusable; i.e., it is safe to call write() after -// calling finish(). The first call to write() after a call to -// finish() initializes a new SHA2 object. resetBits may also be -// called between finish and the next call to write. - -#include <qpdf/Pipeline.hh> #include <sph/sph_sha2.h> +#include <string> -class Pl_SHA2: public Pipeline +class SHA2_native { public: - QPDF_DLL - Pl_SHA2(int bits = 0, Pipeline* next = 0); - QPDF_DLL - virtual ~Pl_SHA2(); - QPDF_DLL - virtual void write(unsigned char*, size_t); - QPDF_DLL - virtual void finish(); - QPDF_DLL - void resetBits(int bits); - QPDF_DLL - std::string getHexDigest(); - QPDF_DLL + SHA2_native(int bits); + ~SHA2_native() = default; + void update(unsigned char const* const, size_t); + void finalize(); std::string getRawDigest(); private: void badBits(); - bool in_progress; int bits; sph_sha256_context ctx256; sph_sha384_context ctx384; @@ -47,4 +25,4 @@ class Pl_SHA2: public Pipeline unsigned char sha512sum[64]; }; -#endif // PL_SHA2_HH +#endif // SHA2_NATIVE_HH |