Bitcoin Core  0.18.99
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 <stdint.h>
9 #include <stdlib.h>
10 
13 class ChaCha20
14 {
15 private:
16  uint32_t input[16];
17 
18 public:
19  ChaCha20();
20  ChaCha20(const unsigned char* key, size_t keylen);
21  void SetKey(const unsigned char* key, size_t keylen);
22  void SetIV(uint64_t iv); // set the 64bit nonce
23  void Seek(uint64_t pos); // set the 64bit block counter
24 
26  void Keystream(unsigned char* c, size_t bytes);
27 
31  void Crypt(const unsigned char* input, unsigned char* output, size_t bytes);
32 };
33 
34 #endif // BITCOIN_CRYPTO_CHACHA20_H
uint32_t input[16]
Definition: chacha20.h:16
void Crypt(const unsigned char *input, unsigned char *output, size_t bytes)
enciphers the message <input> of length <bytes> and write the enciphered representation into <output>...
Definition: chacha20.cpp:182
A class for ChaCha20 256-bit stream cipher developed by Daniel J.
Definition: chacha20.h:13
ChaCha20()
Definition: chacha20.cpp:52
void Seek(uint64_t pos)
Definition: chacha20.cpp:68
void Keystream(unsigned char *c, size_t bytes)
outputs the keystream of size <bytes> into
Definition: chacha20.cpp:74
void SetKey(const unsigned char *key, size_t keylen)
set key with flexible keylength; 256bit recommended */
Definition: chacha20.cpp:24
void SetIV(uint64_t iv)
Definition: chacha20.cpp:62