Loading...
Searching...
No Matches
sizes.h File Reference

AEAD size definitions for the PSA Crypto API. More...

Detailed Description

#include "algorithm.h"
+ Include dependency graph for sizes.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

#define PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE(ciphertext_length)
 A sufficient plaintext buffer size for psa_aead_decrypt(), for any of the supported key types and AEAD algorithms.
 
#define PSA_AEAD_TAG_LENGTH(key_type, key_bits, alg)
 The length of a tag for an AEAD algorithm, in bytes.
 
#define PSA_AEAD_TAG_MAX_SIZE   (16)
 A sufficient buffer size for storing the tag output by psa_aead_finish(), for any of the supported key types and AEAD algorithms.
 
#define PSA_AES_CCM_TAG_MAX_SIZE   (16)
 A sufficient buffer size for storing the tag output by psa_aead_finish(), for AES key types and CCM algorithms.
 
#define PSA_AEAD_DECRYPT_OUTPUT_SIZE(key_type, alg, ciphertext_length)
 A sufficient plaintext buffer size for psa_aead_decrypt(), in bytes.
 
#define PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(plaintext_length)
 A sufficient ciphertext buffer size for psa_aead_encrypt(), for any of the supported key types and AEAD algorithms.
 
#define PSA_AEAD_ENCRYPT_OUTPUT_SIZE(key_type, alg, plaintext_length)
 A sufficient ciphertext buffer size for psa_aead_encrypt(), in bytes.
 
#define PSA_AEAD_FINISH_OUTPUT_MAX_SIZE   /* implementation-defined value */
 A sufficient ciphertext buffer size for psa_aead_finish(), for any of the supported key types and AEAD algorithms.
 
#define PSA_AEAD_FINISH_OUTPUT_SIZE(key_type, alg)
 A sufficient ciphertext buffer size for psa_aead_finish().
 
#define PSA_AEAD_NONCE_LENGTH(key_type, alg)
 The default nonce size for an AEAD algorithm, in bytes.
 
#define PSA_AEAD_NONCE_MAX_SIZE   (13)
 A sufficient buffer size for storing the nonce generated by psa_aead_generate_nonce(), for any of the supported key types and AEAD algorithms.
 
#define PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(input_length)
 A sufficient output buffer size for psa_aead_update(), for any of the supported key types and AEAD algorithms.
 
#define PSA_AEAD_UPDATE_OUTPUT_SIZE(key_type, alg, input_length)
 A sufficient output buffer size for psa_aead_update().
 
#define PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE   /* implementation-defined value */
 A sufficient output buffer size for psa_aead_update(), for any of the supported key types and AEAD algorithms.
 
#define PSA_AEAD_VERIFY_OUTPUT_SIZE(key_type, alg)
 A sufficient plaintext buffer size for psa_aead_verify(), in bytes.
 

Macro Definition Documentation

◆ PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE

#define PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE ( ciphertext_length)
Value:
/* implementation-defined value */

A sufficient plaintext buffer size for psa_aead_decrypt(), for any of the supported key types and AEAD algorithms.

If the size of the plaintext buffer is at least this large, it is guaranteed that psa_aead_decrypt() will not fail due to an insufficient buffer size.

See also PSA_AEAD_DECRYPT_OUTPUT_SIZE().

Parameters
ciphertext_lengthSize of the ciphertext in bytes.

Definition at line 42 of file sizes.h.

◆ PSA_AEAD_DECRYPT_OUTPUT_SIZE

#define PSA_AEAD_DECRYPT_OUTPUT_SIZE ( key_type,
alg,
ciphertext_length )
Value:
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
((ciphertext_length) > PSA_AEAD_TAG_LENGTH(key_type, 0, alg)) ? \
(ciphertext_length) - PSA_AEAD_TAG_LENGTH(key_type, 0, alg) : 0)
#define PSA_AEAD_NONCE_LENGTH(key_type, alg)
The default nonce size for an AEAD algorithm, in bytes.
Definition sizes.h:202
#define PSA_AEAD_TAG_LENGTH(key_type, key_bits, alg)
The length of a tag for an AEAD algorithm, in bytes.
Definition sizes.h:64

