algorithm.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2024 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 "psa/algorithm.h"
26 
30 #define PSA_ALG_CATEGORY_AEAD ((psa_algorithm_t)0x05000000)
31 
41 #define PSA_ALG_IS_AEAD(alg) (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_AEAD)
42 
51 #define PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) (((alg) & 0x7f400000) == 0x05400000)
52 
94 #define PSA_ALG_CCM ((psa_algorithm_t)0x05500100)
95 
121 #define PSA_ALG_GCM ((psa_algorithm_t)0x05500200)
122 
150 #define PSA_ALG_CHACHA20_POLY1305 ((psa_algorithm_t)0x05100500)
151 
174 #define PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, tag_length) \
175  ((psa_algorithm_t)(((aead_alg) & ~0x003f0000) | (((tag_length) & 0x3f) << 16)))
176 
187 #define PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(aead_alg) \
188  ((((aead_alg) & ~0x003f0000) == 0x05400100) ? PSA_ALG_CCM : \
189  (((aead_alg) & ~0x003f0000) == 0x05400200) ? PSA_ALG_GCM : \
190  (((aead_alg) & ~0x003f0000) == 0x05000500) ? PSA_ALG_CHACHA20_POLY1305 : \
191  PSA_ALG_NONE)
192 
217 #define PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(aead_alg, min_tag_length) \
218  /* specification-defined value */
219 
220 #ifdef __cplusplus
221 }
222 #endif
223 
Algorithm definitions for the PSA Crypto API.