Fabcoin Core  0.16.2
P2P Digital Currency
chacha.h
Go to the documentation of this file.
1 // chacha.h - written and placed in the public domain by Jeffrey Walton.
2 // Copyright assigned to the Crypto++ project.
3 // Based on Wei Dai's Salsa20 and Bernstein's reference ChaCha
4 // family implementation at http://cr.yp.to/chacha.html.
5 
13 
14 #ifndef CRYPTOPP_CHACHA_H
15 #define CRYPTOPP_CHACHA_H
16 
17 #include "strciphr.h"
18 #include "secblock.h"
19 
21 
22 template <unsigned int R>
26 struct ChaCha_Info : public VariableKeyLength<32, 16, 32, 16, SimpleKeyingInterface::UNIQUE_IV, 8>, public FixedRounds<R>
27 {
29  return (R==8?"ChaCha8":(R==12?"ChaCha12":(R==20?"ChaCha20":"ChaCha")));
30  }
31 };
32 
36 template <unsigned int R>
38 {
39 protected:
41 
42  void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
43  void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
44  void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
45  bool CipherIsRandomAccess() const {return false;} // TODO
46  void SeekToIteration(lword iterationCount);
47  unsigned int GetAlignment() const;
48  unsigned int GetOptimalBlockSize() const;
49 
51 };
52 
58 {
60  typedef Encryption Decryption;
61 };
62 
71 {
73  typedef Encryption Decryption;
74 };
75 
83 struct ChaCha20 : public ChaCha_Info<20>, public SymmetricCipherDocumentation
84 {
86  typedef Encryption Decryption;
87 };
88 
90 
91 #endif // CRYPTOPP_CHACHA_H
ChaCha stream cipher information.
Definition: chacha.h:26
uint8_t byte
Definition: Common.h:57
#define CRYPTOPP_STATIC_CONSTEXPR
Definition: config.h:892
Encryption Decryption
Definition: chacha.h:86
unsigned int GetAlignment() const
Provides data alignment requirements.
Definition: strciphr.h:196
Base class for additive stream ciphers.
Definition: strciphr.h:186
Encryption Decryption
Definition: chacha.h:60
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
#define R(a, b)
bool CipherIsRandomAccess() const
Flag indicating random access.
Definition: chacha.h:45
SymmetricCipherFinal< ConcretePolicyHolder< ChaCha_Policy< 20 >, AdditiveCipherTemplate<> >, ChaCha_Info< 20 > > Encryption
Definition: chacha.h:85
ChaCha8 stream cipher.
Definition: chacha.h:57
SymmetricCipherFinal< ConcretePolicyHolder< ChaCha_Policy< 12 >, AdditiveCipherTemplate<> >, ChaCha_Info< 12 > > Encryption
Definition: chacha.h:72
Classes and functions for secure memory allocations.
A PRNG class for ChaCha20.
Definition: chacha20.h:12
ChaCha stream cipher implementation.
Definition: chacha.h:37
FixedSizeAlignedSecBlock< word32, 16 > m_state
Definition: chacha.h:50
virtual void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)=0
Operates the keystream.
Interface for algorithms that take byte strings as keys.
Definition: cryptlib.h:524
#define CRYPTOPP_CONSTANT(x)
Definition: config.h:540
Inherited by algorithms with fixed number of rounds.
Definition: seckey.h:53
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:169
#define CRYPTOPP_NO_VTABLE
Definition: config.h:369
Classes for implementing stream ciphers.
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher...
Definition: seckey.h:424
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
Definition: chacha.h:28
#define NAMESPACE_END
Definition: config.h:201
KeystreamOperation
Keystream operation flags.
Definition: strciphr.h:90
word64 lword
Definition: config.h:245
SymmetricCipher implementation.
Definition: strciphr.h:584
Base class for additive stream ciphers with SymmetricCipher interface.
Definition: strciphr.h:267
SymmetricCipherFinal< ConcretePolicyHolder< ChaCha_Policy< 8 >, AdditiveCipherTemplate<> >, ChaCha_Info< 8 > > Encryption
Definition: chacha.h:59
ChaCha12 stream cipher.
Definition: chacha.h:70
Interface for retrieving values given their names.
Definition: cryptlib.h:279
Encryption Decryption
Definition: chacha.h:73