aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/chacha20.h
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2019-03-01 17:03:58 +0100
committerJonas Schnelli <dev@jonasschnelli.ch>2019-05-03 20:31:18 +0200
commit2bc2b8b49ad87376d98591b14403dc3b46e3166b (patch)
tree48125d1bf8a013325c48cc079d211a5a915ae726 /src/crypto/chacha20.h
parenta6d7026a45c915794338c178b7f95d5c1f8e977f (diff)
downloadbitcoin-2bc2b8b49ad87376d98591b14403dc3b46e3166b.tar.xz
Add ChaCha20 encryption option (XOR)
Diffstat (limited to 'src/crypto/chacha20.h')
-rw-r--r--src/crypto/chacha20.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/crypto/chacha20.h b/src/crypto/chacha20.h
index a305977bcd..5a4674f4a8 100644
--- a/src/crypto/chacha20.h
+++ b/src/crypto/chacha20.h
@@ -8,7 +8,8 @@
#include <stdint.h>
#include <stdlib.h>
-/** A PRNG class for ChaCha20. */
+/** A class for ChaCha20 256-bit stream cipher developed by Daniel J. Bernstein
+ https://cr.yp.to/chacha/chacha-20080128.pdf */
class ChaCha20
{
private:
@@ -17,10 +18,17 @@ private:
public:
ChaCha20();
ChaCha20(const unsigned char* key, size_t keylen);
- void SetKey(const unsigned char* key, size_t keylen);
- void SetIV(uint64_t iv);
- void Seek(uint64_t pos);
- void Output(unsigned char* output, size_t bytes);
+ void SetKey(const unsigned char* key, size_t keylen); //!< set key with flexible keylength; 256bit recommended */
+ void SetIV(uint64_t iv); // set the 64bit nonce
+ void Seek(uint64_t pos); // set the 64bit block counter
+
+ /** outputs the keystream of size <bytes> into <c> */
+ void Keystream(unsigned char* c, size_t bytes);
+
+ /** enciphers the message <input> of length <bytes> and write the enciphered representation into <output>
+ * Used for encryption and decryption (XOR)
+ */
+ void Crypt(const unsigned char* input, unsigned char* output, size_t bytes);
};
#endif // BITCOIN_CRYPTO_CHACHA20_H