A sufficient plaintext buffer size for psa_aead_decrypt(), in bytes.

If the size of the plaintext buffer is at least this large, it is guaranteed that psa_aead_decrypt() will not fail due to an insufficient buffer size. Depending on the algorithm, the actual size of the plaintext might be smaller.

See also PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE.

Parameters
key_typeA symmetric key type that is compatible with algorithm alg.
algAn AEAD algorithm: a value of type psa_algorithm_t such that PSA_ALG_IS_AEAD(alg) is true.
ciphertext_lengthSize of the ciphertext in bytes.
Returns
The AEAD plaintext size for the specified key type and algorithm. 0 if the key type or AEAD algorithm is not recognized, not supported or the parameters are incompatible.

Definition at line 109 of file sizes.h.

◆ PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE

#define PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE ( plaintext_length)
Value:
((plaintext_length) + PSA_AEAD_TAG_MAX_SIZE)
#define PSA_AEAD_TAG_MAX_SIZE
A sufficient buffer size for storing the tag output by psa_aead_finish(), for any of the supported ke...
Definition sizes.h:78

A sufficient ciphertext buffer size for psa_aead_encrypt(), for any of the supported key types and AEAD algorithms.

If the size of the ciphertext buffer is at least this large, it is guaranteed that psa_aead_encrypt() will not fail due to an insufficient buffer size.

See also PSA_AEAD_ENCRYPT_OUTPUT_SIZE().

Parameters
plaintext_lengthSize of the plaintext in bytes.

Definition at line 126 of file sizes.h.

◆ PSA_AEAD_ENCRYPT_OUTPUT_SIZE

#define PSA_AEAD_ENCRYPT_OUTPUT_SIZE ( key_type,
alg,
plaintext_length )
Value:
(PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 ? \
(plaintext_length) + PSA_AEAD_TAG_LENGTH(key_type, 0, alg) : 0)

A sufficient ciphertext buffer size for psa_aead_encrypt(), in bytes.

If the size of the ciphertext buffer is at least this large, it is guaranteed that psa_aead_encrypt() will not fail due to an insufficient buffer size. Depending on the algorithm, the actual size of the ciphertext might be smaller.

See also PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE.

Parameters
key_typeA symmetric key type that is compatible with algorithm alg.
algAn AEAD algorithm: a value of type psa_algorithm_t such that PSA_ALG_IS_AEAD(alg) is true.
plaintext_lengthSize of the plaintext in bytes.
Returns
The AEAD ciphertext size for the specified key type and algorithm. 0 if the key type or AEAD algorithm is not recognized, not supported or the parameters are incompatible.

Definition at line 147 of file sizes.h.

◆ PSA_AEAD_FINISH_OUTPUT_MAX_SIZE

#define PSA_AEAD_FINISH_OUTPUT_MAX_SIZE   /* implementation-defined value */

A sufficient ciphertext buffer size for psa_aead_finish(), for any of the supported key types and AEAD algorithms.

If the size of the ciphertext buffer is at least this large, it is guaranteed that psa_aead_finish() will not fail due to an insufficient ciphertext buffer size.

See also PSA_AEAD_FINISH_OUTPUT_SIZE().

Definition at line 160 of file sizes.h.

◆ PSA_AEAD_FINISH_OUTPUT_SIZE

#define PSA_AEAD_FINISH_OUTPUT_SIZE ( key_type,
alg )
Value:
/* implementation-defined value */

A sufficient ciphertext buffer size for psa_aead_finish().

If the size of the ciphertext buffer is at least this large, it is guaranteed that psa_aead_finish() will not fail due to an insufficient ciphertext buffer size. The actual size of the output might be smaller in any given call.

