1 /***************************************************************************//** 2 * \file cy_cryptolite_ecc_key_gen.h 3 * \version 2.30 4 * 5 * \brief 6 * This file provides API for generating ECC key. 7 * 8 ******************************************************************************** 9 * Copyright 2023 Cypress Semiconductor Corporation 10 * SPDX-License-Identifier: Apache-2.0 11 * 12 * Licensed under the Apache License, Version 2.0 (the "License"); 13 * you may not use this file except in compliance with the License. 14 * You may obtain a copy of the License at 15 * 16 * http://www.apache.org/licenses/LICENSE-2.0 17 * 18 * Unless required by applicable law or agreed to in writing, software 19 * distributed under the License is distributed on an "AS IS" BASIS, 20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 * See the License for the specific language governing permissions and 22 * limitations under the License. 23 *******************************************************************************/ 24 25 #if !defined (CY_CRYPTOLITE_ECC_KEY_GEN_H) 26 #define CY_CRYPTOLITE_ECC_KEY_GEN_H 27 28 #include "cy_device.h" 29 30 #if defined (CY_IP_MXCRYPTOLITE) 31 32 #if defined(__cplusplus) 33 extern "C" { 34 #endif 35 36 #include "cy_cryptolite_common.h" 37 #include "cy_cryptolite_vu.h" 38 #include "cy_cryptolite_ecdsa.h" 39 40 #if (CRYPTOLITE_VU_PRESENT == 1) 41 #if defined(CY_CRYPTOLITE_CFG_ECP_C) 42 43 44 45 /** Pointer to a random number supplier function */ 46 typedef int (*cy_func_get_random_data_t)(void *rndInfo, uint8_t *rndData, size_t rndSize); 47 48 /** 49 * \addtogroup group_cryptolite_lld_keygen_functions 50 * \{ 51 */ 52 53 /******************************************************************************* 54 * Function Name: Cy_Cryptolite_ECC_MakeKeyPair 55 ****************************************************************************//** 56 * 57 * Generate a Private & Public Key pair. 58 * 59 * \param base 60 * The pointer to a Cryptolite instance. 61 * 62 * \param cfContext 63 * The pointer to the cy_stc_cryptolite_context_ecdsa_t. 64 * 65 * \param curveID 66 * The ECC curve id. 67 * 68 * \param key 69 * The ECC key. See \ref cy_stc_cryptolite_ecc_key. 70 * 71 * \param GetRandomDataFunc 72 * See \ref cy_func_get_random_data_t. 73 * 74 * \param randomDataInfo 75 * 76 * \return status code. See \ref cy_en_cryptolite_status_t. 77 * 78 *******************************************************************************/ 79 cy_en_cryptolite_status_t Cy_Cryptolite_ECC_MakeKeyPair(CRYPTOLITE_Type *base, 80 cy_stc_cryptolite_context_ecdsa_t *cfContext, 81 cy_en_cryptolite_ecc_curve_id_t curveID, 82 cy_stc_cryptolite_ecc_key *key, 83 cy_func_get_random_data_t GetRandomDataFunc, void *randomDataInfo); 84 85 86 87 /******************************************************************************* 88 * Function Name: Cy_Cryptolite_ECC_MakePrivateKey 89 ****************************************************************************//** 90 * 91 * Generate a Private key. 92 * 93 * \param base 94 * The pointer to a Cryptolite instance. 95 * 96 * \param cfContext 97 * The pointer to the cy_stc_cryptolite_context_ecdsa_t. 98 * 99 * \param curveID 100 * The ECC curve id. 101 * 102 * \param privateKey 103 * The pointer to the ECC private key. 104 * 105 * \param GetRandomDataFunc 106 * See \ref cy_func_get_random_data_t. 107 * 108 * \param randomDataInfo 109 * 110 * \return status code. See \ref cy_en_cryptolite_status_t. 111 * 112 *******************************************************************************/ 113 cy_en_cryptolite_status_t Cy_Cryptolite_ECC_MakePrivateKey(CRYPTOLITE_Type *base, 114 cy_stc_cryptolite_context_ecdsa_t *cfContext, 115 cy_en_cryptolite_ecc_curve_id_t curveID, 116 const uint8_t *privateKey, 117 cy_func_get_random_data_t GetRandomDataFunc, void *randomDataInfo); 118 119 120 /******************************************************************************* 121 * Function Name: Cy_Cryptolite_ECC_MakePublicKey 122 ****************************************************************************//** 123 * 124 * Generate a public key. 125 * 126 * \param base 127 * The pointer to a Cryptolite instance. 128 * 129 * \param cfContext 130 * The pointer to the cy_stc_cryptolite_context_ecdsa_t. 131 * 132 * \param curveID 133 * The ECC curve id. 134 * 135 * \param privateKey 136 * The pointer to the ECC private key. 137 * 138 * \param publicKey 139 * The generated public ECC key. See \ref cy_stc_cryptolite_ecc_key. 140 * 141 * \return status code. See \ref cy_en_cryptolite_status_t. 142 * 143 *******************************************************************************/ 144 cy_en_cryptolite_status_t Cy_Cryptolite_ECC_MakePublicKey(CRYPTOLITE_Type *base, 145 cy_stc_cryptolite_context_ecdsa_t *cfContext, 146 cy_en_cryptolite_ecc_curve_id_t curveID, 147 const uint8_t *privateKey, 148 cy_stc_cryptolite_ecc_key *publicKey); 149 150 /** \} group_cryptolite_lld_keygen_functions */ 151 152 #endif /* #if (CY_CRYPTOLITE_CFG_ECP_C) */ 153 #endif /* #if (CPUSS_CRYPTOLITE_VU == 1) */ 154 155 #if defined(__cplusplus) 156 } 157 #endif 158 159 #endif /* CY_IP_MXCRYPTOLITE */ 160 #endif /* #if !defined (CY_CRYPTOLITE_ECC_KEY_GEN_H) */ 161 162 /* [] END OF FILE */ 163