aboutsummaryrefslogtreecommitdiffstats
path: root/src/stream/arc4/arc4.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-04-19 14:56:02 +0000
committerlloyd <[email protected]>2013-04-19 14:56:02 +0000
commitabbf2b764c6fd2339c9e4fbc4647072087683f48 (patch)
tree21495af9492a03a0707343b3a0d8ade830c0699e /src/stream/arc4/arc4.cpp
parentd6d870741bb2272b564153b26a638fb6e29ddd89 (diff)
Rename ARC4 to RC4
Diffstat (limited to 'src/stream/arc4/arc4.cpp')
-rw-r--r--src/stream/arc4/arc4.cpp109
1 files changed, 0 insertions, 109 deletions
diff --git a/src/stream/arc4/arc4.cpp b/src/stream/arc4/arc4.cpp
deleted file mode 100644
index da1694a96..000000000
--- a/src/stream/arc4/arc4.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-* ARC4
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/arc4.h>
-#include <botan/internal/xor_buf.h>
-#include <botan/internal/rounding.h>
-
-namespace Botan {
-
-/*
-* Combine cipher stream with message
-*/
-void ARC4::cipher(const byte in[], byte out[], size_t length)
- {
- while(length >= buffer.size() - position)
- {
- xor_buf(out, in, &buffer[position], buffer.size() - position);
- length -= (buffer.size() - position);
- in += (buffer.size() - position);
- out += (buffer.size() - position);
- generate();
- }
- xor_buf(out, in, &buffer[position], length);
- position += length;
- }
-
-/*
-* Generate cipher stream
-*/
-void ARC4::generate()
- {
- byte SX, SY;
- for(size_t i = 0; i != 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];
- }
- position = 0;
- }
-
-/*
-* ARC4 Key Schedule
-*/
-void ARC4::key_schedule(const byte key[], size_t length)
- {
- state.resize(256);
- buffer.resize(round_up<size_t>(DEFAULT_BUFFERSIZE, 4));
-
- position = X = Y = 0;
-
- for(size_t i = 0; i != 256; ++i)
- 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]);
- }
-
- for(size_t i = 0; i <= SKIP; i += buffer.size())
- generate();
-
- position += (SKIP % buffer.size());
- }
-
-/*
-* Return the name of this type
-*/
-std::string ARC4::name() const
- {
- if(SKIP == 0) return "ARC4";
- if(SKIP == 256) return "MARK-4";
- else return "RC4_skip(" + std::to_string(SKIP) + ")";
- }
-
-/*
-* Clear memory of sensitive data
-*/
-void ARC4::clear()
- {
- zap(state);
- zap(buffer);
- position = X = Y = 0;
- }
-
-/*
-* ARC4 Constructor
-*/
-ARC4::ARC4(size_t s) : SKIP(s) {}
-
-}