1 /******************************************************************************
2  * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
3  * All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************/
18 #ifndef ECC_LL_H_
19 #define ECC_LL_H_
20 
21 #include "algorithm/ecc/ecc_curve.h"
22 
23 extern const u8 blt_ecc_dbg_priv_key192[24];
24 extern const u8 blt_ecc_dbg_pub_key192[48];
25 
26 extern const u8 blt_ecc_dbg_priv_key256[32];
27 extern const u8 blt_ecc_dbg_pub_key256[64];
28 
29 
30 /**
31 * @brief		This function is used to register the random number function needed for ECC calculation
32 * @param		none
33 * @return		none
34 */
35 void 			blt_ecc_init(void);
36 
37 /**
38 * @brief		This function is used to generate an ECDH public-private key pairs
39 * @param[out]  pub[64]:  output ecdh public key
40 * @param[out]  priv[64]: output ecdh private key
41 * @param[in]   use_dbg_key: 0: Non-debug key , others: debug key
42 * @return		1:  success
43 *              0: failure
44 */
45 int 			blt_ecc_gen_key_pair(unsigned char *pub, unsigned char *priv, ecc_curve_t curve, bool use_dbg_key);
46 
47 /**
48 * @brief		This function is used to calculate DHKEY based on the peer public key and own private key
49 * @param[in]   peer_pub_key[64]: peer public key
50 * @param[in]   own_priv_key[32]: own private key
51 * @param[out]  out_dhkey[32]: dhkey key
52 * @return		1:  success
53 *              0: failure
54 */
55 int 			blt_ecc_gen_dhkey(const unsigned char *peer_pub, const unsigned char *own_priv, unsigned char *out_dhkey, ecc_curve_t curve);
56 
57 
58 
59 
60 #endif /* ECC_LL_H_ */
61 
62 
63 
64 
65