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

ISAP authenticated encryption algorithm for ASCON. More...

#include <ascon/permutation.h>

Go to the source code of this file.

Classes

struct  ascon128a_isap_aead_key_t
 Pre-computed key information for ISAP-A-128A. More...
 
struct  ascon128_isap_aead_key_t
 Pre-computed key information for ISAP-A-128. More...
 
struct  ascon80pq_isap_aead_key_t
 Pre-computed key information for ISAP-A-80PQ. More...
 

Macros

#define ASCON128_ISAP_KEY_SIZE   16
 Size of the key for all ISAP-A family members with 128-bit keys. More...
 
#define ASCON80PQ_ISAP_KEY_SIZE   20
 Size of the key for all ISAP-A family members with 160-bit keys. More...
 
#define ASCON_ISAP_TAG_SIZE   16
 Size of the authentication tag for all ISAP-A family members. More...
 
#define ASCON_ISAP_NONCE_SIZE   16
 Size of the nonce for all ISAP-A family members. More...
 
#define ASCON_ISAP_SAVED_KEY_SIZE   80
 Size of a pre-computed key in its save format. More...
 

Functions

void ascon128a_isap_aead_init (ascon128a_isap_aead_key_t *pk, const unsigned char *k)
 Initializes a pre-computed key for ISAP-A-128A. More...
 
void ascon128a_isap_aead_load_key (ascon128a_isap_aead_key_t *pk, const unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
 Initializes a pre-computed key for ISAP-A-128A from a previously-saved key value. More...
 
void ascon128a_isap_aead_save_key (ascon128a_isap_aead_key_t *pk, unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
 Saves a previously pre-computed key for ISAP-A-128A to a buffer. More...
 
void ascon128a_isap_aead_free (ascon128a_isap_aead_key_t *pk)
 Frees a pre-computed key for ISAP-A-128A. More...
 
void ascon128a_isap_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 ascon128a_isap_aead_key_t *pk)
 Encrypts and authenticates a packet with ISAP-A-128A and pre-computed keys. More...
 
int ascon128a_isap_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 ascon128a_isap_aead_key_t *pk)
 Decrypts and authenticates a packet with ISAP-A-128A and pre-computed keys. More...
 
void ascon128_isap_aead_init (ascon128_isap_aead_key_t *pk, const unsigned char *k)
 Initializes a pre-computed key for ISAP-A-128. More...
 
void ascon128_isap_aead_load_key (ascon128_isap_aead_key_t *pk, const unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
 Initializes a pre-computed key for ISAP-A-128 from a previously-saved key value. More...
 
void ascon128_isap_aead_save_key (ascon128_isap_aead_key_t *pk, unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
 Saves a previously pre-computed key for ISAP-A-128 to a buffer. More...
 
void ascon128_isap_aead_free (ascon128_isap_aead_key_t *pk)
 Frees a pre-computed key for ISAP-A-128. More...
 
void ascon128_isap_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 ascon128_isap_aead_key_t *pk)
 Encrypts and authenticates a packet with ISAP-A-128 and pre-computed keys. More...
 
int ascon128_isap_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 ascon128_isap_aead_key_t *pk)
 Decrypts and authenticates a packet with ISAP-A-128 and pre-computed keys. More...
 
void ascon80pq_isap_aead_init (ascon80pq_isap_aead_key_t *pk, const unsigned char *k)
 Initializes a pre-computed key for ISAP-A-80PQ. More...
 
void ascon80pq_isap_aead_load_key (ascon80pq_isap_aead_key_t *pk, const unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
 Initializes a pre-computed key for ISAP-A-80PQ from a previously-saved key value. More...
 
void ascon80pq_isap_aead_save_key (ascon80pq_isap_aead_key_t *pk, unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
 Saves a previously pre-computed key for ISAP-A-80PQ to a buffer. More...
 
void ascon80pq_isap_aead_free (ascon80pq_isap_aead_key_t *pk)
 Frees a pre-computed key for ISAP-A-80PQ. More...
 
void ascon80pq_isap_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 ascon80pq_isap_aead_key_t *pk)
 Encrypts and authenticates a packet with ISAP-A-80PQ and pre-computed keys. More...
 
int ascon80pq_isap_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 ascon80pq_isap_aead_key_t *pk)
 Decrypts and authenticates a packet with ISAP-A-80PQ and pre-computed keys. More...
 

Detailed Description

ISAP authenticated encryption algorithm for ASCON.

ISAP is a family of authenticated encryption algorithms that were built around the Keccak-p[400] and ASCON permutations. This API implements the versions that were built around ASCON: ISAP-A-128 and ISAP-A-128A.

This API also provides ISAP-A-80PQ which is almost identical to ISAP-A-128, except that it uses a 160-bit key instead of the default 128-bit key.

ISAP is designed to provide some protection against adversaries using differential power analysis to determine the key. The downside is that key setup is very slow.

To alleviate slow key setup, the ascon128_isap_aead_init() and ascon128a_isap_aead_init() functions pre-compute the key setup so that the same pre-computed key can be reused on multiple packets.

