SE RT Services Utilities library

| SE RT Services Utilities library

Macros
Data size definitions
IFX SE PSA crypto API

## General Description

Data size definitions.

## Macros
#define | IFX_SE_HASH_LENGTH(alg)
| The size of the output of ifx_se_hash_finish(), in bytes. More...
#define | IFX_SE_HASH_BLOCK_LENGTH(alg)
| The input block size of a hash algorithm, in bytes. More...
#define | IFX_SE_HASH_MAX_SIZE 32u
| Maximum size of a hash. More...
#define | IFX_SE_MAC_MAX_SIZE IFX_SE_HASH_MAX_SIZE
| Maximum size of a MAC. More...
#define | IFX_SE_AEAD_TAG_LENGTH(key_type, key_bits, alg)
| The length of a tag for an AEAD algorithm, in bytes. More...
#define | IFX_SE_AEAD_TAG_MAX_SIZE 16u
| The maximum tag size for all supported AEAD algorithms, in bytes. More...
#define | IFX_SE_VENDOR_RSA_MAX_KEY_BITS 4096u
| The maximum size of an RSA key on this implementation, in bits. More...
#define | IFX_SE_VENDOR_ECC_MAX_CURVE_BITS 384u
| The maximum size of an ECC key on this implementation, in bits. More...
#define | IFX_SE_TLS12_PSK_TO_MS_PSK_MAX_SIZE 128u
| This macro returns the maximum supported length of the PSK for the TLS-1.2 PSK-to-MS key derivation (IFX_SE_ALG_TLS12_PSK_TO_MS(`hash_alg`)). More...
#define | IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE 16u
| The maximum size of a block cipher.
#define | IFX_SE_MAC_LENGTH(key_type, key_bits, alg)
| The size of the output of ifx_se_mac_sign_finish(), in bytes. More...
#define | IFX_SE_AEAD_ENCRYPT_OUTPUT_SIZE(key_type, alg, plaintext_length)
| The maximum size of the output of ifx_se_aead_encrypt(), in bytes. More...
#define | IFX_SE_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(plaintext_length) ((plaintext_length) + IFX_SE_AEAD_TAG_MAX_SIZE)
| A sufficient output buffer size for ifx_se_aead_encrypt(), for any of the supported key types and AEAD algorithms. More...
#define | IFX_SE_AEAD_DECRYPT_OUTPUT_SIZE(key_type, alg, ciphertext_length)
| The maximum size of the output of ifx_se_aead_decrypt(), in bytes. More...
#define | IFX_SE_AEAD_DECRYPT_OUTPUT_MAX_SIZE(ciphertext_length) (ciphertext_length)
| A sufficient output buffer size for ifx_se_aead_decrypt(), for any of the supported key types and AEAD algorithms. More...
#define | IFX_SE_AEAD_NONCE_LENGTH(key_type, alg)
| The default nonce size for an AEAD algorithm, in bytes. More...
#define | IFX_SE_AEAD_NONCE_MAX_SIZE 13u
| The maximum default nonce size among all supported pairs of key types and AEAD algorithms, in bytes. More...
#define | IFX_SE_AEAD_UPDATE_OUTPUT_SIZE(key_type, alg, input_length)
| A sufficient output buffer size for ifx_se_aead_update(). More...
#define | IFX_SE_AEAD_UPDATE_OUTPUT_MAX_SIZE(input_length) (IFX_SE_ROUND_UP_TO_MULTIPLE(IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE, (input_length)))
| A sufficient output buffer size for ifx_se_aead_update(), for any of the supported key types and AEAD algorithms. More...
#define | IFX_SE_AEAD_FINISH_OUTPUT_SIZE(key_type, alg)
| A sufficient ciphertext buffer size for ifx_se_aead_finish(). More...
#define | IFX_SE_AEAD_FINISH_OUTPUT_MAX_SIZE (IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE)
| A sufficient ciphertext buffer size for ifx_se_aead_finish(), for any of the supported key types and AEAD algorithms. More...
#define | IFX_SE_AEAD_VERIFY_OUTPUT_SIZE(key_type, alg)
| A sufficient plaintext buffer size for ifx_se_aead_verify(). More...
#define | IFX_SE_AEAD_VERIFY_OUTPUT_MAX_SIZE (IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE)
| A sufficient plaintext buffer size for ifx_se_aead_verify(), for any of the supported key types and AEAD algorithms. More...
#define | IFX_SE_ECDSA_SIGNATURE_SIZE(curve_bits) (IFX_SE_BITS_TO_BYTES(curve_bits) * 2u)
| ECDSA signature size for a given curve bit size. More...
#define | IFX_SE_SIGN_OUTPUT_SIZE(key_type, key_bits, alg)
| Sufficient signature buffer size for ifx_se_sign_hash(). More...
#define | IFX_SE_SIGNATURE_MAX_SIZE 1
| Maximum size of an asymmetric signature. More...
#define | IFX_SE_SIGNATURE_MAX_SIZE IFX_SE_BITS_TO_BYTES(IFX_SE_VENDOR_RSA_MAX_KEY_BITS)
| Maximum size of an asymmetric signature. More...
#define | IFX_SE_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) (2u * IFX_SE_BITS_TO_BYTES(key_bits) + 1u)
| Maximum size of the export encoding of an ECC public key. More...
#define | IFX_SE_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) (IFX_SE_BITS_TO_BYTES(key_bits))
| Maximum size of the export encoding of an ECC key pair. More...
#define | IFX_SE_EXPORT_KEY_OUTPUT_SIZE(key_type, key_bits)
| Sufficient output buffer size for ifx_se_export_key() or ifx_se_export_public_key(). More...
#define | IFX_SE_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(key_type, key_bits)
| Sufficient output buffer size for ifx_se_export_public_key(). More...
#define | IFX_SE_EXPORT_KEY_PAIR_MAX_SIZE IFX_SE_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(IFX_SE_VENDOR_ECC_MAX_CURVE_BITS)
| Sufficient buffer size for exporting any asymmetric key pair. More...
#define | IFX_SE_EXPORT_PUBLIC_KEY_MAX_SIZE IFX_SE_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(IFX_SE_VENDOR_ECC_MAX_CURVE_BITS)
| Sufficient buffer size for exporting any asymmetric public key. More...
#define | IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_SIZE(key_type, key_bits)
| Sufficient output buffer size for ifx_se_raw_key_agreement(). More...
#define | IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE 1
| Maximum size of the output from ifx_se_raw_key_agreement(). More...
#define | IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE IFX_SE_BITS_TO_BYTES(IFX_SE_VENDOR_ECC_MAX_CURVE_BITS)
| Maximum size of the output from ifx_se_raw_key_agreement(). More...
#define | IFX_SE_CIPHER_IV_LENGTH(key_type, alg)
| The default IV size for a cipher algorithm, in bytes. More...
#define | IFX_SE_CIPHER_IV_MAX_SIZE 16u
| The maximum IV size for all supported cipher algorithms, in bytes. More...
#define | IFX_SE_CIPHER_ENCRYPT_OUTPUT_SIZE(key_type, alg, input_length)
| The maximum size of the output of ifx_se_cipher_encrypt(), in bytes. More...
#define | IFX_SE_CIPHER_ENCRYPT_OUTPUT_MAX_SIZE(input_length)
| A sufficient output buffer size for ifx_se_cipher_encrypt(), for any of the supported key types and cipher algorithms. More...
#define | IFX_SE_CIPHER_DECRYPT_OUTPUT_SIZE(key_type, alg, input_length)
| The maximum size of the output of ifx_se_cipher_decrypt(), in bytes. More...
#define | IFX_SE_CIPHER_DECRYPT_OUTPUT_MAX_SIZE(input_length) (input_length)
| A sufficient output buffer size for ifx_se_cipher_decrypt(), for any of the supported key types and cipher algorithms. More...
#define | IFX_SE_CIPHER_UPDATE_OUTPUT_SIZE(key_type, alg, input_length)
| A sufficient output buffer size for ifx_se_cipher_update(). More...
#define | IFX_SE_CIPHER_UPDATE_OUTPUT_MAX_SIZE(input_length) (IFX_SE_ROUND_UP_TO_MULTIPLE(IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE, input_length))
| A sufficient output buffer size for ifx_se_cipher_update(), for any of the supported key types and cipher algorithms. More...
#define | IFX_SE_CIPHER_FINISH_OUTPUT_SIZE(key_type, alg)
| A sufficient ciphertext buffer size for ifx_se_cipher_finish(). More...
#define | IFX_SE_CIPHER_FINISH_OUTPUT_MAX_SIZE (IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE)
| A sufficient ciphertext buffer size for ifx_se_cipher_finish(), for any of the supported key types and cipher algorithms. More...

