Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
sizes.h
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2025 TU Dresden
3
* SPDX-FileCopyrightText: 2021 HAW Hamburg
4
* SPDX-License-Identifier: LGPL-2.1-only
5
*/
6
7
#pragma once
8
21
#ifdef __cplusplus
22
extern
"C"
{
23
#endif
24
25
#include "
kernel_defines.h
"
26
#include "
psa/hash/algorithm.h
"
27
42
#define PSA_HASH_LENGTH(alg) \
43
( \
44
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD2 ? 16 : \
45
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD4 ? 16 : \
46
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD5 ? 16 : \
47
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_RIPEMD160 ? 20 : \
48
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_1 ? 20 : \
49
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_224 ? 28 : \
50
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_256 ? 32 : \
51
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_384 ? 48 : \
52
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512 ? 64 : \
53
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_224 ? 28 : \
54
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_256 ? 32 : \
55
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_224 ? 28 : \
56
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_256 ? 32 : \
57
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_384 ? 48 : \
58
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_512 ? 64 : \
59
0)
60
66
#define PSA_HASH_MAX_SIZE (64)
67
73
#if (IS_USED(MODULE_PSA_HASH_SHA3_256))
74
#define PSA_HASH_MAX_BLOCK_SIZE 136
75
#elif (IS_USED(MODULE_PSA_HASH_SHA_512) || \
76
IS_USED(MODULE_PSA_HASH_SHA_384) || \
77
IS_USED(MODULE_PSA_HASH_SHA_512_224) || \
78
IS_USED(MODULE_PSA_HASH_SHA_512_256))
79
#define PSA_HASH_MAX_BLOCK_SIZE 128
80
#elif (IS_USED(MODULE_PSA_HASH_SHA3_384))
81
#define PSA_HASH_MAX_BLOCK_SIZE 104
82
#elif (IS_USED(MODULE_PSA_HASH_SHA3_512))
83
#define PSA_HASH_MAX_BLOCK_SIZE 72
84
#elif (IS_USED(MODULE_PSA_HASH_MD5) || \
85
IS_USED(MODULE_PSA_HASH_SHA_1) || \
86
IS_USED(MODULE_PSA_HASH_SHA_224) || \
87
IS_USED(MODULE_PSA_HASH_SHA_256))
88
#define PSA_HASH_MAX_BLOCK_SIZE 64
89
#else
90
#define PSA_HASH_MAX_BLOCK_SIZE 0
91
#endif
92
117
#define PSA_HASH_SUSPEND_OUTPUT_SIZE(alg)
/* specification-defined value */
118
128
#define PSA_HASH_SUSPEND_OUTPUT_MAX_SIZE
/* implementation-defined value */
129
137
#define PSA_HASH_SUSPEND_ALGORITHM_FIELD_LENGTH ((size_t)4)
138
153
#define PSA_HASH_SUSPEND_INPUT_LENGTH_FIELD_LENGTH(alg) \
154
/* specification-defined value */
155
170
#define PSA_HASH_SUSPEND_HASH_STATE_FIELD_LENGTH(alg) \
171
/* specification-defined value */
172
189
#define PSA_HASH_BLOCK_LENGTH(alg) \
190
( \
191
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD2 ? 16 : \
192
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD4 ? 64 : \
193
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD5 ? 64 : \
194
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_RIPEMD160 ? 64 : \
195
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_1 ? 64 : \
196
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_224 ? 64 : \
197
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_256 ? 64 : \
198
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_384 ? 128 : \
199
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512 ? 128 : \
200
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_224 ? 128 : \
201
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_256 ? 128 : \
202
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_224 ? 144 : \
203
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_256 ? 136 : \
204
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_384 ? 104 : \
205
PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_512 ? 72 : \
206
0)
207
208
#ifdef __cplusplus
209
}
210
#endif
211
algorithm.h
Hash algorithm definitions for the PSA Crypto API.
kernel_defines.h
Common macros and compiler attributes/pragmas configuration.
Generated on Mon Nov 24 2025 18:43:16 by
1.9.1