aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/Pl_SHA2.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-04-02 23:14:10 +0200
committerJay Berkenbilt <ejb@ql.org>2022-04-04 14:10:40 +0200
commit12f1eb15ca3fed6310402847559a7c99d3c77847 (patch)
tree8935675b623c6f3b4914b8b44f7fa5f2816a9241 /libqpdf/Pl_SHA2.cc
parentf20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb (diff)
downloadqpdf-12f1eb15ca3fed6310402847559a7c99d3c77847.tar.zst
Programmatically apply new formatting to code
Run this: for i in **/*.cc **/*.c **/*.h **/*.hh; do clang-format < $i >| $i.new && mv $i.new $i done
Diffstat (limited to 'libqpdf/Pl_SHA2.cc')
-rw-r--r--libqpdf/Pl_SHA2.cc30
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");
}