## Macro Definition Documentation

## ◆ IFX_SE_HASH_LENGTH

#define IFX_SE_HASH_LENGTH | ( |  | alg | ) |

Value:
( \
IFX_SE_ALG_HMAC_GET_HASH(alg) == IFX_SE_ALG_SHA_256 ? 32u : \
IFX_SE_ALG_HMAC_GET_HASH(alg) == IFX_SE_ALG_SHA_384 ? 48u : \
IFX_SE_ALG_HMAC_GET_HASH(alg) == IFX_SE_ALG_SHA_512 ? 64u : \
IFX_SE_ALG_HMAC_GET_HASH(alg) == IFX_SE_ALG_SHA_512_224 ? 28u : \
IFX_SE_ALG_HMAC_GET_HASH(alg) == IFX_SE_ALG_SHA_512_256 ? 32u : \
0u)
IFX_SE_ALG_SHA_512
#define IFX_SE_ALG_SHA_512
SHA2-512.
Definition: ifx_se_psacrypto_values.h:909
IFX_SE_ALG_SHA_512_256
#define IFX_SE_ALG_SHA_512_256
SHA2-512/256.
Definition: ifx_se_psacrypto_values.h:913
IFX_SE_ALG_SHA_384
#define IFX_SE_ALG_SHA_384
SHA2-384.
Definition: ifx_se_psacrypto_values.h:907
IFX_SE_ALG_SHA_256
#define IFX_SE_ALG_SHA_256
SHA2-256.
Definition: ifx_se_psacrypto_values.h:905
IFX_SE_ALG_SHA_512_224
#define IFX_SE_ALG_SHA_512_224
SHA2-512/224.
Definition: ifx_se_psacrypto_values.h:911

The size of the output of ifx_se_hash_finish(), in bytes.

This is also the hash size that ifx_se_hash_verify() expects.

Parameters

  alg | A hash algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_HASH(`alg`) is true), or an HMAC algorithm (IFX_SE_ALG_HMAC(`hash_alg`) where `hash_alg` is a hash algorithm).

Returns
  The hash size for the specified hash algorithm. If the hash algorithm is not recognized, return 0.

## ◆ IFX_SE_HASH_BLOCK_LENGTH

#define IFX_SE_HASH_BLOCK_LENGTH | ( |  | alg | ) |

Value:
( \
IFX_SE_ALG_HMAC_GET_HASH(alg) == IFX_SE_ALG_SHA_256 ? 64u : \
IFX_SE_ALG_HMAC_GET_HASH(alg) == IFX_SE_ALG_SHA_384 ? 128u : \
IFX_SE_ALG_HMAC_GET_HASH(alg) == IFX_SE_ALG_SHA_512 ? 128u : \
IFX_SE_ALG_HMAC_GET_HASH(alg) == IFX_SE_ALG_SHA_512_224 ? 128u : \
IFX_SE_ALG_HMAC_GET_HASH(alg) == IFX_SE_ALG_SHA_512_256 ? 128u : \
0)

The input block size of a hash algorithm, in bytes.

Hash algorithms process their input data in blocks. Hash operations will retain any partial blocks until they have enough input to fill the block or until the operation is finished. This affects the output from ifx_se_hash_suspend().

Parameters

  alg | A hash algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_HASH(`alg`) is true).

Returns
  The block size in bytes for the specified hash algorithm. If the hash algorithm is not recognized, return 0. An implementation can return either 0 or the correct size for a hash algorithm that it recognizes, but does not support.

## ◆ IFX_SE_HASH_MAX_SIZE

#define IFX_SE_HASH_MAX_SIZE 32u

Maximum size of a hash.

This macro expands to a compile-time constant integer. This value is the maximum size of a hash in bytes.

## ◆ IFX_SE_MAC_MAX_SIZE

#define IFX_SE_MAC_MAX_SIZE IFX_SE_HASH_MAX_SIZE

Maximum size of a MAC.

This macro expands to a compile-time constant integer. This value is the maximum size of a MAC in bytes.

## ◆ IFX_SE_AEAD_TAG_LENGTH

#define IFX_SE_AEAD_TAG_LENGTH | ( |  | key_type,
|  |  | key_bits,
|  |  | alg
| ) |  |

Value:
(IFX_SE_AEAD_NONCE_LENGTH(key_type, alg) != 0 ? \
IFX_SE_ALG_AEAD_GET_TAG_LENGTH(alg) : \
((void) (key_bits), 0u))
IFX_SE_AEAD_NONCE_LENGTH
#define IFX_SE_AEAD_NONCE_LENGTH(key_type, alg)
The default nonce size for an AEAD algorithm, in bytes.
Definition: ifx_se_psacrypto_sizes.h:380

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

This macro can be used to allocate a buffer of sufficient size to store the tag output from ifx_se_aead_finish().

See also IFX_SE_AEAD_TAG_MAX_SIZE.

