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 
22 #ifndef PSA_CRYPTO_PSA_ASYMMETRIC_SIGNATURE_ALGORITHM_H
23 #define PSA_CRYPTO_PSA_ASYMMETRIC_SIGNATURE_ALGORITHM_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include "psa/algorithm.h"
30 #include "psa/hash/algorithm.h"
31 
35 #define PSA_ALG_CATEGORY_SIGN ((psa_algorithm_t)0x06000000)
36 
46 #define PSA_ALG_IS_SIGN(alg) \
47  (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_ASYMMETRIC_SIGNATURE)
48 
57 #define PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) \
58  (((alg) & ~0x000000ff) == 0x06000200)
59 
71 #define PSA_ALG_IS_RSA_PSS(alg) \
72  (((alg) & ~0x000000ff) == 0x06000300)
73 
88 #define PSA_ALG_IS_RSA_PSS_ANY_SALT(alg) \
89  (((alg) & ~0x000000ff) == 0x06001300)
90 
105 #define PSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg) \
106  (((alg) & ~0x000000ff) == 0x06000300)
107 
116 #define PSA_ALG_IS_ECDSA(alg) \
117  (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_SIGN)
118 
129 #define PSA_ALG_IS_DETERMINISTIC_ECDSA(alg) \
130  (((alg) & ~0x000000ff) == 0x06000700)
131 
142 #define PSA_ALG_IS_RANDOMIZED_ECDSA(alg) \
143  (((alg) & ~0x000000ff) == 0x06000600)
144 
153 #define PSA_ALG_IS_HASH_EDDSA(alg) \
154  (((alg) & ~0x000000ff) == 0x06000900)
155 
171 #define PSA_ALG_IS_SIGN_HASH(alg) \
172  (PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \
173  PSA_ALG_IS_ECDSA(alg) || PSA_ALG_IS_HASH_EDDSA(alg))
174 
207 #define PSA_ALG_IS_HASH_AND_SIGN(alg) \
208  (PSA_ALG_IS_SIGN_HASH(alg) && \
209  ((alg) & PSA_ALG_HASH_MASK) != 0)
210 
222 #define PSA_ALG_IS_SIGN_MESSAGE(alg) \
223  (PSA_ALG_IS_SIGN_HASH(alg) || (alg) == PSA_ALG_PURE_EDDSA)
224 
239 #define PSA_ALG_IS_WILDCARD(alg) \
240  (PSA_ALG_GET_HASH(alg) == PSA_ALG_ANY_HASH)
241 
284 #define PSA_ALG_ANY_HASH ((psa_algorithm_t)0x020000ff)
285 
311 #define PSA_ALG_RSA_PKCS1V15_SIGN(hash_alg) \
312  ((psa_algorithm_t)(0x06000200 | ((hash_alg) & 0x000000ff)))
313 
336 #define PSA_ALG_RSA_PKCS1V15_SIGN_RAW ((psa_algorithm_t)0x06000200)
337 
367 #define PSA_ALG_RSA_PSS(hash_alg) \
368  ((psa_algorithm_t)(0x06000300 | ((hash_alg) & 0x000000ff)))
369 
400 #define PSA_ALG_RSA_PSS_ANY_SALT(hash_alg) \
401  ((psa_algorithm_t)(0x06001300 | ((hash_alg) & 0x000000ff)))
402 
406 #define PSA_ALG_ECDSA_BASE ((psa_algorithm_t)0x06000600)
407 
457 #define PSA_ALG_ECDSA(hash_alg) \
458  (PSA_ALG_ECDSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
459 
487 #define PSA_ALG_ECDSA_ANY PSA_ALG_ECDSA_BASE
488 
530 #define PSA_ALG_DETERMINISTIC_ECDSA(hash_alg) \
531  ((psa_algorithm_t)(0x06000700 | ((hash_alg) & 0x000000ff)))
532 
568 #define PSA_ALG_PURE_EDDSA ((psa_algorithm_t)0x06000800)
569 
597 #define PSA_ALG_ED25519PH ((psa_algorithm_t)0x0600090B)
598 
627 #define PSA_ALG_ED448PH ((psa_algorithm_t)0x06000915)
628 
629 #ifdef __cplusplus
630 }
631 #endif
632 
633 #endif /* PSA_CRYPTO_PSA_ASYMMETRIC_SIGNATURE_ALGORITHM_H */
Algorithm definitions for the PSA Crypto API.
Hash algorithm definitions for the PSA Crypto API.