SE RT Services Utilities library

General Description

Key algorithms operations definitions.

Macros

#define IFX_SE_ALG_VENDOR_FLAG   ((ifx_se_algorithm_t)0x80000000U)
 Vendor-defined algorithm flag. More...
 
#define IFX_SE_ALG_IS_VENDOR_DEFINED(alg)    (((alg) & IFX_SE_ALG_VENDOR_FLAG) != 0)
 Whether an algorithm is vendor-defined. More...
 
#define IFX_SE_ALG_IS_HASH(alg)    (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_HASH)
 Whether the specified algorithm is a hash algorithm. More...
 
#define IFX_SE_ALG_IS_MAC(alg)    (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_MAC)
 Whether the specified algorithm is a MAC algorithm. More...
 
#define IFX_SE_ALG_IS_CIPHER(alg)    (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_CIPHER)
 Whether the specified algorithm is a symmetric cipher algorithm. More...
 
#define IFX_SE_ALG_IS_AEAD(alg)    (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_AEAD)
 Whether the specified algorithm is an authenticated encryption with associated data (AEAD) algorithm. More...
 
#define IFX_SE_ALG_IS_SIGN(alg)    (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_SIGN)
 Whether the specified algorithm is an asymmetric signature algorithm, also known as public-key signature algorithm. More...
 
#define IFX_SE_ALG_IS_ASYMMETRIC_ENCRYPTION(alg)    (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION)
 Whether the specified algorithm is an asymmetric encryption algorithm, also known as public-key encryption algorithm. More...
 
#define IFX_SE_ALG_IS_KEY_AGREEMENT(alg)    (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_KEY_AGREEMENT)
 Whether the specified algorithm is a key agreement algorithm. More...
 
#define IFX_SE_ALG_IS_KEY_DERIVATION(alg)    (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_KEY_DERIVATION)
 Whether the specified algorithm is a key derivation algorithm. More...
 
#define IFX_SE_ALG_IS_KEY_DERIVATION_STRETCHING(alg)
 Whether the specified algorithm is a key stretching / password hashing algorithm. More...
 
#define IFX_SE_ALG_NONE   ((ifx_se_algorithm_t)0)
 An invalid algorithm identifier value.
 
#define IFX_SE_ALG_HASH_MASK   ((ifx_se_algorithm_t)0x000000ff)
 MASK.
 
#define IFX_SE_ALG_MD5   ((ifx_se_algorithm_t)0x02000003)
 MD5.
 
#define IFX_SE_ALG_RIPEMD160   ((ifx_se_algorithm_t)0x02000004)
 IFX_SE_ALG_RIPEMD160.
 
#define IFX_SE_ALG_SHA_1   ((ifx_se_algorithm_t)0x02000005)
 SHA1.
 
#define IFX_SE_ALG_SHA_224   ((ifx_se_algorithm_t)0x02000008)
 SHA2-224.
 
#define IFX_SE_ALG_SHA_256   ((ifx_se_algorithm_t)0x02000009)
 SHA2-256.
 
#define IFX_SE_ALG_SHA_384   ((ifx_se_algorithm_t)0x0200000a)
 SHA2-384.
 
#define IFX_SE_ALG_SHA_512   ((ifx_se_algorithm_t)0x0200000b)
 SHA2-512.
 
#define IFX_SE_ALG_SHA_512_224   ((ifx_se_algorithm_t)0x0200000c)
 SHA2-512/224.
 
#define IFX_SE_ALG_SHA_512_256   ((ifx_se_algorithm_t)0x0200000d)
 SHA2-512/256.
 
#define IFX_SE_ALG_SHA3_224   ((ifx_se_algorithm_t)0x02000010)
 SHA3-224.
 
#define IFX_SE_ALG_SHA3_256   ((ifx_se_algorithm_t)0x02000011)
 SHA3-256.
 
#define IFX_SE_ALG_SHA3_384   ((ifx_se_algorithm_t)0x02000012)
 SHA3-384.
 
#define IFX_SE_ALG_SHA3_512   ((ifx_se_algorithm_t)0x02000013)
 SHA3-512.
 
#define IFX_SE_ALG_SHAKE256_512   ((ifx_se_algorithm_t)0x02000015)
 The first 512 bits (64 bytes) of the SHAKE256 output. More...
 
#define IFX_SE_ALG_ANY_HASH   ((ifx_se_algorithm_t)0x020000ff)
 In a hash-and-sign algorithm policy, allow any hash algorithm. More...
 
#define IFX_SE_ALG_HMAC(hash_alg)    (IFX_SE_ALG_HMAC_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 Macro to build an HMAC algorithm. More...
 
#define IFX_SE_ALG_IS_HMAC(alg)
 Whether the specified algorithm is an HMAC algorithm. More...
 
#define IFX_SE_ALG_MAC_TRUNCATION_MASK   ((ifx_se_algorithm_t)0x003f0000)
 In the encoding of a MAC algorithm, the bits corresponding to IFX_SE_ALG_MAC_TRUNCATION_MASK encode the length to which the MAC is truncated. More...
 
#define IFX_SE_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG   ((ifx_se_algorithm_t)0x00008000)
 In the encoding of a MAC algorithm, the bit corresponding to IFX_SE_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG encodes the fact that the algorithm is a wildcard algorithm. More...
 
#define IFX_SE_ALG_TRUNCATED_MAC(mac_alg, mac_length)
 Macro to build a truncated MAC algorithm. More...
 
#define IFX_SE_ALG_FULL_LENGTH_MAC(mac_alg)
 Macro to build the base MAC algorithm corresponding to a truncated MAC algorithm. More...
 
#define IFX_SE_MAC_TRUNCATED_LENGTH(mac_alg)    (((mac_alg) & IFX_SE_ALG_MAC_TRUNCATION_MASK) >> IFX_SE_MAC_TRUNCATION_OFFSET)
 Length to which a MAC algorithm is truncated. More...
 
#define IFX_SE_ALG_AT_LEAST_THIS_LENGTH_MAC(mac_alg, min_mac_length)
 Macro to build a MAC minimum-MAC-length wildcard algorithm. More...
 
#define IFX_SE_ALG_CBC_MAC   ((ifx_se_algorithm_t)0x03c00100)
 The CBC-MAC construction over a block cipher. More...
 
#define IFX_SE_ALG_CMAC   ((ifx_se_algorithm_t)0x03c00200)
 The CMAC construction over a block cipher.
 
#define IFX_SE_ALG_IS_BLOCK_CIPHER_MAC(alg)
 Whether the specified algorithm is a MAC algorithm based on a block cipher. More...
 
#define IFX_SE_ALG_IS_STREAM_CIPHER(alg)
 Whether the specified algorithm is a stream cipher. More...
 
#define IFX_SE_ALG_STREAM_CIPHER   ((ifx_se_algorithm_t)0x04800100)
 The stream cipher mode of a stream cipher algorithm. More...
 
#define IFX_SE_ALG_CTR   ((ifx_se_algorithm_t)0x04c01000)
 The CTR stream cipher mode. More...
 
#define IFX_SE_ALG_CFB   ((ifx_se_algorithm_t)0x04c01100)
 The CFB stream cipher mode. More...
 
#define IFX_SE_ALG_OFB   ((ifx_se_algorithm_t)0x04c01200)
 The OFB stream cipher mode. More...
 
#define IFX_SE_ALG_XTS   ((ifx_se_algorithm_t)0x0440ff00)
 The XTS cipher mode. More...
 
#define IFX_SE_ALG_ECB_NO_PADDING   ((ifx_se_algorithm_t)0x04404400)
 The Electronic Code Book (ECB) mode of a block cipher, with no padding. More...
 
#define IFX_SE_ALG_CBC_NO_PADDING   ((ifx_se_algorithm_t)0x04404000)
 The CBC block cipher chaining mode, with no padding. More...
 
#define IFX_SE_ALG_CBC_PKCS7   ((ifx_se_algorithm_t)0x04404100)
 The CBC block cipher chaining mode with PKCS#7 padding. More...
 
#define IFX_SE_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg)
 Whether the specified algorithm is an AEAD mode on a block cipher. More...
 
#define IFX_SE_ALG_CCM   ((ifx_se_algorithm_t)0x05500100)
 The CCM authenticated encryption algorithm. More...
 
#define IFX_SE_ALG_CCM_STAR_NO_TAG   ((ifx_se_algorithm_t)0x04c01300)
 The CCM* cipher mode without authentication. More...
 
#define IFX_SE_ALG_GCM   ((ifx_se_algorithm_t)0x05500200)
 The GCM authenticated encryption algorithm. More...
 
#define IFX_SE_ALG_CHACHA20_POLY1305   ((ifx_se_algorithm_t)0x05100500)
 The Chacha20-Poly1305 AEAD algorithm. More...
 
#define IFX_SE_ALG_AEAD_TAG_LENGTH_MASK   ((ifx_se_algorithm_t)0x003f0000)
 In the encoding of an AEAD algorithm, the bits corresponding to IFX_SE_ALG_AEAD_TAG_LENGTH_MASK encode the length of the AEAD tag. More...
 
#define IFX_SE_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG   ((ifx_se_algorithm_t)0x00008000)
 In the encoding of an AEAD algorithm, the bit corresponding to IFX_SE_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG encodes the fact that the algorithm is a wildcard algorithm. More...
 
#define IFX_SE_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, tag_length)
 Macro to build a shortened AEAD algorithm. More...
 
#define IFX_SE_ALG_AEAD_GET_TAG_LENGTH(aead_alg)
 Retrieve the tag length of a specified AEAD algorithm. More...
 
#define IFX_SE_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(aead_alg)
 Calculate the corresponding AEAD algorithm with the default tag length. More...
 
