1 /* 2 * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #include <stdint.h> 10 #include "sdkconfig.h" 11 #include "mbedtls/pk.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #if CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN || __DOXYGEN__ 18 19 /** 20 * @brief Initialize MPI to notify mbedtls_ecdsa_sign to use the private key in efuse 21 * We break the MPI struct of the private key in order to 22 * differentiate between hardware key and software key 23 * 24 * @param key The MPI in which this functions stores the hardware context. 25 * This must be uninitialized 26 * @param efuse_blk The efuse key block that should be used as the private key. 27 * The key purpose of this block must be ECDSA_KEY 28 * 29 * @return - 0 if successful 30 * - -1 otherwise 31 * 32 */ 33 int esp_ecdsa_privkey_load_mpi(mbedtls_mpi *key, int efuse_blk); 34 35 /** 36 * @brief Initialize PK context to notify mbedtls_ecdsa_sign to use the private key in efuse 37 * We break the MPI struct used to represent the private key `d` in ECP keypair 38 * in order to differentiate between hardware key and software key 39 * 40 * @param key_ctx The context in which this functions stores the hardware context. 41 * This must be uninitialized 42 * @param efuse_blk The efuse key block that should be used as the private key. 43 * The key purpose of this block must be ECDSA_KEY 44 * 45 * @return - 0 if successful 46 * - -1 otherwise 47 */ 48 int esp_ecdsa_privkey_load_pk_context(mbedtls_pk_context *key_ctx, int efuse_blk); 49 50 #endif // CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN || __DOXYGEN__ 51 52 #ifdef __cplusplus 53 } 54 #endif 55