Parameters

  key_type | The type of the AEAD key.
  key_bits | The size of the AEAD key in bits.
  alg | An AEAD algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_AEAD(`alg`) is true).

Returns
  The tag length for the specified algorithm and key. If the AEAD algorithm does not have an identified tag that can be distinguished from the rest of the ciphertext, return 0. If the key type or AEAD algorithm is not recognized, or the parameters are incompatible, return 0.

## ◆ IFX_SE_AEAD_TAG_MAX_SIZE

#define IFX_SE_AEAD_TAG_MAX_SIZE 16u

The maximum tag size for all supported AEAD algorithms, in bytes.

See also IFX_SE_AEAD_TAG_LENGTH(`key_type`, `key_bits`, `alg`).

## ◆ IFX_SE_VENDOR_RSA_MAX_KEY_BITS

#define IFX_SE_VENDOR_RSA_MAX_KEY_BITS 4096u

The maximum size of an RSA key on this implementation, in bits.

This is a vendor-specific macro.

Mbed TLS does not set a hard limit on the size of RSA keys: any key whose parameters fit in a bignum is accepted. However large keys can induce a large memory usage and long computation times. Unlike other auxiliary macros in this file and in crypto.h, which reflect how the library is configured, this macro defines how the library is configured. This implementation refuses to import or generate an RSA key whose size is larger than the value defined here.

Note that an implementation may set different size limits for different operations, and does not need to accept all key sizes up to the limit.

## ◆ IFX_SE_VENDOR_ECC_MAX_CURVE_BITS

#define IFX_SE_VENDOR_ECC_MAX_CURVE_BITS 384u

The maximum size of an ECC key on this implementation, in bits.

This is a vendor-specific macro.

## ◆ IFX_SE_TLS12_PSK_TO_MS_PSK_MAX_SIZE

#define IFX_SE_TLS12_PSK_TO_MS_PSK_MAX_SIZE 128u

This macro returns the maximum supported length of the PSK for the TLS-1.2 PSK-to-MS key derivation (IFX_SE_ALG_TLS12_PSK_TO_MS(`hash_alg`)).

The maximum supported length does not depend on the chosen hash algorithm.

Quoting RFC 4279, Sect 5.3: TLS implementations supporting these ciphersuites MUST support arbitrary PSK identities up to 128 octets in length, and arbitrary PSKs up to 64 octets in length. Supporting longer identities and keys is RECOMMENDED.

Therefore, no implementation should define a value smaller than 64 for IFX_SE_TLS12_PSK_TO_MS_PSK_MAX_SIZE.

## ◆ IFX_SE_MAC_LENGTH

#define IFX_SE_MAC_LENGTH | ( |  | key_type,
|  |  | key_bits,
|  |  | alg
| ) |  |

Value:
((alg) & IFX_SE_ALG_MAC_TRUNCATION_MASK ? IFX_SE_MAC_TRUNCATED_LENGTH(alg) : \
IFX_SE_ALG_IS_HMAC(alg) ? IFX_SE_HASH_LENGTH(IFX_SE_ALG_HMAC_GET_HASH(alg)) : \
IFX_SE_ALG_IS_BLOCK_CIPHER_MAC(alg) ? IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
((void)(key_type), (void)(key_bits), 0u))
IFX_SE_HASH_LENGTH
#define IFX_SE_HASH_LENGTH(alg)
The size of the output of ifx_se_hash_finish(), in bytes.
Definition: ifx_se_psacrypto_sizes.h:82
IFX_SE_ALG_IS_BLOCK_CIPHER_MAC
#define IFX_SE_ALG_IS_BLOCK_CIPHER_MAC(alg)
Whether the specified algorithm is a MAC algorithm based on a block cipher.
Definition: ifx_se_psacrypto_values.h:1137
IFX_SE_MAC_TRUNCATED_LENGTH
#define IFX_SE_MAC_TRUNCATED_LENGTH(mac_alg)
Length to which a MAC algorithm is truncated.
Definition: ifx_se_psacrypto_values.h:1083
IFX_SE_ALG_MAC_TRUNCATION_MASK
#define IFX_SE_ALG_MAC_TRUNCATION_MASK
In the encoding of a MAC algorithm, the bits corresponding to IFX_SE_ALG_MAC_TRUNCATION_MASK encode t...
Definition: ifx_se_psacrypto_values.h:1008
IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH
#define IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(type)
The block size of a block cipher.
Definition: ifx_se_psacrypto_values.h:743

The size of the output of ifx_se_mac_sign_finish(), in bytes.

This is also the MAC size that ifx_se_mac_verify_finish() expects.

Warning
  This macro may evaluate its arguments multiple times or zero times, so you should not pass arguments that contain side effects.

Parameters

  key_type | The type of the MAC key.
  key_bits | The size of the MAC key in bits.
  alg | A MAC algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_MAC(`alg`) is true).

Returns
  The MAC size for the specified algorithm with the specified key parameters.
  0 if the MAC algorithm is not recognized.
  Either 0 or the correct size for a MAC algorithm that the implementation recognizes, but does not support.
  Unspecified if the key parameters are not consistent with the algorithm.

## ◆ IFX_SE_AEAD_ENCRYPT_OUTPUT_SIZE

#define IFX_SE_AEAD_ENCRYPT_OUTPUT_SIZE | ( |  | key_type,
|  |  | alg,
|  |  | plaintext_length
| ) |  |

Value:
(IFX_SE_AEAD_NONCE_LENGTH(key_type, alg) != 0 ? \
(plaintext_length) + IFX_SE_ALG_AEAD_GET_TAG_LENGTH(alg) : \
0u)
IFX_SE_ALG_AEAD_GET_TAG_LENGTH
#define IFX_SE_ALG_AEAD_GET_TAG_LENGTH(aead_alg)
Retrieve the tag length of a specified AEAD algorithm.
Definition: ifx_se_psacrypto_values.h:1330

The maximum size of the output of ifx_se_aead_encrypt(), in bytes.

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

See also IFX_SE_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(`plaintext_length`).

Warning
  This macro may evaluate its arguments multiple times or zero times, so you should not pass arguments that contain side effects.

Parameters

  key_type | A symmetric key type that is compatible with algorithm `alg`.
  alg | An AEAD algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_AEAD(`alg`) is true).
  plaintext_length | Size of the plaintext in bytes.

Returns
  The AEAD ciphertext size for the specified algorithm. If the key type or AEAD algorithm is not recognized, or the parameters are incompatible, return 0.

## ◆ IFX_SE_AEAD_ENCRYPT_OUTPUT_MAX_SIZE

#define IFX_SE_AEAD_ENCRYPT_OUTPUT_MAX_SIZE | ( |  | plaintext_length | ) | ((plaintext_length) + IFX_SE_AEAD_TAG_MAX_SIZE)

