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

Hash algorithm definitions for the PSA Crypto API. More...

Detailed Description

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

Go to the source code of this file.

#define PSA_ALG_CATEGORY_HASH   ((psa_algorithm_t)0x02000000)
 Category for hash algorithms.
 
#define PSA_ALG_HASH_MASK   ((psa_algorithm_t)0x000000ff)
 Hash algorithm mask.
 
#define PSA_ALG_IS_HASH(alg)   (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_HASH)
 Whether the specified algorithm is a hash algorithm.
 
#define PSA_ALG_GET_HASH(alg)
 Get the hash used by a composite algorithm.
 
#define PSA_ALG_HMAC_GET_HASH(hmac_alg)    (PSA_ALG_CATEGORY_HASH | ((hmac_alg) & PSA_ALG_HASH_MASK))
 Get the hash operation of a hmac algorithm.
 
#define PSA_ALG_MD2   ((psa_algorithm_t)0x02000001)
 The MD2 message-digest algorithm.
 
#define PSA_ALG_MD4   ((psa_algorithm_t)0x02000002)
 The MD4 message-digest algorithm.
 
#define PSA_ALG_MD5   ((psa_algorithm_t)0x02000003)
 The MD5 message-digest algorithm.
 
#define PSA_ALG_RIPEMD160   ((psa_algorithm_t)0x02000004)
 The RIPEMD-160 message-digest algorithm.
 
#define PSA_ALG_SHA_1   ((psa_algorithm_t)0x02000005)
 The SHA-1 message-digest algorithm.
 
#define PSA_ALG_SHA_224   ((psa_algorithm_t)0x02000008) /** SHA-224 */
 The SHA-224 message-digest algorithm.
 
#define PSA_ALG_SHA_256   ((psa_algorithm_t)0x02000009) /** SHA-256 */
 The SHA-256 message-digest algorithm.
 
#define PSA_ALG_SHA_384   ((psa_algorithm_t)0x0200000a) /** SHA-384 */
 The SHA-384 message-digest algorithm.
 
#define PSA_ALG_SHA_512   ((psa_algorithm_t)0x0200000b) /** SHA-512 */
 The SHA-512 message-digest algorithm.
 
#define PSA_ALG_SHA_512_224   ((psa_algorithm_t)0x0200000c) /** SHA-512/224 */
 The SHA-512/224 message-digest algorithm.
 
#define PSA_ALG_SHA_512_256   ((psa_algorithm_t)0x0200000d) /** SHA-512/256 */
 The SHA-512/256 message-digest algorithm.
 
#define PSA_ALG_SHA3_224   ((psa_algorithm_t)0x02000010) /** SHA-3-224 */
 The SHA3-224 message-digest algorithm.
 
#define PSA_ALG_SHA3_256   ((psa_algorithm_t)0x02000011) /** SHA-3-256 */
 The SHA3-256 message-digest algorithm.
 
#define PSA_ALG_SHA3_384   ((psa_algorithm_t)0x02000012) /** SHA-3-384 */
 The SHA3-384 message-digest algorithm.
 
#define PSA_ALG_SHA3_512   ((psa_algorithm_t)0x02000013) /** SHA-3-512 */
 The SHA3-512 message-digest algorithm.
 
#define PSA_ALG_SM3   ((psa_algorithm_t)0x02000014) /** SM3 */
 The SM3 message-digest algorithm.
 
#define PSA_ALG_SHAKE256_512   ((psa_algorithm_t)0x02000015)
 The first 512 bits (64 bytes) of the SHAKE256 output.
 

Macro Definition Documentation

◆ PSA_ALG_CATEGORY_HASH

#define PSA_ALG_CATEGORY_HASH   ((psa_algorithm_t)0x02000000)

Category for hash algorithms.

Definition at line 34 of file algorithm.h.

◆ PSA_ALG_GET_HASH