#define IFX_SE_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(aead_alg, min_tag_length)
 Macro to build an AEAD minimum-tag-length wildcard algorithm. More...
 
#define IFX_SE_ALG_RSA_PKCS1V15_SIGN(hash_alg)    (IFX_SE_ALG_RSA_PKCS1V15_SIGN_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 RSA PKCS#1 v1.5 signature with hashing. More...
 
#define IFX_SE_ALG_RSA_PKCS1V15_SIGN_RAW   IFX_SE_ALG_RSA_PKCS1V15_SIGN_BASE
 Raw PKCS#1 v1.5 signature. More...
 
#define IFX_SE_ALG_RSA_PSS(hash_alg)    (IFX_SE_ALG_RSA_PSS_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 RSA PSS signature with hashing. More...
 
#define IFX_SE_ALG_RSA_PSS_ANY_SALT(hash_alg)    (IFX_SE_ALG_RSA_PSS_ANY_SALT_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 RSA PSS signature with hashing with relaxed verification. More...
 
#define IFX_SE_ALG_IS_RSA_PSS_STANDARD_SALT(alg)    (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_RSA_PSS_BASE)
 Whether the specified algorithm is RSA PSS with standard salt. More...
 
#define IFX_SE_ALG_IS_RSA_PSS_ANY_SALT(alg)    (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_RSA_PSS_ANY_SALT_BASE)
 Whether the specified algorithm is RSA PSS with any salt. More...
 
#define IFX_SE_ALG_IS_RSA_PSS(alg)
 Whether the specified algorithm is RSA PSS. More...
 
#define IFX_SE_ALG_ECDSA(hash_alg)    (IFX_SE_ALG_ECDSA_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 ECDSA signature with hashing. More...
 
#define IFX_SE_ALG_ECDSA_ANY   IFX_SE_ALG_ECDSA_BASE
 ECDSA signature without hashing. More...
 
#define IFX_SE_ALG_DETERMINISTIC_ECDSA(hash_alg)    (IFX_SE_ALG_DETERMINISTIC_ECDSA_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 Deterministic ECDSA signature with hashing. More...
 
#define IFX_SE_ALG_PURE_EDDSA   ((ifx_se_algorithm_t)0x06000800)
 Edwards-curve digital signature algorithm without prehashing (PureEdDSA), using standard parameters. More...
 
#define IFX_SE_ALG_ED25519PH    (IFX_SE_ALG_HASH_EDDSA_BASE | (IFX_SE_ALG_SHA_512 & IFX_SE_ALG_HASH_MASK))
 Edwards-curve digital signature algorithm with prehashing (HashEdDSA), using SHA-512 and the Edwards25519 curve. More...
 
#define IFX_SE_ALG_ED448PH    (IFX_SE_ALG_HASH_EDDSA_BASE | (IFX_SE_ALG_SHAKE256_512 & IFX_SE_ALG_HASH_MASK))
 Edwards-curve digital signature algorithm with prehashing (HashEdDSA), using SHAKE256 and the Edwards448 curve. More...
 
#define IFX_SE_ALG_IS_VENDOR_HASH_AND_SIGN(alg)   0
 Default definition, to be overridden if the library is extended with more hash-and-sign algorithms that we want to keep out of this header file.
 
#define IFX_SE_ALG_IS_SIGN_HASH(alg)
 Whether the specified algorithm is a signature algorithm that can be used with ifx_se_sign_hash() and ifx_se_verify_hash(). More...
 
#define IFX_SE_ALG_IS_SIGN_MESSAGE(alg)    (IFX_SE_ALG_IS_SIGN_HASH(alg) || (alg) == IFX_SE_ALG_PURE_EDDSA )
 Whether the specified algorithm is a signature algorithm that can be used with ifx_se_sign_message() and ifx_se_verify_message(). More...
 
#define IFX_SE_ALG_IS_HASH_AND_SIGN(alg)
 Whether the specified algorithm is a hash-and-sign algorithm. More...
 
#define IFX_SE_ALG_SIGN_GET_HASH(alg)
 Get the hash used by a hash-and-sign signature algorithm. More...
 
#define IFX_SE_ALG_RSA_PKCS1V15_CRYPT   ((ifx_se_algorithm_t)0x07000200)
 RSA PKCS#1 v1.5 encryption.
 
#define IFX_SE_ALG_RSA_OAEP(hash_alg)    (IFX_SE_ALG_RSA_OAEP_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 RSA OAEP encryption. More...
 
#define IFX_SE_ALG_HKDF(hash_alg)    (IFX_SE_ALG_HKDF_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 Macro to build an HKDF algorithm. More...
 
#define IFX_SE_ALG_IS_HKDF(alg)    (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_HKDF_BASE)
 Whether the specified algorithm is an HKDF algorithm. More...
 
#define IFX_SE_ALG_HKDF_EXTRACT(hash_alg)    (IFX_SE_ALG_HKDF_EXTRACT_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 Macro to build an HKDF-Extract algorithm. More...
 
#define IFX_SE_ALG_IS_HKDF_EXTRACT(alg)    (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_HKDF_EXTRACT_BASE)
 Whether the specified algorithm is an HKDF-Extract algorithm. More...
 
#define IFX_SE_ALG_HKDF_EXPAND(hash_alg)    (IFX_SE_ALG_HKDF_EXPAND_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 Macro to build an HKDF-Expand algorithm. More...
 
#define IFX_SE_ALG_IS_HKDF_EXPAND(alg)    (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_HKDF_EXPAND_BASE)
 Whether the specified algorithm is an HKDF-Expand algorithm. More...
 
#define IFX_SE_ALG_IS_ANY_HKDF(alg)
 Whether the specified algorithm is an HKDF or HKDF-Extract or HKDF-Expand algorithm. More...
 
#define IFX_SE_ALG_TLS12_PRF(hash_alg)    (IFX_SE_ALG_TLS12_PRF_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 Macro to build a TLS-1.2 PRF algorithm. More...
 
#define IFX_SE_ALG_IS_TLS12_PRF(alg)    (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_TLS12_PRF_BASE)
 Whether the specified algorithm is a TLS-1.2 PRF algorithm. More...
 
#define IFX_SE_ALG_TLS12_PSK_TO_MS(hash_alg)    (IFX_SE_ALG_TLS12_PSK_TO_MS_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 Macro to build a TLS-1.2 PSK-to-MasterSecret algorithm. More...
 
#define IFX_SE_ALG_IS_TLS12_PSK_TO_MS(alg)    (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_TLS12_PSK_TO_MS_BASE)
 Whether the specified algorithm is a TLS-1.2 PSK to MS algorithm. More...
 
#define IFX_SE_ALG_KEY_DERIVATION_STRETCHING_FLAG   ((ifx_se_algorithm_t)0x00800000)
 This flag indicates whether the key derivation algorithm is suitable for use on low-entropy secrets such as password - these algorithms are also known as key stretching or password hashing schemes. More...
 
#define IFX_SE_ALG_PBKDF2_HMAC(hash_alg)    (IFX_SE_ALG_PBKDF2_HMAC_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))
 Macro to build a PBKDF2-HMAC password hashing / key stretching algorithm. More...
 
#define IFX_SE_ALG_IS_PBKDF2_HMAC(alg)    (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_PBKDF2_HMAC_BASE)
 Whether the specified algorithm is a PBKDF2-HMAC algorithm. More...
 
#define IFX_SE_ALG_PBKDF2_AES_CMAC_PRF_128   ((ifx_se_algorithm_t)0x08800200)
 The PBKDF2-AES-CMAC-PRF-128 password hashing / key stretching algorithm. More...
 
#define IFX_SE_ALG_KDF_AES_CMAC   ((ifx_se_algorithm_t)0x08000600)
 The CMAC KDF algorithm. More...
 
#define IFX_SE_ALG_KEY_AGREEMENT(ka_alg, kdf_alg)    ((ka_alg) | (kdf_alg))
 Macro to build a combined algorithm that chains a key agreement with a key derivation. More...
 
#define IFX_SE_ALG_IS_RAW_KEY_AGREEMENT(alg)
 Whether the specified algorithm is a raw key agreement algorithm. More...
 
#define IFX_SE_ALG_FFDH   ((ifx_se_algorithm_t)0x09010000)
 The finite-field Diffie-Hellman (DH) key agreement algorithm. More...
 
#define IFX_SE_ALG_IS_FFDH(alg)    (IFX_SE_ALG_KEY_AGREEMENT_GET_BASE(alg) == IFX_SE_ALG_FFDH)
 Whether the specified algorithm is a finite field Diffie-Hellman algorithm. More...
 
#define IFX_SE_ALG_ECDH   ((ifx_se_algorithm_t)0x09020000)
 The elliptic curve Diffie-Hellman (ECDH) key agreement algorithm. More...
 
#define IFX_SE_ALG_IS_ECDH(alg)    (IFX_SE_ALG_KEY_AGREEMENT_GET_BASE(alg) == IFX_SE_ALG_ECDH)
 Whether the specified algorithm is an elliptic curve Diffie-Hellman algorithm. More...
 
#define IFX_SE_ALG_IS_WILDCARD(alg)
 Whether the specified algorithm encoding is a wildcard. More...
 
#define IFX_SE_ALG_GET_HASH(alg)    (((alg) & 0x000000ff) == 0 ? ((ifx_se_algorithm_t)0) : 0x02000000 | ((alg) & 0x000000ff))
 Get the hash used by a composite algorithm. More...
 
#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 they encode. More...
 

Typedefs

typedef uint32_t ifx_se_algorithm_t
 Encoding of a cryptographic algorithm. More...
 

Functions

