Skip to content

Commit b604b14

Browse files
committed
Address PR comments
1 parent 4933943 commit b604b14

5 files changed

Lines changed: 60 additions & 20 deletions

File tree

wolfcrypt/src/port/nxp/README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,46 @@
11
# wolfSSL NXP Hardware Acceleration Ports
22

3-
wolfSSL supports hardware acceleration on NXP DCP, LTC (KSDK), and SE050.
3+
wolfSSL supports hardware acceleration on NXP DCP, LTC (KSDK), LPC55S69, and SE050.
4+
5+
## NXP LPC55S69
6+
7+
The LPC55S69 is a general purpose edge computing device, with dual ARM
8+
Cortex-M33 cores running up to 150 MHz, 640/320 KB internal flash/ram,
9+
TrustZone-M, a DSP accelerator, and extensive cryptographic acceleration.
10+
11+
wolfSSL supports the following hardware acceleration on the LPC55S69:
12+
- TRNG
13+
- HashCrypt (Hash/AES Crypto Engine)
14+
- AES (128, 192, 256) encrypt/decrypt
15+
- AES-CBC, AES-ECB, AES-CTR, AES-OFB, AES-CFB
16+
- SHA-1, SHA-256
17+
- CASPER (Asymmetric Crypto Accelerator)
18+
- RSA verify/encrypt/decrypt (up to 4096-bit, public key only)
19+
20+
### LPC55S69 Hardware Acceleration Caveats
21+
22+
The following caveats should be noted about the LPC55S69 hardware acceleration:
23+
- AES-CTR mode fails when the counter wraps from all FF's to 0. User should
24+
ensure this never happens, by properly managing the iv/counter in use.
25+
- AES-CFB and AES-OFB only support full 16-byte blocks and multiples thereof.
26+
Encrypt/Decrypt requests of other sizes will fail.
27+
- RSA acceleration is only supported for public keys. Private key operations
28+
will use a fully software implementation.
29+
- When the HashCrypt engine is in use for SHA-1 or SHA-256, it must not be
30+
interrupted with another hash request or an AES request. The hash must be
31+
completed before another operation is requested.
32+
33+
### wolfSSL LPC55S69 Hardware Acceleration Enable/Disable
34+
35+
To enable LPC55S69 hardware acceleration, define the following symbol:
36+
37+
**`WOLFSSL_NXP_LPC55S69_WITH_HWACCEL`**
38+
39+
To disable LPC55S69 hardware acceleration, define the following symbol:
40+
41+
**`WOLFSSL_NXP_LPC55S69_NO_HWACCEL`**
42+
43+
NOTE: In either case, the TRNG is always enabled for use.
444

545
## NXP SE050
646

@@ -10,3 +50,4 @@ see [README_SE050.md](./README_SE050.md).
1050
## Support
1151

1252
For questions please email support@wolfssl.com
53+

wolfcrypt/src/port/nxp/casper_port.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int casper_rsa_public_exptmod(
8282

8383
return 0;
8484
}
85-
#endif
85+
#endif /* !NO_RSA && WOLFSSL_NXP_CASPER_RSA_PUB_EXPTMOD */
8686

8787

8888
/* 32 for 256 bits, 48 for 384 bits and 72 for 521 bits... */
@@ -157,7 +157,7 @@ int casper_ecc_mulmod(
157157

158158
return 0;
159159
}
160-
#endif
160+
#endif /* HAVE_ECC && WOLFSSL_NXP_CASPER_ECC_MULMOD */
161161

162162
#if defined(HAVE_ECC) && defined(WOLFSSL_NXP_CASPER_ECC_MUL2ADD)
163163
/* calculates R = m*P[X, Y] + n*Q[X, Y] */
@@ -248,6 +248,6 @@ int casper_ecc_mul2add(
248248

249249
return 0;
250250
}
251-
#endif
251+
#endif /* HAVE_ECC && WOLFSSL_NXP_CASPER_ECC_MUL2ADD */
252252

253253
#endif /* WOLFSSL_NXP_CASPER */

wolfcrypt/test/test.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12119,7 +12119,7 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
1211912119
if (XMEMCMP(cipher + WC_AES_BLOCK_SIZE, cipher1 + WC_AES_BLOCK_SIZE,
1212012120
WC_AES_BLOCK_SIZE))
1212112121
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
12122-
#endif
12122+
#endif /* !WOLFSSL_NXP_HASHCRYPT_AES */
1212312123

1212412124
#ifdef HAVE_AES_DECRYPT
1212512125
ret = wc_AesOfbDecrypt(dec, plain, cipher1, WC_AES_BLOCK_SIZE);
@@ -12138,7 +12138,7 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
1213812138
if (XMEMCMP(plain + WC_AES_BLOCK_SIZE, plain1 + WC_AES_BLOCK_SIZE,
1213912139
WC_AES_BLOCK_SIZE))
1214012140
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
12141-
#endif
12141+
#endif /* !WOLFSSL_NXP_HASHCRYPT_AES */
1214212142
#endif /* HAVE_AES_DECRYPT */
1214312143

1214412144
/* multiple blocks at once */
@@ -12223,7 +12223,7 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
1222312223
#ifndef WOLFSSL_NXP_HASHCRYPT_AES
1222412224
if (XMEMCMP(cipher + 3, cipher1 + 3, WC_AES_BLOCK_SIZE))
1222512225
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
12226-
#endif
12226+
#endif /* !WOLFSSL_NXP_HASHCRYPT_AES */
1222712227

