Loading...
Searching...
No Matches
type.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
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#include <stdint.h>
29
44typedef uint16_t psa_key_type_t;
45
56typedef uint8_t psa_ecc_family_t;
57
68typedef uint8_t psa_dh_family_t;
69
75#define PSA_KEY_TYPE_NONE ((psa_key_type_t)0x0000)
76
85#define PSA_KEY_TYPE_VENDOR_FLAG ((psa_key_type_t)0x8000)
86
90#define PSA_KEY_TYPE_CATEGORY_MASK ((psa_key_type_t)0x7000)
91
95#define PSA_KEY_TYPE_CATEGORY_RAW ((psa_key_type_t)0x1000)
96
100#define PSA_KEY_TYPE_CATEGORY_SYMMETRIC ((psa_key_type_t)0x2000)
101
105#define PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY ((psa_key_type_t)0x4000)
106
110#define PSA_KEY_TYPE_CATEGORY_KEY_PAIR ((psa_key_type_t)0x7000)
111
115#define PSA_KEY_TYPE_CATEGORY_FLAG_PAIR ((psa_key_type_t)0x3000)
116
123#define PSA_KEY_TYPE_IS_UNSTRUCTURED(type) \
124 (((type) & 0x7000) == 0x1000 || ((type) & 0x7000) == 0x2000)
125
131#define PSA_KEY_TYPE_IS_ASYMMETRIC(type) \
132 (((type) & 0x4000) == 0x4000)
133
139#define PSA_KEY_TYPE_IS_PUBLIC_KEY(type) \
140 (((type) & 0x7000) == 0x4000)
141
147#define PSA_KEY_TYPE_IS_KEY_PAIR(type) \
148 (((type) & 0x7000) == 0x7000)
149
164#define PSA_KEY_TYPE_RAW_DATA ((psa_key_type_t)0x1001)
165
188#define PSA_KEY_TYPE_HMAC ((psa_key_type_t)0x1100)
189
209#define PSA_KEY_TYPE_DERIVE ((psa_key_type_t)0x1200)
210
234#define PSA_KEY_TYPE_PASSWORD ((psa_key_type_t)0x1203)
235
246#define PSA_KEY_TYPE_PASSWORD_HASH ((psa_key_type_t)0x1205)
247
258#define PSA_KEY_TYPE_PEPPER ((psa_key_type_t)0x1206)
259
290#define PSA_KEY_TYPE_AES ((psa_key_type_t)0x2400)
291
322#define PSA_KEY_TYPE_ARIA ((psa_key_type_t)0x2406)
323
351#define PSA_KEY_TYPE_DES ((psa_key_type_t)0x2301)
352
385#define PSA_KEY_TYPE_CAMELLIA ((psa_key_type_t)0x2403)
386
414#define PSA_KEY_TYPE_SM4 ((psa_key_type_t)0x2405)
415
427#define PSA_KEY_TYPE_ARC4 ((psa_key_type_t)0x2002)
428
444#define PSA_KEY_TYPE_CHACHA20 ((psa_key_type_t)0x2004)
445
459#define PSA_KEY_TYPE_RSA_KEY_PAIR ((psa_key_type_t)0x7001)
460
474#define PSA_KEY_TYPE_RSA_PUBLIC_KEY ((psa_key_type_t)0x4001)
475
481#define PSA_KEY_TYPE_IS_RSA(type) \
482 (PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) == 0x4001)
483
487#define PSA_KEY_TYPE_ECC_KEY_PAIR_BASE ((psa_key_type_t)0x7100)
488
504#define PSA_KEY_TYPE_ECC_KEY_PAIR(curve) \
505 (PSA_KEY_TYPE_ECC_KEY_PAIR_BASE | (curve))
506
510#define PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE ((psa_key_type_t)0x4100)
511
515#define PSA_KEY_TYPE_ECC_CURVE_MASK ((psa_key_type_t)0x00ff)
516
532#define PSA_KEY_TYPE_ECC_PUBLIC_KEY(curve) \
533 (PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE | (curve))
534
552#define PSA_ECC_FAMILY_SECP_K1 ((psa_ecc_family_t)0x17)
553
572#define PSA_ECC_FAMILY_SECP_R1 ((psa_ecc_family_t)0x12)
573
589#define PSA_ECC_FAMILY_SECP_R2 ((psa_ecc_family_t)0x1b)
590
613#define PSA_ECC_FAMILY_SECT_K1 ((psa_ecc_family_t)0x27)
614
636#define PSA_ECC_FAMILY_SECT_R1 ((psa_ecc_family_t)0x22)
637
655#define PSA_ECC_FAMILY_SECT_R2 ((psa_ecc_family_t)0x2b)
656
681#define PSA_ECC_FAMILY_BRAINPOOL_P_R1 ((psa_ecc_family_t)0x30)
682
700#define PSA_ECC_FAMILY_FRP ((psa_ecc_family_t)0x33)
701
717#define PSA_ECC_FAMILY_MONTGOMERY ((psa_ecc_family_t)0x41)
718
736#define PSA_ECC_FAMILY_TWISTED_EDWARDS ((psa_ecc_family_t)0x42)
737
743#define PSA_KEY_TYPE_IS_ECC(type) \
744 ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) & 0xff00) == 0x4100)
745
751#define PSA_KEY_TYPE_IS_ECC_KEY_PAIR(type) \
752 (((type) & 0xff00) == 0x7100)
753
759#define PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(type) \
760 (((type) & 0xff00) == 0x4100)
761
771#define PSA_KEY_TYPE_ECC_GET_FAMILY(type) \
772 ((psa_ecc_family_t)((type) & 0x00ff))
773
783#define PSA_KEY_TYPE_DH_KEY_PAIR(group) \
784 ((psa_key_type_t)(0x7200 | (group)))
785
797#define PSA_KEY_TYPE_DH_PUBLIC_KEY(group) \
798 ((psa_key_type_t)(0x4200 | (group)))
799
812#define PSA_DH_FAMILY_RFC7919 ((psa_dh_family_t)0x03)
813
824#define PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY(type) \
825 ((psa_key_type_t)((type) | 0x3000))
826
836#define PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) \
837 ((psa_key_type_t)((type) & ~0x3000))
838
844#define PSA_KEY_TYPE_IS_DH(type) \
845 ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) & 0xff00) == 0x4200)
846
852#define PSA_KEY_TYPE_IS_DH_KEY_PAIR(type) \
853 (((type) & 0xff00) == 0x7200)
854
860#define PSA_KEY_TYPE_IS_DH_PUBLIC_KEY(type) \
861 (((type) & 0xff00) == 0x4200)
862
872#define PSA_KEY_TYPE_DH_GET_FAMILY(type) \
873 ((psa_dh_family_t)((type) & 0x00ff))
874
875#ifdef __cplusplus
876}
877#endif
878
uint16_t psa_key_type_t
Encoding of a key type.
Definition type.h:44
uint8_t psa_ecc_family_t
The type of PSA elliptic curve family identifiers.
Definition type.h:56
uint8_t psa_dh_family_t
The type of PSA finite-field Diffie-Hellman group family identifiers.
Definition type.h:68