static void ifx_se_set_key_algorithm (ifx_se_key_attributes_t *attributes, ifx_se_algorithm_t alg)
 Sets key algorithm in key attributes structure. More...
 
static ifx_se_algorithm_t ifx_se_get_key_algorithm (const ifx_se_key_attributes_t *attributes)
 Gets key algorithm from key attributes structure. More...
 
static void ifx_se_set_key_enrollment_algorithm (ifx_se_key_attributes_t *attributes, ifx_se_algorithm_t alg2)
 Sets enrollment key algorithm in key attributes structure. More...
 
static ifx_se_algorithm_t ifx_se_get_key_enrollment_algorithm (const ifx_se_key_attributes_t *attributes)
 Gets enrollment key algorithm from key attributes structure. More...
 

Macro Definition Documentation

◆ IFX_SE_ALG_VENDOR_FLAG

#define IFX_SE_ALG_VENDOR_FLAG   ((ifx_se_algorithm_t)0x80000000U)

Vendor-defined algorithm flag.

Algorithms defined by this standard will never have the IFX_SE_ALG_VENDOR_FLAG bit set. Vendors who define additional algorithms must use an encoding with the IFX_SE_ALG_VENDOR_FLAG bit set and should respect the bitwise structure used by standard encodings whenever practical.

◆ IFX_SE_ALG_IS_VENDOR_DEFINED

#define IFX_SE_ALG_IS_VENDOR_DEFINED (   alg)     (((alg) & IFX_SE_ALG_VENDOR_FLAG) != 0)

Whether an algorithm is vendor-defined.

See also IFX_SE_ALG_VENDOR_FLAG.

◆ IFX_SE_ALG_IS_HASH

#define IFX_SE_ALG_IS_HASH (   alg)     (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_HASH)

Whether the specified algorithm is a hash algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a hash algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_IS_MAC

#define IFX_SE_ALG_IS_MAC (   alg)     (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_MAC)

Whether the specified algorithm is a MAC algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a MAC algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_IS_CIPHER

#define IFX_SE_ALG_IS_CIPHER (   alg)     (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_CIPHER)

Whether the specified algorithm is a symmetric cipher algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a symmetric cipher algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_IS_AEAD

#define IFX_SE_ALG_IS_AEAD (   alg)     (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_AEAD)

Whether the specified algorithm is an authenticated encryption with associated data (AEAD) algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is an AEAD algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_IS_SIGN

#define IFX_SE_ALG_IS_SIGN (   alg)     (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_SIGN)

Whether the specified algorithm is an asymmetric signature algorithm, also known as public-key signature algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is an asymmetric signature algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_IS_ASYMMETRIC_ENCRYPTION

#define IFX_SE_ALG_IS_ASYMMETRIC_ENCRYPTION (   alg)     (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION)

Whether the specified algorithm is an asymmetric encryption algorithm, also known as public-key encryption algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is an asymmetric encryption algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_IS_KEY_AGREEMENT

#define IFX_SE_ALG_IS_KEY_AGREEMENT (   alg)     (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_KEY_AGREEMENT)

Whether the specified algorithm is a key agreement algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a key agreement algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_IS_KEY_DERIVATION

#define IFX_SE_ALG_IS_KEY_DERIVATION (   alg)     (((alg) & IFX_SE_ALG_CATEGORY_MASK) == IFX_SE_ALG_CATEGORY_KEY_DERIVATION)

Whether the specified algorithm is a key derivation algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a key derivation algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_IS_KEY_DERIVATION_STRETCHING

#define IFX_SE_ALG_IS_KEY_DERIVATION_STRETCHING (   alg)
Value:
#define IFX_SE_ALG_KEY_DERIVATION_STRETCHING_FLAG
This flag indicates whether the key derivation algorithm is suitable for use on low-entropy secrets s...
Definition: ifx_se_psacrypto_values.h:2075
#define IFX_SE_ALG_IS_KEY_DERIVATION(alg)
Whether the specified algorithm is a key derivation algorithm.
Definition: ifx_se_psacrypto_values.h:870

Whether the specified algorithm is a key stretching / password hashing algorithm.

A key stretching / password hashing algorithm is a key derivation algorithm that is suitable for use with a low-entropy secret such as a password. Equivalently, it's a key derivation algorithm that uses a IFX_SE_KEY_DERIVATION_INPUT_PASSWORD input step.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a key stretching / password hashing algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_SHAKE256_512

#define IFX_SE_ALG_SHAKE256_512   ((ifx_se_algorithm_t)0x02000015)

The first 512 bits (64 bytes) of the SHAKE256 output.

This is the prehashing for Ed448ph (see IFX_SE_ALG_ED448PH). For other scenarios where a hash function based on SHA3/SHAKE is desired, SHA3-512 has the same output size and a (theoretically) higher security strength.

◆ IFX_SE_ALG_ANY_HASH

#define IFX_SE_ALG_ANY_HASH   ((ifx_se_algorithm_t)0x020000ff)

In a hash-and-sign algorithm policy, allow any hash algorithm.

This value may be used to form the algorithm usage field of a policy for a signature algorithm that is parametrized by a hash. The key may then be used to perform operations using the same signature algorithm parametrized with any supported hash.

That is, suppose that IFX_SE_xxx_SIGNATURE is one of the following macros:

This value may not be used to build other algorithms that are parametrized over a hash. For any valid use of this macro to build an algorithm alg, IFX_SE_ALG_IS_HASH_AND_SIGN(alg) is true.

This value may not be used to build an algorithm specification to perform an operation. It is only valid to build policies.

◆ IFX_SE_ALG_HMAC

#define IFX_SE_ALG_HMAC (   hash_alg)     (IFX_SE_ALG_HMAC_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

Macro to build an HMAC algorithm.

For example, IFX_SE_ALG_HMAC(IFX_SE_ALG_SHA_256) is HMAC-SHA-256.

Parameters
hash_algA hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true).
Returns
The corresponding HMAC algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_IS_HMAC

#define IFX_SE_ALG_IS_HMAC (   alg)
Value:
(((alg) & (IFX_SE_ALG_CATEGORY_MASK | IFX_SE_ALG_MAC_SUBCATEGORY_MASK)) == \
IFX_SE_ALG_HMAC_BASE)

Whether the specified algorithm is an HMAC algorithm.

HMAC is a family of MAC algorithms that are based on a hash function.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is an HMAC algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_MAC_TRUNCATION_MASK

#define IFX_SE_ALG_MAC_TRUNCATION_MASK   ((ifx_se_algorithm_t)0x003f0000)

In the encoding of a MAC algorithm, the bits corresponding to IFX_SE_ALG_MAC_TRUNCATION_MASK encode the length to which the MAC is truncated.

As an exception, the value 0 means the untruncated algorithm, whatever its length is. The length is encoded in 6 bits, so it can reach up to 63; the largest MAC is 64 bytes so its trivial truncation to full length is correctly encoded as 0 and any non-trivial truncation is correctly encoded as a value between 1 and 63.

◆ IFX_SE_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG

#define IFX_SE_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG   ((ifx_se_algorithm_t)0x00008000)

In the encoding of a MAC algorithm, the bit corresponding to IFX_SE_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG encodes the fact that the algorithm is a wildcard algorithm.

A key with such wildcard algorithm as permitted algorithm policy can be used with any algorithm corresponding to the same base class and having a (potentially truncated) MAC length greater or equal than the one encoded in IFX_SE_ALG_MAC_TRUNCATION_MASK.

◆ IFX_SE_ALG_TRUNCATED_MAC

