• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 * @brief		This function is used to register the random number function needed for ECC calculation
31 * @param		none
32 * @return		none
33 */
34 void blt_ecc_init(void);
35 
36 /**
37 * @brief		This function is used to generate an ECDH public-private key pairs
38 * @param[out]  pub[64]:  output ecdh public key
39 * @param[out]  priv[64]: output ecdh private key
40 * @param[in]   use_dbg_key: 0: Non-debug key , others: debug key
41 * @return		1:  success
42 *              0: failure
43 */
44 int blt_ecc_gen_key_pair(unsigned char *pub, unsigned char *priv, ecc_curve_t curve, bool use_dbg_key);
45 
46 /**
47 * @brief		This function is used to calculate DHKEY based on the peer public key and own private key
48 * @param[in]   peer_pub_key[64]: peer public key
49 * @param[in]   own_priv_key[32]: own private key
50 * @param[out]  out_dhkey[32]: dhkey key
51 * @return		1:  success
52 *              0: failure
53 */
54 int blt_ecc_gen_dhkey(const unsigned char *peer_pub, const unsigned char *own_priv, unsigned char *out_dhkey,
55                       ecc_curve_t curve);
56 
57 #endif /* ECC_LL_H_ */
58