aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/stream/chacha/chacha.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-04-04 23:30:13 -0400
committerJack Lloyd <[email protected]>2016-04-09 12:57:47 -0400
commit088e85ea774e9035c0b951c27a1a00d0793fa01e (patch)
tree9254702508469a6148c5c5ba28d78239cb1eb028 /src/lib/stream/chacha/chacha.h
parent8dd6eb9252ad91f59630e2889fa6803f6e3bf554 (diff)
Add support for ChaCha(12)
Diffstat (limited to 'src/lib/stream/chacha/chacha.h')
-rw-r--r--src/lib/stream/chacha/chacha.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/stream/chacha/chacha.h b/src/lib/stream/chacha/chacha.h
index 92f8ef035..ba93d6260 100644
--- a/src/lib/stream/chacha/chacha.h
+++ b/src/lib/stream/chacha/chacha.h
@@ -18,6 +18,14 @@ namespace Botan {
class BOTAN_DLL ChaCha final : public StreamCipher
{
public:
+ StreamCipher* clone() const override { return new ChaCha(m_rounds); }
+
+ /**
+ * Currently only 12 or 20 rounds are supported, all others
+ * will throw an exception
+ */
+ ChaCha(size_t rounds);
+
void cipher(const byte in[], byte out[], size_t length) override;
void set_iv(const byte iv[], size_t iv_len) override;
@@ -31,14 +39,13 @@ class BOTAN_DLL ChaCha final : public StreamCipher
}
void clear() override;
- std::string name() const override { return "ChaCha"; }
- StreamCipher* clone() const override { return new ChaCha; }
- protected:
- virtual void chacha(byte output[64], const u32bit input[16]);
+ std::string name() const override;
+
private:
void key_schedule(const byte key[], size_t key_len) override;
+ size_t m_rounds;
secure_vector<u32bit> m_state;
secure_vector<byte> m_buffer;
size_t m_position = 0;