A sufficient output buffer size for ifx_se_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 ifx_se_aead_encrypt() will not fail due to an insufficient buffer size.

Note
  This macro returns a compile-time constant if its arguments are compile-time constants.

See also IFX_SE_AEAD_ENCRYPT_OUTPUT_SIZE(`key_type`, `alg`, `plaintext_length`).

Parameters

  plaintext_length | Size of the plaintext in bytes.

Returns
  A sufficient output buffer size for any of the supported key types and AEAD algorithms.

## ◆ IFX_SE_AEAD_DECRYPT_OUTPUT_SIZE

#define IFX_SE_AEAD_DECRYPT_OUTPUT_SIZE | ( |  | key_type,
|  |  | alg,
|  |  | ciphertext_length
| ) |  |

Value:
(IFX_SE_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
(ciphertext_length) > IFX_SE_ALG_AEAD_GET_TAG_LENGTH(alg) ? \
(ciphertext_length) - IFX_SE_ALG_AEAD_GET_TAG_LENGTH(alg) : \
0u)

The maximum size of the output of ifx_se_aead_decrypt(), in bytes.

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

See also IFX_SE_AEAD_DECRYPT_OUTPUT_MAX_SIZE(`ciphertext_length`).

Warning
  This macro may evaluate its arguments multiple times or zero times, so you should not pass arguments that contain side effects.

Parameters

  key_type | A symmetric key type that is compatible with algorithm `alg`.
  alg | An AEAD algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_AEAD(`alg`) is true).
  ciphertext_length | Size of the plaintext in bytes.

Returns
  The AEAD ciphertext size for the specified algorithm. If the key type or AEAD algorithm is not recognized, or the parameters are incompatible, return 0.

## ◆ IFX_SE_AEAD_DECRYPT_OUTPUT_MAX_SIZE

#define IFX_SE_AEAD_DECRYPT_OUTPUT_MAX_SIZE | ( |  | ciphertext_length | ) | (ciphertext_length)

A sufficient output buffer size for ifx_se_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 ifx_se_aead_decrypt() will not fail due to an insufficient buffer size.

Note
  This macro returns a compile-time constant if its arguments are compile-time constants.

See also IFX_SE_AEAD_DECRYPT_OUTPUT_SIZE(`key_type`, `alg`, `ciphertext_length`).

Parameters

  ciphertext_length | Size of the ciphertext in bytes.

Returns
  A sufficient output buffer size for any of the supported key types and AEAD algorithms.

## ◆ IFX_SE_AEAD_NONCE_LENGTH

#define IFX_SE_AEAD_NONCE_LENGTH | ( |  | key_type,
|  |  | alg
| ) |  |

Value:
(IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type) == 16 ? \
IFX_SE_ALG_AEAD_EQUAL(alg, IFX_SE_ALG_CCM) ? 13u : \
IFX_SE_ALG_AEAD_EQUAL(alg, IFX_SE_ALG_GCM) ? 12u : \
0u : \
(key_type) == IFX_SE_KEY_TYPE_CHACHA20 && \
IFX_SE_ALG_AEAD_EQUAL(alg, IFX_SE_ALG_CHACHA20_POLY1305) ? 12u : \
0u)
IFX_SE_ALG_CCM
#define IFX_SE_ALG_CCM
The CCM authenticated encryption algorithm.
Definition: ifx_se_psacrypto_values.h:1252
IFX_SE_ALG_AEAD_EQUAL
#define IFX_SE_ALG_AEAD_EQUAL(aead_alg_1, aead_alg_2)
Check if two AEAD algorithm identifiers refer to the same AEAD algorithm regardless of the tag length...
Definition: ifx_se_psacrypto_values.h:2711
IFX_SE_ALG_CHACHA20_POLY1305
#define IFX_SE_ALG_CHACHA20_POLY1305
The Chacha20-Poly1305 AEAD algorithm.
Definition: ifx_se_psacrypto_values.h:1280
IFX_SE_ALG_GCM
#define IFX_SE_ALG_GCM
The GCM authenticated encryption algorithm.
Definition: ifx_se_psacrypto_values.h:1269
IFX_SE_KEY_TYPE_CHACHA20
#define IFX_SE_KEY_TYPE_CHACHA20
Key for the ChaCha20 stream cipher or the Chacha20-Poly1305 AEAD algorithm.
Definition: ifx_se_psacrypto_values.h:514

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

This macro can be used to allocate a buffer of sufficient size to store the nonce output from ifx_se_aead_generate_nonce().

See also IFX_SE_AEAD_NONCE_MAX_SIZE.

Note
  This is not the maximum size of nonce supported as input to ifx_se_aead_set_nonce(), ifx_se_aead_encrypt() or ifx_se_aead_decrypt(), just the default size that is generated by ifx_se_aead_generate_nonce().

Warning
  This macro may evaluate its arguments multiple times or zero times, so you should not pass arguments that contain side effects.

Parameters

  key_type | A symmetric key type that is compatible with algorithm `alg`.
  alg | An AEAD algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_AEAD(`alg`) is true).

Returns
  The default nonce 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.

## ◆ IFX_SE_AEAD_NONCE_MAX_SIZE

#define IFX_SE_AEAD_NONCE_MAX_SIZE 13u

The maximum default nonce size among all supported pairs of key types and AEAD algorithms, in bytes.

This is equal to or greater than any value that IFX_SE_AEAD_NONCE_LENGTH() may return.

Note
  This is not the maximum size of nonce supported as input to ifx_se_aead_set_nonce(), ifx_se_aead_encrypt() or ifx_se_aead_decrypt(), just the largest size that may be generated by ifx_se_aead_generate_nonce().

## ◆ IFX_SE_AEAD_UPDATE_OUTPUT_SIZE

#define IFX_SE_AEAD_UPDATE_OUTPUT_SIZE | ( |  | key_type,
|  |  | alg,
|  |  | input_length
| ) |  |

Value:
(IFX_SE_AEAD_NONCE_LENGTH(key_type, alg) != 0 ? \
IFX_SE_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
IFX_SE_ROUND_UP_TO_MULTIPLE(IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type), (input_length)) : \
(input_length) : \
0u)

A sufficient output buffer size for ifx_se_aead_update().

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

See also IFX_SE_AEAD_UPDATE_OUTPUT_MAX_SIZE(`input_length`).

Warning
  This macro may evaluate its arguments multiple times or zero times, so you should not pass arguments that contain side effects.

Parameters

  key_type | A symmetric key type that is compatible with algorithm `alg`.
  alg | An AEAD algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_AEAD(`alg`) is true).
  input_length | Size of the input in bytes.

Returns
  A sufficient output buffer size for the specified algorithm. If the key type or AEAD algorithm is not recognized, or the parameters are incompatible, return 0.

## ◆ IFX_SE_AEAD_UPDATE_OUTPUT_MAX_SIZE

