ASCON Suite
Classes | Macros | Functions
aead.h File Reference

ASCON-128 encryption algorithm and related family members. More...

#include <ascon/permutation.h>

Go to the source code of this file.

Classes

struct  ascon128_state_t
 State information for the incremental version of ASCON-128. More...
 
struct  ascon128a_state_t
 State information for the incremental version of ASCON-128a. More...
 
struct  ascon80pq_state_t
 State information for the incremental version of ASCON-80pq. More...
 

Macros

#define ASCON128_KEY_SIZE   16
 Size of the key for ASCON-128 and ASCON-128a. More...
 
#define ASCON128_NONCE_SIZE   16
 Size of the nonce for ASCON-128 and ASCON-128a. More...
 
#define ASCON128_TAG_SIZE   16
 Size of the authentication tag for ASCON-128 and ASCON-128a. More...
 
#define ASCON80PQ_KEY_SIZE   20
 Size of the key for ASCON-80pq. More...
 
#define ASCON80PQ_NONCE_SIZE   16
 Size of the nonce for ASCON-80pq. More...
 
#define ASCON80PQ_TAG_SIZE   16
 Size of the authentication tag for ASCON-80pq. More...
 
#define ASCON128_RATE   8
 Rate of absorbing and squeezing for ASCON-128. More...
 
#define ASCON128A_RATE   16
 Rate of absorbing and squeezing for ASCON-128a. More...
 
#define ASCON80PQ_RATE   8
 Rate of absorbing and squeezing for ASCON-80pq. More...
 

Functions

