diff options
Diffstat (limited to 'libqpdf/Pl_SHA2.cc')
-rw-r--r-- | libqpdf/Pl_SHA2.cc | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/libqpdf/Pl_SHA2.cc b/libqpdf/Pl_SHA2.cc index 8844eb16..d41e6a78 100644 --- a/libqpdf/Pl_SHA2.cc +++ b/libqpdf/Pl_SHA2.cc @@ -1,17 +1,16 @@ #include <qpdf/Pl_SHA2.hh> -#include <stdexcept> -#include <cstdio> #include <qpdf/PointerHolder.hh> -#include <qpdf/QUtil.hh> #include <qpdf/QPDFCryptoProvider.hh> +#include <qpdf/QUtil.hh> +#include <cstdio> +#include <stdexcept> Pl_SHA2::Pl_SHA2(int bits, Pipeline* next) : Pipeline("sha2", next), in_progress(false) { - if (bits) - { + if (bits) { resetBits(bits); } } @@ -23,8 +22,7 @@ Pl_SHA2::~Pl_SHA2() void Pl_SHA2::write(unsigned char* buf, size_t len) { - if (! this->in_progress) - { + if (!this->in_progress) { this->in_progress = true; } @@ -33,16 +31,14 @@ Pl_SHA2::write(unsigned char* buf, size_t len) static size_t const max_bytes = 1 << 30; size_t bytes_left = len; unsigned char* data = buf; - while (bytes_left > 0) - { + while (bytes_left > 0) { size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left); this->crypto->SHA2_update(data, bytes); bytes_left -= bytes; data += bytes; } - if (this->getNext(true)) - { + if (this->getNext(true)) { this->getNext()->write(buf, len); } } @@ -50,8 +46,7 @@ Pl_SHA2::write(unsigned char* buf, size_t len) void Pl_SHA2::finish() { - if (this->getNext(true)) - { + if (this->getNext(true)) { this->getNext()->finish(); } this->crypto->SHA2_finalize(); @@ -61,8 +56,7 @@ Pl_SHA2::finish() void Pl_SHA2::resetBits(int bits) { - if (this->in_progress) - { + if (this->in_progress) { throw std::logic_error( "bit reset requested for in-progress SHA2 Pipeline"); } @@ -73,8 +67,7 @@ Pl_SHA2::resetBits(int bits) std::string Pl_SHA2::getRawDigest() { - if (this->in_progress) - { + if (this->in_progress) { throw std::logic_error( "digest requested for in-progress SHA2 Pipeline"); } @@ -84,8 +77,7 @@ Pl_SHA2::getRawDigest() std::string Pl_SHA2::getHexDigest() { - if (this->in_progress) - { + if (this->in_progress) { throw std::logic_error( "digest requested for in-progress SHA2 Pipeline"); } |