Update the built-in Chacha20-Poly1305 code to an RFC 7539 complaint version.
[tinc] / src / chacha-poly1305 / chacha.h
index 103c3d8..a137ab6 100644 (file)
@@ -7,18 +7,28 @@ Public domain.
 #ifndef CHACHA_H
 #define CHACHA_H
 
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define CHACHA_BLOCKLEN         64
+
+/* use memcpy() to copy blocks of memory (typically faster) */
+#define USE_MEMCPY          1
+/* use unaligned little-endian load/store (can be faster) */
+#define USE_UNALIGNED       0
+
 struct chacha_ctx {
        uint32_t input[16];
 };
 
-#define CHACHA_MINKEYLEN        16
-#define CHACHA_NONCELEN         8
-#define CHACHA_CTRLEN           8
-#define CHACHA_STATELEN         (CHACHA_NONCELEN+CHACHA_CTRLEN)
-#define CHACHA_BLOCKLEN         64
+void chacha_keysetup(struct chacha_ctx *x, const unsigned char *k,
+                     uint32_t kbits);
+void chacha_ivsetup(struct chacha_ctx *x, const unsigned char *iv,
+                    const unsigned char *ctr);
+void chacha_encrypt_bytes(struct chacha_ctx *x, const unsigned char *m,
+                          unsigned char *c, uint32_t bytes);
 
-void chacha_keysetup(struct chacha_ctx *x, const uint8_t *k, uint32_t kbits);
-void chacha_ivsetup(struct chacha_ctx *x, const uint8_t *iv, const uint8_t *ctr);
-void chacha_encrypt_bytes(struct chacha_ctx *x, const uint8_t *m, uint8_t *c, uint32_t bytes);
+#endif  /* CHACHA_H */
 
-#endif /* CHACHA_H */