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/algorithm.h"
27 #include "psa/cipher/sizes.h"
28 #include "psa/hash/algorithm.h"
29 #include "psa/hash/sizes.h"
30 #include "psa/mac/algorithm.h"
31 
54 #define PSA_MAC_LENGTH(key_type, key_bits, alg) \
55  ((PSA_ALG_IS_HMAC(alg)) ? PSA_HASH_LENGTH(PSA_ALG_HMAC_GET_HASH(alg)) : \
56  PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) ? PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
57  ((void)(key_type), (void)(key_bits), 0))
58 
69 #if (IS_USED(MODULE_PSA_MAC_HMAC_SHA_512) || \
70  IS_USED(MODULE_PSA_MAC_HMAC_SHA3_512))
71 #define PSA_MAC_MAX_SIZE (PSA_HASH_LENGTH(PSA_ALG_SHA3_512)) /* 64 */
72 #elif (IS_USED(MODULE_PSA_MAC_HMAC_SHA_384) || \
73  IS_USED(MODULE_PSA_MAC_HMAC_SHA3_384))
74 #define PSA_MAC_MAX_SIZE (PSA_HASH_LENGTH(PSA_ALG_SHA3_384)) /* 48 */
75 #elif (IS_USED(MODULE_PSA_MAC_HMAC_SHA_256) || \
76  IS_USED(MODULE_PSA_MAC_HMAC_SHA_512_256) || \
77  IS_USED(MODULE_PSA_MAC_HMAC_SHA3_256))
78 #define PSA_MAC_MAX_SIZE (PSA_HASH_LENGTH(PSA_ALG_SHA3_256)) /* 32 */
79 #elif (IS_USED(MODULE_PSA_MAC_HMAC_SHA_224) || \
80  IS_USED(MODULE_PSA_MAC_HMAC_SHA_512_224) || \
81  IS_USED(MODULE_PSA_MAC_HMAC_SHA3_224))
82 #define PSA_MAC_MAX_SIZE (PSA_HASH_LENGTH(PSA_ALG_SHA3_224)) /* 28 */
83 #elif (IS_USED(MODULE_PSA_MAC_HMAC_RIPEMD160) || \
84  IS_USED(MODULE_PSA_MAC_HMAC_SHA_1))
85 #define PSA_MAC_MAX_SIZE (PSA_HASH_LENGTH(PSA_ALG_SHA_1)) /* 20 */
86 #elif (IS_USED(MODULE_PSA_MAC_HMAC_MD2) || \
87  IS_USED(MODULE_PSA_MAC_HMAC_MD4) || \
88  IS_USED(MODULE_PSA_MAC_HMAC_MD5))
89 #define PSA_MAC_MAX_SIZE (PSA_HASH_LENGTH(PSA_ALG_MD5)) /* 16 */
90 #else
91 #define PSA_MAC_MAX_SIZE 0
92 #endif
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
Algorithm definitions for the PSA Crypto API.
Cipher size definitions for the PSA Crypto API.
Hash algorithm definitions for the PSA Crypto API.
Hash size definitions for the PSA Crypto API.
Common macros and compiler attributes/pragmas configuration.
MAC algorithm definitions for the PSA Crypto API.