diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-04-02 23:14:10 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-04-04 14:10:40 +0200 |
commit | 12f1eb15ca3fed6310402847559a7c99d3c77847 (patch) | |
tree | 8935675b623c6f3b4914b8b44f7fa5f2816a9241 /libqpdf/SHA2_native.cc | |
parent | f20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb (diff) | |
download | qpdf-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/SHA2_native.cc')
-rw-r--r-- | libqpdf/SHA2_native.cc | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/libqpdf/SHA2_native.cc b/libqpdf/SHA2_native.cc index c40b48b4..949d5634 100644 --- a/libqpdf/SHA2_native.cc +++ b/libqpdf/SHA2_native.cc @@ -1,26 +1,24 @@ #include <qpdf/SHA2_native.hh> -#include <stdexcept> -#include <cstdio> #include <qpdf/PointerHolder.hh> #include <qpdf/QUtil.hh> - +#include <cstdio> +#include <stdexcept> SHA2_native::SHA2_native(int bits) : bits(bits) { - switch (bits) - { - case 256: + switch (bits) { + case 256: sph_sha256_init(&this->ctx256); break; - case 384: + case 384: sph_sha384_init(&this->ctx384); break; - case 512: + case 512: sph_sha512_init(&this->ctx512); break; - default: + default: badBits(); break; } @@ -35,18 +33,17 @@ SHA2_native::badBits() void SHA2_native::update(unsigned char const* buf, size_t len) { - switch (bits) - { - case 256: + switch (bits) { + case 256: sph_sha256(&this->ctx256, buf, len); break; - case 384: + case 384: sph_sha384(&this->ctx384, buf, len); break; - case 512: + case 512: sph_sha512(&this->ctx512, buf, len); break; - default: + default: badBits(); break; } @@ -55,18 +52,17 @@ SHA2_native::update(unsigned char const* buf, size_t len) void SHA2_native::finalize() { - switch (bits) - { - case 256: + switch (bits) { + case 256: sph_sha256_close(&this->ctx256, sha256sum); break; - case 384: + case 384: sph_sha384_close(&this->ctx384, sha384sum); break; - case 512: + case 512: sph_sha512_close(&this->ctx512, sha512sum); break; - default: + default: badBits(); break; } @@ -76,21 +72,20 @@ std::string SHA2_native::getRawDigest() { std::string result; - switch (bits) - { - case 256: - result = std::string(reinterpret_cast<char*>(this->sha256sum), - sizeof(this->sha256sum)); + switch (bits) { + case 256: + result = std::string( + reinterpret_cast<char*>(this->sha256sum), sizeof(this->sha256sum)); break; - case 384: - result = std::string(reinterpret_cast<char*>(this->sha384sum), - sizeof(this->sha384sum)); + case 384: + result = std::string( + reinterpret_cast<char*>(this->sha384sum), sizeof(this->sha384sum)); break; - case 512: - result = std::string(reinterpret_cast<char*>(this->sha512sum), - sizeof(this->sha512sum)); + case 512: + result = std::string( + reinterpret_cast<char*>(this->sha512sum), sizeof(this->sha512sum)); break; - default: + default: badBits(); break; } |