forked from wolfSSL/wolfssl
Fixups to the SE050 ECC pkey insert function
This commit is contained in:
@ -65,6 +65,10 @@ struct ecc_key;
|
|||||||
#define SE050_ECC_DER_MAX 256
|
#define SE050_ECC_DER_MAX 256
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SE050_KEYID_START
|
||||||
|
#define SE050_KEYID_START 100
|
||||||
|
#endif
|
||||||
|
|
||||||
/* enable for debugging */
|
/* enable for debugging */
|
||||||
/* #define SE050_DEBUG*/
|
/* #define SE050_DEBUG*/
|
||||||
/* enable to factory erase chip */
|
/* enable to factory erase chip */
|
||||||
@ -122,7 +126,7 @@ int wc_se050_init(const char* portName)
|
|||||||
int se050_allocate_key(int keyType)
|
int se050_allocate_key(int keyType)
|
||||||
{
|
{
|
||||||
int keyId = -1;
|
int keyId = -1;
|
||||||
static int keyId_allocator = 100;
|
static int keyId_allocator = SE050_KEYID_START;
|
||||||
switch (keyType) {
|
switch (keyType) {
|
||||||
case SE050_AES_KEY:
|
case SE050_AES_KEY:
|
||||||
case SE050_ECC_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,
|
int se050_ecc_insert_private_key(int keyId, const byte* eccDer,
|
||||||
word32 eccDerSize)
|
word32 eccDerSize)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
struct ecc_key key;
|
struct ecc_key key;
|
||||||
sss_object_t newKey;
|
sss_object_t newKey;
|
||||||
sss_key_store_t host_keystore;
|
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 */
|
/* Avoid key ID conflicts with temporary key storage */
|
||||||
if (keyId >= 100) {
|
if (keyId >= SE050_KEYID_START) {
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,10 +560,8 @@ int se050_ecc_insert_private_key(int keyId, const byte* eccDer,
|
|||||||
}
|
}
|
||||||
wolfSSL_CryptHwMutexUnLock();
|
wolfSSL_CryptHwMutexUnLock();
|
||||||
|
|
||||||
if (status == kStatus_SSS_Success) {
|
wc_ecc_free(&key);
|
||||||
ret = 0;
|
if (status != kStatus_SSS_Success) {
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = WC_HW_E;
|
ret = WC_HW_E;
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,8 @@ WOLFSSL_API int wc_se050_set_config(sss_session_t *pSession,
|
|||||||
#ifdef WOLFSSL_SE050_INIT
|
#ifdef WOLFSSL_SE050_INIT
|
||||||
WOLFSSL_API int wc_se050_init(const char* portName);
|
WOLFSSL_API int wc_se050_init(const char* portName);
|
||||||
#endif
|
#endif
|
||||||
|
WOLFSSL_API int se050_ecc_insert_private_key(int keyId, const byte* eccDer,
|
||||||
|
word32 eccDerSize);
|
||||||
|
|
||||||
/* Private Functions */
|
/* Private Functions */
|
||||||
WOLFSSL_LOCAL int se050_allocate_key(int keyType);
|
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,
|
WOLFSSL_LOCAL int se050_ecc_shared_secret(struct ecc_key* private_key,
|
||||||
struct ecc_key* public_key, byte* out, word32* outlen);
|
struct ecc_key* public_key, byte* out, word32* outlen);
|
||||||
WOLFSSL_LOCAL void se050_ecc_free_key(struct ecc_key* key);
|
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;
|
struct ed25519_key;
|
||||||
WOLFSSL_LOCAL int se050_ed25519_create_key(struct ed25519_key* key);
|
WOLFSSL_LOCAL int se050_ed25519_create_key(struct ed25519_key* key);
|
||||||
|
Reference in New Issue
Block a user