See also PSA_AEAD_FINISH_OUTPUT_MAX_SIZE.

Parameters
key_typeA symmetric key type that is compatible with algorithm alg.
algAn AEAD algorithm: a value of type psa_algorithm_t such that PSA_ALG_IS_AEAD(alg) is true.
Returns
A sufficient ciphertext buffer size for the specified key type and algorithm. If the key type or AEAD algorithm is not recognized, or the parameters are incompatible, return 0. An implementation can return either 0 or a correct size for a key type and AEAD algorithm that it recognizes, but does not support.

Definition at line 180 of file sizes.h.

◆ PSA_AEAD_NONCE_LENGTH

#define PSA_AEAD_NONCE_LENGTH ( key_type,
alg )
Value:
((PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) == 16 && \
(key_type == PSA_KEY_TYPE_CHACHA20 && \
12 : 0)
#define PSA_ALG_CHACHA20_POLY1305
The ChaCha20-Poly1305 AEAD algorithm.
Definition algorithm.h:153
#define PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(aead_alg)
An AEAD algorithm with the default tag length.
Definition algorithm.h:190
#define PSA_ALG_CCM
The Counter with CBC-MAC (CCM) authenticated encryption algorithm.
Definition algorithm.h:97
#define PSA_BLOCK_CIPHER_BLOCK_LENGTH(type)
The block size of a block cipher.
Definition sizes.h:44
#define PSA_KEY_TYPE_CHACHA20
Key for the ChaCha20 stream cipher or the ChaCha20-Poly1305 AEAD algorithm.
Definition type.h:444

The default nonce size for an AEAD algorithm, in bytes.

If the size of the nonce buffer is at least this large, it is guaranteed that psa_aead_generate_nonce() will not fail due to an insufficient buffer size.

For most AEAD algorithms, PSA_AEAD_NONCE_LENGTH() evaluates to the exact size of the nonce generated by psa_aead_generate_nonce().

See also PSA_AEAD_NONCE_MAX_SIZE.

Parameters
key_typeA symmetric key type that is compatible with algorithm alg.
algAn AEAD algorithm: a value of type psa_algorithm_t such that PSA_ALG_IS_AEAD(alg) is true.
Returns
The default nonce size for the specified key type and algorithm. 0 if the key type or AEAD algorithm is not recognized, not supported or the parameters are incompatible.

Definition at line 202 of file sizes.h.

◆ PSA_AEAD_NONCE_MAX_SIZE

#define PSA_AEAD_NONCE_MAX_SIZE   (13)

A sufficient buffer size for storing the nonce generated by psa_aead_generate_nonce(), for any of the supported key types and AEAD algorithms.

If the size of the nonce buffer is at least this large, it is guaranteed that psa_aead_generate_nonce() will not fail due to an insufficient buffer size.

See also PSA_AEAD_NONCE_LENGTH().

Definition at line 219 of file sizes.h.

◆ PSA_AEAD_TAG_LENGTH

#define PSA_AEAD_TAG_LENGTH ( key_type,
key_bits,
alg )
Value:
(PSA_ALG_IS_AEAD(alg) ? \
(((alg) & 0x003f0000) >> 16) : \
((void) (key_type), (void) (key_bits), 0))
#define PSA_ALG_IS_AEAD(alg)
Whether the specified algorithm is an authenticated encryption with associated data (AEAD) algorithm.
Definition algorithm.h:44

The length of a tag for an AEAD algorithm, in bytes.

This is the size of the tag output from psa_aead_finish(). If the size of the tag buffer is at least this large, it is guaranteed that psa_aead_finish() will not fail due to an insufficient tag buffer size.

See also PSA_AEAD_TAG_MAX_SIZE.

Parameters
key_typeThe type of the AEAD key.
key_bitsThe size of the AEAD key in bits.
algAn AEAD algorithm: a value of type psa_algorithm_t such that PSA_ALG_IS_AEAD(alg) is true.
Returns
The tag length for the specified algorithm and key. 0 if the AEAD algorithm does not have an identified tag that can be distinguished from the rest of the ciphertext. 0 if the AEAD algorithm is not recognized or not supported.