#define IFX_SE_AEAD_UPDATE_OUTPUT_MAX_SIZE | ( |  | input_length | ) | (IFX_SE_ROUND_UP_TO_MULTIPLE(IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE, (input_length)))

A sufficient output buffer size for ifx_se_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 ifx_se_aead_update() will not fail due to an insufficient buffer size.

See also IFX_SE_AEAD_UPDATE_OUTPUT_SIZE(`key_type`, `alg`, `input_length`).

Parameters

  input_length | Size of the input in bytes.

## ◆ IFX_SE_AEAD_FINISH_OUTPUT_SIZE

#define IFX_SE_AEAD_FINISH_OUTPUT_SIZE | ( |  | key_type,
|  |  | alg
| ) |  |

Value:
(IFX_SE_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
IFX_SE_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
0u)

A sufficient ciphertext buffer size for ifx_se_aead_finish().

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

See also IFX_SE_AEAD_FINISH_OUTPUT_MAX_SIZE.

Parameters

  key_type | A symmetric key type that is compatible with algorithm `alg`.
  alg | An AEAD algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_AEAD(`alg`) is true).

Returns
  A sufficient ciphertext buffer size for the specified algorithm. If the key type or AEAD algorithm is not recognized, or the parameters are incompatible, return 0.

## ◆ IFX_SE_AEAD_FINISH_OUTPUT_MAX_SIZE

#define IFX_SE_AEAD_FINISH_OUTPUT_MAX_SIZE (IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE)

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

See also IFX_SE_AEAD_FINISH_OUTPUT_SIZE(`key_type`, `alg`).

## ◆ IFX_SE_AEAD_VERIFY_OUTPUT_SIZE

#define IFX_SE_AEAD_VERIFY_OUTPUT_SIZE | ( |  | key_type,
|  |  | alg
| ) |  |

Value:
(IFX_SE_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
IFX_SE_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
0u)

A sufficient plaintext buffer size for ifx_se_aead_verify().

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

See also IFX_SE_AEAD_VERIFY_OUTPUT_MAX_SIZE.

Parameters

  key_type | A symmetric key type that is compatible with algorithm `alg`.
  alg | An AEAD algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_AEAD(`alg`) is true).

Returns
  A sufficient plaintext buffer size for the specified algorithm. If the key type or AEAD algorithm is not recognized, or the parameters are incompatible, return 0.

## ◆ IFX_SE_AEAD_VERIFY_OUTPUT_MAX_SIZE

#define IFX_SE_AEAD_VERIFY_OUTPUT_MAX_SIZE (IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE)

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

See also IFX_SE_AEAD_VERIFY_OUTPUT_SIZE(`key_type`, `alg`).

## ◆ IFX_SE_ECDSA_SIGNATURE_SIZE

#define IFX_SE_ECDSA_SIGNATURE_SIZE | ( |  | curve_bits | ) | (IFX_SE_BITS_TO_BYTES(curve_bits) * 2u)

ECDSA signature size for a given curve bit size.

Parameters

  curve_bits | Curve size in bits.

Returns
  Signature size in bytes.

Note
  This macro returns a compile-time constant if its argument is one.

## ◆ IFX_SE_SIGN_OUTPUT_SIZE

#define IFX_SE_SIGN_OUTPUT_SIZE | ( |  | key_type,
|  |  | key_bits,
|  |  | alg
| ) |  |

Value:
(IFX_SE_KEY_TYPE_IS_ECC(key_type) ? IFX_SE_ECDSA_SIGNATURE_SIZE(key_bits) : \
((void)alg, 0u))
IFX_SE_ECDSA_SIGNATURE_SIZE
#define IFX_SE_ECDSA_SIGNATURE_SIZE(curve_bits)
ECDSA signature size for a given curve bit size.
Definition: ifx_se_psacrypto_sizes.h:528
IFX_SE_KEY_TYPE_IS_ECC
#define IFX_SE_KEY_TYPE_IS_ECC(type)
Whether a key type is an elliptic curve key (pair or public-only).
Definition: ifx_se_psacrypto_values.h:560

Sufficient signature buffer size for ifx_se_sign_hash().

This macro returns a sufficient buffer size for a signature using a key of the specified type and size, with the specified algorithm. Note that the actual size of the signature may be smaller (some algorithms produce a variable-size signature).

Warning
  This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.

Parameters

  key_type | An asymmetric key type (this may indifferently be a key pair type or a public key type).
  key_bits | The size of the key in bits.
  alg | The signature algorithm.

Returns
  If the parameters are valid and supported, return a buffer size in bytes that guarantees that ifx_se_sign_hash() will not fail with IFX_SE_ERROR_BUFFER_TOO_SMALL. If the parameters are a valid combination that is not supported, return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.

## ◆ IFX_SE_SIGNATURE_MAX_SIZE [1/2]

#define IFX_SE_SIGNATURE_MAX_SIZE 1

Maximum size of an asymmetric signature.

This macro expands to a compile-time constant integer. This value is the maximum size of a signature in bytes.

## ◆ IFX_SE_SIGNATURE_MAX_SIZE [2/2]

#define IFX_SE_SIGNATURE_MAX_SIZE IFX_SE_BITS_TO_BYTES(IFX_SE_VENDOR_RSA_MAX_KEY_BITS)

Maximum size of an asymmetric signature.

This macro expands to a compile-time constant integer. This value is the maximum size of a signature in bytes.

## ◆ IFX_SE_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE

#define IFX_SE_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE | ( |  | key_bits | ) | (2u * IFX_SE_BITS_TO_BYTES(key_bits) + 1u)

Maximum size of the export encoding of an ECC public key.

The representation of an ECC public key is:

- The byte 0x04;
- `x_P` as a `ceiling(m/8)`-byte string, big-endian;
- `y_P` as a `ceiling(m/8)`-byte string, big-endian;
- where m is the bit size associated with the curve.

-> 1 byte + 2 * point size.

## ◆ IFX_SE_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE

#define IFX_SE_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE | ( |  | key_bits | ) | (IFX_SE_BITS_TO_BYTES(key_bits))

Maximum size of the export encoding of an ECC key pair.

An ECC key pair is represented by the secret value.

## ◆ IFX_SE_EXPORT_KEY_OUTPUT_SIZE

#define IFX_SE_EXPORT_KEY_OUTPUT_SIZE | ( |  | key_type,
|  |  | key_bits
| ) |  |

