-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathchacha.h
38 lines (30 loc) · 919 Bytes
/
chacha.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
chacha-merged.c version 20080118
D. J. Bernstein
Public domain.
*/
#ifndef CHACHA_H
#define CHACHA_H
#include <sys/types.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#define CHACHA_MINKEYLEN 16
#define CHACHA_NONCELEN 8
#define CHACHA_CTRLEN 8
#define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN)
#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];
};
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);
#endif /* CHACHA_H */