Botan  1.10.9
salsa20.h
Go to the documentation of this file.
1 /*
2 * Salsa20 / XSalsa20
3 * (C) 1999-2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_SALSA20_H__
9 #define BOTAN_SALSA20_H__
10 
11 #include <botan/stream_cipher.h>
12 
13 namespace Botan {
14 
15 /**
16 * DJB's Salsa20 (and XSalsa20)
17 */
18 class BOTAN_DLL Salsa20 : public StreamCipher
19  {
20  public:
21  void cipher(const byte in[], byte out[], size_t length);
22 
23  void set_iv(const byte iv[], size_t iv_len);
24 
25  bool valid_iv_length(size_t iv_len) const
26  { return (iv_len == 8 || iv_len == 24); }
27 
29  {
30  return Key_Length_Specification(16, 32, 16);
31  }
32 
33  void clear();
34  std::string name() const;
35  StreamCipher* clone() const { return new Salsa20; }
36 
37  Salsa20() : state(16), buffer(64), position(0) {}
38  private:
39  void key_schedule(const byte key[], size_t key_len);
40 
42  SecureVector<byte> buffer;
43  size_t position;
44  };
45 
46 }
47 
48 #endif
Key_Length_Specification key_spec() const
Definition: salsa20.h:28
bool valid_iv_length(size_t iv_len) const
Definition: salsa20.h:25
unsigned char byte
Definition: types.h:22
RC4_KEY state
Definition: ossl_arc4.cpp:39
StreamCipher * clone() const
Definition: salsa20.h:35