mirror of https://github.com/wolfSSL/wolfssl.git
Fixups to the SE050 ECC pkey insert function
parent
ea34fb1643
commit
d7b4abfa0b
|
@ -65,6 +65,10 @@ struct ecc_key;
|
|||
#define SE050_ECC_DER_MAX 256
|
||||
#endif
|
||||
|
||||
#ifndef SE050_KEYID_START
|
||||
#define SE050_KEYID_START 100
|
||||
#endif
|
||||
|
||||
/* enable for debugging */
|
||||
/* #define SE050_DEBUG*/
|
||||
/* enable to factory erase chip */
|
||||
|
@ -122,7 +126,7 @@ int wc_se050_init(const char* portName)
|
|||
int se050_allocate_key(int keyType)
|
||||
{
|
||||
int keyId = -1;
|
||||
static int keyId_allocator = 100;
|
||||
static int keyId_allocator = SE050_KEYID_START;
|
||||
switch (keyType) {
|
||||
case SE050_AES_KEY:
|
||||
case SE050_ECC_KEY:
|
||||
|
@ -504,7 +508,7 @@ static sss_algorithm_t se050_map_hash_alg(int hashLen)
|
|||
int se050_ecc_insert_private_key(int keyId, const byte* eccDer,
|
||||
word32 eccDerSize)
|
||||
{
|
||||
int ret;
|
||||
int ret = 0;
|
||||
struct ecc_key key;
|
||||
sss_object_t newKey;
|
||||
sss_key_store_t host_keystore;
|
||||
|
@ -519,7 +523,7 @@ int se050_ecc_insert_private_key(int keyId, const byte* eccDer,
|
|||
}
|
||||
|
||||
/* Avoid key ID conflicts with temporary key storage */
|
||||
if (keyId >= 100) {
|
||||
if (keyId >= SE050_KEYID_START) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
|
@ -556,10 +560,8 @@ int se050_ecc_insert_private_key(int keyId, const byte* eccDer,
|
|||
}
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
|
||||
if (status == kStatus_SSS_Success) {
|
||||
ret = 0;
|
||||
}
|
||||
else {
|
||||
wc_ecc_free(&key);
|
||||
if (status != kStatus_SSS_Success) {
|
||||
if (ret == 0)
|
||||
ret = WC_HW_E;
|
||||
}
|
||||
|
|
|
@ -95,6 +95,8 @@ WOLFSSL_API int wc_se050_set_config(sss_session_t *pSession,
|
|||
#ifdef WOLFSSL_SE050_INIT
|
||||
WOLFSSL_API int wc_se050_init(const char* portName);
|
||||
#endif
|
||||
WOLFSSL_API int se050_ecc_insert_private_key(int keyId, const byte* eccDer,
|
||||
word32 eccDerSize);
|
||||
|
||||
/* Private Functions */
|
||||
WOLFSSL_LOCAL int se050_allocate_key(int keyType);
|
||||
|
@ -138,8 +140,7 @@ WOLFSSL_LOCAL int se050_ecc_create_key(struct ecc_key* key, int curve_id, int ke
|
|||
WOLFSSL_LOCAL int se050_ecc_shared_secret(struct ecc_key* private_key,
|
||||
struct ecc_key* public_key, byte* out, word32* outlen);
|
||||
WOLFSSL_LOCAL void se050_ecc_free_key(struct ecc_key* key);
|
||||
WOLFSSL_LOCAL int se050_ecc_insert_private_key(int keyId, const byte* eccDer,
|
||||
word32 eccDerSize);
|
||||
|
||||
|
||||
struct ed25519_key;
|
||||
WOLFSSL_LOCAL int se050_ed25519_create_key(struct ed25519_key* key);
|
||||
|
|
Loading…
Reference in New Issue