VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Crypto/chacha256.h
blob: e9533a3918eb0b24536a549c63f4a5899e39f47c (plain)
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
#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