diff options
author | René Korthaus <[email protected]> | 2015-12-23 11:52:19 +0100 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-01-08 19:09:51 -0500 |
commit | d22bc10cd4f67924acd82bcd46a31e3de3b20ce3 (patch) | |
tree | 58459585e6675cd799b6ef5900be026825cd6f9d /src/lib/stream/rc4/rc4.cpp | |
parent | 2fbfdd7e5afb5e888fd8c0b56c6df09e2bdeaca7 (diff) |
Mass-prefix member vars with m_
Diffstat (limited to 'src/lib/stream/rc4/rc4.cpp')
-rw-r--r-- | src/lib/stream/rc4/rc4.cpp | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/src/lib/stream/rc4/rc4.cpp b/src/lib/stream/rc4/rc4.cpp index 9a6268b8c..895f38091 100644 --- a/src/lib/stream/rc4/rc4.cpp +++ b/src/lib/stream/rc4/rc4.cpp @@ -23,16 +23,16 @@ RC4* RC4::make(const Spec& spec) */ void RC4::cipher(const byte in[], byte out[], size_t length) { - while(length >= buffer.size() - position) + while(length >= m_buffer.size() - m_position) { - xor_buf(out, in, &buffer[position], buffer.size() - position); - length -= (buffer.size() - position); - in += (buffer.size() - position); - out += (buffer.size() - position); + xor_buf(out, in, &m_buffer[m_position], m_buffer.size() - m_position); + length -= (m_buffer.size() - m_position); + in += (m_buffer.size() - m_position); + out += (m_buffer.size() - m_position); generate(); } - xor_buf(out, in, &buffer[position], length); - position += length; + xor_buf(out, in, &m_buffer[m_position], length); + m_position += length; } /* @@ -41,26 +41,26 @@ void RC4::cipher(const byte in[], byte out[], size_t length) void RC4::generate() { byte SX, SY; - for(size_t i = 0; i != buffer.size(); i += 4) + for(size_t i = 0; i != m_buffer.size(); i += 4) { - SX = state[X+1]; Y = (Y + SX) % 256; SY = state[Y]; - state[X+1] = SY; state[Y] = SX; - buffer[i] = state[(SX + SY) % 256]; - - SX = state[X+2]; Y = (Y + SX) % 256; SY = state[Y]; - state[X+2] = SY; state[Y] = SX; - buffer[i+1] = state[(SX + SY) % 256]; - - SX = state[X+3]; Y = (Y + SX) % 256; SY = state[Y]; - state[X+3] = SY; state[Y] = SX; - buffer[i+2] = state[(SX + SY) % 256]; - - X = (X + 4) % 256; - SX = state[X]; Y = (Y + SX) % 256; SY = state[Y]; - state[X] = SY; state[Y] = SX; - buffer[i+3] = state[(SX + SY) % 256]; + SX = m_state[m_X+1]; m_Y = (m_Y + SX) % 256; SY = m_state[m_Y]; + m_state[m_X+1] = SY; m_state[m_Y] = SX; + m_buffer[i] = m_state[(SX + SY) % 256]; + + SX = m_state[m_X+2]; m_Y = (m_Y + SX) % 256; SY = m_state[m_Y]; + m_state[m_X+2] = SY; m_state[m_Y] = SX; + m_buffer[i+1] = m_state[(SX + SY) % 256]; + + SX = m_state[m_X+3]; m_Y = (m_Y + SX) % 256; SY = m_state[m_Y]; + m_state[m_X+3] = SY; m_state[m_Y] = SX; + m_buffer[i+2] = m_state[(SX + SY) % 256]; + + m_X = (m_X + 4) % 256; + SX = m_state[m_X]; m_Y = (m_Y + SX) % 256; SY = m_state[m_Y]; + m_state[m_X] = SY; m_state[m_Y] = SX; + m_buffer[i+3] = m_state[(SX + SY) % 256]; } - position = 0; + m_position = 0; } /* @@ -68,24 +68,24 @@ void RC4::generate() */ void RC4::key_schedule(const byte key[], size_t length) { - state.resize(256); - buffer.resize(256); + m_state.resize(256); + m_buffer.resize(256); - position = X = Y = 0; + m_position = m_X = m_Y = 0; for(size_t i = 0; i != 256; ++i) - state[i] = static_cast<byte>(i); + m_state[i] = static_cast<byte>(i); for(size_t i = 0, state_index = 0; i != 256; ++i) { - state_index = (state_index + key[i % length] + state[i]) % 256; - std::swap(state[i], state[state_index]); + state_index = (state_index + key[i % length] + m_state[i]) % 256; + std::swap(m_state[i], m_state[state_index]); } - for(size_t i = 0; i <= SKIP; i += buffer.size()) + for(size_t i = 0; i <= m_SKIP; i += m_buffer.size()) generate(); - position += (SKIP % buffer.size()); + m_position += (m_SKIP % m_buffer.size()); } /* @@ -93,9 +93,9 @@ void RC4::key_schedule(const byte key[], size_t length) */ std::string RC4::name() const { - if(SKIP == 0) return "RC4"; - if(SKIP == 256) return "MARK-4"; - else return "RC4_skip(" + std::to_string(SKIP) + ")"; + if(m_SKIP == 0) return "RC4"; + if(m_SKIP == 256) return "MARK-4"; + else return "RC4_skip(" + std::to_string(m_SKIP) + ")"; } /* @@ -103,14 +103,14 @@ std::string RC4::name() const */ void RC4::clear() { - zap(state); - zap(buffer); - position = X = Y = 0; + zap(m_state); + zap(m_buffer); + m_position = m_X = m_Y = 0; } /* * RC4 Constructor */ -RC4::RC4(size_t s) : SKIP(s) {} +RC4::RC4(size_t s) : m_SKIP(s) {} } |