diff options
Diffstat (limited to 'src/lib/block/rc2/rc2.cpp')
-rw-r--r-- | src/lib/block/rc2/rc2.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/lib/block/rc2/rc2.cpp b/src/lib/block/rc2/rc2.cpp index bcd8475e3..112c6561d 100644 --- a/src/lib/block/rc2/rc2.cpp +++ b/src/lib/block/rc2/rc2.cpp @@ -24,24 +24,24 @@ void RC2::encrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 16; ++j) { - R0 += (R1 & ~R3) + (R2 & R3) + K[4*j]; + R0 += (R1 & ~R3) + (R2 & R3) + m_K[4*j]; R0 = rotate_left(R0, 1); - R1 += (R2 & ~R0) + (R3 & R0) + K[4*j + 1]; + R1 += (R2 & ~R0) + (R3 & R0) + m_K[4*j + 1]; R1 = rotate_left(R1, 2); - R2 += (R3 & ~R1) + (R0 & R1) + K[4*j + 2]; + R2 += (R3 & ~R1) + (R0 & R1) + m_K[4*j + 2]; R2 = rotate_left(R2, 3); - R3 += (R0 & ~R2) + (R1 & R2) + K[4*j + 3]; + R3 += (R0 & ~R2) + (R1 & R2) + m_K[4*j + 3]; R3 = rotate_left(R3, 5); if(j == 4 || j == 10) { - R0 += K[R3 % 64]; - R1 += K[R0 % 64]; - R2 += K[R1 % 64]; - R3 += K[R2 % 64]; + R0 += m_K[R3 % 64]; + R1 += m_K[R0 % 64]; + R2 += m_K[R1 % 64]; + R3 += m_K[R2 % 64]; } } @@ -67,23 +67,23 @@ void RC2::decrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 16; ++j) { R3 = rotate_right(R3, 5); - R3 -= (R0 & ~R2) + (R1 & R2) + K[63 - (4*j + 0)]; + R3 -= (R0 & ~R2) + (R1 & R2) + m_K[63 - (4*j + 0)]; R2 = rotate_right(R2, 3); - R2 -= (R3 & ~R1) + (R0 & R1) + K[63 - (4*j + 1)]; + R2 -= (R3 & ~R1) + (R0 & R1) + m_K[63 - (4*j + 1)]; R1 = rotate_right(R1, 2); - R1 -= (R2 & ~R0) + (R3 & R0) + K[63 - (4*j + 2)]; + R1 -= (R2 & ~R0) + (R3 & R0) + m_K[63 - (4*j + 2)]; R0 = rotate_right(R0, 1); - R0 -= (R1 & ~R3) + (R2 & R3) + K[63 - (4*j + 3)]; + R0 -= (R1 & ~R3) + (R2 & R3) + m_K[63 - (4*j + 3)]; if(j == 4 || j == 10) { - R3 -= K[R2 % 64]; - R2 -= K[R1 % 64]; - R1 -= K[R0 % 64]; - R0 -= K[R3 % 64]; + R3 -= m_K[R2 % 64]; + R2 -= m_K[R1 % 64]; + R1 -= m_K[R0 % 64]; + R0 -= m_K[R3 % 64]; } } @@ -134,13 +134,13 @@ void RC2::key_schedule(const byte key[], size_t length) for(s32bit i = 127-length; i >= 0; --i) L[i] = TABLE[L[i+1] ^ L[i+length]]; - K.resize(64); - load_le<u16bit>(K.data(), L.data(), 64); + m_K.resize(64); + load_le<u16bit>(m_K.data(), L.data(), 64); } void RC2::clear() { - zap(K); + zap(m_K); } /* |