Botan
1.11.15
|
00001 /* 00002 * Salsa20 / XSalsa20 00003 * (C) 1999-2010 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_SALSA20_H__ 00009 #define BOTAN_SALSA20_H__ 00010 00011 #include <botan/stream_cipher.h> 00012 00013 namespace Botan { 00014 00015 /** 00016 * DJB's Salsa20 (and XSalsa20) 00017 */ 00018 class BOTAN_DLL Salsa20 : public StreamCipher 00019 { 00020 public: 00021 void cipher(const byte in[], byte out[], size_t length); 00022 00023 void set_iv(const byte iv[], size_t iv_len); 00024 00025 bool valid_iv_length(size_t iv_len) const 00026 { return (iv_len == 8 || iv_len == 24); } 00027 00028 Key_Length_Specification key_spec() const 00029 { 00030 return Key_Length_Specification(16, 32, 16); 00031 } 00032 00033 void clear(); 00034 std::string name() const; 00035 StreamCipher* clone() const { return new Salsa20; } 00036 private: 00037 void key_schedule(const byte key[], size_t key_len); 00038 00039 secure_vector<u32bit> m_state; 00040 secure_vector<byte> m_buffer; 00041 size_t m_position; 00042 }; 00043 00044 } 00045 00046 #endif