summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-05-05 22:35:00 +0200
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-05-05 22:35:00 +0200
commit80caac69c56411ef2df487f3e514abccad480572 (patch)
treec0aa5dcf7d3ba4282e4d1ab17d96b734fce53298
parent556b463a79594c4a90e12237d6d5212d460f41d1 (diff)
downloadIT-Sicherheit-80caac69c56411ef2df487f3e514abccad480572.tar.gz
IT-Sicherheit-80caac69c56411ef2df487f3e514abccad480572.zip
Fix a rare bug according to Heiko
-rw-r--r--src/crypt/cryptrc4.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/crypt/cryptrc4.cpp b/src/crypt/cryptrc4.cpp
index 88806c8..2154b04 100644
--- a/src/crypt/cryptrc4.cpp
+++ b/src/crypt/cryptrc4.cpp
@@ -24,12 +24,14 @@ void CryptRc4::rc4SetKeyOwn(QByteArray key)
m_rc4Key.x = 0;
m_rc4Key.y = 0;
- for(RC4_INT i = 0; i < 256; i++)
+ for (int i = 0; i < 256; i++)
{
- m_rc4Key.data[i] = i;
+ m_rc4Key.data[i] = i;
}
+
RC4_INT j = 0;
- for(RC4_INT i = 0; i < 256; i++)
+
+ for (int i = 0; i < 256; i++)
{
j = (j + m_rc4Key.data[i] + key[i % key.length()]) % 256;
swap(m_rc4Key.data[i], m_rc4Key.data[j]);
@@ -50,14 +52,16 @@ QByteArray CryptRc4::rc4RunOwn(QByteArray clear)
RC4_INT i = 0;
RC4_INT j = 0;
- for(int k = 0; k < crypt.length(); k++)
+
+ for (int k = 0; k < crypt.length(); k++)
{
i = (i + 1) % 256;
j = (j + m_rc4Key.data[i]) % 256;
swap(m_rc4Key.data[i], m_rc4Key.data[j]);
- crypt[k] = crypt[k] ^ m_rc4Key.data[(m_rc4Key.data[i] + m_rc4Key.data[j]) % 256];
+ crypt[k] = crypt[k] ^ m_rc4Key.data[(m_rc4Key.data[i] + m_rc4Key.data[j]) %
+ 256];
}
return crypt;