• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 #ifndef __CRYPTO_WRAPPER_H__
13 #define __CRYPTO_WRAPPER_H__
14 
15 #include <stdint.h>
16 #include <tee_defines.h>
17 #include <chinadrm.h>
18 #include "crypto_aes_wrapper.h"
19 #include "crypto_ec_wrapper.h"
20 #include "crypto_rsa_wrapper.h"
21 #include "crypto_x509_wrapper.h"
22 #include "crypto_inner_wrapper.h"
23 
24 #define SHA256_LEN                   32
25 #define OEM_KEY_LEN                  16
26 #define ECC_P256_PRIV_LEN            64
27 #define ECC_P256_PUB_LEN             32
28 #define ATTEST_TBS_MAXSIZE           512
29 #define ATTESTATION_KEY_USAGE_OFFSET 16
30 #define EC_FIX_BUFFER_LEN            66
31 #define SHA256_HASH_LEN              32
32 
33 /* macro in tomcrypto start */
34 /* ECC domain id */
35 #define NIST_P192                    0
36 #define NIST_P224                    1
37 #define NIST_P256                    2
38 #define NIST_P384                    3
39 #define NIST_P521                    4
40 
41 #define SHA1_HASH                    1
42 #define SHA224_HASH                  2
43 #define SHA256_HASH                  3
44 #define SHA384_HASH                  4
45 #define SHA512_HASH                  5
46 /* Algorithm id */
47 #define RSA_ALG                      0
48 #define ECC_ALG                      1
49 /* macro in tomcrypto end */
50 #define DIR_ENC                      0
51 #define DIR_DEC                      1
52 
53 #define CRYPTO_NUMBER_TWO            2
54 #define CRYPTO_NUMBER_THREE          3
55 #define CRYPTO_NUMBER_FOUR           4
56 #define CRYPTO_NUMBER_FIVE           5
57 #define CRYPTO_NUMBER_SIX            6
58 #define CRYPTO_NUMBER_SEVEN          7
59 #define CRYPTO_NUMBER_EIGHT          8
60 #define VALIDITY_TIME_SIZE           13
61 #define SECRET_KEY_MAX_LEN           64
62 #define CER_PUBLIC_KEY_MAX_LEN       300
63 #define VALIDITY_FIX_LEN             32
64 #define KEY_USAGE_FIX_LEN            41
65 #define ITEM_THREE_ADD_LEN           12
66 #define ITEM_THREE_MOVE_LEN          27
67 #define ITEM_TWO_ADD_LEN             23
68 
69 /* table struct for match convert */
70 typedef struct {
71     uint32_t src;
72     uint32_t dest;
73 } crypto_u2u;
74 
75 #endif
76