aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-03 17:53:36 +0000
committerlloyd <[email protected]>2010-03-03 17:53:36 +0000
commit24cef321a2f79907c209f9894c1f486c839c3a7a (patch)
tree39ef40f4415aabb56a07c70515acd9f4052dd81c
parentabbd349e79e1548a5934fb5a2bb7e93388679613 (diff)
Minor cleanups in Salsa20 code
-rw-r--r--src/stream/salsa20/salsa20.cpp48
-rw-r--r--src/stream/salsa20/salsa20.h3
2 files changed, 9 insertions, 42 deletions
diff --git a/src/stream/salsa20/salsa20.cpp b/src/stream/salsa20/salsa20.cpp
index 7238bdcb8..a38e6e305 100644
--- a/src/stream/salsa20/salsa20.cpp
+++ b/src/stream/salsa20/salsa20.cpp
@@ -27,22 +27,10 @@ namespace {
*/
void hsalsa20(u32bit output[8], const u32bit input[16])
{
- u32bit x00 = input[0];
- u32bit x01 = input[1];
- u32bit x02 = input[2];
- u32bit x03 = input[3];
- u32bit x04 = input[4];
- u32bit x05 = input[5];
- u32bit x06 = input[6];
- u32bit x07 = input[7];
- u32bit x08 = input[8];
- u32bit x09 = input[9];
- u32bit x10 = input[10];
- u32bit x11 = input[11];
- u32bit x12 = input[12];
- u32bit x13 = input[13];
- u32bit x14 = input[14];
- u32bit x15 = input[15];
+ u32bit x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3],
+ x04 = input[ 4], x05 = input[ 5], x06 = input[ 6], x07 = input[ 7],
+ x08 = input[ 8], x09 = input[ 9], x10 = input[10], x11 = input[11],
+ x12 = input[12], x13 = input[13], x14 = input[14], x15 = input[15];
for(u32bit i = 0; i != 10; ++i)
{
@@ -72,22 +60,10 @@ void hsalsa20(u32bit output[8], const u32bit input[16])
*/
void salsa20(byte output[64], const u32bit input[16])
{
- u32bit x00 = input[0];
- u32bit x01 = input[1];
- u32bit x02 = input[2];
- u32bit x03 = input[3];
- u32bit x04 = input[4];
- u32bit x05 = input[5];
- u32bit x06 = input[6];
- u32bit x07 = input[7];
- u32bit x08 = input[8];
- u32bit x09 = input[9];
- u32bit x10 = input[10];
- u32bit x11 = input[11];
- u32bit x12 = input[12];
- u32bit x13 = input[13];
- u32bit x14 = input[14];
- u32bit x15 = input[15];
+ u32bit x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3],
+ x04 = input[ 4], x05 = input[ 5], x06 = input[ 6], x07 = input[ 7],
+ x08 = input[ 8], x09 = input[ 9], x10 = input[10], x11 = input[11],
+ x12 = input[12], x13 = input[13], x14 = input[14], x15 = input[15];
for(u32bit i = 0; i != 10; ++i)
{
@@ -261,12 +237,4 @@ void Salsa20::clear()
position = 0;
}
-/*
-* Salsa20 Constructor
-*/
-Salsa20::Salsa20() : StreamCipher(16, 32, 16)
- {
- clear();
- }
-
}
diff --git a/src/stream/salsa20/salsa20.h b/src/stream/salsa20/salsa20.h
index 016745355..af7ddd145 100644
--- a/src/stream/salsa20/salsa20.h
+++ b/src/stream/salsa20/salsa20.h
@@ -29,13 +29,12 @@ class BOTAN_DLL Salsa20 : public StreamCipher
std::string name() const;
StreamCipher* clone() const { return new Salsa20; }
- Salsa20();
+ Salsa20() : StreamCipher(16, 32, 16) { position = 0; }
~Salsa20() { clear(); }
private:
void key_schedule(const byte key[], u32bit key_len);
SecureBuffer<u32bit, 16> state;
-
SecureBuffer<byte, 64> buffer;
u32bit position;
};