Bitcoin Core 22.99.0
P2P Digital Currency
chacha20.h
Go to the documentation of this file.
1// Copyright (c) 2017-2019 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
14{
15private:
16 uint32_t input[16];
17
18public:
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
A class for ChaCha20 256-bit stream cipher developed by Daniel J.
Definition: chacha20.h:14
void Keystream(unsigned char *c, size_t bytes)
outputs the keystream of size <bytes> into
Definition: chacha20.cpp:74
uint32_t input[16]
Definition: chacha20.h:16
void SetIV(uint64_t iv)
Definition: chacha20.cpp:62
ChaCha20()
Definition: chacha20.cpp:52
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
void Seek(uint64_t pos)
Definition: chacha20.cpp:68
void SetKey(const unsigned char *key, size_t keylen)
set key with flexible keylength; 256bit recommended *‍/
Definition: chacha20.cpp:24