mirror of https://github.com/wolfSSL/wolfssl.git
SiLabs: address PR comments to cleanup
parent
3abc4719ae
commit
919c2a2dfb
|
@ -4864,7 +4864,7 @@ static int wc_ecc_sign_hash_hw(const byte* in, word32 inlen,
|
|||
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
|
||||
err = silabs_ecc_sign_hash(in, inlen, out, outlen, key);
|
||||
if (err != 0) {
|
||||
return BAD_COND_E;
|
||||
return WC_HW_E;
|
||||
}
|
||||
#elif defined(WOLFSSL_CRYPTOCELL)
|
||||
|
||||
|
@ -6231,7 +6231,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||
word32 msgLenInBytes = hashlen;
|
||||
CRYS_ECPKI_HASH_OpMode_t hash_mode;
|
||||
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
|
||||
byte sigRS[64*2];
|
||||
byte sigRS[ECC_MAX_CRYPTO_HW_SIZE * 2];
|
||||
#elif !defined(WOLFSSL_SP_MATH) || defined(FREESCALE_LTC_ECC)
|
||||
int did_init = 0;
|
||||
ecc_point *mG = NULL, *mQ = NULL;
|
||||
|
@ -6351,9 +6351,9 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||
return err;
|
||||
}
|
||||
|
||||
silabs_ecc_verify_hash(&sigRS[0], keySz*2,
|
||||
hash, hashlen,
|
||||
res, key);
|
||||
err = silabs_ecc_verify_hash(&sigRS[0], keySz*2,
|
||||
hash, hashlen,
|
||||
res, key);
|
||||
|
||||
#else
|
||||
/* checking if private key with no public part */
|
||||
|
|
|
@ -29,6 +29,7 @@ Update was preformed under Simplicity Studio directory:
|
|||
versions requesting too much data or too quickly may result in
|
||||
system reset and setting `SESYSREQ`.
|
||||
|
||||
|
||||
## Benchmarks
|
||||
|
||||
See our [benchmarks](https://www.wolfssl.com/docs/benchmarks/) on the wolfSSL website.
|
||||
|
@ -61,9 +62,6 @@ ECDSA 256 sign 158 ops took 1.010 sec, avg 6.392 ms, 156.436 ops/sec
|
|||
ECDSA 256 verify 148 ops took 1.001 sec, avg 6.764 ms, 147.852 ops/sec
|
||||
```
|
||||
|
||||
### Benchmarks and Memory Use
|
||||
|
||||
|
||||
|
||||
# Support
|
||||
|
||||
|
|
|
@ -33,10 +33,11 @@
|
|||
#include <wolfssl/wolfcrypt/port/silabs/silabs_ecc.h>
|
||||
|
||||
|
||||
#define SILABS_UNSUPPORTED_KEY_TYPE 0xFFFFFFFF
|
||||
|
||||
sl_se_key_type_t silabs_map_key_type (ecc_curve_id curve_id)
|
||||
static sl_se_key_type_t silabs_map_key_type (ecc_curve_id curve_id)
|
||||
{
|
||||
sl_se_key_type_t res = 0;
|
||||
sl_se_key_type_t res = SILABS_UNSUPPORTED_KEY_TYPE;
|
||||
|
||||
switch(curve_id) {
|
||||
case ECC_SECP192R1:
|
||||
|
@ -71,8 +72,7 @@ sl_se_key_type_t silabs_map_key_type (ecc_curve_id curve_id)
|
|||
#endif
|
||||
|
||||
default:
|
||||
WOLFSSL_MSG("silabs_map_key_type() ECC curve unsupported by hardware");
|
||||
res = 0;
|
||||
res = SILABS_UNSUPPORTED_KEY_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -139,12 +139,14 @@ int silabs_ecc_make_key(ecc_key* key, int keysize)
|
|||
sl_status_t sl_stat;
|
||||
|
||||
key->key.type = silabs_map_key_type(key->dp->id);
|
||||
if (SILABS_UNSUPPORTED_KEY_TYPE == key->key.type)
|
||||
return WC_HW_E;
|
||||
|
||||
key->key.size = keysize;
|
||||
key->key.storage.method = SL_SE_KEY_STORAGE_EXTERNAL_PLAINTEXT;
|
||||
key->key.flags = SL_SE_KEY_FLAG_ASYMMETRIC_BUFFER_HAS_PRIVATE_KEY
|
||||
| SL_SE_KEY_FLAG_ASYMMETRIC_BUFFER_HAS_PUBLIC_KEY
|
||||
| SL_SE_KEY_FLAG_ASYMMMETRIC_SIGNING_ONLY
|
||||
;
|
||||
| SL_SE_KEY_FLAG_ASYMMMETRIC_SIGNING_ONLY;
|
||||
|
||||
sl_stat = sl_se_get_storage_size(&key->key, &key->key.storage.location.buffer.size);
|
||||
key->key.storage.location.buffer.pointer = key->key_raw;
|
||||
|
@ -175,12 +177,14 @@ int silabs_ecc_import(ecc_key* key, word32 keysize)
|
|||
word32 used = keysize;
|
||||
|
||||
key->key.type = silabs_map_key_type(key->dp->id);
|
||||
if (SILABS_UNSUPPORTED_KEY_TYPE == key->key.type)
|
||||
return WC_HW_E;
|
||||
|
||||
key->key.size = keysize;
|
||||
key->key.storage.method = SL_SE_KEY_STORAGE_EXTERNAL_PLAINTEXT;
|
||||
key->key.flags = SL_SE_KEY_FLAG_ASYMMETRIC_BUFFER_HAS_PRIVATE_KEY
|
||||
| SL_SE_KEY_FLAG_ASYMMETRIC_BUFFER_HAS_PUBLIC_KEY
|
||||
| SL_SE_KEY_FLAG_ASYMMMETRIC_SIGNING_ONLY
|
||||
;
|
||||
| SL_SE_KEY_FLAG_ASYMMMETRIC_SIGNING_ONLY;
|
||||
|
||||
sl_stat = sl_se_get_storage_size(&key->key, &key->key.storage.location.buffer.size);
|
||||
key->key.storage.location.buffer.pointer = key->key_raw;
|
||||
|
@ -211,11 +215,13 @@ int silabs_ecc_import_private(ecc_key* key, word32 keysize)
|
|||
sl_status_t sl_stat;
|
||||
word32 keySz = keysize;
|
||||
key->key.type = silabs_map_key_type(key->dp->id);
|
||||
if (SILABS_UNSUPPORTED_KEY_TYPE == key->key.type)
|
||||
return WC_HW_E;
|
||||
|
||||
key->key.size = key->dp->size;
|
||||
key->key.storage.method = SL_SE_KEY_STORAGE_EXTERNAL_PLAINTEXT;
|
||||
key->key.flags = SL_SE_KEY_FLAG_ASYMMETRIC_BUFFER_HAS_PRIVATE_KEY
|
||||
| SL_SE_KEY_FLAG_ASYMMMETRIC_SIGNING_ONLY
|
||||
;
|
||||
| SL_SE_KEY_FLAG_ASYMMMETRIC_SIGNING_ONLY;
|
||||
|
||||
sl_stat = sl_se_get_storage_size(&key->key, &key->key.storage.location.buffer.size);
|
||||
key->key.storage.location.buffer.pointer = key->key_raw;
|
||||
|
@ -233,6 +239,9 @@ int silabs_ecc_sig_to_rs(ecc_key* key, word32 keySz)
|
|||
int err = MP_OKAY;
|
||||
|
||||
key->key.type = silabs_map_key_type(key->dp->id);
|
||||
if (SILABS_UNSUPPORTED_KEY_TYPE == key->key.type)
|
||||
return WC_HW_E;
|
||||
|
||||
key->key.size = keySz;
|
||||
key->key.storage.method = SL_SE_KEY_STORAGE_EXTERNAL_PLAINTEXT;
|
||||
key->key.flags = SL_SE_KEY_FLAG_ASYMMETRIC_BUFFER_HAS_PUBLIC_KEY
|
||||
|
@ -294,7 +303,7 @@ int silabs_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key,
|
|||
sl_status_t sl_stat;
|
||||
|
||||
pub_key = public_key->key;
|
||||
pub_key.flags = 0x2000;
|
||||
pub_key.flags = SL_SE_KEY_FLAG_ASYMMETRIC_BUFFER_HAS_PUBLIC_KEY;
|
||||
|
||||
*outlen = pub_key.size * 2;
|
||||
pub_sz = pub_key.size * 2;
|
||||
|
|
|
@ -40,10 +40,10 @@ int wc_silabs_se_hash_init (wc_silabs_sha_t* sha, enum wc_HashType type)
|
|||
int ret = 0;
|
||||
sl_status_t rr;
|
||||
|
||||
// set sizes and state
|
||||
/* set sizes and state */
|
||||
XMEMSET(sha, 0, sizeof(wc_silabs_sha_t));
|
||||
|
||||
// set init state
|
||||
/* set init state */
|
||||
switch(type) {
|
||||
case WC_HASH_TYPE_SHA:
|
||||
rr = sl_se_hash_starts(&sha->hash_ctx,
|
||||
|
@ -88,7 +88,7 @@ int wc_silabs_se_hash_init (wc_silabs_sha_t* sha, enum wc_HashType type)
|
|||
}
|
||||
|
||||
if (rr == SL_STATUS_OK) {
|
||||
// init handles if it is already initialized
|
||||
/* init handles if it is already initialized */
|
||||
ret = sl_se_init();
|
||||
} else {
|
||||
ret = BUFFER_E;
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
typedef enum ecc_curve_id ecc_curve_id;
|
||||
typedef struct ecc_key ecc_key;
|
||||
|
||||
sl_se_key_type_t silabs_map_key_type (ecc_curve_id curve_id);
|
||||
int silabs_ecc_sign_hash (const byte* in, word32 inlen,
|
||||
byte* out, word32 *outlen,
|
||||
ecc_key* key);
|
||||
|
|
|
@ -1394,7 +1394,9 @@ extern void uITRON4_free(void *p) ;
|
|||
#if defined(RTOS_MODULE_NET_AVAIL) || (APP_CFG_TCPIP_EN == DEF_ENABLED)
|
||||
#include <net_cfg.h>
|
||||
#include <net_sock.h>
|
||||
//#include <net_err.h>
|
||||
#if (OS_VERSION < 50000)
|
||||
#include <net_err.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <lib_mem.h>
|
||||
#include <lib_math.h>
|
||||
|
|
Loading…
Reference in New Issue