]> AND Private Git Repository - Cipher_code.git/blob - Grain-128AEAD-sw-ref/grain128aead.h
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
new
[Cipher_code.git] / Grain-128AEAD-sw-ref / grain128aead.h
1 #ifndef UTILS_H
2 #define UTILS_H
3
4 #define STREAM_BYTES    16
5 #define MSG_BYTES               0
6
7 enum GRAIN_ROUND {INIT, FP1, NORMAL};
8
9 typedef struct {
10         uint8_t lfsr[128];
11         uint8_t nfsr[128];
12         uint8_t auth_acc[64];
13         uint8_t auth_sr[64];
14 } grain_state;
15
16 // TODO: add struct with output: keystream and optionally macstream and tag
17 typedef struct {
18         uint8_t keystream[STREAM_BYTES];
19         uint8_t macstream[STREAM_BYTES];
20         uint8_t *message;
21 } grain_data;
22
23 void init_grain(grain_state *grain, uint8_t *key, uint8_t *iv);
24 uint8_t next_lfsr_fb(grain_state *grain);
25 uint8_t next_nfsr_fb(grain_state *grain);
26 uint8_t next_h(grain_state *grain);
27 uint8_t shift(uint8_t fsr[128], uint8_t fb);
28 void auth_shift(uint8_t sr[32], uint8_t fb);
29 uint8_t next_z(grain_state *grain, uint8_t);
30 void generate_keystream(grain_state *grain, grain_data *data, uint8_t *);
31 void print_state(grain_state *grain);
32
33 #endif