Internal implementation of the Grain-128 stream cipher.
More...
#include "internal-util.h"
Go to the source code of this file.
|
void | grain128_core (grain128_state_t *state, uint32_t x, uint32_t x2) |
| Performs 32 rounds of Grain-128 in parallel. More...
|
|
uint32_t | grain128_preoutput (const grain128_state_t *state) |
| Generates 32 bits of pre-output data. More...
|
|
void | grain128_setup (grain128_state_t *state, const unsigned char *key, const unsigned char *nonce) |
| Sets up the initial Grain-128 state with the key and nonce. More...
|
|
void | grain128_authenticate (grain128_state_t *state, const unsigned char *data, unsigned long long len) |
| Authenticates data with Grain-128. More...
|
|
void | grain128_encrypt (grain128_state_t *state, unsigned char *c, const unsigned char *m, unsigned long long len) |
| Encrypts and authenticates data with Grain-128. More...
|
|
void | grain128_decrypt (grain128_state_t *state, unsigned char *m, const unsigned char *c, unsigned long long len) |
| Decrypts and authenticates data with Grain-128. More...
|
|
void | grain128_compute_tag (grain128_state_t *state) |
| Computes the final authentiation tag. More...
|
|
Internal implementation of the Grain-128 stream cipher.
References: https://grain-128aead.github.io/
void grain128_authenticate |
( |
grain128_state_t * |
state, |
|
|
const unsigned char * |
data, |
|
|
unsigned long long |
len |
|
) |
| |
Authenticates data with Grain-128.
- Parameters
-
state | Grain-128 state. |
data | Points to the data to be authenticated. |
len | Length of the data to be authenticated. |
Computes the final authentiation tag.
- Parameters
-
The final authentication tag is written to the first 8 bytes of state->ks.
Performs 32 rounds of Grain-128 in parallel.
- Parameters
-
state | Grain-128 state. |
x | 32 bits of input to be incorporated into the LFSR state, or zero. |
x2 | Another 32 bits to be incorporated into the NFSR state, or zero. |
void grain128_decrypt |
( |
grain128_state_t * |
state, |
|
|
unsigned char * |
m, |
|
|
const unsigned char * |
c, |
|
|
unsigned long long |
len |
|
) |
| |
Decrypts and authenticates data with Grain-128.
- Parameters
-
state | Grain-128 state. |
m | Points to the plaintext output buffer. |
c | Points to the ciphertext input buffer. |
len | Length of the data to be decrypted. |
void grain128_encrypt |
( |
grain128_state_t * |
state, |
|
|
unsigned char * |
c, |
|
|
const unsigned char * |
m, |
|
|
unsigned long long |
len |
|
) |
| |
Encrypts and authenticates data with Grain-128.
- Parameters
-
state | Grain-128 state. |
c | Points to the ciphertext output buffer. |
m | Points to the plaintext input buffer. |
len | Length of the data to be encrypted. |
Generates 32 bits of pre-output data.
- Parameters
-
- Returns
- The generated 32 bits of pre-output data.
void grain128_setup |
( |
grain128_state_t * |
state, |
|
|
const unsigned char * |
key, |
|
|
const unsigned char * |
nonce |
|
) |
| |
Sets up the initial Grain-128 state with the key and nonce.
- Parameters
-
state | Grain-128 state to be initialized. |
key | Points to the 128-bit key. |
nonce | Points to the 96-bit nonce. |