-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheax64.h
58 lines (48 loc) · 1.48 KB
/
eax64.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef _EAX64_H_
#define _EAX64_H_
/*
See eax128.h for generic comments on usage.
The 64-bit version is almost the same
*/
typedef union
{
uint64_t q; // Little-endian only, yap.
uint8_t b[8];
} eax64_block_t;
typedef struct
{
void *cipher_ctx;
uint64_t mac;
eax64_block_t block;
int bytepos;
} eax64_omac_t;
typedef struct
{
void *cipher_ctx;
uint64_t nonce;
eax64_block_t xorbuf;
int blocknum;
} eax64_ctr_t;
typedef struct
{
eax64_omac_t domac;
eax64_omac_t homac;
eax64_ctr_t ctr;
} eax64_t;
// The external cipher function to be linked.
// ctx is the argument passed to cipher. i.e. it may be used to distinguish cipher instances
extern uint64_t eax64_cipher(void *ctx, uint64_t pt);
void eax64_init(eax64_t *ctx, void *cipher_ctx, const uint8_t *nonce, int nonce_len);
void eax64_auth_data(eax64_t *ctx, int byte);
void eax64_auth_header(eax64_t *ctx, int byte);
int eax64_crypt_data(eax64_t *ctx, int pos, int byte);
uint64_t eax64_digest(eax64_t *ctx);
void eax64_clear(eax64_t *ctx);
void eax64_omac_init(eax64_omac_t *ctx, void *cipher_ctx, int k);
void eax64_omac_process(eax64_omac_t *ctx, int byte);
uint64_t eax64_omac_digest(eax64_omac_t *ctx);
void eax64_omac_clear(eax64_omac_t *ctx);
void eax64_ctr_init(eax64_ctr_t *ctx, void *cipher_ctx, uint64_t nonce);
int eax64_ctr_process(eax64_ctr_t *ctx, int pos, int byte);
void eax64_ctr_clear(eax64_ctr_t *ctx);
#endif