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/RC4_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/RC4_native.cc')
-rw-r--r-- | libqpdf/RC4_native.cc | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/libqpdf/RC4_native.cc b/libqpdf/RC4_native.cc index bb0b9013..e2d36554 100644 --- a/libqpdf/RC4_native.cc +++ b/libqpdf/RC4_native.cc @@ -4,7 +4,8 @@ #include <string.h> -static void swap_byte(unsigned char &a, unsigned char &b) +static void +swap_byte(unsigned char& a, unsigned char& b) { unsigned char t; @@ -15,14 +16,12 @@ static void swap_byte(unsigned char &a, unsigned char &b) RC4_native::RC4_native(unsigned char const* key_data, int key_len) { - if (key_len == -1) - { - key_len = QIntC::to_int( - strlen(reinterpret_cast<char const*>(key_data))); + if (key_len == -1) { + key_len = + QIntC::to_int(strlen(reinterpret_cast<char const*>(key_data))); } - for (int i = 0; i < 256; ++i) - { + for (int i = 0; i < 256; ++i) { key.state[i] = static_cast<unsigned char>(i); } key.x = 0; @@ -30,8 +29,7 @@ RC4_native::RC4_native(unsigned char const* key_data, int key_len) int i1 = 0; int i2 = 0; - for (int i = 0; i < 256; ++i) - { + for (int i = 0; i < 256; ++i) { i2 = (key_data[i1] + key.state[i] + i2) % 256; swap_byte(key.state[i], key.state[i2]); i1 = (i1 + 1) % key_len; @@ -39,16 +37,14 @@ RC4_native::RC4_native(unsigned char const* key_data, int key_len) } void -RC4_native::process(unsigned char *in_data, size_t len, unsigned char* out_data) +RC4_native::process(unsigned char* in_data, size_t len, unsigned char* out_data) { - if (out_data == 0) - { + if (out_data == 0) { // Convert in place out_data = in_data; } - for (size_t i = 0; i < len; ++i) - { + for (size_t i = 0; i < len; ++i) { key.x = static_cast<unsigned char>((key.x + 1) % 256); key.y = static_cast<unsigned char>((key.state[key.x] + key.y) % 256); swap_byte(key.state[key.x], key.state[key.y]); |