Definition at line 64 of file sizes.h.

◆ PSA_AEAD_TAG_MAX_SIZE

#define PSA_AEAD_TAG_MAX_SIZE   (16)

A sufficient buffer size for storing the tag output by psa_aead_finish(), for any of the supported key types and AEAD algorithms.

If the size of the tag buffer is at least this large, it is guaranteed that psa_aead_finish() will not fail due to an insufficient buffer size.

See also PSA_AEAD_TAG_LENGTH().

Definition at line 78 of file sizes.h.

◆ PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE

#define PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE ( input_length)
Value:
/* implementation-defined value */

A sufficient output buffer size for psa_aead_update(), for any of the supported key types and AEAD algorithms.

If the size of the output buffer is at least this large, it is guaranteed that psa_aead_update() will not fail due to an insufficient buffer size.

See also PSA_AEAD_UPDATE_OUTPUT_SIZE().

Parameters
input_lengthSize of the input in bytes.

Definition at line 232 of file sizes.h.

◆ PSA_AEAD_UPDATE_OUTPUT_SIZE

#define PSA_AEAD_UPDATE_OUTPUT_SIZE ( key_type,
alg,
input_length )
Value:
/* implementation-defined value */

A sufficient output buffer size for psa_aead_update().

If the size of the output buffer is at least this large, it is guaranteed that psa_aead_update() will not fail due to an insufficient buffer size. The actual size of the output might be smaller in any given call.

See also PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE.

Parameters
key_typeA symmetric key type that is compatible with algorithm alg.
algAn AEAD algorithm: a value of type psa_algorithm_t such that PSA_ALG_IS_AEAD(alg) is true.
input_lengthSize of the input in bytes.
Returns
A sufficient output buffer size for the specified key type and algorithm. 0 if the key type or AEAD algorithm is not recognized, not supported or the parameters are incompatible.

Definition at line 253 of file sizes.h.

◆ PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE

#define PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE   /* implementation-defined value */

A sufficient output buffer size for psa_aead_update(), for any of the supported key types and AEAD algorithms.

If the size of the output buffer is at least this large, it is guaranteed that psa_aead_update() will not fail due to an insufficient buffer size.

See also PSA_AEAD_UPDATE_OUTPUT_SIZE().

Parameters
input_lengthSize of the input in bytes.

Definition at line 267 of file sizes.h.

◆ PSA_AEAD_VERIFY_OUTPUT_SIZE

#define PSA_AEAD_VERIFY_OUTPUT_SIZE ( key_type,
alg )
Value:
/* implementation-defined value */

A sufficient plaintext buffer size for psa_aead_verify(), in bytes.

If the size of the plaintext buffer is at least this large, it is guaranteed that psa_aead_verify() will not fail due to an insufficient plaintext buffer size. The actual size of the output might be smaller in any given call.

See also PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE.

Parameters
key_typeA symmetric key type that is compatible with algorithm alg.
algAn AEAD algorithm: a value of type psa_algorithm_t such that PSA_ALG_IS_AEAD(alg) is true.
Returns
A sufficient plaintext buffer size for the specified key type and algorithm. 0 if the key type or AEAD algorithm is not recognized, not supported or the parameters are incompatible.

Definition at line 286 of file sizes.h.

◆ PSA_AES_CCM_TAG_MAX_SIZE

#define PSA_AES_CCM_TAG_MAX_SIZE   (16)

A sufficient buffer size for storing the tag output by psa_aead_finish(), for AES key types and CCM algorithms.

If the size of the tag buffer is at least this large, it is guaranteed that psa_aead_finish() will not fail due to an insufficient buffer size.

See also PSA_AEAD_TAG_LENGTH().

Definition at line 89 of file sizes.h.