Loading...
Searching...
No Matches
type.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
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#include <stdint.h>
26
41typedef uint16_t psa_key_type_t;
42
53typedef uint8_t psa_ecc_family_t;
54
65typedef uint8_t psa_dh_family_t;
66
72#define PSA_KEY_TYPE_NONE ((psa_key_type_t)0x0000)
73
82#define PSA_KEY_TYPE_VENDOR_FLAG ((psa_key_type_t)0x8000)
83
87#define PSA_KEY_TYPE_CATEGORY_MASK ((psa_key_type_t)0x7000)
88
92#define PSA_KEY_TYPE_CATEGORY_RAW ((psa_key_type_t)0x1000)
93
97#define PSA_KEY_TYPE_CATEGORY_SYMMETRIC ((psa_key_type_t)0x2000)
98
102#define PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY ((psa_key_type_t)0x4000)
103
107#define PSA_KEY_TYPE_CATEGORY_KEY_PAIR ((psa_key_type_t)0x7000)
108
112#define PSA_KEY_TYPE_CATEGORY_FLAG_PAIR ((psa_key_type_t)0x3000)
113
120#define PSA_KEY_TYPE_IS_UNSTRUCTURED(type) \
121 (((type) & 0x7000) == 0x1000 || ((type) & 0x7000) == 0x2000)
122
128#define PSA_KEY_TYPE_IS_ASYMMETRIC(type) \
129 (((type) & 0x4000) == 0x4000)
130
136#define PSA_KEY_TYPE_IS_PUBLIC_KEY(type) \
137 (((type) & 0x7000) == 0x4000)
138
144#define PSA_KEY_TYPE_IS_KEY_PAIR(type) \
145 (((type) & 0x7000) == 0x7000)
146
161#define PSA_KEY_TYPE_RAW_DATA ((psa_key_type_t)0x1001)
162
185#define PSA_KEY_TYPE_HMAC ((psa_key_type_t)0x1100)
186
206#define PSA_KEY_TYPE_DERIVE ((psa_key_type_t)0x1200)
207
231#define PSA_KEY_TYPE_PASSWORD ((psa_key_type_t)0x1203)
232
243#define PSA_KEY_TYPE_PASSWORD_HASH ((psa_key_type_t)0x1205)
244
255#define PSA_KEY_TYPE_PEPPER ((psa_key_type_t)0x1206)
256
287#define PSA_KEY_TYPE_AES ((psa_key_type_t)0x2400)
288
319#define PSA_KEY_TYPE_ARIA ((psa_key_type_t)0x2406)
320
348#define PSA_KEY_TYPE_DES ((psa_key_type_t)0x2301)
349
382#define PSA_KEY_TYPE_CAMELLIA ((psa_key_type_t)0x2403)
383
411#define PSA_KEY_TYPE_SM4 ((psa_key_type_t)0x2405)
412
424#define PSA_KEY_TYPE_ARC4 ((psa_key_type_t)0x2002)
425
441#define PSA_KEY_TYPE_CHACHA20 ((psa_key_type_t)0x2004)
442
456#define PSA_KEY_TYPE_RSA_KEY_PAIR ((psa_key_type_t)0x7001)
457
471#define PSA_KEY_TYPE_RSA_PUBLIC_KEY ((psa_key_type_t)0x4001)
472
478#define PSA_KEY_TYPE_IS_RSA(type) \
479 (PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) == 0x4001)
480
484#define PSA_KEY_TYPE_ECC_KEY_PAIR_BASE ((psa_key_type_t)0x7100)
485
501#define PSA_KEY_TYPE_ECC_KEY_PAIR(curve) \
502 (PSA_KEY_TYPE_ECC_KEY_PAIR_BASE | (curve))
503
507#define PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE ((psa_key_type_t)0x4100)
508
512#define PSA_KEY_TYPE_ECC_CURVE_MASK ((psa_key_type_t)0x00ff)
513
529#define PSA_KEY_TYPE_ECC_PUBLIC_KEY(curve) \
530 (PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE | (curve))
531
549#define PSA_ECC_FAMILY_SECP_K1 ((psa_ecc_family_t)0x17)
550
569#define PSA_ECC_FAMILY_SECP_R1 ((psa_ecc_family_t)0x12)
570
586#define PSA_ECC_FAMILY_SECP_R2 ((psa_ecc_family_t)0x1b)
587
610#define PSA_ECC_FAMILY_SECT_K1 ((psa_ecc_family_t)0x27)
611
633#define PSA_ECC_FAMILY_SECT_R1 ((psa_ecc_family_t)0x22)
634
652#define PSA_ECC_FAMILY_SECT_R2 ((psa_ecc_family_t)0x2b)
653
678#define PSA_ECC_FAMILY_BRAINPOOL_P_R1 ((psa_ecc_family_t)0x30)
679
697#define PSA_ECC_FAMILY_FRP ((psa_ecc_family_t)0x33)
698
714#define PSA_ECC_FAMILY_MONTGOMERY ((psa_ecc_family_t)0x41)
715
733#define PSA_ECC_FAMILY_TWISTED_EDWARDS ((psa_ecc_family_t)0x42)
734
740#define PSA_KEY_TYPE_IS_ECC(type) \
741 ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) & 0xff00) == 0x4100)
742
748#define PSA_KEY_TYPE_IS_ECC_KEY_PAIR(type) \
749 (((type) & 0xff00) == 0x7100)
750
756#define PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(type) \
757 (((type) & 0xff00) == 0x4100)
758
768#define PSA_KEY_TYPE_ECC_GET_FAMILY(type) \
769 ((psa_ecc_family_t)((type) & 0x00ff))
770
780#define PSA_KEY_TYPE_DH_KEY_PAIR(group) \
781 ((psa_key_type_t)(0x7200 | (group)))
782
794#define PSA_KEY_TYPE_DH_PUBLIC_KEY(group) \
795 ((psa_key_type_t)(0x4200 | (group)))
796
809#define PSA_DH_FAMILY_RFC7919 ((psa_dh_family_t)0x03)
810
821#define PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY(type) \
822 ((psa_key_type_t)((type) | 0x3000))
823
833#define PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) \
834 ((psa_key_type_t)((type) & ~0x3000))
835
841#define PSA_KEY_TYPE_IS_DH(type) \
842 ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) & 0xff00) == 0x4200)
843
849#define PSA_KEY_TYPE_IS_DH_KEY_PAIR(type) \
850 (((type) & 0xff00) == 0x7200)
851
857#define PSA_KEY_TYPE_IS_DH_PUBLIC_KEY(type) \
858 (((type) & 0xff00) == 0x4200)
859
869#define PSA_KEY_TYPE_DH_GET_FAMILY(type) \
870 ((psa_dh_family_t)((type) & 0x00ff))
871
872#ifdef __cplusplus
873}
874#endif
875
uint16_t psa_key_type_t
Encoding of a key type.
Definition type.h:41
uint8_t psa_ecc_family_t
The type of PSA elliptic curve family identifiers.
Definition type.h:53
uint8_t psa_dh_family_t
The type of PSA finite-field Diffie-Hellman group family identifiers.
Definition type.h:65