aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/RC4_native.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-02-08 15:18:08 +0100
committerJay Berkenbilt <ejb@ql.org>2022-02-08 17:51:15 +0100
commitcb769c62e55599e9f980001830bc61d9fcaa64a9 (patch)
tree0bf980c385a61cbc8720cf990762ffc1200f9d6a /libqpdf/RC4_native.cc
parent716381f65a2b2dc72f8da2426ba71aeab02c507f (diff)
downloadqpdf-cb769c62e55599e9f980001830bc61d9fcaa64a9.tar.zst
WHITESPACE ONLY -- expand tabs in source code
This comment expands all tabs using an 8-character tab-width. You should ignore this commit when using git blame or use git blame -w. In the early days, I used to use tabs where possible for indentation, since emacs did this automatically. In recent years, I have switched to only using spaces, which means qpdf source code has been a mixture of spaces and tabs. I have avoided cleaning this up because of not wanting gratuitous whitespaces change to cloud the output of git blame, but I changed my mind after discussing with users who view qpdf source code in editors/IDEs that have other tab widths by default and in light of the fact that I am planning to start applying automatic code formatting soon.
Diffstat (limited to 'libqpdf/RC4_native.cc')
-rw-r--r--libqpdf/RC4_native.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/libqpdf/RC4_native.cc b/libqpdf/RC4_native.cc
index 8559d9bd..bb0b9013 100644
--- a/libqpdf/RC4_native.cc
+++ b/libqpdf/RC4_native.cc
@@ -17,7 +17,7 @@ RC4_native::RC4_native(unsigned char const* key_data, int key_len)
{
if (key_len == -1)
{
- key_len = QIntC::to_int(
+ key_len = QIntC::to_int(
strlen(reinterpret_cast<char const*>(key_data)));
}
@@ -32,9 +32,9 @@ RC4_native::RC4_native(unsigned char const* key_data, int key_len)
int i2 = 0;
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;
+ i2 = (key_data[i1] + key.state[i] + i2) % 256;
+ swap_byte(key.state[i], key.state[i2]);
+ i1 = (i1 + 1) % key_len;
}
}
@@ -43,16 +43,16 @@ RC4_native::process(unsigned char *in_data, size_t len, unsigned char* out_data)
{
if (out_data == 0)
{
- // Convert in place
- out_data = in_data;
+ // Convert in place
+ out_data = in_data;
}
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]);
- int xor_index = (key.state[key.x] + key.state[key.y]) % 256;
- out_data[i] = in_data[i] ^ key.state[xor_index];
+ 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]);
+ int xor_index = (key.state[key.x] + key.state[key.y]) % 256;
+ out_data[i] = in_data[i] ^ key.state[xor_index];
}
}