Value:
(IFX_SE_KEY_TYPE_IS_UNSTRUCTURED(key_type) ? IFX_SE_BITS_TO_BYTES(key_bits) : \
IFX_SE_KEY_TYPE_IS_ECC_KEY_PAIR(key_type) ? IFX_SE_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) : \
IFX_SE_KEY_TYPE_IS_ECC_PUBLIC_KEY(key_type) ? IFX_SE_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) : \
0u)
IFX_SE_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE
#define IFX_SE_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits)
Maximum size of the export encoding of an ECC public key.
Definition: ifx_se_psacrypto_sizes.h:593
IFX_SE_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE
#define IFX_SE_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits)
Maximum size of the export encoding of an ECC key pair.
Definition: ifx_se_psacrypto_sizes.h:600
IFX_SE_KEY_TYPE_IS_ECC_KEY_PAIR
#define IFX_SE_KEY_TYPE_IS_ECC_KEY_PAIR(type)
Whether a key type is an elliptic curve key pair.
Definition: ifx_se_psacrypto_values.h:564
IFX_SE_KEY_TYPE_IS_UNSTRUCTURED
#define IFX_SE_KEY_TYPE_IS_UNSTRUCTURED(type)
Whether a key type is an unstructured array of bytes.
Definition: ifx_se_psacrypto_values.h:369
IFX_SE_KEY_TYPE_IS_ECC_PUBLIC_KEY
#define IFX_SE_KEY_TYPE_IS_ECC_PUBLIC_KEY(type)
Whether a key type is an elliptic curve public key.
Definition: ifx_se_psacrypto_values.h:568

Sufficient output buffer size for ifx_se_export_key() or ifx_se_export_public_key().

This macro returns a compile-time constant if its arguments are compile-time constants.

Warning
  This macro may evaluate its arguments multiple times or zero times, so you should not pass arguments that contain side effects.

The following code illustrates how to allocate enough memory to export a key by querying the key type and size at runtime.

ifx_se_key_attributes_t attributes = IFX_SE_KEY_ATTRIBUTES_INIT;
ifx_se_status_t status;
status = ifx_se_get_key_attributes(key, &attributes);
if (status != IFX_SE_SUCCESS) handle_error(...);
ifx_se_key_type_t key_type = ifx_se_get_key_type(&attributes);
size_t key_bits = ifx_se_get_key_bits(&attributes);
size_t buffer_size = IFX_SE_EXPORT_KEY_OUTPUT_SIZE(key_type, key_bits);
ifx_se_reset_key_attributes(&attributes);
uint8_t *buffer = malloc(buffer_size);
if (buffer == NULL) handle_error(...);
size_t buffer_length;
status = ifx_se_export_key(key, buffer, buffer_size, &buffer_length);
if (status != IFX_SE_SUCCESS) handle_error(...);
IFX_SE_EXPORT_KEY_OUTPUT_SIZE
#define IFX_SE_EXPORT_KEY_OUTPUT_SIZE(key_type, key_bits)
Sufficient output buffer size for ifx_se_export_key() or ifx_se_export_public_key().
Definition: ifx_se_psacrypto_sizes.h:642
ifx_se_key_type_t
uint16_t ifx_se_key_type_t
Encoding of a key type.
Definition: ifx_se_psacrypto_types.h:132
ifx_se_get_key_bits
static size_t ifx_se_get_key_bits(const ifx_se_key_attributes_t *attributes)
Gets key length in bits from key attributes structure.
Definition: ifx_se_psacrypto_struct.h:483
ifx_se_get_key_type
static ifx_se_key_type_t ifx_se_get_key_type(const ifx_se_key_attributes_t *attributes)
Gets key type from key attributes structure.
Definition: ifx_se_psacrypto_struct.h:454
ifx_se_fih_uint
All ints are replaced with two int - the normal one and a backup which is XORed with the mask.
Definition: ifx_se_fih.h:112
ifx_se_export_key
ifx_se_status_t ifx_se_export_key(ifx_se_key_id_fih_t key, ifx_se_fih_ptr_t data, ifx_se_fih_t data_size, ifx_se_fih_ptr_t data_length, void *ctx)
Export a key in binary format.
Definition: ifx_se_psacrypto.c:1025
ifx_se_reset_key_attributes
void ifx_se_reset_key_attributes(ifx_se_key_attributes_t *attributes)
Reset a key attribute structure to a freshly initialized state.
Definition: ifx_se_psacrypto.c:1534
IFX_SE_KEY_ATTRIBUTES_INIT
#define IFX_SE_KEY_ATTRIBUTES_INIT
The initial value of the key attributes.
Definition: ifx_se_psacrypto_struct.h:239
ifx_se_get_key_attributes
ifx_se_status_t ifx_se_get_key_attributes(ifx_se_key_id_fih_t key, ifx_se_key_attributes_t *attributes, void *ctx)
Retrieve the attributes of a key.
Definition: ifx_se_psacrypto.c:1539
ifx_se_key_attributes_t
struct ifx_se_key_attributes_s ifx_se_key_attributes_t
The type of a structure containing key attributes.
Definition: ifx_se_psacrypto_types.h:465
IFX_SE_SUCCESS
#define IFX_SE_SUCCESS
Success operation.
Definition: ifx_se_syscall.h:201

Parameters

  key_type | A supported key type.
  key_bits | The size of the key in bits.

Returns
  If the parameters are valid and supported, return a buffer size in bytes that guarantees that ifx_se_export_key() or ifx_se_export_public_key() will not fail with IFX_SE_ERROR_BUFFER_TOO_SMALL. If the parameters are a valid combination that is not supported, return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.

## ◆ IFX_SE_EXPORT_PUBLIC_KEY_OUTPUT_SIZE

#define IFX_SE_EXPORT_PUBLIC_KEY_OUTPUT_SIZE | ( |  | key_type,
|  |  | key_bits
| ) |  |

Value:
(IFX_SE_KEY_TYPE_IS_ECC(key_type) ? IFX_SE_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) : \
0u)

Sufficient output buffer size for ifx_se_export_public_key().

This macro returns a compile-time constant if its arguments are compile-time constants.

Warning
  This macro may evaluate its arguments multiple times or zero times, so you should not pass arguments that contain side effects.

The following code illustrates how to allocate enough memory to export a public key by querying the key type and size at runtime.

ifx_se_key_attributes_t attributes = IFX_SE_KEY_ATTRIBUTES_INIT;
ifx_se_status_t status;
status = ifx_se_get_key_attributes(key, &attributes);
if (status != IFX_SE_SUCCESS) handle_error(...);
ifx_se_key_type_t key_type = ifx_se_get_key_type(&attributes);
size_t key_bits = ifx_se_get_key_bits(&attributes);
size_t buffer_size = IFX_SE_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(key_type, key_bits);
ifx_se_reset_key_attributes(&attributes);
uint8_t *buffer = malloc(buffer_size);
if (buffer == NULL) handle_error(...);
size_t buffer_length;
status = ifx_se_export_public_key(key, buffer, buffer_size, &buffer_length);
if (status != IFX_SE_SUCCESS) handle_error(...);
IFX_SE_EXPORT_PUBLIC_KEY_OUTPUT_SIZE
#define IFX_SE_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(key_type, key_bits)
Sufficient output buffer size for ifx_se_export_public_key().
Definition: ifx_se_psacrypto_sizes.h:693
ifx_se_export_public_key
ifx_se_status_t ifx_se_export_public_key(ifx_se_key_id_fih_t key, ifx_se_fih_ptr_t data, ifx_se_fih_t data_size, ifx_se_fih_ptr_t data_length, void *ctx)
Export a public key or the public part of a key pair in binary format.
Definition: ifx_se_psacrypto.c:1052

