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

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

Detailed Description

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

Go to the source code of this file.

#define PSA_HASH_LENGTH(alg)
 The size of the output of psa_hash_compute() and psa_hash_finish(), in bytes.
 
#define PSA_HASH_MAX_SIZE   (64)
 Maximum size of a hash supported by this implementation, in bytes.
 
#define PSA_HASH_MAX_BLOCK_SIZE   0
 Maximum size of a hash block supported by this implementation, in bytes.
 
#define PSA_HASH_SUSPEND_OUTPUT_SIZE(alg)
 A sufficient hash suspend state buffer size for psa_hash_suspend(), in bytes.
 
#define PSA_HASH_SUSPEND_OUTPUT_MAX_SIZE   /* implementation-defined value */
 A sufficient hash suspend state buffer size for psa_hash_suspend(), for any supported hash algorithms.
 
#define PSA_HASH_SUSPEND_ALGORITHM_FIELD_LENGTH   ((size_t)4)
 The size of the algorithm field that is part of the output of psa_hash_suspend(), in bytes.
 
#define PSA_HASH_SUSPEND_INPUT_LENGTH_FIELD_LENGTH(alg)
 The size of the input-length field that is part of the output of psa_hash_suspend(), in bytes.
 
#define PSA_HASH_SUSPEND_HASH_STATE_FIELD_LENGTH(alg)
 The size of the hash-state field that is part of the output of psa_hash_suspend(), in bytes.
 
#define PSA_HASH_BLOCK_LENGTH(alg)
 The input block size of a hash algorithm, in bytes.
 

Macro Definition Documentation

◆ PSA_HASH_BLOCK_LENGTH

#define PSA_HASH_BLOCK_LENGTH ( alg)
Value:
( \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD2 ? 16 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD4 ? 64 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD5 ? 64 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_RIPEMD160 ? 64 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_1 ? 64 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_224 ? 64 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_256 ? 64 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_384 ? 128 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512 ? 128 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_224 ? 128 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_256 ? 128 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_224 ? 144 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_256 ? 136 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_384 ? 104 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_512 ? 72 : \
0)
#define PSA_ALG_SHA3_224
The SHA3-224 message-digest algorithm.
Definition algorithm.h:189
#define PSA_ALG_SHA_224
The SHA-224 message-digest algorithm.
Definition algorithm.h:141
#define PSA_ALG_SHA3_512
The SHA3-512 message-digest algorithm.
Definition algorithm.h:210
#define PSA_ALG_SHA_1
The SHA-1 message-digest algorithm.
Definition algorithm.h:133
#define PSA_ALG_SHA_512_224
The SHA-512/224 message-digest algorithm.
Definition algorithm.h:173
#define PSA_ALG_SHA_384
The SHA-384 message-digest algorithm.
Definition algorithm.h:157
#define PSA_ALG_SHA_512_256
The SHA-512/256 message-digest algorithm.
Definition algorithm.h:181
#define PSA_ALG_SHA_256
The SHA-256 message-digest algorithm.
Definition algorithm.h:149
#define PSA_ALG_RIPEMD160
The RIPEMD-160 message-digest algorithm.
Definition algorithm.h:122
#define PSA_ALG_MD4
The MD4 message-digest algorithm.
Definition algorithm.h:102
#define PSA_ALG_SHA3_256
The SHA3-256 message-digest algorithm.
Definition algorithm.h:196
#define PSA_ALG_MD2
The MD2 message-digest algorithm.
Definition algorithm.h:91
#define PSA_ALG_SHA3_384
The SHA3-384 message-digest algorithm.
Definition algorithm.h:203
#define PSA_ALG_MD5
The MD5 message-digest algorithm.
Definition algorithm.h:113
#define PSA_ALG_SHA_512
The SHA-512 message-digest algorithm.
Definition algorithm.h:165

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 psa_hash_suspend().

Parameters
algA hash algorithm: a value of type psa_algorithm_t such that PSA_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.

Definition at line 192 of file sizes.h.

◆ PSA_HASH_LENGTH

#define PSA_HASH_LENGTH ( alg)
Value:
( \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD2 ? 16 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD4 ? 16 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD5 ? 16 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_RIPEMD160 ? 20 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_1 ? 20 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_224 ? 28 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_256 ? 32 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_384 ? 48 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512 ? 64 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_224 ? 28 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_256 ? 32 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_224 ? 28 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_256 ? 32 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_384 ? 48 : \
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_512 ? 64 : \
0)

The size of the output of psa_hash_compute() and psa_hash_finish(), in bytes.

This is also the hash length that psa_hash_compare() and psa_hash_verify() expect.

See also PSA_HASH_MAX_SIZE.