If a device has a long-lived key, then the pre-computed key can be stored in ROM or flash memory using ascon128_isap_aead_save_key() or ascon128a_isap_aead_save_key(). The long-lived key is reloaded later using ascon128_isap_aead_load_key() or ascon128a_isap_aead_load_key(). This may avoid leakage when loading the key bits at runtime.

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

Definition in file isap.h.

Macro Definition Documentation

◆ ASCON128_ISAP_KEY_SIZE

#define ASCON128_ISAP_KEY_SIZE   16

Size of the key for all ISAP-A family members with 128-bit keys.

Definition at line 63 of file isap.h.

◆ ASCON80PQ_ISAP_KEY_SIZE

#define ASCON80PQ_ISAP_KEY_SIZE   20

Size of the key for all ISAP-A family members with 160-bit keys.

Definition at line 68 of file isap.h.

◆ ASCON_ISAP_NONCE_SIZE

#define ASCON_ISAP_NONCE_SIZE   16

Size of the nonce for all ISAP-A family members.

Definition at line 78 of file isap.h.

◆ ASCON_ISAP_SAVED_KEY_SIZE

#define ASCON_ISAP_SAVED_KEY_SIZE   80

Size of a pre-computed key in its save format.

Definition at line 83 of file isap.h.

◆ ASCON_ISAP_TAG_SIZE

#define ASCON_ISAP_TAG_SIZE   16

Size of the authentication tag for all ISAP-A family members.

Definition at line 73 of file isap.h.

Function Documentation

◆ ascon128_isap_aead_decrypt()

int ascon128_isap_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 ascon128_isap_aead_key_t pk 
)

Decrypts and authenticates a packet with ISAP-A-128 and pre-computed keys.

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.
pkPoints to the pre-computed key value.
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_isap_aead_encrypt(), ascon128_isap_aead_init()

◆ ascon128_isap_aead_encrypt()

void ascon128_isap_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 ascon128_isap_aead_key_t pk 
)

Encrypts and authenticates a packet with ISAP-A-128 and pre-computed keys.

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.
pkPoints to the pre-computed key value.
See also
ascon128_isap_aead_decrypt(), ascon128_isap_aead_init()

◆ ascon128_isap_aead_free()

void ascon128_isap_aead_free ( ascon128_isap_aead_key_t pk)

Frees a pre-computed key for ISAP-A-128.

Parameters
pkPoints to the pre-computed key value.
See also
ascon128_isap_aead_init()

◆ ascon128_isap_aead_init()

void ascon128_isap_aead_init ( ascon128_isap_aead_key_t pk,
const unsigned char *  k 
)

Initializes a pre-computed key for ISAP-A-128.

Parameters
pkPoints to the object to receive the pre-computed key value.
kPoints to the 16 bytes of the key.

The ascon128_isap_aead_load_key() function can be used to initialize the pre-computed key from a value that was previously saved with ascon128_isap_aead_save_key().

See also
ascon128_isap_aead_free(), ascon128_isap_aead_encrypt(), ascon128_isap_aead_decrypt(), ascon128_isap_aead_load_key()

◆ ascon128_isap_aead_load_key()

void ascon128_isap_aead_load_key ( ascon128_isap_aead_key_t pk,
const unsigned char  k[ASCON_ISAP_SAVED_KEY_SIZE] 
)

Initializes a pre-computed key for ISAP-A-128 from a previously-saved key value.

Parameters
pkPoints to the object to receive the pre-computed key value.
kPoints to the bytes of the previously-saved key.
See also
ascon128_isap_aead_free(), ascon128_isap_aead_encrypt(), ascon128_isap_aead_decrypt(), ascon128_isap_aead_save_key()

◆ ascon128_isap_aead_save_key()

void ascon128_isap_aead_save_key ( ascon128_isap_aead_key_t pk,
unsigned char  k[ASCON_ISAP_SAVED_KEY_SIZE] 
)

Saves a previously pre-computed key for ISAP-A-128 to a buffer.

Parameters
pkPoints to the object to receive the pre-computed key value.
kPoints to the buffer to save the pre-computed key in.
See also
ascon128_isap_aead_free(), ascon128_isap_aead_encrypt(), ascon128_isap_aead_decrypt(), ascon128_isap_aead_load_key()

◆ ascon128a_isap_aead_decrypt()

int ascon128a_isap_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 ascon128a_isap_aead_key_t pk 
)

Decrypts and authenticates a packet with ISAP-A-128A and pre-computed keys.

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.
pkPoints to the pre-computed key value.
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_isap_aead_encrypt(), ascon128a_isap_aead_init()

◆ ascon128a_isap_aead_encrypt()

void ascon128a_isap_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 ascon128a_isap_aead_key_t pk 
)

Encrypts and authenticates a packet with ISAP-A-128A and pre-computed keys.

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.
pkPoints to the pre-computed key value.
See also
ascon128a_isap_aead_decrypt(), ascon128a_isap_aead_init()

◆ ascon128a_isap_aead_free()

