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 
33 #define PSA_ALG_CATEGORY_AEAD ((psa_algorithm_t)0x05000000)
34 
44 #define PSA_ALG_IS_AEAD(alg) (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_AEAD)
45 
54 #define PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) (((alg) & 0x7f400000) == 0x05400000)
55 
97 #define PSA_ALG_CCM ((psa_algorithm_t)0x05500100)
98 
124 #define PSA_ALG_GCM ((psa_algorithm_t)0x05500200)
125 
153 #define PSA_ALG_CHACHA20_POLY1305 ((psa_algorithm_t)0x05100500)
154 
177 #define PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, tag_length) \
178  ((psa_algorithm_t)(((aead_alg) & ~0x003f0000) | (((tag_length) & 0x3f) << 16)))
179 
190 #define PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(aead_alg) \
191  ((((aead_alg) & ~0x003f0000) == 0x05400100) ? PSA_ALG_CCM : \
192  (((aead_alg) & ~0x003f0000) == 0x05400200) ? PSA_ALG_GCM : \
193  (((aead_alg) & ~0x003f0000) == 0x05000500) ? PSA_ALG_CHACHA20_POLY1305 : \
194  PSA_ALG_NONE)
195 
220 #define PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(aead_alg, min_tag_length) \
221  /* specification-defined value */
222 
223 #ifdef __cplusplus
224 }
225 #endif
226 
Algorithm definitions for the PSA Crypto API.