VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Crypto/chacha256.h
diff options
context:
space:
mode:
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
+