TA-REF
tee_api_tee_types.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (C) 2019 National Institute of Advanced Industrial Science
5 * and Technology (AIST)
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef TEE_API_TYPES_KEYSTONE_H
32#define TEE_API_TYPES_KEYSTONE_H
33
34#ifndef DOXYGEN_SHOULD_SKIP_THIS
35#define MBEDCRYPT 1
36#define WOLFCRYPT 2
37#endif /*DOXYGEN_SHOULD_SKIP_THIS*/
38
39#if CRYPTLIB==MBEDCRYPT
40#ifndef DOXYGEN_SHOULD_SKIP_THIS
41# define MBEDTLS_CONFIG_FILE "mbed-crypto-config.h"
42# define AES256 1
43#endif /*DOXYGEN_SHOULD_SKIP_THIS*/
44# include "mbedtls/gcm.h"
45# include "mbedtls/aes.h"
46# include "sha3.h"
47# include "ed25519/ed25519.h"
48#elif CRYPTLIB==WOLFCRYPT
49#ifndef DOXYGEN_SHOULD_SKIP_THIS
50# define HAVE_AESGCM 1
51# define HAVE_AES_CBC 1
52# define HAVE_AES_DECRYPT 1
53# define HAVE_FIPS 1
54# define HAVE_FIPS_VERSION 2
55# define HAVE_ED25519 1
56# define HAVE_ED25519_SIGN 1
57# define HAVE_ED25519_VERIFY 1
58# define WOLFSSL_SHA512 1
59# define WOLFSSL_SHA3 1
60# define WOLFSSL_SHA3_SMALL 1
61# define WOLFCRYPT_ONLY 1
62# define WOLF_CRYPT_PORT_H
63#endif /*DOXYGEN_SHOULD_SKIP_THIS*/
64# include "wolfssl/wolfcrypt/sha3.h"
65# include "wolfssl/wolfcrypt/aes.h"
66# include "wolfssl/wolfcrypt/sha512.h"
67# include "wolfssl/wolfcrypt/ed25519.h"
68#else
69# include "sha3.h"
70# include "ed25519/ed25519.h"
71# include "tiny_AES_c/aes.h"
72#ifndef DOXYGEN_SHOULD_SKIP_THIS
73# define AES256 1
74#endif /*DOXYGEN_SHOULD_SKIP_THIS*/
75#endif
76
77#ifndef DOXYGEN_SHOULD_SKIP_THIS
78#define SHA_LENGTH (256/8)
79#define TEE_OBJECT_NONCE_SIZE 16
80#define TEE_OBJECT_KEY_SIZE 32
81#define TEE_OBJECT_SKEY_SIZE 64
82#define TEE_OBJECT_AAD_SIZE 16
83#define TEE_OBJECT_TAG_SIZE 16
84#endif /*DOXYGEN_SHOULD_SKIP_THIS*/
85
87{
88 int mode;
89 int flags;
90 int alg;
91#if CRYPTLIB==MBEDCRYPT
92 sha3_ctx_t ctx;
93 mbedtls_aes_context aectx;
94 mbedtls_gcm_context aegcmctx;
95#elif CRYPTLIB==WOLFCRYPT
96 wc_Sha3 ctx;
97 Aes aectx;
98 Aes aegcmctx;
99 unsigned int aegcm_aadsz;
100 unsigned char aegcm_aad[TEE_OBJECT_AAD_SIZE];
101 ed25519_key key;
102#else
103 sha3_ctx_t ctx;
104 struct AES_ctx aectx;
105#endif
107 unsigned char aeiv[TEE_OBJECT_NONCE_SIZE];
108 unsigned char aekey[32];
109 unsigned char pubkey[TEE_OBJECT_KEY_SIZE];
110 unsigned char prikey[TEE_OBJECT_SKEY_SIZE];
111};
112
114{
115 unsigned int type;
116 int flags;
117 int desc;
118#if CRYPTLIB==MBEDCRYPT
119 mbedtls_aes_context persist_ctx;
120 unsigned char persist_iv[TEE_OBJECT_NONCE_SIZE];
121#elif CRYPTLIB==WOLFCRYPT
122 Aes persist_ctx;
123 unsigned char persist_iv[TEE_OBJECT_NONCE_SIZE];
124 ed25519_key key;
125#else
126 struct AES_ctx persist_ctx;
127#endif
128 unsigned char public_key[TEE_OBJECT_KEY_SIZE];
129 unsigned char private_key[TEE_OBJECT_SKEY_SIZE];
130};
131
132// defined in tee_api_defines.h
133// enum Data_Flag_Constants {
134// TEE_DATA_FLAG_ACCESS_READ = 0x00000001,
135// TEE_DATA_FLAG_ACCESS_WRITE = 0x00000002,
136// //TEE_DATA_FLAG_ACCESS_WRITE_META = 0x00000004,
137// //TEE_DATA_FLAG_SHARE_READ = 0x00000010,
138// //TEE_DATA_FLAG_SHARE_WRITE = 0x00000020,
139// TEE_DATA_FLAG_OVERWRITE = 0x00000400
140// };
141// enum Data_Flag_Constants {
142// TEE_DATA_FLAG_ACCESS_READ = 0x00000001,
143// TEE_DATA_FLAG_ACCESS_WRITE = 0x00000002,
144// //TEE_DATA_FLAG_ACCESS_WRITE_META = 0x00000004,
145// //TEE_DATA_FLAG_SHARE_READ = 0x00000010,
146// //TEE_DATA_FLAG_SHARE_WRITE = 0x00000020,
147// TEE_DATA_FLAG_OVERWRITE = 0x00000400
148// };
149#endif
Definition: tee_api_tee_types.h:87
mbedtls_gcm_context aegcmctx
Definition: tee_api_tee_types.h:94
int flags
Definition: tee_api_tee_types.h:89
unsigned char aeiv[TEE_OBJECT_NONCE_SIZE]
Definition: tee_api_tee_types.h:107
int aegcm_state
Definition: tee_api_tee_types.h:106
unsigned char prikey[TEE_OBJECT_SKEY_SIZE]
Definition: tee_api_tee_types.h:110
mbedtls_aes_context aectx
Definition: tee_api_tee_types.h:93
unsigned char pubkey[TEE_OBJECT_KEY_SIZE]
Definition: tee_api_tee_types.h:109
unsigned char aekey[32]
Definition: tee_api_tee_types.h:108
sha3_ctx_t ctx
Definition: tee_api_tee_types.h:92
int alg
Definition: tee_api_tee_types.h:90
int mode
Definition: tee_api_tee_types.h:88
Definition: tee_api_tee_types.h:114
int desc
Definition: tee_api_tee_types.h:117
unsigned int type
Definition: tee_api_tee_types.h:115
int flags
Definition: tee_api_tee_types.h:116
mbedtls_aes_context persist_ctx
Definition: tee_api_tee_types.h:119
unsigned char persist_iv[TEE_OBJECT_NONCE_SIZE]
Definition: tee_api_tee_types.h:120
unsigned char private_key[TEE_OBJECT_SKEY_SIZE]
Definition: tee_api_tee_types.h:129
unsigned char public_key[TEE_OBJECT_KEY_SIZE]
Definition: tee_api_tee_types.h:128