VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Crypto/chacha256.h
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2019-02-08 01:48:12 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2019-02-08 01:50:12 +0100
commitba5da0946c3abaa93d1161ca512c3c326cda3736 (patch)
tree128c238dea40ac0de0c7de8e0b02810eabc8e564 /src/Crypto/chacha256.h
parente5b9cee8681dc45340321f759079b344a3b2676c (diff)
downloadVeraCrypt-ba5da0946c3abaa93d1161ca512c3c326cda3736.tar.gz
VeraCrypt-ba5da0946c3abaa93d1161ca512c3c326cda3736.zip
Windows: Add implementation of ChaCha20 based random generator. Use it for driver need of random bytes (currently only wipe bytes but more to come later).
Diffstat (limited to 'src/Crypto/chacha256.h')
-rw-r--r--src/Crypto/chacha256.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Crypto/chacha256.h b/src/Crypto/chacha256.h
new file mode 100644
index 00000000..e9533a39
--- /dev/null
+++ b/src/Crypto/chacha256.h
@@ -0,0 +1,31 @@
+#ifndef HEADER_Crypto_ChaCha256
+#define HEADER_Crypto_ChaCha256
+
+#include "Common/Tcdefs.h"
+#include "config.h"
+
+typedef struct
+{
+ CRYPTOPP_ALIGN_DATA(16) uint32 block_[16];
+ CRYPTOPP_ALIGN_DATA(16) uint32 input_[16];
+ size_t pos;
+ int internalRounds;
+} ChaCha256Ctx;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * key must be 32 bytes long and iv must be 8 bytes long
+ */
+void ChaCha256Init(ChaCha256Ctx* ctx, const unsigned char* key, const unsigned char* iv, int rounds);
+void ChaCha256Encrypt(ChaCha256Ctx* ctx, const unsigned char* in, size_t len, unsigned char* out);
+#define ChaCha256Decrypt ChaCha256Encrypt
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // HEADER_Crypto_ChaCha
+