Bitcoin ABC  0.22.12
P2P Digital Currency
chacha20.h
Go to the documentation of this file.
1 // Copyright (c) 2017 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_CRYPTO_CHACHA20_H
6 #define BITCOIN_CRYPTO_CHACHA20_H
7 
8 #include <cstdint>
9 #include <cstdlib>
10 
15 class ChaCha20 {
16 private:
17  uint32_t input[16];
18 
19 public:
20  ChaCha20();
21  ChaCha20(const uint8_t *key, size_t keylen);
23  void SetKey(const uint8_t *key, size_t keylen);
24  // set the 64bit nonce
25  void SetIV(uint64_t iv);
26  // set the 64bit block counter
27  void Seek(uint64_t pos);
28 
30  void Keystream(uint8_t *c, size_t bytes);
31 
36  void Crypt(const uint8_t *input, uint8_t *output, size_t bytes);
37 };
38 
39 #endif // BITCOIN_CRYPTO_CHACHA20_H
uint32_t input[16]
Definition: chacha20.h:17
void Keystream(uint8_t *c, size_t bytes)
outputs the keystream of size <bytes> into
Definition: chacha20.cpp:79
A class for ChaCha20 256-bit stream cipher developed by Daniel J.
Definition: chacha20.h:15
ChaCha20()
Definition: chacha20.cpp:61
void Seek(uint64_t pos)
Definition: chacha20.cpp:74
void SetKey(const uint8_t *key, size_t keylen)
set key with flexible keylength; 256bit recommended
Definition: chacha20.cpp:32
void Crypt(const uint8_t *input, uint8_t *output, size_t bytes)
enciphers the message <input> of length <bytes> and write the enciphered representation into <output>...
Definition: chacha20.cpp:194
void SetIV(uint64_t iv)
Definition: chacha20.cpp:69