#define IFX_SE_ALG_TRUNCATED_MAC (   mac_alg,
  mac_length 
)
Value:
(((mac_alg) & ~(IFX_SE_ALG_MAC_TRUNCATION_MASK | \
((mac_length) << IFX_SE_MAC_TRUNCATION_OFFSET & IFX_SE_ALG_MAC_TRUNCATION_MASK))
#define IFX_SE_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG
In the encoding of a MAC algorithm, the bit corresponding to IFX_SE_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG...
Definition: ifx_se_psacrypto_values.h:1016
#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

Macro to build a truncated MAC algorithm.

A truncated MAC algorithm is identical to the corresponding MAC algorithm except that the MAC value for the truncated algorithm consists of only the first mac_length bytes of the MAC value for the untruncated algorithm.

Note
This macro may allow constructing algorithm identifiers that are not valid, either because the specified length is larger than the untruncated MAC or because the specified length is smaller than permitted by the implementation.
It is implementation-defined whether a truncated MAC that is truncated to the same length as the MAC of the untruncated algorithm is considered identical to the untruncated algorithm for policy comparison purposes.
Parameters
mac_algA MAC algorithm identifier (value of type ifx_se_algorithm_t such that IFX_SE_ALG_IS_MAC(mac_alg) is true). This may be a truncated or untruncated MAC algorithm.
mac_lengthDesired length of the truncated MAC in bytes. This must be at most the full length of the MAC and must be at least an implementation-specified minimum. The implementation-specified minimum shall not be zero.
Returns
The corresponding MAC algorithm with the specified length.
Unspecified if mac_alg is not a supported MAC algorithm or if mac_length is too small or too large for the specified MAC algorithm.

◆ IFX_SE_ALG_FULL_LENGTH_MAC

#define IFX_SE_ALG_FULL_LENGTH_MAC (   mac_alg)
Value:

Macro to build the base MAC algorithm corresponding to a truncated MAC algorithm.

Parameters
mac_algA MAC algorithm identifier (value of type ifx_se_algorithm_t such that IFX_SE_ALG_IS_MAC(mac_alg) is true). This may be a truncated or untruncated MAC algorithm.
Returns
The corresponding base MAC algorithm.
Unspecified if mac_alg is not a supported MAC algorithm.

◆ IFX_SE_MAC_TRUNCATED_LENGTH

#define IFX_SE_MAC_TRUNCATED_LENGTH (   mac_alg)     (((mac_alg) & IFX_SE_ALG_MAC_TRUNCATION_MASK) >> IFX_SE_MAC_TRUNCATION_OFFSET)

Length to which a MAC algorithm is truncated.

Parameters
mac_algA MAC algorithm identifier (value of type ifx_se_algorithm_t such that IFX_SE_ALG_IS_MAC(mac_alg) is true).
Returns
Length of the truncated MAC in bytes.
0 if mac_alg is a non-truncated MAC algorithm.
Unspecified if mac_alg is not a supported MAC algorithm.

◆ IFX_SE_ALG_AT_LEAST_THIS_LENGTH_MAC

#define IFX_SE_ALG_AT_LEAST_THIS_LENGTH_MAC (   mac_alg,
  min_mac_length 
)
Value:
( IFX_SE_ALG_TRUNCATED_MAC(mac_alg, min_mac_length) | \
IFX_SE_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG )
#define IFX_SE_ALG_TRUNCATED_MAC(mac_alg, mac_length)
Macro to build a truncated MAC algorithm.
Definition: ifx_se_psacrypto_values.h:1051

Macro to build a MAC minimum-MAC-length wildcard algorithm.

A minimum-MAC-length MAC wildcard algorithm permits all MAC algorithms sharing the same base algorithm, and where the (potentially truncated) MAC length of the specific algorithm is equal to or larger then the wildcard algorithm's minimum MAC length.

Note
When setting the minimum required MAC length to less than the smallest MAC length allowed by the base algorithm, this effectively becomes an 'any-MAC-length-allowed' policy for that base algorithm.
Parameters
mac_algA MAC algorithm identifier (value of type ifx_se_algorithm_t such that IFX_SE_ALG_IS_MAC(mac_alg) is true).
min_mac_lengthDesired minimum length of the message authentication code in bytes. This must be at most the untruncated length of the MAC and must be at least 1.
Returns
The corresponding MAC wildcard algorithm with the specified minimum length.
Unspecified if mac_alg is not a supported MAC algorithm or if min_mac_length is less than 1 or too large for the specified MAC algorithm.

◆ IFX_SE_ALG_CBC_MAC

#define IFX_SE_ALG_CBC_MAC   ((ifx_se_algorithm_t)0x03c00100)

The CBC-MAC construction over a block cipher.

Warning
CBC-MAC is insecure in many cases. A more secure mode, such as IFX_SE_ALG_CMAC, is recommended.

◆ IFX_SE_ALG_IS_BLOCK_CIPHER_MAC

#define IFX_SE_ALG_IS_BLOCK_CIPHER_MAC (   alg)
Value:
(((alg) & (IFX_SE_ALG_CATEGORY_MASK | IFX_SE_ALG_MAC_SUBCATEGORY_MASK)) == \
IFX_SE_ALG_CIPHER_MAC_BASE)

Whether the specified algorithm is a MAC algorithm based on a block cipher.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a MAC algorithm based on a block cipher, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_IS_STREAM_CIPHER

#define IFX_SE_ALG_IS_STREAM_CIPHER (   alg)
Value:
(((alg) & (IFX_SE_ALG_CATEGORY_MASK | IFX_SE_ALG_CIPHER_STREAM_FLAG)) == \
(IFX_SE_ALG_CATEGORY_CIPHER | IFX_SE_ALG_CIPHER_STREAM_FLAG))

Whether the specified algorithm is a stream cipher.

A stream cipher is a symmetric cipher that encrypts or decrypts messages by applying a bitwise-xor with a stream of bytes that is generated from a key.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a stream cipher algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier or if it is not a symmetric cipher algorithm.

◆ IFX_SE_ALG_STREAM_CIPHER

#define IFX_SE_ALG_STREAM_CIPHER   ((ifx_se_algorithm_t)0x04800100)

The stream cipher mode of a stream cipher algorithm.

The underlying stream cipher is determined by the key type.

◆ IFX_SE_ALG_CTR

#define IFX_SE_ALG_CTR   ((ifx_se_algorithm_t)0x04c01000)

The CTR stream cipher mode.

CTR is a stream cipher which is built from a block cipher. The underlying block cipher is determined by the key type. For example, to use AES-128-CTR, use this algorithm with a key of type IFX_SE_KEY_TYPE_AES and a length of 128 bits (16 bytes).

◆ IFX_SE_ALG_CFB

#define IFX_SE_ALG_CFB   ((ifx_se_algorithm_t)0x04c01100)

The CFB stream cipher mode.

The underlying block cipher is determined by the key type.

◆ IFX_SE_ALG_OFB

#define IFX_SE_ALG_OFB   ((ifx_se_algorithm_t)0x04c01200)

The OFB stream cipher mode.

The underlying block cipher is determined by the key type.

◆ IFX_SE_ALG_XTS

#define IFX_SE_ALG_XTS   ((ifx_se_algorithm_t)0x0440ff00)

The XTS cipher mode.

XTS is a cipher mode which is built from a block cipher. It requires at least one full block of input, but beyond this minimum the input does not need to be a whole number of blocks.

◆ IFX_SE_ALG_ECB_NO_PADDING

#define IFX_SE_ALG_ECB_NO_PADDING   ((ifx_se_algorithm_t)0x04404400)

The Electronic Code Book (ECB) mode of a block cipher, with no padding.

Warning
ECB mode does not protect the confidentiality of the encrypted data except in extremely narrow circumstances. It is recommended that applications only use ECB if they need to construct an operating mode that the implementation does not provide. Implementations are encouraged to provide the modes that applications need in preference to supporting direct access to ECB.

The underlying block cipher is determined by the key type.

This symmetric cipher mode can only be used with messages whose lengths are a multiple of the block size of the chosen block cipher.

ECB mode does not accept an initialization vector (IV). When using a multi-part cipher operation with this algorithm, ifx_se_cipher_generate_iv() and ifx_se_cipher_set_iv() must not be called.

◆ IFX_SE_ALG_CBC_NO_PADDING

#define IFX_SE_ALG_CBC_NO_PADDING   ((ifx_se_algorithm_t)0x04404000)

The CBC block cipher chaining mode, with no padding.

The underlying block cipher is determined by the key type.

This symmetric cipher mode can only be used with messages whose lengths are whole number of blocks for the chosen block cipher.

◆ IFX_SE_ALG_CBC_PKCS7

#define IFX_SE_ALG_CBC_PKCS7   ((ifx_se_algorithm_t)0x04404100)

The CBC block cipher chaining mode with PKCS#7 padding.

The underlying block cipher is determined by the key type.

This is the padding method defined by PKCS#7 (RFC 2315) §10.3.

◆ IFX_SE_ALG_IS_AEAD_ON_BLOCK_CIPHER

#define IFX_SE_ALG_IS_AEAD_ON_BLOCK_CIPHER (   alg)
Value:
(((alg) & (IFX_SE_ALG_CATEGORY_MASK | IFX_SE_ALG_AEAD_FROM_BLOCK_FLAG)) == \
(IFX_SE_ALG_CATEGORY_AEAD | IFX_SE_ALG_AEAD_FROM_BLOCK_FLAG))

Whether the specified algorithm is an AEAD mode on a block cipher.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is an AEAD algorithm which is an AEAD mode based on a block cipher, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_CCM

#define IFX_SE_ALG_CCM   ((ifx_se_algorithm_t)0x05500100)

The CCM authenticated encryption algorithm.

The underlying block cipher is determined by the key type.

◆ IFX_SE_ALG_CCM_STAR_NO_TAG

#define IFX_SE_ALG_CCM_STAR_NO_TAG   ((ifx_se_algorithm_t)0x04c01300)

The CCM* cipher mode without authentication.

This is CCM* as specified in IEEE 802.15.4 #7, with a tag length of 0. For CCM* with a nonzero tag length, use the AEAD algorithm IFX_SE_ALG_CCM.

The underlying block cipher is determined by the key type.

Currently only 13-byte long IV's are supported.

◆ IFX_SE_ALG_GCM

#define IFX_SE_ALG_GCM   ((ifx_se_algorithm_t)0x05500200)

The GCM authenticated encryption algorithm.

The underlying block cipher is determined by the key type.

◆ IFX_SE_ALG_CHACHA20_POLY1305

#define IFX_SE_ALG_CHACHA20_POLY1305   ((ifx_se_algorithm_t)0x05100500)

The Chacha20-Poly1305 AEAD algorithm.

The ChaCha20_Poly1305 construction is defined in RFC 7539.

Implementations must support 12-byte nonces, may support 8-byte nonces, and should reject other sizes.

Implementations must support 16-byte tags and should reject other sizes.

◆ IFX_SE_ALG_AEAD_TAG_LENGTH_MASK

#define IFX_SE_ALG_AEAD_TAG_LENGTH_MASK   ((ifx_se_algorithm_t)0x003f0000)

In the encoding of an AEAD algorithm, the bits corresponding to IFX_SE_ALG_AEAD_TAG_LENGTH_MASK encode the length of the AEAD tag.

The constants for default lengths follow this encoding.

◆ IFX_SE_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG

#define IFX_SE_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG   ((ifx_se_algorithm_t)0x00008000)

In the encoding of an AEAD algorithm, the bit corresponding to IFX_SE_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG encodes the fact that the algorithm is a wildcard algorithm.

A key with such wildcard algorithm as permitted algorithm policy can be used with any algorithm corresponding to the same base class and having a tag length greater than or equal to the one encoded in IFX_SE_ALG_AEAD_TAG_LENGTH_MASK.

◆ IFX_SE_ALG_AEAD_WITH_SHORTENED_TAG

#define IFX_SE_ALG_AEAD_WITH_SHORTENED_TAG (   aead_alg,
  tag_length 
)
Value:
(((aead_alg) & ~(IFX_SE_ALG_AEAD_TAG_LENGTH_MASK | \
((tag_length) << IFX_SE_AEAD_TAG_LENGTH_OFFSET & \
IFX_SE_ALG_AEAD_TAG_LENGTH_MASK))
#define IFX_SE_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG
In the encoding of an AEAD algorithm, the bit corresponding to IFX_SE_ALG_AEAD_AT_LEAST_THIS_LENGTH_F...
Definition: ifx_se_psacrypto_values.h:1294
#define IFX_SE_ALG_AEAD_TAG_LENGTH_MASK
In the encoding of an AEAD algorithm, the bits corresponding to IFX_SE_ALG_AEAD_TAG_LENGTH_MASK encod...
Definition: ifx_se_psacrypto_values.h:1286

Macro to build a shortened AEAD algorithm.

A shortened AEAD algorithm is similar to the corresponding AEAD algorithm, but has an authentication tag that consists of fewer bytes. Depending on the algorithm, the tag length may affect the calculation of the ciphertext.

Parameters
aead_algAn AEAD algorithm identifier (value of type ifx_se_algorithm_t such that IFX_SE_ALG_IS_AEAD(aead_alg) is true).
tag_lengthDesired length of the authentication tag in bytes.
Returns
The corresponding AEAD algorithm with the specified length.
Unspecified if aead_alg is not a supported AEAD algorithm or if tag_length is not valid for the specified AEAD algorithm.

◆ IFX_SE_ALG_AEAD_GET_TAG_LENGTH

#define IFX_SE_ALG_AEAD_GET_TAG_LENGTH (   aead_alg)
Value:
(((aead_alg) & IFX_SE_ALG_AEAD_TAG_LENGTH_MASK) >> \
IFX_SE_AEAD_TAG_LENGTH_OFFSET )

Retrieve the tag length of a specified AEAD algorithm.

Parameters
aead_algAn AEAD algorithm identifier (value of type ifx_se_algorithm_t such that IFX_SE_ALG_IS_AEAD(aead_alg) is true).
Returns
The tag length specified by the input algorithm.
Unspecified if aead_alg is not a supported AEAD algorithm.

◆ IFX_SE_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG

#define IFX_SE_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG (   aead_alg)
Value:
( \
IFX_SE_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg, IFX_SE_ALG_CCM) \
IFX_SE_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg, IFX_SE_ALG_GCM) \
IFX_SE_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg, IFX_SE_ALG_CHACHA20_POLY1305) \
0)
#define IFX_SE_ALG_CCM
The CCM authenticated encryption algorithm.
Definition: ifx_se_psacrypto_values.h:1252
#define IFX_SE_ALG_CHACHA20_POLY1305
The Chacha20-Poly1305 AEAD algorithm.
Definition: ifx_se_psacrypto_values.h:1280
#define IFX_SE_ALG_GCM
The GCM authenticated encryption algorithm.
Definition: ifx_se_psacrypto_values.h:1269