Parameters

  key_type | A public key or key pair key type.
  key_bits | The size of the key in bits.

Returns
  If the parameters are valid and supported, return a buffer size in bytes that guarantees that ifx_se_export_public_key() will not fail with IFX_SE_ERROR_BUFFER_TOO_SMALL. If the parameters are a valid combination that is not supported, return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.

If the parameters are valid and supported, return the same result as IFX_SE_EXPORT_KEY_OUTPUT_SIZE( `IFX_SE_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR`(`key_type`), `key_bits`).

## ◆ IFX_SE_EXPORT_KEY_PAIR_MAX_SIZE

#define IFX_SE_EXPORT_KEY_PAIR_MAX_SIZE IFX_SE_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(IFX_SE_VENDOR_ECC_MAX_CURVE_BITS)

Sufficient buffer size for exporting any asymmetric key pair.

This macro expands to a compile-time constant integer. This value is a sufficient buffer size when calling ifx_se_export_key() to export any asymmetric key pair, regardless of the exact key type and key size.

See also IFX_SE_EXPORT_KEY_OUTPUT_SIZE(`key_type`, `key_bits`).

## ◆ IFX_SE_EXPORT_PUBLIC_KEY_MAX_SIZE

#define IFX_SE_EXPORT_PUBLIC_KEY_MAX_SIZE IFX_SE_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(IFX_SE_VENDOR_ECC_MAX_CURVE_BITS)

Sufficient buffer size for exporting any asymmetric public key.

This macro expands to a compile-time constant integer. This value is a sufficient buffer size when calling ifx_se_export_key() or ifx_se_export_public_key() to export any asymmetric public key, regardless of the exact key type and key size.

See also IFX_SE_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(`key_type`, `key_bits`).

## ◆ IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_SIZE

#define IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_SIZE | ( |  | key_type,
|  |  | key_bits
| ) |  |

Value:
(IFX_SE_KEY_TYPE_IS_ECC_KEY_PAIR(key_type) ? \
IFX_SE_BITS_TO_BYTES(key_bits) : \
0u)

Sufficient output buffer size for ifx_se_raw_key_agreement().

This macro returns a compile-time constant if its arguments are compile-time constants.

Warning
  This macro may evaluate its arguments multiple times or zero times, so you should not pass arguments that contain side effects.

See also IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE.

Parameters

  key_type | A supported key type.
  key_bits | The size of the key in bits.

Returns
  If the parameters are valid and supported, return a buffer size in bytes that guarantees that ifx_se_raw_key_agreement() will not fail with IFX_SE_ERROR_BUFFER_TOO_SMALL. If the parameters are a valid combination that is not supported, return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.

## ◆ IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE [1/2]

#define IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE 1

Maximum size of the output from ifx_se_raw_key_agreement().

This macro expands to a compile-time constant integer. This value is the maximum size of the output any raw key agreement algorithm, in bytes.

See also IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_SIZE(`key_type`, `key_bits`).

## ◆ IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE [2/2]

#define IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE IFX_SE_BITS_TO_BYTES(IFX_SE_VENDOR_ECC_MAX_CURVE_BITS)

Maximum size of the output from ifx_se_raw_key_agreement().

This macro expands to a compile-time constant integer. This value is the maximum size of the output any raw key agreement algorithm, in bytes.

See also IFX_SE_RAW_KEY_AGREEMENT_OUTPUT_SIZE(`key_type`, `key_bits`).

## ◆ IFX_SE_CIPHER_IV_LENGTH

#define IFX_SE_CIPHER_IV_LENGTH | ( |  | key_type,
|  |  | alg
| ) |  |

Value:
(IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type) > 1 && \
((alg) == IFX_SE_ALG_CTR || \
(alg) == IFX_SE_ALG_CBC_NO_PADDING || \
(alg) == IFX_SE_ALG_CBC_PKCS7) ? IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
0u)
IFX_SE_ALG_CTR
#define IFX_SE_ALG_CTR
The CTR stream cipher mode.
Definition: ifx_se_psacrypto_values.h:1171
IFX_SE_ALG_CBC_PKCS7
#define IFX_SE_ALG_CBC_PKCS7
The CBC block cipher chaining mode with PKCS#7 padding.
Definition: ifx_se_psacrypto_values.h:1228
IFX_SE_ALG_CBC_NO_PADDING
#define IFX_SE_ALG_CBC_NO_PADDING
The CBC block cipher chaining mode, with no padding.
Definition: ifx_se_psacrypto_values.h:1220

The default IV size for a cipher algorithm, in bytes.

The IV that is generated as part of a call to ifx_se_cipher_encrypt() is always the default IV length for the algorithm.

This macro can be used to allocate a buffer of sufficient size to store the IV output from ifx_se_cipher_generate_iv() when using a multi-part cipher operation.

See also IFX_SE_CIPHER_IV_MAX_SIZE.

Warning
  This macro may evaluate its arguments multiple times or zero times, so you should not pass arguments that contain side effects.

Parameters

  key_type | A symmetric key type that is compatible with algorithm `alg`.
  alg | A cipher algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_CIPHER(`alg`) is true).

Returns
  The default IV size for the specified key type and algorithm. If the algorithm does not use an IV, return 0. If the key type or cipher algorithm is not recognized, or the parameters are incompatible, return 0.

## ◆ IFX_SE_CIPHER_IV_MAX_SIZE

#define IFX_SE_CIPHER_IV_MAX_SIZE 16u

The maximum IV size for all supported cipher algorithms, in bytes.

See also IFX_SE_CIPHER_IV_LENGTH().

## ◆ IFX_SE_CIPHER_ENCRYPT_OUTPUT_SIZE

#define IFX_SE_CIPHER_ENCRYPT_OUTPUT_SIZE | ( |  | key_type,
|  |  | alg,
|  |  | input_length
| ) |  |

Value:
(alg == IFX_SE_ALG_CBC_PKCS7 ? \
(IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type) != 0 ? \
IFX_SE_ROUND_UP_TO_MULTIPLE(IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type), \
(input_length) + 1u) + \
IFX_SE_CIPHER_IV_LENGTH((key_type), (alg)) : 0u) : \
(IFX_SE_ALG_IS_CIPHER(alg) ? \
(input_length) + IFX_SE_CIPHER_IV_LENGTH((key_type), (alg)) : \
0u))
IFX_SE_CIPHER_IV_LENGTH
#define IFX_SE_CIPHER_IV_LENGTH(key_type, alg)
The default IV size for a cipher algorithm, in bytes.
Definition: ifx_se_psacrypto_sizes.h:787
IFX_SE_ALG_IS_CIPHER
#define IFX_SE_ALG_IS_CIPHER(alg)
Whether the specified algorithm is a symmetric cipher algorithm.
Definition: ifx_se_psacrypto_values.h:812

