1
// salsa.h - written and placed in the public domain by Wei Dai
3
#ifndef CRYPTOPP_SALSA_H
4
#define CRYPTOPP_SALSA_H
8
NAMESPACE_BEGIN(CryptoPP)
11
struct Salsa20_Info : public VariableKeyLength<32, 16, 32, 16, SimpleKeyingInterface::UNIQUE_IV, 8>
13
static const char *StaticAlgorithmName() {return "Salsa20";}
16
class CRYPTOPP_NO_VTABLE Salsa20_Policy : public AdditiveCipherConcretePolicy<word32, 16>
19
void CipherSetKey(const NameValuePairs ¶ms, 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;
29
FixedSizeAlignedSecBlock<word32, 16> m_state;
33
/// <a href="http://www.cryptolounge.org/wiki/Salsa20">Salsa20</a>, variable rounds: 8, 12 or 20 (default 20)
34
struct Salsa20 : public Salsa20_Info, public SymmetricCipherDocumentation
36
typedef SymmetricCipherFinal<ConcretePolicyHolder<Salsa20_Policy, AdditiveCipherTemplate<> >, Salsa20_Info> Encryption;
37
typedef Encryption Decryption;
41
struct XSalsa20_Info : public FixedKeyLength<32, SimpleKeyingInterface::UNIQUE_IV, 24>
43
static const char *StaticAlgorithmName() {return "XSalsa20";}
46
class CRYPTOPP_NO_VTABLE XSalsa20_Policy : public Salsa20_Policy
49
void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length);
50
void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
53
FixedSizeSecBlock<word32, 8> m_key;
56
/// <a href="http://www.cryptolounge.org/wiki/XSalsa20">XSalsa20</a>, variable rounds: 8, 12 or 20 (default 20)
57
struct XSalsa20 : public XSalsa20_Info, public SymmetricCipherDocumentation
59
typedef SymmetricCipherFinal<ConcretePolicyHolder<XSalsa20_Policy, AdditiveCipherTemplate<> >, XSalsa20_Info> Encryption;
60
typedef Encryption Decryption;