Calculate the corresponding AEAD algorithm with the default tag length.

Parameters
aead_algAn AEAD algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_AEAD(aead_alg) is true).
Returns
The corresponding AEAD algorithm with the default tag length for that algorithm.

◆ IFX_SE_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG

#define IFX_SE_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG (   aead_alg,
  min_tag_length 
)
Value:
( IFX_SE_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, min_tag_length) | \
IFX_SE_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG )
#define IFX_SE_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, tag_length)
Macro to build a shortened AEAD algorithm.
Definition: ifx_se_psacrypto_values.h:1314

Macro to build an AEAD minimum-tag-length wildcard algorithm.

A minimum-tag-length AEAD wildcard algorithm permits all AEAD algorithms sharing the same base algorithm, and where the tag length of the specific algorithm is equal to or larger then the minimum tag length specified by the wildcard algorithm.

Note
When setting the minimum required tag length to less than the smallest tag length allowed by the base algorithm, this effectively becomes an 'any-tag-length-allowed' policy for that base algorithm.
Parameters
aead_algAn AEAD algorithm identifier (value of type ifx_se_algorithm_t such that IFX_SE_ALG_IS_AEAD(aead_alg) is true).
min_tag_lengthDesired minimum length of the authentication tag in bytes. This must be at least 1 and at most the largest allowed tag length of the algorithm.
Returns
The corresponding AEAD wildcard algorithm with the specified minimum length.
Unspecified if aead_alg is not a supported AEAD algorithm or if min_tag_length is less than 1 or too large for the specified AEAD algorithm.

◆ IFX_SE_ALG_RSA_PKCS1V15_SIGN

#define IFX_SE_ALG_RSA_PKCS1V15_SIGN (   hash_alg)     (IFX_SE_ALG_RSA_PKCS1V15_SIGN_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

RSA PKCS#1 v1.5 signature with hashing.

This is the signature scheme defined by RFC 8017 (PKCS#1: RSA Cryptography Specifications) under the name RSASSA-PKCS1-v1_5.

Parameters
hash_algA hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true). This includes IFX_SE_ALG_ANY_HASH when specifying the algorithm in a usage policy.
Returns
The corresponding RSA PKCS#1 v1.5 signature algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_RSA_PKCS1V15_SIGN_RAW

#define IFX_SE_ALG_RSA_PKCS1V15_SIGN_RAW   IFX_SE_ALG_RSA_PKCS1V15_SIGN_BASE

Raw PKCS#1 v1.5 signature.

The input to this algorithm is the DigestInfo structure used by RFC 8017 (PKCS#1: RSA Cryptography Specifications), §9.2 steps 3–6.

◆ IFX_SE_ALG_RSA_PSS

#define IFX_SE_ALG_RSA_PSS (   hash_alg)     (IFX_SE_ALG_RSA_PSS_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

RSA PSS signature with hashing.

This is the signature scheme defined by RFC 8017 (PKCS#1: RSA Cryptography Specifications) under the name RSASSA-PSS, with the message generation function MGF1, and with a salt length equal to the length of the hash. The specified hash algorithm is used to hash the input message, to create the salted hash, and for the mask generation.

Parameters
hash_algA hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true). This includes IFX_SE_ALG_ANY_HASH when specifying the algorithm in a usage policy.
Returns
The corresponding RSA PSS signature algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_RSA_PSS_ANY_SALT

#define IFX_SE_ALG_RSA_PSS_ANY_SALT (   hash_alg)     (IFX_SE_ALG_RSA_PSS_ANY_SALT_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

RSA PSS signature with hashing with relaxed verification.

This algorithm has the same behavior as IFX_SE_ALG_RSA_PSS when signing, but allows an arbitrary salt length (including 0) when verifying a signature.

Parameters
hash_algA hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true). This includes IFX_SE_ALG_ANY_HASH when specifying the algorithm in a usage policy.
Returns
The corresponding RSA PSS signature algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_IS_RSA_PSS_STANDARD_SALT

#define IFX_SE_ALG_IS_RSA_PSS_STANDARD_SALT (   alg)     (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_RSA_PSS_BASE)

Whether the specified algorithm is RSA PSS with standard salt.

Parameters
algAn algorithm value or an algorithm policy wildcard.
Returns
1 if alg is of the form IFX_SE_ALG_RSA_PSS(hash_alg), where hash_alg is a hash algorithm or IFX_SE_ALG_ANY_HASH. 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier or policy.

◆ IFX_SE_ALG_IS_RSA_PSS_ANY_SALT

#define IFX_SE_ALG_IS_RSA_PSS_ANY_SALT (   alg)     (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_RSA_PSS_ANY_SALT_BASE)

Whether the specified algorithm is RSA PSS with any salt.

Parameters
algAn algorithm value or an algorithm policy wildcard.
Returns
1 if alg is of the form IFX_SE_ALG_RSA_PSS_ANY_SALT_BASE(hash_alg), where hash_alg is a hash algorithm or IFX_SE_ALG_ANY_HASH. 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier or policy.

◆ IFX_SE_ALG_IS_RSA_PSS

#define IFX_SE_ALG_IS_RSA_PSS (   alg)
Value:
IFX_SE_ALG_IS_RSA_PSS_ANY_SALT(alg))
#define IFX_SE_ALG_IS_RSA_PSS_STANDARD_SALT(alg)
Whether the specified algorithm is RSA PSS with standard salt.
Definition: ifx_se_psacrypto_values.h:1468

Whether the specified algorithm is RSA PSS.

This includes any of the RSA PSS algorithm variants, regardless of the constraints on salt length.

Parameters
algAn algorithm value or an algorithm policy wildcard.
Returns
1 if alg is of the form IFX_SE_ALG_RSA_PSS(hash_alg) or IFX_SE_ALG_RSA_PSS_ANY_SALT_BASE(hash_alg), where hash_alg is a hash algorithm or IFX_SE_ALG_ANY_HASH. 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier or policy.

◆ IFX_SE_ALG_ECDSA

#define IFX_SE_ALG_ECDSA (   hash_alg)     (IFX_SE_ALG_ECDSA_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

ECDSA signature with hashing.

This is the ECDSA signature scheme defined by ANSI X9.62, with a random per-message secret number (k).

The representation of the signature as a byte string consists of the concatenation of the signature values r and s. Each of r and s is encoded as an N-octet string, where N is the length of the base point of the curve in octets. Each value is represented in big-endian order (most significant octet first).