The maximum size of the output of ifx_se_cipher_encrypt(), in bytes.

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

See also IFX_SE_CIPHER_ENCRYPT_OUTPUT_MAX_SIZE(`input_length`).

Warning
  This macro may evaluate its arguments multiple times or zero times, so you should not pass arguments that contain side effects.

Parameters

  key_type | A symmetric key type that is compatible with algorithm alg.
  alg | A cipher algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_CIPHER(`alg`) is true).
  input_length | Size of the input in bytes.

Returns
  A sufficient output size for the specified key type and algorithm. If the key type or cipher algorithm is not recognized, or the parameters are incompatible, return 0.

## ◆ IFX_SE_CIPHER_ENCRYPT_OUTPUT_MAX_SIZE

#define IFX_SE_CIPHER_ENCRYPT_OUTPUT_MAX_SIZE | ( |  | input_length | ) |

Value:
(IFX_SE_ROUND_UP_TO_MULTIPLE(IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE, \
(input_length) + 1u) + \
IFX_SE_CIPHER_IV_MAX_SIZE)
IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE
#define IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE
The maximum size of a block cipher.
Definition: ifx_se_psacrypto_sizes.h:220

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

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

See also IFX_SE_CIPHER_ENCRYPT_OUTPUT_SIZE(`key_type`, `alg`, `input_length`).

Parameters

  input_length | Size of the input in bytes.

## ◆ IFX_SE_CIPHER_DECRYPT_OUTPUT_SIZE

#define IFX_SE_CIPHER_DECRYPT_OUTPUT_SIZE | ( |  | key_type,
|  |  | alg,
|  |  | input_length
| ) |  |

Value:
(IFX_SE_ALG_IS_CIPHER(alg) && \
((key_type) & IFX_SE_KEY_TYPE_CATEGORY_MASK) == IFX_SE_KEY_TYPE_CATEGORY_SYMMETRIC ? \
(input_length) : \
0u)

The maximum size of the output of ifx_se_cipher_decrypt(), in bytes.

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

See also IFX_SE_CIPHER_DECRYPT_OUTPUT_MAX_SIZE(`input_length`).

Parameters

  key_type | A symmetric key type that is compatible with algorithm alg.
  alg | A cipher algorithm (`IFX_SE_ALG_XXX` value such that IFX_SE_ALG_IS_CIPHER(`alg`) is true).
  input_length | Size of the input in bytes.

Returns
  A sufficient output size for the specified key type and algorithm. If the key type or cipher algorithm is not recognized, or the parameters are incompatible, return 0.

## ◆ IFX_SE_CIPHER_DECRYPT_OUTPUT_MAX_SIZE

#define IFX_SE_CIPHER_DECRYPT_OUTPUT_MAX_SIZE | ( |  | input_length | ) | (input_length)

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

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

See also IFX_SE_CIPHER_DECRYPT_OUTPUT_SIZE(`key_type`, `alg`, `input_length`).

Parameters

  input_length | Size of the input in bytes.

## ◆ IFX_SE_CIPHER_UPDATE_OUTPUT_SIZE

#define IFX_SE_CIPHER_UPDATE_OUTPUT_SIZE | ( |  | key_type,
|  |  | alg,
|  |  | input_length
| ) |  |

Value:
(IFX_SE_ALG_IS_CIPHER(alg) ? \
(IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type) != 0 ? \
(((alg) == IFX_SE_ALG_CBC_PKCS7 || \
(alg) == IFX_SE_ALG_CBC_NO_PADDING || \
(alg) == IFX_SE_ALG_ECB_NO_PADDING) ? \
IFX_SE_ROUND_UP_TO_MULTIPLE(IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type), \
input_length) : \
(input_length)) : 0u) : \
0u)
IFX_SE_ALG_ECB_NO_PADDING
#define IFX_SE_ALG_ECB_NO_PADDING
The Electronic Code Book (ECB) mode of a block cipher, with no padding.
Definition: ifx_se_psacrypto_values.h:1211

A sufficient output buffer size for ifx_se_cipher_update().

If the size of the output buffer is at least this large, it is guaranteed that ifx_se_cipher_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 IFX_SE_CIPHER_UPDATE_OUTPUT_MAX_SIZE(`input_length`).

Parameters

  key_type | A symmetric key type that is compatible with algorithm alg.
  alg | A cipher algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_CIPHER(`alg`) is true).
  input_length | Size of the input in bytes.

Returns
  A sufficient output size for the specified key type and algorithm. If the key type or cipher algorithm is not recognized, or the parameters are incompatible, return 0.

## ◆ IFX_SE_CIPHER_UPDATE_OUTPUT_MAX_SIZE

#define IFX_SE_CIPHER_UPDATE_OUTPUT_MAX_SIZE | ( |  | input_length | ) | (IFX_SE_ROUND_UP_TO_MULTIPLE(IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE, input_length))

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

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

See also IFX_SE_CIPHER_UPDATE_OUTPUT_SIZE(`key_type`, `alg`, `input_length`).

Parameters

  input_length | Size of the input in bytes.

## ◆ IFX_SE_CIPHER_FINISH_OUTPUT_SIZE

#define IFX_SE_CIPHER_FINISH_OUTPUT_SIZE | ( |  | key_type,
|  |  | alg
| ) |  |

Value:
(IFX_SE_ALG_IS_CIPHER(alg) ? \
(alg == IFX_SE_ALG_CBC_PKCS7 ? \
IFX_SE_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
0u) : \
0u)

A sufficient ciphertext buffer size for ifx_se_cipher_finish().

If the size of the ciphertext buffer is at least this large, it is guaranteed that ifx_se_cipher_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 IFX_SE_CIPHER_FINISH_OUTPUT_MAX_SIZE().

Parameters

  key_type | A symmetric key type that is compatible with algorithm alg.
  alg | A cipher algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_CIPHER(`alg`) is true).

Returns
  A sufficient output size for the specified key type and algorithm. If the key type or cipher algorithm is not recognized, or the parameters are incompatible, return 0.

## ◆ IFX_SE_CIPHER_FINISH_OUTPUT_MAX_SIZE

#define IFX_SE_CIPHER_FINISH_OUTPUT_MAX_SIZE (IFX_SE_BLOCK_CIPHER_BLOCK_MAX_SIZE)

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

See also IFX_SE_CIPHER_FINISH_OUTPUT_SIZE(`key_type`, `alg`).