void ascon128_aead_encrypt (unsigned char *c, size_t *clen, const unsigned char *m, size_t mlen, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
 Encrypts and authenticates a packet with ASCON-128. More...
 
int ascon128_aead_decrypt (unsigned char *m, size_t *mlen, const unsigned char *c, size_t clen, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
 Decrypts and authenticates a packet with ASCON-128. More...
 
void ascon128a_aead_encrypt (unsigned char *c, size_t *clen, const unsigned char *m, size_t mlen, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
 Encrypts and authenticates a packet with ASCON-128a. More...
 
int ascon128a_aead_decrypt (unsigned char *m, size_t *mlen, const unsigned char *c, size_t clen, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
 Decrypts and authenticates a packet with ASCON-128a. More...
 
void ascon80pq_aead_encrypt (unsigned char *c, size_t *clen, const unsigned char *m, size_t mlen, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
 Encrypts and authenticates a packet with ASCON-80pq. More...
 
int ascon80pq_aead_decrypt (unsigned char *m, size_t *mlen, const unsigned char *c, size_t clen, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
 Decrypts and authenticates a packet with ASCON-80pq. More...
 
void ascon128_aead_start (ascon128_state_t *state, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
 Starts encrypting or decrypting a packet with ASCON-128 in incremental mode. More...
 
void ascon128_aead_abort (ascon128_state_t *state)
 Aborts use of ASCON-128 in incremental mode. More...
 
void ascon128_aead_encrypt_block (ascon128_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
 Encrypts a block of data with ASCON-128 in incremental mode. More...
 
void ascon128_aead_encrypt_finalize (ascon128_state_t *state, unsigned char *tag)
 Finalizes an incremental ASCON-128 encryption operation and generates the authentication tag. More...
 
void ascon128_aead_decrypt_block (ascon128_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
 Decrypts a block of data with ASCON-128 in incremental mode. More...
 
int ascon128_aead_decrypt_finalize (ascon128_state_t *state, const unsigned char *tag)
 Finalizes an incremental ASCON-128 decryption operation and checks the authentication tag. More...
 
void ascon128a_aead_start (ascon128a_state_t *state, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
 Starts encrypting or decrypting a packet with ASCON-128a in incremental mode. More...
 
void ascon128a_aead_abort (ascon128a_state_t *state)
 Aborts use of ASCON-128a in incremental mode. More...
 
void ascon128a_aead_encrypt_block (ascon128a_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
 Encrypts a block of data with ASCON-128a in incremental mode. More...
 
void ascon128a_aead_encrypt_finalize (ascon128a_state_t *state, unsigned char *tag)
 Finalizes an incremental ASCON-128a encryption operation and generates the authentication tag. More...
 
void ascon128a_aead_decrypt_block (ascon128a_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
 Decrypts a block of data with ASCON-128a in incremental mode. More...
 
int ascon128a_aead_decrypt_finalize (ascon128a_state_t *state, const unsigned char *tag)
 Finalizes an incremental ASCON-128a decryption operation and checks the authentication tag. More...
 
void ascon80pq_aead_start (ascon80pq_state_t *state, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
 Starts encrypting or decrypting a packet with ASCON-80pq in incremental mode. More...
 
void ascon80pq_aead_abort (ascon80pq_state_t *state)
 Aborts use of ASCON-80pq in incremental mode. More...
 
void ascon80pq_aead_encrypt_block (ascon80pq_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
 Encrypts a block of data with ASCON-80pq in incremental mode. More...
 
void ascon80pq_aead_encrypt_finalize (ascon80pq_state_t *state, unsigned char *tag)
 Finalizes an incremental ASCON-80pq encryption operation and generates the authentication tag. More...
 
void ascon80pq_aead_decrypt_block (ascon80pq_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
 Decrypts a block of data with ASCON-80pq in incremental mode. More...
 
int ascon80pq_aead_decrypt_finalize (ascon80pq_state_t *state, const unsigned char *tag)
 Finalizes an incremental ASCON-80pq decryption operation and checks the authentication tag. More...
 

Detailed Description

ASCON-128 encryption algorithm and related family members.

The ASCON family consists of several related algorithms:

References: https://ascon.iaik.tugraz.at/

Definition in file aead.h.

Macro Definition Documentation

◆ ASCON128_KEY_SIZE

#define ASCON128_KEY_SIZE   16

Size of the key for ASCON-128 and ASCON-128a.

Definition at line 55 of file aead.h.

◆ ASCON128_NONCE_SIZE

#define ASCON128_NONCE_SIZE   16

Size of the nonce for ASCON-128 and ASCON-128a.

Definition at line 60 of file aead.h.

◆ ASCON128_RATE

#define ASCON128_RATE   8

Rate of absorbing and squeezing for ASCON-128.

Definition at line 85 of file aead.h.

◆ ASCON128_TAG_SIZE

#define ASCON128_TAG_SIZE   16

Size of the authentication tag for ASCON-128 and ASCON-128a.

Definition at line 65 of file aead.h.

◆ ASCON128A_RATE

#define ASCON128A_RATE   16

Rate of absorbing and squeezing for ASCON-128a.

Definition at line 90 of file aead.h.

◆ ASCON80PQ_KEY_SIZE

#define ASCON80PQ_KEY_SIZE   20

Size of the key for ASCON-80pq.

Definition at line 70 of file aead.h.

◆ ASCON80PQ_NONCE_SIZE

#define ASCON80PQ_NONCE_SIZE   16

Size of the nonce for ASCON-80pq.

Definition at line 75 of file aead.h.

◆ ASCON80PQ_RATE

#define ASCON80PQ_RATE   8

Rate of absorbing and squeezing for ASCON-80pq.

Definition at line 95 of file aead.h.

◆ ASCON80PQ_TAG_SIZE

#define ASCON80PQ_TAG_SIZE   16

Size of the authentication tag for ASCON-80pq.

Examples
asconcrypt/asconcrypt.c.

Definition at line 80 of file aead.h.

Function Documentation

◆ ascon128_aead_abort()

void ascon128_aead_abort ( ascon128_state_t state)

Aborts use of ASCON-128 in incremental mode.

Parameters
stateState to abort.

This function may be used any time after ascon128_aead_start() and before the encryption or decryption process is finalized to abort the process entirely and free the state.

Definition at line 56 of file ascon-aead-inc-128.c.

◆ ascon128_aead_decrypt()

int ascon128_aead_decrypt ( unsigned char *  m,
size_t *  mlen,
const unsigned char *  c,
size_t  clen,
const unsigned char *  ad,
size_t  adlen,
const unsigned char *  npub,
const unsigned char *  k 
)

Decrypts and authenticates a packet with ASCON-128.

Parameters
mBuffer to receive the plaintext message on output.
mlenReceives the length of the plaintext message on output.
cBuffer that contains the ciphertext and authentication tag to decrypt.
clenLength of the input data in bytes, which includes the ciphertext and the 16 byte authentication tag.
adBuffer that contains associated data to authenticate along with the packet but which does not need to be encrypted.
adlenLength of the associated data in bytes.
npubPoints to the public nonce for the packet which must be 16 bytes in length.
kPoints to the 16 bytes of the key to use to decrypt the packet.
Returns
0 on success, -1 if the authentication tag was incorrect, or some other negative number if there was an error in the parameters.
See also
ascon128_aead_encrypt()

Definition at line 71 of file ascon-aead-128.c.

◆ ascon128_aead_decrypt_block()

void ascon128_aead_decrypt_block ( ascon128_state_t state,
const unsigned char *  in,
unsigned char *  out,
size_t  len 
)

Decrypts a block of data with ASCON-128 in incremental mode.

Parameters
stateState to use for ASCON-128 encryption operations.
inBuffer that contains the ciphertext to decrypt.
outBuffer to receive the plaintext output. Can be the same buffer as in.
lenLength of the plaintext and ciphertext in bytes.
See also
ascon128_aead_encrypt_block(), ascon128_aead_start(), ascon128_aead_decrypt_finalize()

Definition at line 93 of file ascon-aead-inc-128.c.

◆ ascon128_aead_decrypt_finalize()

int ascon128_aead_decrypt_finalize ( ascon128_state_t state,
const unsigned char *  tag 
)

Finalizes an incremental ASCON-128 decryption operation and checks the authentication tag.

Parameters
stateState to use for ASCON-128 encryption operations.
tagPoints to the buffer containing the ciphertext's authentication tag. Must be at least ASCON128_TAG_SIZE bytes in length.
Returns
0 on success, -1 if the authentication tag was incorrect, or some other negative number if there was an error in the parameters.

The contents of state will be freed by this function, destroying any sensitive material that may be present.

See also
ascon128_aead_decrypt_block(), ascon128_aead_start()

Definition at line 103 of file ascon-aead-inc-128.c.

◆ ascon128_aead_encrypt()

void ascon128_aead_encrypt ( unsigned char *  c,
size_t *  clen,
const unsigned char *  m,
size_t  mlen,
const unsigned char *  ad,
size_t  adlen,
const unsigned char *  npub,
const unsigned char *  k 
)

Encrypts and authenticates a packet with ASCON-128.

Parameters
cBuffer to receive the output.
clenOn exit, set to the length of the output which includes the ciphertext and the 16 byte authentication tag.
mBuffer that contains the plaintext message to encrypt.
mlenLength of the plaintext message in bytes.
adBuffer that contains associated data to authenticate along with the packet but which does not need to be encrypted.
adlenLength of the associated data in bytes.
npubPoints to the public nonce for the packet which must be 16 bytes in length.
kPoints to the 16 bytes of the key to use to encrypt the packet.
See also
ascon128_aead_decrypt()

Definition at line 31 of file ascon-aead-128.c.

◆ ascon128_aead_encrypt_block()

void ascon128_aead_encrypt_block ( ascon128_state_t state,
const unsigned char *  in,
unsigned char *  out,
size_t  len 
)

Encrypts a block of data with ASCON-128 in incremental mode.

Parameters
stateState to use for ASCON-128 encryption operations.
inBuffer that contains the plaintext to encrypt.
outBuffer to receive the ciphertext output. Can be the same buffer as in.
lenLength of the plaintext and ciphertext in bytes.
See also
ascon128_aead_decrypt_block(), ascon128_aead_start(), ascon128_aead_encrypt_finalize()

Definition at line 65 of file ascon-aead-inc-128.c.

◆ ascon128_aead_encrypt_finalize()

void ascon128_aead_encrypt_finalize ( ascon128_state_t state,
unsigned char *  tag 
)

Finalizes an incremental ASCON-128 encryption operation and generates the authentication tag.

Parameters
stateState to use for ASCON-128 encryption operations.
tagPoints to the buffer to receive the authentication tag. Must be at least ASCON128_TAG_SIZE bytes in length.

The contents of state will be freed by this function, destroying any sensitive material that may be present.

See also
ascon128_aead_encrypt_block(), ascon128_aead_start()

Definition at line 75 of file ascon-aead-inc-128.c.

◆ ascon128_aead_start()

void ascon128_aead_start ( ascon128_state_t state,
const unsigned char *  ad,
size_t  adlen,
const unsigned char *  npub,
const unsigned char *  k 
)

Starts encrypting or decrypting a packet with ASCON-128 in incremental mode.

Parameters
stateState to initialize for ASCON-128 operations.
adBuffer that contains associated data to authenticate along with the packet but which does not need to be encrypted.
adlenLength of the associated data in bytes.
npubPoints to the public nonce for the packet which must be 16 bytes in length.
kPoints to the 16 bytes of the key to use to encrypt the packet.

The following sequence can be used to encrypt a list of i plaintext message blocks (m) to produce i ciphertext message blocks (c) and an authentication tag (t).

ascon128_aead_start(&state, ad, adlen, npub, k);
...;
void ascon128_aead_encrypt_finalize(ascon128_state_t *state, unsigned char *tag)
Finalizes an incremental ASCON-128 encryption operation and generates the authentication tag.
void ascon128_aead_start(ascon128_state_t *state, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
Starts encrypting or decrypting a packet with ASCON-128 in incremental mode.
void ascon128_aead_encrypt_block(ascon128_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Encrypts a block of data with ASCON-128 in incremental mode.
ascon_state_t state
[snippet_key]
Definition: snippets.c:2
State information for the incremental version of ASCON-128.
Definition: aead.h:263

Decryption uses a similar sequence:

ascon128_aead_start(&state, ad, adlen, npub, k);
...;
...; // decryption has failed!
void ascon128_aead_decrypt_block(ascon128_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Decrypts a block of data with ASCON-128 in incremental mode.
int ascon128_aead_decrypt_finalize(ascon128_state_t *state, const unsigned char *tag)
Finalizes an incremental ASCON-128 decryption operation and checks the authentication tag.

It is very important that the plaintext output from decryption be discarded if the authentication tag fails to verify. Applications should not use any of the data before verifying the tag.

See also
ascon128_aead_encrypt_block(), ascon128_aead_decrypt_block(), ascon128_aead_encrypt_finalize(), ascon128_aead_decrypt_finalize()

Definition at line 31 of file ascon-aead-inc-128.c.

◆ ascon128a_aead_abort()

void ascon128a_aead_abort ( ascon128a_state_t state)

Aborts use of ASCON-128a in incremental mode.

Parameters
stateState to abort.

This function may be used any time after ascon128a_aead_start() and before the encryption or decryption process is finalized to abort the process entirely and free the state.

Definition at line 56 of file ascon-aead-inc-128a.c.

◆ ascon128a_aead_decrypt()

int ascon128a_aead_decrypt ( unsigned char *  m,
size_t *  mlen,
const unsigned char *  c,
size_t  clen,
const unsigned char *  ad,
size_t  adlen,
const unsigned char *  npub,
const unsigned char *  k 
)

Decrypts and authenticates a packet with ASCON-128a.

Parameters
mBuffer to receive the plaintext message on output.
mlenReceives the length of the plaintext message on output.
cBuffer that contains the ciphertext and authentication tag to decrypt.
clenLength of the input data in bytes, which includes the ciphertext and the 16 byte authentication tag.
adBuffer that contains associated data to authenticate along with the packet but which does not need to be encrypted.
adlenLength of the associated data in bytes.
npubPoints to the public nonce for the packet which must be 16 bytes in length.
kPoints to the 16 bytes of the key to use to decrypt the packet.
Returns
0 on success, -1 if the authentication tag was incorrect, or some other negative number if there was an error in the parameters.
See also
ascon128a_aead_encrypt()

Definition at line 73 of file ascon-aead-128a.c.

◆ ascon128a_aead_decrypt_block()

void ascon128a_aead_decrypt_block ( ascon128a_state_t state,
const unsigned char *  in,
unsigned char *  out,
size_t  len 
)

Decrypts a block of data with ASCON-128a in incremental mode.

Parameters
stateState to use for ASCON-128a encryption operations.
inBuffer that contains the ciphertext to decrypt.
outBuffer to receive the plaintext output. Can be the same buffer as in.
lenLength of the plaintext and ciphertext in bytes.
See also
ascon128a_aead_encrypt_block(), ascon128a_aead_start(), ascon128a_aead_decrypt_finalize()

Definition at line 93 of file ascon-aead-inc-128a.c.

◆ ascon128a_aead_decrypt_finalize()

int ascon128a_aead_decrypt_finalize ( ascon128a_state_t state,
const unsigned char *  tag 
)

Finalizes an incremental ASCON-128a decryption operation and checks the authentication tag.

Parameters
stateState to use for ASCON-128a encryption operations.
tagPoints to the buffer containing the ciphertext's authentication tag. Must be at least ASCON128_TAG_SIZE bytes in length.
Returns
0 on success, -1 if the authentication tag was incorrect, or some other negative number if there was an error in the parameters.

The contents of state will be freed by this function, destroying any sensitive material that may be present.

See also
ascon128a_aead_decrypt_block(), ascon128a_aead_start()

Definition at line 103 of file ascon-aead-inc-128a.c.

◆ ascon128a_aead_encrypt()

void ascon128a_aead_encrypt ( unsigned char *  c,
size_t *  clen,
const unsigned char *  m,
size_t  mlen,
const unsigned char *  ad,
size_t  adlen,
const unsigned char *  npub,
const unsigned char *  k 
)

Encrypts and authenticates a packet with ASCON-128a.

Parameters
cBuffer to receive the output.
clenOn exit, set to the length of the output which includes the ciphertext and the 16 byte authentication tag.
mBuffer that contains the plaintext message to encrypt.
mlenLength of the plaintext message in bytes.
adBuffer that contains associated data to authenticate along with the packet but which does not need to be encrypted.
adlenLength of the associated data in bytes.
npubPoints to the public nonce for the packet which must be 16 bytes in length.
kPoints to the 16 bytes of the key to use to encrypt the packet.
See also
ascon128a_aead_decrypt()

Definition at line 33 of file ascon-aead-128a.c.

◆ ascon128a_aead_encrypt_block()

void ascon128a_aead_encrypt_block ( ascon128a_state_t state,
const unsigned char *  in,
unsigned char *  out,
size_t  len 
)

Encrypts a block of data with ASCON-128a in incremental mode.

Parameters
stateState to use for ASCON-128a encryption operations.
inBuffer that contains the plaintext to encrypt.
outBuffer to receive the ciphertext output. Can be the same buffer as in.
lenLength of the plaintext and ciphertext in bytes.
See also
ascon128a_aead_decrypt_block(), ascon128a_aead_start(), ascon128a_aead_encrypt_finalize()

Definition at line 65 of file ascon-aead-inc-128a.c.

◆ ascon128a_aead_encrypt_finalize()

void ascon128a_aead_encrypt_finalize ( ascon128a_state_t state,
unsigned char *  tag 
)

Finalizes an incremental ASCON-128a encryption operation and generates the authentication tag.

Parameters
stateState to use for ASCON-128a encryption operations.
tagPoints to the buffer to receive the authentication tag. Must be at least ASCON128_TAG_SIZE bytes in length.

The contents of state will be freed by this function, destroying any sensitive material that may be present.

See also
ascon128a_aead_encrypt_block(), ascon128a_aead_start()

Definition at line 75 of file ascon-aead-inc-128a.c.

◆ ascon128a_aead_start()

void ascon128a_aead_start ( ascon128a_state_t state,
const unsigned char *  ad,
size_t  adlen,
const unsigned char *  npub,
const unsigned char *  k 
)

Starts encrypting or decrypting a packet with ASCON-128a in incremental mode.

Parameters
stateState to initialize for ASCON-128a operations.
adBuffer that contains associated data to authenticate along with the packet but which does not need to be encrypted.
adlenLength of the associated data in bytes.
npubPoints to the public nonce for the packet which must be 16 bytes in length.
kPoints to the 16 bytes of the key to use to encrypt the packet.

The following sequence can be used to encrypt a list of i plaintext message blocks (m) to produce i ciphertext message blocks (c) and an authentication tag (t).

ascon128a_aead_start(&state, ad, adlen, npub, k);
...;
void ascon128a_aead_encrypt_finalize(ascon128a_state_t *state, unsigned char *tag)
Finalizes an incremental ASCON-128a encryption operation and generates the authentication tag.
void ascon128a_aead_start(ascon128a_state_t *state, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
Starts encrypting or decrypting a packet with ASCON-128a in incremental mode.
void ascon128a_aead_encrypt_block(ascon128a_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Encrypts a block of data with ASCON-128a in incremental mode.
State information for the incremental version of ASCON-128a.
Definition: aead.h:281

Decryption uses a similar sequence:

ascon128a_aead_start(&state, ad, adlen, npub, k);
...;
...; // decryption has failed!
int ascon128a_aead_decrypt_finalize(ascon128a_state_t *state, const unsigned char *tag)
Finalizes an incremental ASCON-128a decryption operation and checks the authentication tag.
void ascon128a_aead_decrypt_block(ascon128a_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Decrypts a block of data with ASCON-128a in incremental mode.

It is very important that the plaintext output from decryption be discarded if the authentication tag fails to verify. Applications should not use any of the data before verifying the tag.

See also
ascon128a_aead_encrypt_block(), ascon128a_aead_decrypt_block(), ascon128a_aead_encrypt_finalize(), ascon128a_aead_decrypt_finalize()

Definition at line 31 of file ascon-aead-inc-128a.c.

◆ ascon80pq_aead_abort()

void ascon80pq_aead_abort ( ascon80pq_state_t state)

Aborts use of ASCON-80pq in incremental mode.

Parameters
stateState to abort.

This function may be used any time after ascon80pq_aead_start() and before the encryption or decryption process is finalized to abort the process entirely and free the state.

Definition at line 55 of file ascon-aead-inc-80pq.c.

◆ ascon80pq_aead_decrypt()

int ascon80pq_aead_decrypt ( unsigned char *  m,
size_t *  mlen,
const unsigned char *  c,
size_t  clen,
const unsigned char *  ad,
size_t  adlen,
const unsigned char *  npub,
const unsigned char *  k 
)

Decrypts and authenticates a packet with ASCON-80pq.

Parameters
mBuffer to receive the plaintext message on output.
mlenReceives the length of the plaintext message on output.
cBuffer that contains the ciphertext and authentication tag to decrypt.
clenLength of the input data in bytes, which includes the ciphertext and the 16 byte authentication tag.
adBuffer that contains associated data to authenticate along with the packet but which does not need to be encrypted.
adlenLength of the associated data in bytes.
npubPoints to the public nonce for the packet which must be 16 bytes in length.
kPoints to the 20 bytes of the key to use to decrypt the packet.
Returns
0 on success, -1 if the authentication tag was incorrect, or some other negative number if there was an error in the parameters.
See also
ascon80pq_aead_encrypt()

Definition at line 72 of file ascon-aead-80pq.c.

◆ ascon80pq_aead_decrypt_block()

void ascon80pq_aead_decrypt_block ( ascon80pq_state_t state,
const unsigned char *  in,
unsigned char *  out,
size_t  len 
)

Decrypts a block of data with ASCON-80pq in incremental mode.

Parameters
stateState to use for ASCON-80pq encryption operations.
inBuffer that contains the ciphertext to decrypt.
outBuffer to receive the plaintext output. Can be the same buffer as in.
lenLength of the plaintext and ciphertext in bytes.
See also
ascon80pq_aead_encrypt_block(), ascon80pq_aead_start(), ascon80pq_aead_decrypt_finalize()

Definition at line 92 of file ascon-aead-inc-80pq.c.

◆ ascon80pq_aead_decrypt_finalize()

int ascon80pq_aead_decrypt_finalize ( ascon80pq_state_t state,
const unsigned char *  tag 
)

Finalizes an incremental ASCON-80pq decryption operation and checks the authentication tag.

Parameters
stateState to use for ASCON-80pq encryption operations.
tagPoints to the buffer containing the ciphertext's authentication tag. Must be at least ASCON80PQ_TAG_SIZE bytes in length.
Returns
0 on success, -1 if the authentication tag was incorrect, or some other negative number if there was an error in the parameters.

The contents of state will be freed by this function, destroying any sensitive material that may be present.

See also
ascon80pq_aead_decrypt_block(), ascon80pq_aead_start()

Definition at line 102 of file ascon-aead-inc-80pq.c.

◆ ascon80pq_aead_encrypt()

void ascon80pq_aead_encrypt ( unsigned char *  c,
size_t *  clen,
const unsigned char *  m,
size_t  mlen,
const unsigned char *  ad,
size_t  adlen,
const unsigned char *  npub,
const unsigned char *  k 
)

Encrypts and authenticates a packet with ASCON-80pq.

Parameters
cBuffer to receive the output.
clenOn exit, set to the length of the output which includes the ciphertext and the 16 byte authentication tag.
mBuffer that contains the plaintext message to encrypt.
mlenLength of the plaintext message in bytes.
adBuffer that contains associated data to authenticate along with the packet but which does not need to be encrypted.
adlenLength of the associated data in bytes.
npubPoints to the public nonce for the packet which must be 16 bytes in length.
kPoints to the 20 bytes of the key to use to encrypt the packet.
See also
ascon80pq_aead_decrypt()

Definition at line 32 of file ascon-aead-80pq.c.

◆ ascon80pq_aead_encrypt_block()

void ascon80pq_aead_encrypt_block ( ascon80pq_state_t state,
const unsigned char *  in,
unsigned char *  out,
size_t  len 
)

Encrypts a block of data with ASCON-80pq in incremental mode.

Parameters
stateState to use for ASCON-80pq encryption operations.
inBuffer that contains the plaintext to encrypt.
outBuffer to receive the ciphertext output. Can be the same buffer as in.
lenLength of the plaintext and ciphertext in bytes.
See also
ascon80pq_aead_decrypt_block(), ascon80pq_aead_start(), ascon80pq_aead_encrypt_finalize()

Definition at line 64 of file ascon-aead-inc-80pq.c.

◆ ascon80pq_aead_encrypt_finalize()

void ascon80pq_aead_encrypt_finalize ( ascon80pq_state_t state,
unsigned char *  tag 
)

Finalizes an incremental ASCON-80pq encryption operation and generates the authentication tag.

Parameters
stateState to use for ASCON-80pq encryption operations.
tagPoints to the buffer to receive the authentication tag. Must be at least ASCON80PQ_TAG_SIZE bytes in length.

The contents of state will be freed by this function, destroying any sensitive material that may be present.

See also
ascon80pq_aead_encrypt_block(), ascon80pq_aead_start()

Definition at line 74 of file ascon-aead-inc-80pq.c.

◆ ascon80pq_aead_start()

void ascon80pq_aead_start ( ascon80pq_state_t state,
const unsigned char *  ad,
size_t  adlen,
const unsigned char *  npub,
const unsigned char *  k 
)

Starts encrypting or decrypting a packet with ASCON-80pq in incremental mode.

Parameters
stateState to initialize for ASCON-80pq operations.
adBuffer that contains associated data to authenticate along with the packet but which does not need to be encrypted.
adlenLength of the associated data in bytes.
npubPoints to the public nonce for the packet which must be 16 bytes in length.
kPoints to the 20 bytes of the key to use to encrypt the packet.

The following sequence can be used to encrypt a list of i plaintext message blocks (m) to produce i ciphertext message blocks (c) and an authentication tag (t).

ascon80pq_aead_start(&state, ad, adlen, npub, k);
...;
void ascon80pq_aead_start(ascon80pq_state_t *state, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
Starts encrypting or decrypting a packet with ASCON-80pq in incremental mode.
void ascon80pq_aead_encrypt_block(ascon80pq_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Encrypts a block of data with ASCON-80pq in incremental mode.
void ascon80pq_aead_encrypt_finalize(ascon80pq_state_t *state, unsigned char *tag)
Finalizes an incremental ASCON-80pq encryption operation and generates the authentication tag.
State information for the incremental version of ASCON-80pq.
Definition: aead.h:299

Decryption uses a similar sequence:

ascon80pq_aead_start(&state, ad, adlen, npub, k);
...;
...; // decryption has failed!
void ascon80pq_aead_decrypt_block(ascon80pq_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Decrypts a block of data with ASCON-80pq in incremental mode.
int ascon80pq_aead_decrypt_finalize(ascon80pq_state_t *state, const unsigned char *tag)
Finalizes an incremental ASCON-80pq decryption operation and checks the authentication tag.

It is very important that the plaintext output from decryption be discarded if the authentication tag fails to verify. Applications should not use any of the data before verifying the tag.

See also
ascon80pq_aead_encrypt_block(), ascon80pq_aead_decrypt_block(), ascon80pq_aead_encrypt_finalize(), ascon80pq_aead_decrypt_finalize()

Definition at line 30 of file ascon-aead-inc-80pq.c.