Parameters
hash_algA hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true). This includes IFX_SE_ALG_ANY_HASH when specifying the algorithm in a usage policy.
Returns
The corresponding ECDSA signature algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_ECDSA_ANY

#define IFX_SE_ALG_ECDSA_ANY   IFX_SE_ALG_ECDSA_BASE

ECDSA signature without hashing.

This is the same signature scheme as IFX_SE_ALG_ECDSA(), but without specifying a hash algorithm. This algorithm may only be used to sign or verify a sequence of bytes that should be an already-calculated hash. Note that the input is padded with zeros on the left or truncated on the left as required to fit the curve size.

◆ IFX_SE_ALG_DETERMINISTIC_ECDSA

#define IFX_SE_ALG_DETERMINISTIC_ECDSA (   hash_alg)     (IFX_SE_ALG_DETERMINISTIC_ECDSA_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

Deterministic ECDSA signature with hashing.

This is the deterministic ECDSA signature scheme defined by RFC 6979.

The representation of a signature is the same as with IFX_SE_ALG_ECDSA().

Note that when this algorithm is used for verification, signatures made with randomized ECDSA (IFX_SE_ALG_ECDSA(hash_alg)) with the same private key are accepted. In other words, IFX_SE_ALG_DETERMINISTIC_ECDSA(hash_alg) differs from IFX_SE_ALG_ECDSA(hash_alg) only for signature, not for verification.

Parameters
hash_algA hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true). This includes IFX_SE_ALG_ANY_HASH when specifying the algorithm in a usage policy.
Returns
The corresponding deterministic ECDSA signature algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_PURE_EDDSA

#define IFX_SE_ALG_PURE_EDDSA   ((ifx_se_algorithm_t)0x06000800)

Edwards-curve digital signature algorithm without prehashing (PureEdDSA), using standard parameters.

Contexts are not supported in the current version of this specification because there is no suitable signature interface that can take the context as a parameter. A future version of this specification may add suitable functions and extend this algorithm to support contexts.

PureEdDSA requires an elliptic curve key on a twisted Edwards curve. In this specification, the following curves are supported:

  • IFX_SE_ECC_FAMILY_TWISTED_EDWARDS, 255-bit: Ed25519 as specified in RFC 8032. The curve is Edwards25519. The hash function used internally is SHA-512.
  • IFX_SE_ECC_FAMILY_TWISTED_EDWARDS, 448-bit: Ed448 as specified in RFC 8032. The curve is Edwards448. The hash function used internally is the first 114 bytes of the SHAKE256 output.

This algorithm can be used with ifx_se_sign_message() and ifx_se_verify_message(). Since there is no prehashing, it cannot be used with ifx_se_sign_hash() or ifx_se_verify_hash().

The signature format is the concatenation of R and S as defined by RFC 8032 #5.1.6 and #5.2.6 (a 64-byte string for Ed25519, a 114-byte string for Ed448).

◆ IFX_SE_ALG_ED25519PH

#define IFX_SE_ALG_ED25519PH    (IFX_SE_ALG_HASH_EDDSA_BASE | (IFX_SE_ALG_SHA_512 & IFX_SE_ALG_HASH_MASK))

Edwards-curve digital signature algorithm with prehashing (HashEdDSA), using SHA-512 and the Edwards25519 curve.

See IFX_SE_ALG_PURE_EDDSA regarding context support and the signature format.

This algorithm is Ed25519 as specified in RFC 8032. The curve is Edwards25519. The prehash is SHA-512. The hash function used internally is SHA-512.

This is a hash-and-sign algorithm: to calculate a signature, you can either:

◆ IFX_SE_ALG_ED448PH

#define IFX_SE_ALG_ED448PH    (IFX_SE_ALG_HASH_EDDSA_BASE | (IFX_SE_ALG_SHAKE256_512 & IFX_SE_ALG_HASH_MASK))

Edwards-curve digital signature algorithm with prehashing (HashEdDSA), using SHAKE256 and the Edwards448 curve.

See IFX_SE_ALG_PURE_EDDSA regarding context support and the signature format.

This algorithm is Ed448 as specified in RFC 8032. The curve is Edwards448. The prehash is the first 64 bytes of the SHAKE256 output. The hash function used internally is the first 114 bytes of the SHAKE256 output.

This is a hash-and-sign algorithm: to calculate a signature, you can either:

◆ IFX_SE_ALG_IS_SIGN_HASH

#define IFX_SE_ALG_IS_SIGN_HASH (   alg)
Value:
(IFX_SE_ALG_IS_RSA_PSS(alg) || IFX_SE_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \
IFX_SE_ALG_IS_ECDSA(alg) || IFX_SE_ALG_IS_HASH_EDDSA(alg) || \
IFX_SE_ALG_IS_VENDOR_HASH_AND_SIGN(alg))
#define IFX_SE_ALG_IS_RSA_PSS(alg)
Whether the specified algorithm is RSA PSS.
Definition: ifx_se_psacrypto_values.h:1500

Whether the specified algorithm is a signature algorithm that can be used with ifx_se_sign_hash() and ifx_se_verify_hash().

This encompasses all strict hash-and-sign algorithms categorized by IFX_SE_ALG_IS_HASH_AND_SIGN(), as well as algorithms that follow the paradigm more loosely:

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a signature algorithm that can be used to sign a hash. 0 if alg is a signature algorithm that can only be used to sign a message. 0 if alg is not a signature algorithm. This macro can return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_IS_SIGN_MESSAGE

#define IFX_SE_ALG_IS_SIGN_MESSAGE (   alg)     (IFX_SE_ALG_IS_SIGN_HASH(alg) || (alg) == IFX_SE_ALG_PURE_EDDSA )

Whether the specified algorithm is a signature algorithm that can be used with ifx_se_sign_message() and ifx_se_verify_message().

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a signature algorithm that can be used to sign a message. 0 if alg is a signature algorithm that can only be used to sign an already-calculated hash. 0 if alg is not a signature algorithm. This macro can return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_IS_HASH_AND_SIGN

#define IFX_SE_ALG_IS_HASH_AND_SIGN (   alg)
Value:
((alg) & IFX_SE_ALG_HASH_MASK) != 0)
#define IFX_SE_ALG_IS_SIGN_HASH(alg)
Whether the specified algorithm is a signature algorithm that can be used with ifx_se_sign_hash() and...
Definition: ifx_se_psacrypto_values.h:1687
#define IFX_SE_ALG_HASH_MASK
MASK.
Definition: ifx_se_psacrypto_values.h:895

Whether the specified algorithm is a hash-and-sign algorithm.

Hash-and-sign algorithms are asymmetric (public-key) signature algorithms structured in two parts: first the calculation of a hash in a way that does not depend on the key, then the calculation of a signature from the hash value and the key. Hash-and-sign algorithms encode the hash used for the hashing step, and you can call IFX_SE_ALG_SIGN_GET_HASH to extract this algorithm.

Thus, for a hash-and-sign algorithm, ifx_se_sign_message(key, alg, input, ...) is equivalent to

ifx_se_hash_compute(IFX_SE_ALG_SIGN_GET_HASH(alg), input, ..., hash, ...);
ifx_se_sign_hash(key, alg, hash, ..., signature, ...);
#define IFX_SE_ALG_SIGN_GET_HASH(alg)
Get the hash used by a hash-and-sign signature algorithm.
Definition: ifx_se_psacrypto_values.h:1754
ifx_se_status_t ifx_se_hash_compute(ifx_se_alg_fih_t alg, const ifx_se_fih_ptr_t input, ifx_se_fih_t input_length, ifx_se_fih_ptr_t hash, ifx_se_fih_t hash_size, ifx_se_fih_ptr_t hash_length, void *ctx)
Calculate the hash (digest) of a message.
Definition: ifx_se_psacrypto.c:949

Most usefully, separating the hash from the signature allows the hash to be calculated in multiple steps with ifx_se_hash_setup(), ifx_se_hash_update() and ifx_se_hash_finish(). Likewise ifx_se_verify_message() is equivalent to calculating the hash and then calling ifx_se_verify_hash().

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a hash-and-sign algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_SIGN_GET_HASH

#define IFX_SE_ALG_SIGN_GET_HASH (   alg)
Value:
((alg) & IFX_SE_ALG_HASH_MASK) | IFX_SE_ALG_CATEGORY_HASH : \
0)
#define IFX_SE_ALG_IS_HASH_AND_SIGN(alg)
Whether the specified algorithm is a hash-and-sign algorithm.
Definition: ifx_se_psacrypto_values.h:1732

Get the hash used by a hash-and-sign signature algorithm.

A hash-and-sign algorithm is a signature algorithm which is composed of two phases: first a hashing phase which does not use the key and produces a hash of the input message, then a signing phase which only uses the hash and the key and not the message itself.

Parameters
algA signature algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_SIGN(alg) is true).
Returns
The underlying hash algorithm if alg is a hash-and-sign algorithm.
0 if alg is a signature algorithm that does not follow the hash-and-sign structure.
Unspecified if alg is not a signature algorithm or if it is not supported by the implementation.

◆ IFX_SE_ALG_RSA_OAEP

#define IFX_SE_ALG_RSA_OAEP (   hash_alg)     (IFX_SE_ALG_RSA_OAEP_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

RSA OAEP encryption.

This is the encryption scheme defined by RFC 8017 (PKCS#1: RSA Cryptography Specifications) under the name RSAES-OAEP, with the message generation function MGF1.

Parameters
hash_algThe hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true) to use for MGF1.
Returns
The corresponding RSA OAEP encryption algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_HKDF

#define IFX_SE_ALG_HKDF (   hash_alg)     (IFX_SE_ALG_HKDF_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

