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#define SHA_LENGTH (256/8)
38#define AES256 1
39#endif /*DOXYGEN_SHOULD_SKIP_THIS*/
40
41#include "sha3.h"
42#include "ed25519/ed25519.h"
43
44#if CRYPTLIB==MBEDCRYPT
45#ifndef DOXYGEN_SHOULD_SKIP_THIS
46# define MBEDTLS_CONFIG_FILE "mbed-crypto-config.h"
47#endif /*DOXYGEN_SHOULD_SKIP_THIS*/
48# include "mbedtls/gcm.h"
49# include "mbedtls/aes.h"
50#elif CRYPTLIB==WOLFCRYPT
51#ifndef DOXYGEN_SHOULD_SKIP_THIS
52# define HAVE_AESGCM 1
53# define HAVE_AES_CBC 1
54# define HAVE_AES_DECRYPT 1
55# define HAVE_FIPS 1
56# define HAVE_FIPS_VERSION 2
57# define HAVE_ED25519 1
58# define HAVE_ED25519_SIGN 1
59# define HAVE_ED25519_VERIFY 1
60# define WOLFSSL_SHA3 1
61# define WOLF_CRYPT_PORT_H
62#endif /*DOXYGEN_SHOULD_SKIP_THIS*/
63# include "wolfssl/wolfcrypt/sha3.h"
64# include "wolfssl/wolfcrypt/aes.h"
65# include "wolfssl/wolfcrypt/sha512.h"
66# include "wolfssl/wolfcrypt/ed25519.h"
67#else
68# include "tiny_AES_c/aes.h"
69#endif
70
71#ifndef DOXYGEN_SHOULD_SKIP_THIS
72#define TEE_OBJECT_NONCE_SIZE 16
73#define TEE_OBJECT_KEY_SIZE 32
74#define TEE_OBJECT_SKEY_SIZE 64
75#define TEE_OBJECT_AAD_SIZE 16
76#define TEE_OBJECT_TAG_SIZE 16
77#endif /*DOXYGEN_SHOULD_SKIP_THIS*/
78
80{
81 int mode;
82 int flags;
83 int alg;
84#if CRYPTLIB==MBEDCRYPT
85 sha3_ctx_t ctx;
86 mbedtls_aes_context aectx;
87 mbedtls_gcm_context aegcmctx;
88#elif CRYPTLIB==WOLFCRYPT
89 wc_Sha3 ctx;
90 Aes aectx;
91 Aes aegcmctx;
92 unsigned int aegcm_aadsz;
93 unsigned char aegcm_aad[TEE_OBJECT_AAD_SIZE];
94 ed25519_key key;
95#else
96 sha3_ctx_t ctx;
97 struct AES_ctx aectx;
98#endif
99 int aegcm_state;
100 unsigned char aeiv[TEE_OBJECT_NONCE_SIZE];
101 unsigned char aekey[32];
102 unsigned char pubkey[TEE_OBJECT_KEY_SIZE];
103 unsigned char prikey[TEE_OBJECT_SKEY_SIZE];
104};
105
107{
108 unsigned int type;
109 int flags;
110 int desc;
111#if CRYPTLIB==MBEDCRYPT
112 mbedtls_aes_context persist_ctx;
113 unsigned char persist_iv[TEE_OBJECT_NONCE_SIZE];
114#elif CRYPTLIB==WOLFCRYPT
115 Aes persist_ctx;
116 unsigned char persist_iv[TEE_OBJECT_NONCE_SIZE];
117 ed25519_key key;
118#else
119 struct AES_ctx persist_ctx;
120#endif
121 unsigned char public_key[TEE_OBJECT_KEY_SIZE];
122 unsigned char private_key[TEE_OBJECT_SKEY_SIZE];
123};
124
125// Minimal constant definitions
126#ifndef DOXYGEN_SHOULD_SKIP_THIS
127#define TEE_HANDLE_NULL 0
128#endif /*DOXYGEN_SHOULD_SKIP_THIS*/
129
130#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