#define PSA_ALG_GET_HASH (   alg)
Value:
(((alg) & PSA_ALG_HASH_MASK) == \
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition algorithm.h:39
#define PSA_ALG_HASH_MASK
Hash algorithm mask.
Definition algorithm.h:39
#define PSA_ALG_CATEGORY_HASH
Category for hash algorithms.
Definition algorithm.h:34

Get the hash used by a composite algorithm.

     The following composite algorithms require a hash algorithm:
     - @ref PSA_ALG_ECDSA()
     - @ref PSA_ALG_HKDF()
     - @ref PSA_ALG_HMAC()
     - @ref PSA_ALG_RSA_OAEP()
     - @ref PSA_ALG_IS_RSA_PKCS1V15_SIGN()
     - @ref PSA_ALG_RSA_PSS()
     - @ref PSA_ALG_RSA_PSS_ANY_SALT()
     - @ref PSA_ALG_TLS12_PRF()
     - @ref PSA_ALG_TLS12_PSK_TO_MS()
     - @ref PSA_ALG_PBKDF2_HMAC()
Parameters
algAn algorithm identifier: a value of type psa_algorithm_t.
Returns
The underlying hash algorithm if alg is a composite algorithm that uses a hash algorithm PSA_ALG_NONE if alg is not a composite algorithm that uses a hash.

Definition at line 71 of file algorithm.h.

◆ PSA_ALG_HASH_MASK

#define PSA_ALG_HASH_MASK   ((psa_algorithm_t)0x000000ff)

Hash algorithm mask.

Definition at line 39 of file algorithm.h.

◆ PSA_ALG_HMAC_GET_HASH

#define PSA_ALG_HMAC_GET_HASH (   hmac_alg)     (PSA_ALG_CATEGORY_HASH | ((hmac_alg) & PSA_ALG_HASH_MASK))

Get the hash operation of a hmac algorithm.

Parameters
hmac_algHMAC algorithm

Definition at line 80 of file algorithm.h.

◆ PSA_ALG_IS_HASH

#define PSA_ALG_IS_HASH (   alg)    (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_HASH)

Whether the specified algorithm is a hash algorithm.

Parameters
algAn algorithm identifier: a value of type psa_algorithm_t.
Returns
1 if alg is a hash algorithm 0 otherwise

Definition at line 49 of file algorithm.h.

◆ PSA_ALG_MD2

#define PSA_ALG_MD2   ((psa_algorithm_t)0x02000001)

The MD2 message-digest algorithm.

Warning
The MD2 hash is weak and deprecated and is only recommended for use in legacy protocols.

MD2 is defined in The MD2 Message-Digest Algorithm RFC1319.

Definition at line 92 of file algorithm.h.

◆ PSA_ALG_MD4

#define PSA_ALG_MD4   ((psa_algorithm_t)0x02000002)

The MD4 message-digest algorithm.

Warning
The MD4 hash is weak and deprecated and is only recommended for use in legacy protocols.

MD4 is defined in The MD4 Message-Digest Algorithm RFC1320.

Definition at line 103 of file algorithm.h.

◆ PSA_ALG_MD5

#define PSA_ALG_MD5   ((psa_algorithm_t)0x02000003)

The MD5 message-digest algorithm.

Warning
The MD5 hash is weak and deprecated and is only recommended for use in legacy protocols.

MD5 is defined in The MD5 Message-Digest Algorithm RFC1321.

Definition at line 114 of file algorithm.h.

◆ PSA_ALG_RIPEMD160

#define PSA_ALG_RIPEMD160   ((psa_algorithm_t)0x02000004)

The RIPEMD-160 message-digest algorithm.

RIPEMD-160 is defined in RIPEMD-160: A Strengthened Version of RIPEMD, and also in ISO/IEC 10118-3:2018 IT Security techniques — Hash-functions — Part 3: Dedicated hash-functions ISO10118.

Definition at line 123 of file algorithm.h.

◆ PSA_ALG_SHA3_224

#define PSA_ALG_SHA3_224   ((psa_algorithm_t)0x02000010) /** SHA-3-224 */

The SHA3-224 message-digest algorithm.

SHA3-224 is defined in FIPS Publication 202: SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions FIPS202.

Definition at line 190 of file algorithm.h.

◆ PSA_ALG_SHA3_256

#define PSA_ALG_SHA3_256   ((psa_algorithm_t)0x02000011) /** SHA-3-256 */

The SHA3-256 message-digest algorithm.

SHA3-256 is defined in FIPS202.

Definition at line 197 of file algorithm.h.

◆ PSA_ALG_SHA3_384

#define PSA_ALG_SHA3_384   ((psa_algorithm_t)0x02000012) /** SHA-3-384 */

The SHA3-384 message-digest algorithm.

SHA3-384 is defined in FIPS202.

Definition at line 204 of file algorithm.h.

◆ PSA_ALG_SHA3_512

#define PSA_ALG_SHA3_512   ((psa_algorithm_t)0x02000013) /** SHA-3-512 */

The SHA3-512 message-digest algorithm.

SHA3-512 is defined in FIPS202.

Definition at line 211 of file algorithm.h.

◆ PSA_ALG_SHA_1

#define PSA_ALG_SHA_1   ((psa_algorithm_t)0x02000005)

The SHA-1 message-digest algorithm.

Warning
The SHA-1 hash is weak and deprecated and is only recommended for use in legacy protocols.

SHA-1 is defined in FIPS Publication 180-4: Secure Hash Standard (SHS) FIPS180-4.

Definition at line 134 of file algorithm.h.

◆ PSA_ALG_SHA_224

#define PSA_ALG_SHA_224   ((psa_algorithm_t)0x02000008) /** SHA-224 */

The SHA-224 message-digest algorithm.

SHA-224 is defined in FIPS Publication 180-4: Secure Hash Standard (SHS) FIPS180-4.

Definition at line 142 of file algorithm.h.

◆ PSA_ALG_SHA_256

#define PSA_ALG_SHA_256   ((psa_algorithm_t)0x02000009) /** SHA-256 */

The SHA-256 message-digest algorithm.

SHA-256 is defined in FIPS Publication 180-4: Secure Hash Standard (SHS) FIPS180-4.

Definition at line 150 of file algorithm.h.

◆ PSA_ALG_SHA_384

#define PSA_ALG_SHA_384   ((psa_algorithm_t)0x0200000a) /** SHA-384 */

The SHA-384 message-digest algorithm.

SHA-384 is defined in FIPS Publication 180-4: Secure Hash Standard (SHS) FIPS180-4.

Definition at line 158 of file algorithm.h.

◆ PSA_ALG_SHA_512

#define PSA_ALG_SHA_512   ((psa_algorithm_t)0x0200000b) /** SHA-512 */

The SHA-512 message-digest algorithm.

SHA-512 is defined in FIPS Publication 180-4: Secure Hash Standard (SHS) FIPS180-4.

Definition at line 166 of file algorithm.h.

◆ PSA_ALG_SHA_512_224

#define PSA_ALG_SHA_512_224   ((psa_algorithm_t)0x0200000c) /** SHA-512/224 */

The SHA-512/224 message-digest algorithm.

SHA-512-224 is defined in FIPS Publication 180-4: Secure Hash Standard (SHS) FIPS180-4.

Definition at line 174 of file algorithm.h.

◆ PSA_ALG_SHA_512_256

#define PSA_ALG_SHA_512_256   ((psa_algorithm_t)0x0200000d) /** SHA-512/256 */

The SHA-512/256 message-digest algorithm.

SHA-512-256 is defined in FIPS Publication 180-4: Secure Hash Standard (SHS) FIPS180-4.

Definition at line 182 of file algorithm.h.

◆ PSA_ALG_SHAKE256_512

#define PSA_ALG_SHAKE256_512   ((psa_algorithm_t)0x02000015)

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

This is the prehashing for Ed448ph (see PSA_ALG_ED448PH).

     SHAKE256 is defined in [FIPS202](https://doi.org/10.6028/NIST.FIPS.202).
Note
For other scenarios where a hash function based on SHA3 or SHAKE is required, SHA3-512 is recommended. SHA3-512 has the same output size, and a theoretically higher security strength.

Definition at line 236 of file algorithm.h.

◆ PSA_ALG_SM3

#define PSA_ALG_SM3   ((psa_algorithm_t)0x02000014) /** SM3 */

The SM3 message-digest algorithm.

SM3 is defined in ISO/IEC 10118-3:2018 IT Security techniques — Hash-functions — Part 3: Dedicated hash-functions ISO10118, and also in GM/T 0004-2012: SM3 cryptographic hash algorithm CSTC0004 (English version CSTC0004/E).

Definition at line 223 of file algorithm.h.