julhal01 | 734dbad | 2020-12-21 10:27:41 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. |
| 3 | * SPDX-License-Identifier: BSD-3-Clause |
| 4 | */ |
| 5 | |
| 6 | #ifndef TS_CRYPTO_KEY_ATTRIBUTES_H |
| 7 | #define TS_CRYPTO_KEY_ATTRIBUTES_H |
| 8 | |
| 9 | #include <stdint.h> |
| 10 | |
| 11 | /* Key types */ |
| 12 | #define TS_CRYPTO_KEY_TYPE_NONE (0x0000) |
| 13 | #define TS_CRYPTO_KEY_TYPE_RAW_DATA (0x1001) |
| 14 | #define TS_CRYPTO_KEY_TYPE_HMAC (0x1100) |
| 15 | #define TS_CRYPTO_KEY_TYPE_DERIVE (0x1200) |
| 16 | #define TS_CRYPTO_KEY_TYPE_AES (0x2400) |
| 17 | #define TS_CRYPTO_KEY_TYPE_DES (0x2301) |
| 18 | #define TS_CRYPTO_KEY_TYPE_CAMELLIA (0x2403) |
| 19 | #define TS_CRYPTO_KEY_TYPE_ARC4 (0x2002) |
| 20 | #define TS_CRYPTO_KEY_TYPE_CHACHA20 (0x2004) |
| 21 | #define TS_CRYPTO_KEY_TYPE_RSA_PUBLIC_KEY (0x4001) |
| 22 | #define TS_CRYPTO_KEY_TYPE_RSA_KEY_PAIR (0x7001) |
| 23 | #define TS_CRYPTO_KEY_TYPE_ECC_PUBLIC_KEY_BASE (0x4100) |
| 24 | #define TS_CRYPTO_KEY_TYPE_ECC_KEY_PAIR_BASE (0x7100) |
| 25 | #define TS_CRYPTO_KEY_TYPE_ECC_CURVE_MASK (0x00ff) |
| 26 | #define TS_CRYPTO_KEY_TYPE_DH_PUBLIC_KEY_BASE (0x4200) |
| 27 | #define TS_CRYPTO_KEY_TYPE_DH_KEY_PAIR_BASE (0x7200) |
| 28 | #define TS_CRYPTO_KEY_TYPE_DH_GROUP_MASK (0x00ff) |
| 29 | |
| 30 | /* ECC curves for use with ECC Key types */ |
| 31 | #define TS_CRYPTO_ECC_CURVE_NONE (0x00) |
| 32 | #define TS_CRYPTO_ECC_CURVE_SECP_K1 (0x17) |
| 33 | #define TS_CRYPTO_ECC_CURVE_SECP_R1 (0x12) |
| 34 | #define TS_CRYPTO_ECC_CURVE_SECP_R2 (0x1b) |
| 35 | #define TS_CRYPTO_ECC_CURVE_SECT_K1 (0x27) |
| 36 | #define TS_CRYPTO_ECC_CURVE_SECT_R1 (0x22) |
| 37 | #define TS_CRYPTO_ECC_CURVE_SECT_R2 (0x2b) |
| 38 | #define TS_CRYPTO_ECC_CURVE_BRAINPOOL_P_R1 (0x30) |
| 39 | #define TS_CRYPTO_ECC_CURVE_MONTGOMERY (0x41) |
| 40 | |
| 41 | /* Diffie-Hellman groups for use with DH key types */ |
| 42 | #define TS_CRYPTO_DH_GROUP_NONE (0x00) |
| 43 | #define TS_CRYPTO_DH_GROUP_RFC7919 (0x03) |
| 44 | |
| 45 | /* Crypto algorithms */ |
| 46 | #define TS_CRYPTO_ALG_NONE (0x00000000) |
| 47 | #define TS_CRYPTO_ALG_HASH_MASK (0x000000ff) |
| 48 | #define TS_CRYPTO_ALG_MD2 (0x01000001) |
| 49 | #define TS_CRYPTO_ALG_MD4 (0x01000002) |
| 50 | #define TS_CRYPTO_ALG_MD5 (0x01000003) |
| 51 | #define TS_CRYPTO_ALG_RIPEMD160 (0x01000004) |
| 52 | #define TS_CRYPTO_ALG_SHA_1 (0x01000005) |
| 53 | #define TS_CRYPTO_ALG_SHA_224 (0x01000008) |
| 54 | #define TS_CRYPTO_ALG_SHA_256 (0x01000009) |
| 55 | #define TS_CRYPTO_ALG_SHA_384 (0x0100000a) |
| 56 | #define TS_CRYPTO_ALG_SHA_512 (0x0100000b) |
| 57 | #define TS_CRYPTO_ALG_SHA_512_224 (0x0100000c) |
| 58 | #define TS_CRYPTO_ALG_SHA_512_256 (0x0100000d) |
| 59 | #define TS_CRYPTO_ALG_SHA3_224 (0x01000010) |
| 60 | #define TS_CRYPTO_ALG_SHA3_256 (0x01000011) |
| 61 | #define TS_CRYPTO_ALG_SHA3_384 (0x01000012) |
| 62 | #define TS_CRYPTO_ALG_SHA3_512 (0x01000013) |
| 63 | #define TS_CRYPTO_ALG_CBC_MAC (0x02c00001) |
| 64 | #define TS_CRYPTO_ALG_CMAC (0x02c00002) |
| 65 | #define TS_CRYPTO_ALG_ARC4 (0x04800001) |
| 66 | #define TS_CRYPTO_ALG_CHACHA20 (0x04800005) |
| 67 | #define TS_CRYPTO_ALG_CTR (0x04c00001) |
| 68 | #define TS_CRYPTO_ALG_CFB (0x04c00002) |
| 69 | #define TS_CRYPTO_ALG_OFB (0x04c00003) |
| 70 | #define TS_CRYPTO_ALG_XTS (0x044000ff) |
| 71 | #define TS_CRYPTO_ALG_CBC_NO_PADDING (0x04600100) |
| 72 | #define TS_CRYPTO_ALG_CBC_PKCS7 (0x04600101) |
| 73 | #define TS_CRYPTO_ALG_AEAD_FROM_BLOCK_FLAG (0x00400000) |
| 74 | #define TS_CRYPTO_ALG_CCM (0x06401001) |
| 75 | #define TS_CRYPTO_ALG_GCM (0x06401002) |
| 76 | #define TS_CRYPTO_ALG_CHACHA20_POLY1305 (0x06001005) |
| 77 | #define TS_CRYPTO_ALG_RSA_PKCS1V15_SIGN_BASE (0x10020000) |
| 78 | #define TS_CRYPTO_ALG_RSA_PSS_BASE (0x10030000) |
| 79 | #define TS_CRYPTO_ALG_ECDSA_BASE (0x10060000) |
| 80 | #define TS_CRYPTO_ALG_DETERMINISTIC_ECDSA_BASE (0x10070000) |
| 81 | #define TS_CRYPTO_ALG_RSA_PKCS1V15_CRYPT (0x12020000) |
| 82 | #define TS_CRYPTO_ALG_RSA_OAEP_BASE (0x12030000) |
| 83 | #define TS_CRYPTO_ALG_HKDF_BASE (0x20000100) |
| 84 | #define TS_CRYPTO_ALG_TLS12_PRF_BASE (0x20000200) |
| 85 | #define TS_CRYPTO_ALG_TLS12_PSK_TO_MS_BASE (0x20000300) |
| 86 | #define TS_CRYPTO_ALG_KEY_DERIVATION_MASK (0x0803ffff) |
| 87 | #define TS_CRYPTO_ALG_KEY_AGREEMENT_MASK (0x10fc0000) |
| 88 | #define TS_CRYPTO_ALG_FFDH (0x30100000) |
| 89 | #define TS_CRYPTO_ALG_ECDH (0x30200000) |
| 90 | |
| 91 | /* Key lifetime */ |
| 92 | #define TS_CRYPTO_KEY_LIFETIME_VOLATILE (0x00000000) |
| 93 | #define TS_CRYPTO_KEY_LIFETIME_PERSISTENT (0x00000001) |
| 94 | |
| 95 | /* Key usage constraints */ |
| 96 | #define TS_CRYPTO_KEY_USAGE_NONE (0x00000000) |
| 97 | #define TS_CRYPTO_KEY_USAGE_EXPORT (0x00000001) |
| 98 | #define TS_CRYPTO_KEY_USAGE_COPY (0x00000002) |
| 99 | #define TS_CRYPTO_KEY_USAGE_ENCRYPT (0x00000100) |
| 100 | #define TS_CRYPTO_KEY_USAGE_DECRYPT (0x00000200) |
| 101 | #define TS_CRYPTO_KEY_USAGE_SIGN_HASH (0x00000400) |
| 102 | #define TS_CRYPTO_KEY_USAGE_VERIFY_HASH (0x00000800) |
| 103 | #define TS_CRYPTO_KEY_USAGE_DERIVE (0x00001000) |
| 104 | |
| 105 | /* Key policy to define what key can be used for */ |
| 106 | struct __attribute__ ((__packed__)) ts_crypto_key_policy |
| 107 | { |
| 108 | uint32_t usage; |
| 109 | uint32_t alg; |
| 110 | }; |
| 111 | |
| 112 | /* Key attributes object */ |
| 113 | struct __attribute__ ((__packed__)) ts_crypto_key_attributes |
| 114 | { |
| 115 | uint32_t type; |
| 116 | uint32_t key_bits; |
| 117 | uint32_t lifetime; |
| 118 | uint32_t id; |
| 119 | struct ts_crypto_key_policy policy; |
| 120 | }; |
| 121 | |
| 122 | #endif /* TS_CRYPTO_KEY_ATTRIBUTES_H */ |