Skip to content

Commit 71dc933

Browse files
committed
format code
1 parent a26c9c4 commit 71dc933

File tree

2 files changed

+32
-34
lines changed

2 files changed

+32
-34
lines changed

src/obfuscate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class obfuscator {
5959
}
6060

6161
private:
62-
6362
char m_data[N]{};
6463
};
6564

@@ -111,7 +110,6 @@ class obfuscated_data {
111110
}
112111

113112
private:
114-
115113
// Local storage for the string. Call is_encrypted() to check whether or
116114
// not the string is currently obfuscated.
117115
char m_data[N];

src/rc4.h

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,38 @@ typedef unsigned int u32;
3131
* encryption/decryption.
3232
*/
3333
FORCE_INLINE void rc4_skip(const u8 *key, size_t keylen, size_t skip,
34-
u8 *data, size_t data_len)
34+
u8 *data, size_t data_len)
3535
{
36-
u32 i, j, k;
37-
u8 S[256], *pos;
38-
size_t kpos;
39-
/* Setup RC4 state */
40-
for (i = 0; i < 256; i++)
41-
S[i] = i;
42-
j = 0;
43-
kpos = 0;
44-
for (i = 0; i < 256; i++) {
45-
j = (j + S[i] + key[kpos]) & 0xff;
46-
kpos++;
47-
if (kpos >= keylen)
48-
kpos = 0;
49-
S_SWAP(i, j);
50-
}
51-
/* Skip the start of the stream */
52-
i = j = 0;
53-
for (k = 0; k < skip; k++) {
54-
i = (i + 1) & 0xff;
55-
j = (j + S[i]) & 0xff;
56-
S_SWAP(i, j);
57-
}
58-
/* Apply RC4 to data */
59-
pos = data;
60-
for (k = 0; k < data_len; k++) {
61-
i = (i + 1) & 0xff;
62-
j = (j + S[i]) & 0xff;
63-
S_SWAP(i, j);
64-
*pos++ ^= S[(S[i] + S[j]) & 0xff];
65-
}
36+
u32 i, j, k;
37+
u8 S[256], *pos;
38+
size_t kpos;
39+
/* Setup RC4 state */
40+
for (i = 0; i < 256; i++)
41+
S[i] = i;
42+
j = 0;
43+
kpos = 0;
44+
for (i = 0; i < 256; i++) {
45+
j = (j + S[i] + key[kpos]) & 0xff;
46+
kpos++;
47+
if (kpos >= keylen)
48+
kpos = 0;
49+
S_SWAP(i, j);
50+
}
51+
/* Skip the start of the stream */
52+
i = j = 0;
53+
for (k = 0; k < skip; k++) {
54+
i = (i + 1) & 0xff;
55+
j = (j + S[i]) & 0xff;
56+
S_SWAP(i, j);
57+
}
58+
/* Apply RC4 to data */
59+
pos = data;
60+
for (k = 0; k < data_len; k++) {
61+
i = (i + 1) & 0xff;
62+
j = (j + S[i]) & 0xff;
63+
S_SWAP(i, j);
64+
*pos++ ^= S[(S[i] + S[j]) & 0xff];
65+
}
6666
}
6767
/**
6868
* rc4 - XOR RC4 stream to given data
@@ -76,5 +76,5 @@ FORCE_INLINE void rc4_skip(const u8 *key, size_t keylen, size_t skip,
7676
*/
7777
FORCE_INLINE void rc4(u8 *buf, size_t len, const u8 *key, size_t key_len)
7878
{
79-
rc4_skip(key, key_len, 0, buf, len);
79+
rc4_skip(key, key_len, 0, buf, len);
8080
}

0 commit comments

Comments
 (0)