Macro to build an HKDF algorithm.

For example, IFX_SE_ALG_HKDF(IFX_SE_ALG_SHA256) is HKDF using HMAC-SHA-256.

This key derivation algorithm uses the following inputs:

◆ IFX_SE_ALG_IS_HKDF

#define IFX_SE_ALG_IS_HKDF (   alg)     (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_HKDF_BASE)

Whether the specified algorithm is an HKDF algorithm.

HKDF is a family of key derivation algorithms that are based on a hash function and the HMAC construction.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is an HKDF algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported key derivation algorithm identifier.

◆ IFX_SE_ALG_HKDF_EXTRACT

#define IFX_SE_ALG_HKDF_EXTRACT (   hash_alg)     (IFX_SE_ALG_HKDF_EXTRACT_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

Macro to build an HKDF-Extract algorithm.

For example, IFX_SE_ALG_HKDF_EXTRACT(IFX_SE_ALG_SHA256) is HKDF-Extract using HMAC-SHA-256.

This key derivation algorithm uses the following inputs:

  • IFX_SE_KEY_DERIVATION_INPUT_SALT is the salt.
  • IFX_SE_KEY_DERIVATION_INPUT_SECRET is the input keying material used in the "extract" step. The inputs are mandatory and must be passed in the order above. Each input may only be passed once.
Warning
HKDF-Extract is not meant to be used on its own. IFX_SE_ALG_HKDF should be used instead if possible. IFX_SE_ALG_HKDF_EXTRACT is provided as a separate algorithm for the sake of protocols that use it as a building block. It may also be a slight performance optimization in applications that use HKDF with the same salt and key but many different info strings.
HKDF processes the salt as follows: first hash it with hash_alg if the salt is longer than the block size of the hash algorithm; then pad with null bytes up to the block size. As a result, it is possible for distinct salt inputs to result in the same outputs. To ensure unique outputs, it is recommended to use a fixed length for salt values.
Parameters
hash_algA hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true).
Returns
The corresponding HKDF-Extract algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_IS_HKDF_EXTRACT

#define IFX_SE_ALG_IS_HKDF_EXTRACT (   alg)     (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_HKDF_EXTRACT_BASE)

Whether the specified algorithm is an HKDF-Extract algorithm.

HKDF-Extract is a family of key derivation algorithms that are based on a hash function and the HMAC construction.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is an HKDF-Extract algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported key derivation algorithm identifier.

◆ IFX_SE_ALG_HKDF_EXPAND

#define IFX_SE_ALG_HKDF_EXPAND (   hash_alg)     (IFX_SE_ALG_HKDF_EXPAND_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

Macro to build an HKDF-Expand algorithm.

For example, IFX_SE_ALG_HKDF_EXPAND(IFX_SE_ALG_SHA256) is HKDF-Expand using HMAC-SHA-256.

This key derivation algorithm uses the following inputs:

  • IFX_SE_KEY_DERIVATION_INPUT_SECRET is the pseudorandom key (PRK).
  • IFX_SE_KEY_DERIVATION_INPUT_INFO is the info string.

The inputs are mandatory and must be passed in the order above. Each input may only be passed once.

Warning
HKDF-Expand is not meant to be used on its own. IFX_SE_ALG_HKDF should be used instead if possible. IFX_SE_ALG_HKDF_EXPAND is provided as a separate algorithm for the sake of protocols that use it as a building block. It may also be a slight performance optimization in applications that use HKDF with the same salt and key but many different info strings.
Parameters
hash_algA hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true).
Returns
The corresponding HKDF-Expand algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_IS_HKDF_EXPAND

#define IFX_SE_ALG_IS_HKDF_EXPAND (   alg)     (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_HKDF_EXPAND_BASE)

Whether the specified algorithm is an HKDF-Expand algorithm.

HKDF-Expand is a family of key derivation algorithms that are based on a hash function and the HMAC construction.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is an HKDF-Expand algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported key derivation algorithm identifier.

◆ IFX_SE_ALG_IS_ANY_HKDF

#define IFX_SE_ALG_IS_ANY_HKDF (   alg)
Value:
(((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_HKDF_BASE || \
((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_HKDF_EXTRACT_BASE || \
((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_HKDF_EXPAND_BASE)

Whether the specified algorithm is an HKDF or HKDF-Extract or HKDF-Expand algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is any HKDF type algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported key derivation algorithm identifier.

◆ IFX_SE_ALG_TLS12_PRF

#define IFX_SE_ALG_TLS12_PRF (   hash_alg)     (IFX_SE_ALG_TLS12_PRF_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

Macro to build a TLS-1.2 PRF algorithm.

TLS 1.2 uses a custom pseudorandom function (PRF) for key schedule, specified in Section 5 of RFC 5246. It is based on HMAC and can be used with either SHA-256 or SHA-384.

This key derivation algorithm uses the following inputs, which must be passed in the order given here:

For the application to TLS-1.2 key expansion, the seed is the concatenation of ServerHello.Random + ClientHello.Random, and the label is "key expansion".

For example, IFX_SE_ALG_TLS12_PRF(IFX_SE_ALG_SHA256) represents the TLS 1.2 PRF using HMAC-SHA-256.

Parameters
hash_algA hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true).
Returns
The corresponding TLS-1.2 PRF algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_IS_TLS12_PRF

#define IFX_SE_ALG_IS_TLS12_PRF (   alg)     (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_TLS12_PRF_BASE)

Whether the specified algorithm is a TLS-1.2 PRF algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a TLS-1.2 PRF algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported key derivation algorithm identifier.

◆ IFX_SE_ALG_TLS12_PSK_TO_MS

#define IFX_SE_ALG_TLS12_PSK_TO_MS (   hash_alg)     (IFX_SE_ALG_TLS12_PSK_TO_MS_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

Macro to build a TLS-1.2 PSK-to-MasterSecret algorithm.

In a pure-PSK handshake in TLS 1.2, the master secret is derived from the PreSharedKey (PSK) through the application of padding (RFC 4279, Section 2) and the TLS-1.2 PRF (RFC 5246, Section 5). The latter is based on HMAC and can be used with either SHA-256 or SHA-384.

This key derivation algorithm uses the following inputs, which must be passed in the order given here:

For the application to TLS-1.2, the seed (which is forwarded to the TLS-1.2 PRF) is the concatenation of the ClientHello.Random + ServerHello.Random, the label is "master secret" or "extended master secret" and the other secret depends on the key exchange specified in the cipher suite:

For example, IFX_SE_ALG_TLS12_PSK_TO_MS(IFX_SE_ALG_SHA256) represents the TLS-1.2 PSK to MasterSecret derivation PRF using HMAC-SHA-256.

Parameters
hash_algA hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true).
Returns
The corresponding TLS-1.2 PSK to MS algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_IS_TLS12_PSK_TO_MS

#define IFX_SE_ALG_IS_TLS12_PSK_TO_MS (   alg)     (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_TLS12_PSK_TO_MS_BASE)

Whether the specified algorithm is a TLS-1.2 PSK to MS algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a TLS-1.2 PSK to MS algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported key derivation algorithm identifier.

◆ IFX_SE_ALG_KEY_DERIVATION_STRETCHING_FLAG

#define IFX_SE_ALG_KEY_DERIVATION_STRETCHING_FLAG   ((ifx_se_algorithm_t)0x00800000)

This flag indicates whether the key derivation algorithm is suitable for use on low-entropy secrets such as password - these algorithms are also known as key stretching or password hashing schemes.

These are also the algorithms that accepts inputs of type IFX_SE_KEY_DERIVATION_INPUT_PASSWORD.

Those algorithms cannot be combined with a key agreement algorithm.

◆ IFX_SE_ALG_PBKDF2_HMAC

#define IFX_SE_ALG_PBKDF2_HMAC (   hash_alg)     (IFX_SE_ALG_PBKDF2_HMAC_BASE | ((hash_alg) & IFX_SE_ALG_HASH_MASK))

Macro to build a PBKDF2-HMAC password hashing / key stretching algorithm.

PBKDF2 is defined by PKCS#5, republished as RFC 8018 (section 5.2). This macro specifies the PBKDF2 algorithm constructed using a PRF based on HMAC with the specified hash. For example, IFX_SE_ALG_PBKDF2_HMAC(IFX_SE_ALG_SHA256) specifies PBKDF2 using the PRF HMAC-SHA-256.

This key derivation algorithm uses the following inputs, which must be provided in the following order:

Parameters
hash_algA hash algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_HASH(hash_alg) is true).
Returns
The corresponding PBKDF2-HMAC algorithm.
Unspecified if hash_alg is not a supported hash algorithm.

◆ IFX_SE_ALG_IS_PBKDF2_HMAC

#define IFX_SE_ALG_IS_PBKDF2_HMAC (   alg)     (((alg) & ~IFX_SE_ALG_HASH_MASK) == IFX_SE_ALG_PBKDF2_HMAC_BASE)

Whether the specified algorithm is a PBKDF2-HMAC algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a PBKDF2-HMAC algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported key derivation algorithm identifier.

◆ IFX_SE_ALG_PBKDF2_AES_CMAC_PRF_128

#define IFX_SE_ALG_PBKDF2_AES_CMAC_PRF_128   ((ifx_se_algorithm_t)0x08800200)

The PBKDF2-AES-CMAC-PRF-128 password hashing / key stretching algorithm.

PBKDF2 is defined by PKCS#5, republished as RFC 8018 (section 5.2). This macro specifies the PBKDF2 algorithm constructed using the AES-CMAC-PRF-128 PRF specified by RFC 4615.

This key derivation algorithm uses the same inputs as IFX_SE_ALG_PBKDF2_HMAC() with the same constraints.

◆ IFX_SE_ALG_KDF_AES_CMAC

#define IFX_SE_ALG_KDF_AES_CMAC   ((ifx_se_algorithm_t)0x08000600)

The CMAC KDF algorithm.

Key derivation in Counter Mode using CMAC as pseudo random function (PRF) is defined in NIST SP 800-108 section 4.1.

This key derivation algorithm uses the following inputs

  • IFX_SE_KEY_DERIVATION_INPUT_SECRET is the key derivation key. It is a key that is used as an input to a key-derivation function (along with other input data) to derive keying material.
  • IFX_SE_KEY_DERIVATION_INPUT_LABEL is a string that identifies the purpose for the derived keying material, which is encoded as a bit string. The encoding method for the Label is defined in a larger context, for example, in the protocol that uses a KDF. This input is optional.
  • IFX_SE_KEY_DERIVATION_INPUT_SEED is a bit string that is used to seed the PRF. This input is optional.

◆ IFX_SE_ALG_KEY_AGREEMENT

#define IFX_SE_ALG_KEY_AGREEMENT (   ka_alg,
  kdf_alg 
)     ((ka_alg) | (kdf_alg))

Macro to build a combined algorithm that chains a key agreement with a key derivation.

Parameters
ka_algA key agreement algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_KEY_AGREEMENT(ka_alg) is true).
kdf_algA key derivation algorithm (IFX_SE_ALG_XXX value such that IFX_SE_ALG_IS_KEY_DERIVATION(kdf_alg) is true).
Returns
The corresponding key agreement and derivation algorithm.
Unspecified if ka_alg is not a supported key agreement algorithm or kdf_alg is not a supported key derivation algorithm.

◆ IFX_SE_ALG_IS_RAW_KEY_AGREEMENT

#define IFX_SE_ALG_IS_RAW_KEY_AGREEMENT (   alg)
Value:
IFX_SE_ALG_KEY_AGREEMENT_GET_KDF(alg) == IFX_SE_ALG_CATEGORY_KEY_DERIVATION)
#define IFX_SE_ALG_IS_KEY_AGREEMENT(alg)
Whether the specified algorithm is a key agreement algorithm.
Definition: ifx_se_psacrypto_values.h:859

