• 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 
13 #ifndef __CRYPTO_INNER_INTERFACE_H__
14 #define __CRYPTO_INNER_INTERFACE_H__
15 
16 #include "crypto_wrapper.h"
17 #define TBL_HEADER_FIX_LEN 16
18 #define SIGNING_ALGO_LEN   50
19 #define DIGEST_MAX_LEN     64
20 #define SIG_MAX_LEN        512
21 #define ALGO_TLV_MAX_LEN   50
22 #define HASH_LEN           32
23 
24 #include <openssl/rsa.h>
25 
26 RSA *build_boringssl_pub_key(rsa_pub_key_t *pub);
27 
28 RSA *build_boringssl_priv_key(rsa_priv_key_t *priv);
29 
30 TEE_Result ecc_pubkey_tee_to_boring(void *publickey, EC_KEY **eckey);
31 
32 TEE_Result ecc_privkey_tee_to_boring(void *priv, void **eckey);
33 
34 int32_t get_class_ecc_key(uint8_t *priv, uint32_t priv_len);
35 
36 int32_t ec_nid_tom2boringssl(uint32_t domain);
37 
38 int32_t get_keytype_from_sp(const uint8_t *in, uint32_t inlen);
39 
40 int32_t generate_rsa_from_secret(rsa_priv_key_t *rsa, uint32_t nbits, uint8_t *secret, uint32_t secret_len,
41     const uint8_t *file_name);
42 
43 int32_t derive_private_key_from_secret(void *priv, uint8_t *secret, uint32_t secret_len, uint32_t bits,
44     uint32_t keytype, uint8_t *file_name);
45 
46 #endif
47