void ascon128a_isap_aead_free ( ascon128a_isap_aead_key_t pk)

Frees a pre-computed key for ISAP-A-128A.

Parameters
pkPoints to the pre-computed key value.
See also
ascon128a_isap_aead_init()

◆ ascon128a_isap_aead_init()

void ascon128a_isap_aead_init ( ascon128a_isap_aead_key_t pk,
const unsigned char *  k 
)

Initializes a pre-computed key for ISAP-A-128A.

Parameters
pkPoints to the object to receive the pre-computed key value.
kPoints to the 16 bytes of the key.

The ascon128a_isap_aead_load_key() function can be used to initialize the pre-computed key from a value that was previously saved with ascon128a_isap_aead_save_key().

See also
ascon128a_isap_aead_free(), ascon128a_isap_aead_encrypt(), ascon128a_isap_aead_decrypt(), ascon128a_isap_aead_load_key()

◆ ascon128a_isap_aead_load_key()

void ascon128a_isap_aead_load_key ( ascon128a_isap_aead_key_t pk,
const unsigned char  k[ASCON_ISAP_SAVED_KEY_SIZE] 
)

Initializes a pre-computed key for ISAP-A-128A from a previously-saved key value.

Parameters
pkPoints to the object to receive the pre-computed key value.
kPoints to the bytes of the previously-saved key.
See also
ascon128a_isap_aead_free(), ascon128a_isap_aead_encrypt(), ascon128a_isap_aead_decrypt(), ascon128a_isap_aead_save_key()

◆ ascon128a_isap_aead_save_key()

void ascon128a_isap_aead_save_key ( ascon128a_isap_aead_key_t pk,
unsigned char  k[ASCON_ISAP_SAVED_KEY_SIZE] 
)

Saves a previously pre-computed key for ISAP-A-128A to a buffer.

Parameters
pkPoints to the object to receive the pre-computed key value.
kPoints to the buffer to save the pre-computed key in.
See also
ascon128a_isap_aead_free(), ascon128a_isap_aead_encrypt(), ascon128a_isap_aead_decrypt(), ascon128a_isap_aead_load_key()

◆ ascon80pq_isap_aead_decrypt()

int ascon80pq_isap_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 ascon80pq_isap_aead_key_t pk 
)

Decrypts and authenticates a packet with ISAP-A-80PQ and pre-computed keys.

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.
pkPoints to the pre-computed key value.
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_isap_aead_encrypt(), ascon80pq_isap_aead_init()

◆ ascon80pq_isap_aead_encrypt()

void ascon80pq_isap_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 ascon80pq_isap_aead_key_t pk 
)

Encrypts and authenticates a packet with ISAP-A-80PQ and pre-computed keys.

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.
pkPoints to the pre-computed key value.
See also
ascon80pq_isap_aead_decrypt(), ascon80pq_isap_aead_init()

◆ ascon80pq_isap_aead_free()

void ascon80pq_isap_aead_free ( ascon80pq_isap_aead_key_t pk)

Frees a pre-computed key for ISAP-A-80PQ.

Parameters
pkPoints to the pre-computed key value.
See also
ascon80pq_isap_aead_init()

◆ ascon80pq_isap_aead_init()

void ascon80pq_isap_aead_init ( ascon80pq_isap_aead_key_t pk,
const unsigned char *  k 
)

Initializes a pre-computed key for ISAP-A-80PQ.

Parameters
pkPoints to the object to receive the pre-computed key value.
kPoints to the 20 bytes of the key.

The ascon80pq_isap_aead_load_key() function can be used to initialize the pre-computed key from a value that was previously saved with ascon80pq_isap_aead_save_key().

See also
ascon80pq_isap_aead_free(), ascon80pq_isap_aead_encrypt(), ascon80pq_isap_aead_decrypt(), ascon80pq_isap_aead_load_key()

◆ ascon80pq_isap_aead_load_key()

void ascon80pq_isap_aead_load_key ( ascon80pq_isap_aead_key_t pk,
const unsigned char  k[ASCON_ISAP_SAVED_KEY_SIZE] 
)

Initializes a pre-computed key for ISAP-A-80PQ from a previously-saved key value.

Parameters
pkPoints to the object to receive the pre-computed key value.
kPoints to the bytes of the previously-saved key.
See also
ascon80pq_isap_aead_free(), ascon80pq_isap_aead_encrypt(), ascon80pq_isap_aead_decrypt(), ascon80pq_isap_aead_save_key()

◆ ascon80pq_isap_aead_save_key()

void ascon80pq_isap_aead_save_key ( ascon80pq_isap_aead_key_t pk,
unsigned char  k[ASCON_ISAP_SAVED_KEY_SIZE] 
)

Saves a previously pre-computed key for ISAP-A-80PQ to a buffer.

Parameters
pkPoints to the object to receive the pre-computed key value.
kPoints to the buffer to save the pre-computed key in.
See also
ascon80pq_isap_aead_free(), ascon80pq_isap_aead_encrypt(), ascon80pq_isap_aead_decrypt(), ascon80pq_isap_aead_load_key()