Crypto++
salsa.h
1 // salsa.h - written and placed in the public domain by Wei Dai
2 
3 #ifndef CRYPTOPP_SALSA_H
4 #define CRYPTOPP_SALSA_H
5 
6 #include "strciphr.h"
7 
8 NAMESPACE_BEGIN(CryptoPP)
9 
10 //! _
11 struct Salsa20_Info : public VariableKeyLength<32, 16, 32, 16, SimpleKeyingInterface::UNIQUE_IV, 8>
12 {
13  static const char *StaticAlgorithmName() {return "Salsa20";}
14 };
15 
16 class CRYPTOPP_NO_VTABLE Salsa20_Policy : public AdditiveCipherConcretePolicy<word32, 16>
17 {
18 protected:
19  void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
20  void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
21  void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
22  bool CipherIsRandomAccess() const {return true;}
23  void SeekToIteration(lword iterationCount);
24 #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X64
25  unsigned int GetAlignment() const;
26  unsigned int GetOptimalBlockSize() const;
27 #endif
28 
30  int m_rounds;
31 };
32 
33 /// <a href="http://www.cryptolounge.org/wiki/Salsa20">Salsa20</a>, variable rounds: 8, 12 or 20 (default 20)
35 {
37  typedef Encryption Decryption;
38 };
39 
40 //! _
41 struct XSalsa20_Info : public FixedKeyLength<32, SimpleKeyingInterface::UNIQUE_IV, 24>
42 {
43  static const char *StaticAlgorithmName() {return "XSalsa20";}
44 };
45 
46 class CRYPTOPP_NO_VTABLE XSalsa20_Policy : public Salsa20_Policy
47 {
48 public:
49  void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
50  void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
51 
52 protected:
54 };
55 
56 /// <a href="http://www.cryptolounge.org/wiki/XSalsa20">XSalsa20</a>, variable rounds: 8, 12 or 20 (default 20)
58 {
60  typedef Encryption Decryption;
61 };
62 
63 NAMESPACE_END
64 
65 #endif