1222812228
#ifdef HAVE_AES_DECRYPT
1222912229
ret = wc_AesOfbDecrypt(dec, plain, cipher1, 6);
@@ -12240,7 +12240,7 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
1224012240
#ifndef WOLFSSL_NXP_HASHCRYPT_AES
1224112241
if (XMEMCMP(plain + 6, plain1 + 6, WC_AES_BLOCK_SIZE))
1224212242
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
12243-
#endif
12243+
#endif /* !WOLFSSL_NXP_HASHCRYPT_AES */
1224412244
#endif /* HAVE_AES_DECRYPT */
1224512245
#endif /* WOLFSSL_AES_256 */
1224612246

@@ -12460,7 +12460,7 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
1246012460
if (XMEMCMP(plain, msg1, WC_AES_BLOCK_SIZE * 3))
1246112461
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
1246212462
#endif /* HAVE_AES_DECRYPT */
12463-
#endif
12463+
#endif /* !WOLFSSL_NXP_HASHCRYPT_AES */
1246412464
#endif /* WOLFSSL_AES_128 */
1246512465

1246612466
#ifdef WOLFSSL_AES_192
@@ -12574,7 +12574,7 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key,
1257412574
if (XMEMCMP(plain, msg3, WC_AES_BLOCK_SIZE * 4))
1257512575
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
1257612576
#endif /* HAVE_AES_DECRYPT */
12577-
#endif
12577+
#endif /* !WOLFSSL_NXP_HASHCRYPT_AES */
1257812578
#endif /* WOLFSSL_AES_256 */
1257912579

1258012580
out:
@@ -16038,7 +16038,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_ctr_test(void)
1603816038
{ ctr128Key, (int)sizeof(ctr128Key), ctrIvWrap128,
1603916039
ctrPlain, (int)sizeof(ctr128Wrap128CipherLong),
1604016040
ctr128Wrap128CipherLong },
16041-
#endif
16041+
#endif /* !WOLFSSL_NXP_HASHCRYPT_AES */
1604216042
#if defined(WOLFSSL_ARMASM) || defined(WOLFSSL_RISCV_ASM)
1604316043
{ ctr128Key, (int)sizeof(ctr128Key), ctrIvWrap128_2,
1604416044
ctrPlain, (int)sizeof(ctr128Wrap128_2CipherLong),
@@ -16082,7 +16082,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_ctr_test(void)
1608216082
{ ctr192Key, (int)sizeof(ctr192Key), ctrIvWrap128,
1608316083
ctrPlain, (int)sizeof(ctr192Wrap128CipherLong),
1608416084
ctr192Wrap128CipherLong },
16085-
#endif
16085+
#endif /* !WOLFSSL_NXP_HASHCRYPT_AES */
1608616086
#if defined(WOLFSSL_ARMASM) || defined(WOLFSSL_RISCV_ASM)
1608716087
{ ctr192Key, (int)sizeof(ctr192Key), ctrIvWrap128_2,
1608816088
ctrPlain, (int)sizeof(ctr192Wrap128_2CipherLong),
@@ -16126,7 +16126,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_ctr_test(void)
1612616126
{ ctr256Key, (int)sizeof(ctr256Key), ctrIvWrap128,
1612716127
ctrPlain, (int)sizeof(ctr256Wrap128CipherLong),
1612816128
ctr256Wrap128CipherLong },
16129-
#endif
16129+
#endif /* !WOLFSSL_NXP_HASHCRYPT_AES */
1613016130
#if defined(WOLFSSL_ARMASM) || defined(WOLFSSL_RISCV_ASM)
1613116131
{ ctr256Key, (int)sizeof(ctr256Key), ctrIvWrap128_2,
1613216132
ctrPlain, (int)sizeof(ctr256Wrap128_2CipherLong),

wolfssl/wolfcrypt/port/nxp/casper_port.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@
2626
int wc_casper_init(void);
2727

2828
#if !defined(NO_RSA) && defined(WOLFSSL_NXP_CASPER_RSA_PUB_EXPTMOD)
29-
3029
#include <wolfssl/wolfcrypt/rsa.h>
3130

3231
int casper_rsa_public_exptmod(
3332
const byte* in, word32 inLen, byte* out, word32* outLen, RsaKey* key
3433
);
35-
#endif
34+
#endif /* !NO_RSA && WOLFSSL_NXP_CASPER_RSA_PUB_EXPTMOD */
3635

3736

3837
#if defined(HAVE_ECC)
@@ -42,14 +41,14 @@ int casper_rsa_public_exptmod(
4241
int casper_ecc_mulmod(
4342
const mp_int *m, ecc_point *P, ecc_point *R, int curve_id
4443
);
45-
#endif
44+
#endif /* WOLFSSL_NXP_CASPER_ECC_MULMOD */
4645

4746
#ifdef WOLFSSL_NXP_CASPER_ECC_MUL2ADD
4847
int casper_ecc_mul2add(
4948
const mp_int *m, ecc_point *P, const mp_int *n, ecc_point *Q,
5049
ecc_point *R, int curve_id
5150
);
52-
#endif
53-
#endif
51+
#endif /* WOLFSSL_NXP_CASPER_ECC_MUL2ADD */
52+
#endif /* HAVE_ECC */
5453

55-
#endif
54+
#endif /* _CASPER_PORT_H_ */

wolfssl/wolfcrypt/port/nxp/hashcrypt_port.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525

2626
int wc_hashcrypt_init(void);
2727

28-
#endif
28+
#endif /* _HASHCRYPT_PORT_H_ */

0 commit comments

Comments
 (0)