Whether the specified algorithm is a raw key agreement algorithm.

A raw key agreement algorithm is one that does not specify a key derivation function. Usually, raw key agreement algorithms are constructed directly with a IFX_SE_ALG_xxx macro while non-raw key agreement algorithms are constructed with IFX_SE_ALG_KEY_AGREEMENT().

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a raw key agreement algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_FFDH

#define IFX_SE_ALG_FFDH   ((ifx_se_algorithm_t)0x09010000)

The finite-field Diffie-Hellman (DH) key agreement algorithm.

The shared secret produced by key agreement is g^{ab} in big-endian format. It is ceiling(m / 8) bytes long where m is the size of the prime p in bits.

◆ IFX_SE_ALG_IS_FFDH

#define IFX_SE_ALG_IS_FFDH (   alg)     (IFX_SE_ALG_KEY_AGREEMENT_GET_BASE(alg) == IFX_SE_ALG_FFDH)

Whether the specified algorithm is a finite field Diffie-Hellman algorithm.

This includes the raw finite field Diffie-Hellman algorithm as well as finite-field Diffie-Hellman followed by any supporter key derivation algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a finite field Diffie-Hellman algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported key agreement algorithm identifier.

◆ IFX_SE_ALG_ECDH

#define IFX_SE_ALG_ECDH   ((ifx_se_algorithm_t)0x09020000)

The elliptic curve Diffie-Hellman (ECDH) key agreement algorithm.

The shared secret produced by key agreement is the x-coordinate of the shared secret point. It is always ceiling(m / 8) bytes long where m is the bit size associated with the curve, i.e. the bit size of the order of the curve's coordinate field. When m is not a multiple of 8, the byte containing the most significant bit of the shared secret is padded with zero bits. The byte order is either little-endian or big-endian depending on the curve type.

  • For Montgomery curves (curve types IFX_SE_ECC_FAMILY_CURVEXXX), the shared secret is the x-coordinate of d_A Q_B = d_B Q_A in little-endian byte order. The bit size is 448 for Curve448 and 255 for Curve25519.
  • For Weierstrass curves over prime fields (curve types IFX_SE_ECC_FAMILY_SECPXXX and IFX_SE_ECC_FAMILY_BRAINPOOL_PXXX), the shared secret is the x-coordinate of d_A Q_B = d_B Q_A in big-endian byte order. The bit size is m = ceiling(log_2(p)) for the field F_p.
  • For Weierstrass curves over binary fields (curve types IFX_SE_ECC_FAMILY_SECTXXX), the shared secret is the x-coordinate of d_A Q_B = d_B Q_A in big-endian byte order. The bit size is m for the field F_{2^m}.

◆ IFX_SE_ALG_IS_ECDH

#define IFX_SE_ALG_IS_ECDH (   alg)     (IFX_SE_ALG_KEY_AGREEMENT_GET_BASE(alg) == IFX_SE_ALG_ECDH)

Whether the specified algorithm is an elliptic curve Diffie-Hellman algorithm.

This includes the raw elliptic curve Diffie-Hellman algorithm as well as elliptic curve Diffie-Hellman followed by any supporter key derivation algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is an elliptic curve Diffie-Hellman algorithm, 0 otherwise. This macro may return either 0 or 1 if alg is not a supported key agreement algorithm identifier.

◆ IFX_SE_ALG_IS_WILDCARD

#define IFX_SE_ALG_IS_WILDCARD (   alg)
Value:
IFX_SE_ALG_SIGN_GET_HASH(alg) == IFX_SE_ALG_ANY_HASH : \
IFX_SE_ALG_IS_MAC(alg) ? \
#define IFX_SE_ALG_IS_AEAD(alg)
Whether the specified algorithm is an authenticated encryption with associated data (AEAD) algorithm.
Definition: ifx_se_psacrypto_values.h:824

Whether the specified algorithm encoding is a wildcard.

Wildcard values may only be used to set the usage algorithm field in a policy, not to perform an operation.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
1 if alg is a wildcard algorithm encoding.
0 if alg is a non-wildcard algorithm encoding (suitable for an operation).
This macro may return either 0 or 1 if alg is not a supported algorithm identifier.

◆ IFX_SE_ALG_GET_HASH

#define IFX_SE_ALG_GET_HASH (   alg)     (((alg) & 0x000000ff) == 0 ? ((ifx_se_algorithm_t)0) : 0x02000000 | ((alg) & 0x000000ff))

Get the hash used by a composite algorithm.

Parameters
algAn algorithm identifier (value of type ifx_se_algorithm_t).
Returns
The underlying hash algorithm if alg is a composite algorithm that uses a hash algorithm.
0 if alg is not a composite algorithm that uses a hash.

◆ IFX_SE_ALG_AEAD_EQUAL

#define IFX_SE_ALG_AEAD_EQUAL (   aead_alg_1,
  aead_alg_2 
)
Value:

Check if two AEAD algorithm identifiers refer to the same AEAD algorithm regardless of the tag length they encode.

Parameters
aead_alg_1An AEAD algorithm identifier.
aead_alg_2An AEAD algorithm identifier.
Returns
1 if both identifiers refer to the same AEAD algorithm, 0 otherwise. Unspecified if neither aead_alg_1 nor aead_alg_2 are a supported AEAD algorithm.

Typedef Documentation

◆ ifx_se_algorithm_t

typedef uint32_t ifx_se_algorithm_t

Encoding of a cryptographic algorithm.

For algorithms that can be applied to multiple key types, this type does not encode the key type. For example, for symmetric ciphers based on a block cipher, ifx_se_algorithm_t encodes the block cipher mode and the padding mode while the block cipher itself is encoded via ifx_se_key_type_t.

Function Documentation

◆ ifx_se_set_key_algorithm()

static void ifx_se_set_key_algorithm ( ifx_se_key_attributes_t attributes,
ifx_se_algorithm_t  alg 
)
inlinestatic

Sets key algorithm in key attributes structure.

Parameters
[in]attributesKey attributes structure
[in]algKey algorithm

◆ ifx_se_get_key_algorithm()

static ifx_se_algorithm_t ifx_se_get_key_algorithm ( const ifx_se_key_attributes_t attributes)
inlinestatic

Gets key algorithm from key attributes structure.

Parameters
[in]attributesKey attributes structure
Returns
Key algorithm

◆ ifx_se_set_key_enrollment_algorithm()

static void ifx_se_set_key_enrollment_algorithm ( ifx_se_key_attributes_t attributes,
ifx_se_algorithm_t  alg2 
)
inlinestatic

Sets enrollment key algorithm in key attributes structure.

Parameters
[in]attributesKey attributes structure
[in]alg2A second algorithm that the key may be used for, in addition to the algorithm set with ifx_se_set_key_algorithm().
Warning
Setting an enrollment algorithm is not recommended, because using the same key with different algorithms can allow some attacks based on arithmetic relations between different computations made with the same key, or can escalate harmless side channels into exploitable ones. Use this function only if it is necessary to support a protocol for which it has been verified that the usage of the key with multiple algorithms is safe.

◆ ifx_se_get_key_enrollment_algorithm()

static ifx_se_algorithm_t ifx_se_get_key_enrollment_algorithm ( const ifx_se_key_attributes_t attributes)
inlinestatic

Gets enrollment key algorithm from key attributes structure.

Parameters
[in]attributesKey attributes structure
Returns
The enrollment algorithm stored in the attribute structure