aboutsummaryrefslogtreecommitdiffstats
path: root/src/stream
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-06-17 21:48:55 +0000
committerlloyd <[email protected]>2010-06-17 21:48:55 +0000
commitc06b260b3328c5ce4be44c4f1a88feb55ee3dbc4 (patch)
tree41b05df5982b5b2e8a23b55972263d2172d6a9fd /src/stream
parent0eecae9f21172c0a74ad62acaf77148c94a25be7 (diff)
parent3dde5683f69b9cb9f558bfb18087ce35fbbec78a (diff)
propagate from branch 'net.randombit.botan' (head 294e2082ce9231d6165276e2f2a4153a0116aca3)
to branch 'net.randombit.botan.c++0x' (head 0b695fad10f924601e07b009fcd781191fafcb28)
Diffstat (limited to 'src/stream')
-rw-r--r--src/stream/arc4/arc4.h10
-rw-r--r--src/stream/ctr/ctr.cpp2
-rw-r--r--src/stream/ctr/ctr.h9
-rw-r--r--src/stream/ofb/ofb.h9
-rw-r--r--src/stream/salsa20/salsa20.h4
-rw-r--r--src/stream/stream_cipher.cpp24
-rw-r--r--src/stream/stream_cipher.h19
-rw-r--r--src/stream/turing/turing.h4
-rw-r--r--src/stream/wid_wake/wid_wake.h5
9 files changed, 60 insertions, 26 deletions
diff --git a/src/stream/arc4/arc4.h b/src/stream/arc4/arc4.h
index 07633f9ef..0488783ef 100644
--- a/src/stream/arc4/arc4.h
+++ b/src/stream/arc4/arc4.h
@@ -13,8 +13,8 @@
namespace Botan {
-/*
-* ARC4
+/**
+* Alleged RC4
*/
class BOTAN_DLL ARC4 : public StreamCipher
{
@@ -26,7 +26,11 @@ class BOTAN_DLL ARC4 : public StreamCipher
StreamCipher* clone() const { return new ARC4(SKIP); }
- ARC4(u32bit = 0);
+ /**
+ * @param skip skip this many initial bytes in the keystream
+ */
+ ARC4(u32bit skip = 0);
+
~ARC4() { clear(); }
private:
void key_schedule(const byte[], u32bit);
diff --git a/src/stream/ctr/ctr.cpp b/src/stream/ctr/ctr.cpp
index 421c9f0c0..8a24cd4d0 100644
--- a/src/stream/ctr/ctr.cpp
+++ b/src/stream/ctr/ctr.cpp
@@ -22,7 +22,7 @@ CTR_BE::CTR_BE(BlockCipher* ciph) :
{
position = 0;
- counter.resize(permutation->BLOCK_SIZE * permutation->parallelism());
+ counter.resize(permutation->parallel_bytes());
buffer.resize(counter.size());
}
diff --git a/src/stream/ctr/ctr.h b/src/stream/ctr/ctr.h
index 5f94170cc..fc7ba522f 100644
--- a/src/stream/ctr/ctr.h
+++ b/src/stream/ctr/ctr.h
@@ -13,8 +13,8 @@
namespace Botan {
-/*
-* CTR-BE (Counter, big-endian)
+/**
+* CTR-BE (Counter mode, big-endian)
*/
class BOTAN_DLL CTR_BE : public StreamCipher
{
@@ -33,7 +33,10 @@ class BOTAN_DLL CTR_BE : public StreamCipher
void clear();
- CTR_BE(BlockCipher*);
+ /**
+ * @param cipher the underlying block cipher to use
+ */
+ CTR_BE(BlockCipher* cipher);
~CTR_BE();
private:
void key_schedule(const byte key[], u32bit key_len);
diff --git a/src/stream/ofb/ofb.h b/src/stream/ofb/ofb.h
index 1985ae5a9..2871dd8ee 100644
--- a/src/stream/ofb/ofb.h
+++ b/src/stream/ofb/ofb.h
@@ -13,8 +13,8 @@
namespace Botan {
-/*
-* OFB Mode
+/**
+* Output Feedback Mode
*/
class BOTAN_DLL OFB : public StreamCipher
{
@@ -33,7 +33,10 @@ class BOTAN_DLL OFB : public StreamCipher
void clear();
- OFB(BlockCipher*);
+ /**
+ * @param cipher the underlying block cipher to use
+ */
+ OFB(BlockCipher* cipher);
~OFB();
private:
void key_schedule(const byte key[], u32bit key_len);
diff --git a/src/stream/salsa20/salsa20.h b/src/stream/salsa20/salsa20.h
index 67fe54dda..4ba483082 100644
--- a/src/stream/salsa20/salsa20.h
+++ b/src/stream/salsa20/salsa20.h
@@ -12,8 +12,8 @@
namespace Botan {
-/*
-* Salsa20 (and XSalsa20)
+/**
+* DJB's Salsa20 (and XSalsa20)
*/
class BOTAN_DLL Salsa20 : public StreamCipher
{
diff --git a/src/stream/stream_cipher.cpp b/src/stream/stream_cipher.cpp
new file mode 100644
index 000000000..9ae548a9e
--- /dev/null
+++ b/src/stream/stream_cipher.cpp
@@ -0,0 +1,24 @@
+/*
+* Stream Cipher
+* (C) 1999-2010 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/stream_cipher.h>
+
+namespace Botan {
+
+void StreamCipher::set_iv(const byte[], u32bit iv_len)
+ {
+ if(iv_len)
+ throw Invalid_Argument("The stream cipher " + name() +
+ " does not support resyncronization");
+ }
+
+bool StreamCipher::valid_iv_length(u32bit iv_len) const
+ {
+ return (iv_len == 0);
+ }
+
+}
diff --git a/src/stream/stream_cipher.h b/src/stream/stream_cipher.h
index cb6fb3481..edeb1aff5 100644
--- a/src/stream/stream_cipher.h
+++ b/src/stream/stream_cipher.h
@@ -1,4 +1,4 @@
-/**
+/*
* Stream Cipher
* (C) 1999-2007 Jack Lloyd
*
@@ -12,8 +12,8 @@
namespace Botan {
-/*
-* Stream Cipher
+/**
+* Base class for all stream ciphers
*/
class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
{
@@ -39,19 +39,13 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
* @param iv the initialization vector
* @param iv_len the length of the IV in bytes
*/
- virtual void set_iv(const byte[], u32bit iv_len)
- {
- if(iv_len)
- throw Invalid_Argument("The stream cipher " + name() +
- " does not support resyncronization");
- }
+ virtual void set_iv(const byte iv[], u32bit iv_len);
/**
* @param iv_len the length of the IV in bytes
* @return if the length is valid for this algorithm
*/
- virtual bool valid_iv_length(u32bit iv_len) const
- { return (iv_len == 0); }
+ virtual bool valid_iv_length(u32bit iv_len) const;
/**
* Get a new object representing the same algorithm as *this
@@ -65,6 +59,9 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
/**
* StreamCipher constructor
+ * @param key_min the minimum key size
+ * @param key_max the maximum key size
+ * @param key_mod the modulo restriction on the key size
*/
StreamCipher(u32bit key_min,
u32bit key_max = 0,
diff --git a/src/stream/turing/turing.h b/src/stream/turing/turing.h
index 19d151fca..92c5083a4 100644
--- a/src/stream/turing/turing.h
+++ b/src/stream/turing/turing.h
@@ -12,14 +12,14 @@
namespace Botan {
-/*
+/**
* Turing
*/
class BOTAN_DLL Turing : public StreamCipher
{
public:
void cipher(const byte in[], byte out[], u32bit length);
- void set_iv(const byte[], u32bit);
+ void set_iv(const byte iv[], u32bit iv_length);
bool valid_iv_length(u32bit iv_len) const
{ return (iv_len % 4 == 0 && iv_len <= 16); }
diff --git a/src/stream/wid_wake/wid_wake.h b/src/stream/wid_wake/wid_wake.h
index 1c52e8ba1..365a6d9ff 100644
--- a/src/stream/wid_wake/wid_wake.h
+++ b/src/stream/wid_wake/wid_wake.h
@@ -12,8 +12,11 @@
namespace Botan {
-/*
+/**
* WiderWake4+1-BE
+*
+* Note: quite old and possibly not safe; use XSalsa20 or a block
+* cipher in counter mode.
*/
class BOTAN_DLL WiderWake_41_BE : public StreamCipher
{