Skip to content

Commit f55ecb5

Browse files
committed
se050: add support for SE050 SIGN ONLY options
1 parent 5cd2db0 commit f55ecb5

4 files changed

Lines changed: 30 additions & 3 deletions

File tree

.wolfssl_known_macro_extras

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,10 @@ WOLFSSL_SE050_AUTO_ERASE
880880
WOLFSSL_SE050_CRYPT
881881
WOLFSSL_SE050_HASH
882882
WOLFSSL_SE050_INIT
883+
WOLFSSL_SE050_NOECDHE
884+
WOLFSSL_SE050_NO_ECDSA_VERIFY
883885
WOLFSSL_SE050_NO_RSA
886+
WOLFSSL_SE050_NO_RSA_VERIFY
884887
WOLFSSL_SE050_NO_TRNG
885888
WOLFSSL_SECURE_RENEGOTIATION_ON_BY_DEFAULT
886889
WOLFSSL_SERVER_EXAMPLE

wolfcrypt/src/ecc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ ECC Curve Sizes:
291291
#undef HAVE_ECC_VERIFY_HELPER
292292
#define HAVE_ECC_VERIFY_HELPER
293293
#endif
294+
#if defined(WOLFSSL_SE050_NO_ECDSA_VERIFY)
295+
#define HAVE_ECC_VERIFY_HELPER
296+
#endif
294297

295298
#if !defined(WOLFSSL_ATECC508A) && !defined(WOLFSSL_ATECC608A) && \
296299
!defined(WOLFSSL_CRYPTOCELL) && !defined(WOLFSSL_SILABS_SE_ACCEL) && \
@@ -4767,7 +4770,7 @@ int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
47674770
err = silabs_ecc_shared_secret(private_key, public_key, out, outlen);
47684771
#elif defined(WOLFSSL_KCAPI_ECC)
47694772
err = KcapiEcc_SharedSecret(private_key, public_key, out, outlen);
4770-
#elif defined(WOLFSSL_SE050)
4773+
#elif defined(WOLFSSL_SE050) && !defined(WOLFSSL_SE050_NOECDHE)
47714774
err = se050_ecc_shared_secret(private_key, public_key, out, outlen);
47724775
#else
47734776
err = wc_ecc_shared_secret_ex(private_key, &public_key->pubkey, out, outlen);
@@ -5761,7 +5764,7 @@ static int _ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key,
57615764
else {
57625765
err = NOT_COMPILED_IN;
57635766
}
5764-
#elif defined(WOLFSSL_SE050)
5767+
#elif defined(WOLFSSL_SE050) && !defined(WOLFSSL_SE050_NOECDHE)
57655768
err = se050_ecc_create_key(key, key->dp->id, key->dp->size);
57665769
key->type = ECC_PRIVATEKEY;
57675770
#elif defined(WOLFSSL_CRYPTOCELL)
@@ -9261,7 +9264,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
92619264
#elif defined(WOLFSSL_XILINX_CRYPT_VERSAL)
92629265
byte sigRS[ECC_MAX_CRYPTO_HW_SIZE * 2];
92639266
byte hashcopy[ECC_MAX_CRYPTO_HW_SIZE] = {0};
9264-
#elif defined(WOLFSSL_SE050)
9267+
#elif defined(WOLFSSL_SE050) && !defined(WOLFSSL_SE050_NO_ECDSA_VERIFY)
92659268
#else
92669269
int curveLoaded = 0;
92679270
DECLARE_CURVE_SPECS(ECC_CURVE_FIELD_COUNT);

wolfcrypt/src/port/nxp/README_SE050.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,25 @@ defined, wolfCrypt will instead fall back to using `/dev/random` and
246246
Disables using the SE050 for RSA, useful for the SE050E which does not have
247247
RSA support.
248248

249+
**`WOLFSSL_SE050_NOECDHE`**
250+
251+
Disables offloading ECDH key generation and shared secret operations to the
252+
SE050. When defined, `wc_ecc_make_key()` and `wc_ecc_shared_secret()` will
253+
use wolfCrypt software instead of the SE050.
254+
255+
**`WOLFSSL_SE050_NO_ECDSA_VERIFY`**
256+
257+
When defined, ECDSA signing (`wc_ecc_sign_hash()`) continues to be offloaded
258+
to the SE050, but ECDSA verification (`wc_ecc_verify_hash()`) uses wolfCrypt
259+
software.
260+
261+
**`WOLFSSL_SE050_NO_RSA_VERIFY`**
262+
263+
When defined, RSA PKCS#1 v1.5 signing (`wc_RsaSSL_Sign()`) continues to be
264+
offloaded to the SE050, but RSA PKCS#1 v1.5 verification (`wc_RsaSSL_Verify()`)
265+
uses wolfCrypt software (public-key exponentiation + unpad). RSA PSS verify and
266+
RSA key-exchange decrypt are unaffected.
267+
249268
## wolfSSL HostCrypto Support
250269

251270
The NXP SE05x Plug & Trust Middleware by default can use either OpenSSL or

wolfcrypt/src/rsa.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,6 +3660,7 @@ static int RsaPrivateDecryptEx(const byte* in, word32 inLen, byte* out,
36603660
}
36613661
return ret;
36623662
}
3663+
#if !defined(WOLFSSL_SE050_NO_RSA_VERIFY)
36633664
else if (rsa_type == RSA_PUBLIC_DECRYPT &&
36643665
pad_value == RSA_BLOCK_TYPE_1 &&
36653666
pad_type != WC_RSA_PSS_PAD) {
@@ -3675,6 +3676,7 @@ static int RsaPrivateDecryptEx(const byte* in, word32 inLen, byte* out,
36753676
}
36763677
return ret;
36773678
}
3679+
#endif /* !WOLFSSL_SE050_NO_RSA_VERIFY */
36783680
#endif /* RSA CRYPTO HW */
36793681

36803682

0 commit comments

Comments
 (0)