algorithm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 TU Dresden
3  * Copyright (C) 2021 HAW Hamburg
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
10 #pragma once
11 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include "psa/algorithm.h"
29 #include "psa/hash/algorithm.h"
30 
34 #define PSA_ALG_CATEGORY_MAC ((psa_algorithm_t)0x03000000)
35 
39 #define PSA_ALG_HMAC_BASE (0x03800000)
40 
49 #define PSA_ALG_IS_MAC(alg) (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_MAC)
50 
61 #define PSA_ALG_IS_HMAC(alg) (((alg) & 0x7fc0ff00) == 0x03800000)
62 
71 #define PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) (((alg) & 0x7fc00000) == 0x03c00000)
72 
90 #define PSA_ALG_HMAC(hash_alg) \
91  ((psa_algorithm_t)(PSA_ALG_HMAC_BASE | ((hash_alg) & PSA_ALG_HASH_MASK)))
92 
114 #define PSA_ALG_CBC_MAC ((psa_algorithm_t)0x03c00100)
115 
133 #define PSA_ALG_CMAC ((psa_algorithm_t)0x03c00200)
134 
168 #define PSA_ALG_TRUNCATED_MAC(mac_alg, mac_length) \
169  ((psa_algorithm_t)(((mac_alg) & ~0x003f0000) | (((mac_length) & 0x3f) << 16)))
170 
186 #define PSA_ALG_FULL_LENGTH_MAC(mac_alg) \
187  ((psa_algorithm_t)((mac_alg) & ~0x003f0000))
188 
217 #define PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(mac_alg, min_mac_length) \
218  /* specification-defined value */
219 
220 #ifdef __cplusplus
221 }
222 #endif
223 
Algorithm definitions for the PSA Crypto API.
Hash algorithm definitions for the PSA Crypto API.