Parameters
algA hash algorithm or an HMAC algorithm: a value of type psa_algorithm_t such that (PSA_ALG_IS_HASH(alg) || PSA_ALG_IS_HMAC(alg)) is true.
Returns
The hash length for the specified hash algorithm. 0 if the hash algorithm is not recognized or not supported.

Definition at line 45 of file sizes.h.

◆ PSA_HASH_MAX_BLOCK_SIZE

#define PSA_HASH_MAX_BLOCK_SIZE   0

Maximum size of a hash block supported by this implementation, in bytes.

     See also @ref PSA_HASH_BLOCK_LENGTH().

Definition at line 93 of file sizes.h.

◆ PSA_HASH_MAX_SIZE

#define PSA_HASH_MAX_SIZE   (64)

Maximum size of a hash supported by this implementation, in bytes.

     See also @ref PSA_HASH_LENGTH().

Definition at line 69 of file sizes.h.

◆ PSA_HASH_SUSPEND_ALGORITHM_FIELD_LENGTH

#define PSA_HASH_SUSPEND_ALGORITHM_FIELD_LENGTH   ((size_t)4)

The size of the algorithm field that is part of the output of psa_hash_suspend(), in bytes.

Applications can use this value to unpack the hash suspend state that is output by psa_hash_suspend().

Definition at line 140 of file sizes.h.

◆ PSA_HASH_SUSPEND_HASH_STATE_FIELD_LENGTH

#define PSA_HASH_SUSPEND_HASH_STATE_FIELD_LENGTH ( alg)
Value:
/* specification-defined value */

The size of the hash-state field that is part of the output of psa_hash_suspend(), in bytes.

Applications can use this value to unpack the hash suspend state that is output by psa_hash_suspend().

Parameters
algA hash algorithm: a value of type psa_algorithm_t such that PSA_ALG_IS_HASH(alg) is true.
Returns
The size, in bytes, of the hash-state field of the hash suspend state for the specified hash algorithm. 0 if the hash algorithm is not recognized or not supported.

Definition at line 173 of file sizes.h.

◆ PSA_HASH_SUSPEND_INPUT_LENGTH_FIELD_LENGTH

#define PSA_HASH_SUSPEND_INPUT_LENGTH_FIELD_LENGTH ( alg)
Value:
/* specification-defined value */

The size of the input-length field that is part of the output of psa_hash_suspend(), in bytes.

Applications can use this value to unpack the hash suspend state that is output by psa_hash_suspend().

Parameters
algA hash algorithm: a value of type psa_algorithm_t such that PSA_ALG_IS_HASH(alg) is true.
Returns
The size, in bytes, of the input-length field of the hash suspend state for the specified hash algorithm. 0 i f the hash algorithm is not recognized or not supported.

Definition at line 156 of file sizes.h.

◆ PSA_HASH_SUSPEND_OUTPUT_MAX_SIZE

#define PSA_HASH_SUSPEND_OUTPUT_MAX_SIZE   /* implementation-defined value */

A sufficient hash suspend state buffer size for psa_hash_suspend(), for any supported hash algorithms.

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

See also PSA_HASH_SUSPEND_OUTPUT_SIZE().

Definition at line 131 of file sizes.h.

◆ PSA_HASH_SUSPEND_OUTPUT_SIZE

#define PSA_HASH_SUSPEND_OUTPUT_SIZE ( alg)
Value:
/* specification-defined value */

A sufficient hash suspend state buffer size for psa_hash_suspend(), in bytes.

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

See also PSA_HASH_SUSPEND_OUTPUT_MAX_SIZE.

Parameters
algA hash algorithm: a value of type psa_algorithm_t such that PSA_ALG_IS_HASH(alg) is true.
Returns
A sufficient output size for the algorithm. 0 if the hash algorithm is not recognized, or is not supported by psa_hash_suspend().

For a supported hash algorithm alg, the following expression is true:

#define PSA_HASH_SUSPEND_HASH_STATE_FIELD_LENGTH(alg)
The size of the hash-state field that is part of the output of psa_hash_suspend(),...
Definition sizes.h:173
#define PSA_HASH_SUSPEND_OUTPUT_SIZE(alg)
A sufficient hash suspend state buffer size for psa_hash_suspend(), in bytes.
Definition sizes.h:120
#define PSA_HASH_SUSPEND_ALGORITHM_FIELD_LENGTH
The size of the algorithm field that is part of the output of psa_hash_suspend(), in bytes.
Definition sizes.h:140
#define PSA_HASH_BLOCK_LENGTH(alg)
The input block size of a hash algorithm, in bytes.
Definition sizes.h:192
#define PSA_HASH_SUSPEND_INPUT_LENGTH_FIELD_LENGTH(alg)
The size of the input-length field that is part of the output of psa_hash_suspend(),...
Definition sizes.h:156

Definition at line 120 of file sizes.h.