ASCON Suite
Functions
ascon-aead-common.h File Reference
#include <ascon/aead.h>
#include <ascon/permutation.h>
#include <ascon/utility.h>

Go to the source code of this file.

Functions

int ascon_aead_check_tag (unsigned char *plaintext, size_t plaintext_len, const unsigned char *tag1, const unsigned char *tag2, size_t size)
 Check an authentication tag in constant time. More...
 
void ascon_aead_absorb_8 (ascon_state_t *state, const unsigned char *data, size_t len, uint8_t first_round, int last_permute)
 Absorbs data into an ASCON state with an 8-byte rate. More...
 
void ascon_aead_absorb_16 (ascon_state_t *state, const unsigned char *data, size_t len, uint8_t first_round, int last_permute)
 Absorbs data into an ASCON state with a 16-byte rate. More...
 
unsigned char ascon_aead_encrypt_8 (ascon_state_t *state, unsigned char *dest, const unsigned char *src, size_t len, uint8_t first_round, unsigned char partial)
 Encrypts a block of data with an ASCON state and an 8-byte rate. More...
 
unsigned char ascon_aead_encrypt_16 (ascon_state_t *state, unsigned char *dest, const unsigned char *src, size_t len, uint8_t first_round, unsigned char partial)
 Encrypts a block of data with an ASCON state and a 16-byte rate. More...
 
unsigned char ascon_aead_decrypt_8 (ascon_state_t *state, unsigned char *dest, const unsigned char *src, size_t len, uint8_t first_round, unsigned char partial)
 Decrypts a block of data with an ASCON state and an 8-byte rate. More...
 
unsigned char ascon_aead_decrypt_16 (ascon_state_t *state, unsigned char *dest, const unsigned char *src, size_t len, uint8_t first_round, unsigned char partial)
 Decrypts a block of data with an ASCON state and a 16-byte rate. More...
 

Function Documentation

◆ ascon_aead_absorb_16()

void ascon_aead_absorb_16 ( ascon_state_t state,
const unsigned char *  data,
size_t  len,
uint8_t  first_round,
int  last_permute 
)

Absorbs data into an ASCON state with a 16-byte rate.

Parameters
stateThe state to absorb the data into.
dataPoints to the data to be absorbed.
lenLength of the data to be absorbed.
first_roundFirst round of the permutation to apply each block.
last_permuteNon-zero to permute the last block, or zero to delay the permutation.

Definition at line 65 of file ascon-aead-common.c.

◆ ascon_aead_absorb_8()

void ascon_aead_absorb_8 ( ascon_state_t state,
const unsigned char *  data,
size_t  len,
uint8_t  first_round,
int  last_permute 
)

Absorbs data into an ASCON state with an 8-byte rate.

Parameters
stateThe state to absorb the data into.
dataPoints to the data to be absorbed.
lenLength of the data to be absorbed.
first_roundFirst round of the permutation to apply each block.
last_permuteNon-zero to permute the last block, or zero to delay the permutation.

Definition at line 48 of file ascon-aead-common.c.

◆ ascon_aead_check_tag()

int ascon_aead_check_tag ( unsigned char *  plaintext,
size_t  plaintext_len,
const unsigned char *  tag1,
const unsigned char *  tag2,
size_t  size 
)

Check an authentication tag in constant time.

Parameters
plaintextPoints to the plaintext data.
plaintext_lenLength of the plaintext in bytes.
tag1First tag to compare.
tag2Second tag to compare.
sizeLength of the tags in bytes.
Returns
Returns -1 if the tag check failed or 0 if the check succeeded.

If the tag check fails, then the plaintext will also be zeroed to prevent it from being used accidentally by the application when the ciphertext was invalid.

Definition at line 26 of file ascon-aead-common.c.

◆ ascon_aead_decrypt_16()

unsigned char ascon_aead_decrypt_16 ( ascon_state_t state,
unsigned char *  dest,
const unsigned char *  src,
size_t  len,
uint8_t  first_round,
unsigned char  partial 
)

Decrypts a block of data with an ASCON state and a 16-byte rate.

Parameters
stateThe state to decrypt with.
destPoints to the destination buffer.
srcPoints to the source buffer.
lenLength of the data to decrypt from src into dest.
first_roundFirst round of the permutation to apply each block.
partialNon-zero if the first byte to be decrypted should start partway through the first block.
Returns
Partial block length for the last block.

Definition at line 184 of file ascon-aead-common.c.

◆ ascon_aead_decrypt_8()

unsigned char ascon_aead_decrypt_8 ( ascon_state_t state,
unsigned char *  dest,
const unsigned char *  src,
size_t  len,
uint8_t  first_round,
unsigned char  partial 
)

Decrypts a block of data with an ASCON state and an 8-byte rate.

Parameters
stateThe state to decrypt with.
destPoints to the destination buffer.
srcPoints to the source buffer.
lenLength of the data to decrypt from src into dest.
first_roundFirst round of the permutation to apply each block.
partialNon-zero if the first byte to be decrypted should start partway through the first block.
Returns
Partial block length for the last block.

Definition at line 150 of file ascon-aead-common.c.

◆ ascon_aead_encrypt_16()

unsigned char ascon_aead_encrypt_16 ( ascon_state_t state,
unsigned char *  dest,
const unsigned char *  src,
size_t  len,
uint8_t  first_round,
unsigned char  partial 
)

Encrypts a block of data with an ASCON state and a 16-byte rate.

Parameters
stateThe state to encrypt with.
destPoints to the destination buffer.
srcPoints to the source buffer.
lenLength of the data to encrypt from src into dest.
first_roundFirst round of the permutation to apply each block.
partialNon-zero if the first byte to be encrypted should start partway through the first block.
Returns
Partial block length for the last block.

Definition at line 116 of file ascon-aead-common.c.

◆ ascon_aead_encrypt_8()

unsigned char ascon_aead_encrypt_8 ( ascon_state_t state,
unsigned char *  dest,
const unsigned char *  src,
size_t  len,
uint8_t  first_round,
unsigned char  partial 
)

Encrypts a block of data with an ASCON state and an 8-byte rate.

Parameters
stateThe state to encrypt with.
destPoints to the destination buffer.
srcPoints to the source buffer.
lenLength of the data to encrypt from src into dest.
first_roundFirst round of the permutation to apply each block.
partialNon-zero if the first byte to be encrypted should start partway through the first block.
Returns
Partial block length for the last block.

Definition at line 82 of file ascon-aead-common.c.