Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .wolfssl_known_macro_extras
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,10 @@ WOLFSSL_STSAFE_TAKES_SLOT
WOLFSSL_TELIT_M2MB
WOLFSSL_TEMPLATE_EXAMPLE
WOLFSSL_THREADED_CRYPT
WOLFSSL_TI_AM64X
WOLFSSL_TI_AM64X_RNG_CTR_DRBG
WOLFSSL_TI_AM64X_NO_AES
WOLFSSL_TI_AM64X_NO_SHA
WOLFSSL_TICKET_DECRYPT_NO_CREATE
WOLFSSL_TICKET_ENC_AES128_GCM
WOLFSSL_TICKET_ENC_AES256_CBC
Expand Down
41 changes: 31 additions & 10 deletions wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@
#endif
#endif

#ifdef WOLFSSL_TI_AM64X
#include <wolfssl/wolfcrypt/port/ti/ti-sa2ul_port.h>
#endif

#ifdef WOLFSSL_ASYNC_CRYPT
#include <wolfssl/wolfcrypt/async.h>
#endif
Expand Down Expand Up @@ -729,6 +733,10 @@ static WC_INLINE void bench_append_memory_info(char* buffer, size_t size,
#define fprintf(fp, ...) \
__android_log_print(ANDROID_LOG_DEBUG, "[WOLFCRYPT]", __VA_ARGS__)

#elif defined(TI_MCU_PLUS_SDK)
#include "kernel/nortos/dpl/common/printf.h"
#define printf printf_

#else
#if defined(XMALLOC_USER) || defined(FREESCALE_MQX)
/* MQX classic needs for EXIT_FAILURE */
Expand Down Expand Up @@ -2428,7 +2436,11 @@ static const char* bench_result_words2[][6] = {
};
/* how many kB to test (en/de)cryption */
#define NUM_BLOCKS 25
#define BENCH_SIZE (1024uL)
#ifdef BENCH_SIZE_EMBEDDED
# define BENCH_SIZE BENCH_SIZE_EMBEDDED
#else
# define BENCH_SIZE (1024uL)
#endif
#else
#ifndef BENCH_NTIMES
#define BENCH_NTIMES 100
Expand Down Expand Up @@ -2578,7 +2590,11 @@ static void benchmark_static_init(int force)
bench_pq_asym_algs = 0;
bench_other_algs = 0;
bench_pq_hash_sig_algs = 0;
#ifdef WOLFSSL_BENCHMARK_FIXED_CSV
csv_format = 1;
#else
csv_format = 0;
#endif
}
}

Expand Down Expand Up @@ -3054,7 +3070,7 @@ static void bench_stats_sym_finish(const char* desc, int useDeviceID,
#ifdef GENERATE_MACHINE_PARSEABLE_REPORT
/* machine parseable CSV */
#ifdef HAVE_GET_CYCLES
printf("%s", "\"sym\",Algorithm,HW/SW,bytes_total,"
printf("%s", "\"sym\",Algorithm,HW/SW,block_size,bytes_total,"
WOLFSSL_FIXED_TIME_UNIT "econds_total,"
WOLFSSL_FIXED_UNIT "/" WOLFSSL_FIXED_TIME_UNIT
",cycles_total,Cycles per byte,"
Expand All @@ -3066,7 +3082,7 @@ static void bench_stats_sym_finish(const char* desc, int useDeviceID,
#endif
);
#else
printf("%s", "\"sym\",Algorithm,HW/SW,bytes_total,"
printf("%s", "\"sym\",Algorithm,HW/SW,block_size,bytes_total,"
WOLFSSL_FIXED_TIME_UNIT "econds_total,"
WOLFSSL_FIXED_UNIT "/" WOLFSSL_FIXED_TIME_UNIT
",cycles_total,"
Expand Down Expand Up @@ -3177,8 +3193,9 @@ static void bench_stats_sym_finish(const char* desc, int useDeviceID,
#ifdef WOLFSSL_ESPIDF
#ifdef HAVE_GET_CYCLES
(void)XSNPRINTF(msg, sizeof(msg),
"sym,%s,%s,%lu," FLT_FMT "," FLT_FMT ",%lu,", desc,
"sym,%s,%s,%lu,%lu," FLT_FMT "," FLT_FMT ",%llu,", desc,
BENCH_DEVID_GET_NAME(useDeviceID),
bench_size,
bytes_processed, FLT_FMT_ARGS(total),
FLT_FMT_ARGS(persec),
(long unsigned int) total_cycles);
Expand All @@ -3191,14 +3208,16 @@ static void bench_stats_sym_finish(const char* desc, int useDeviceID,
#else
#ifdef HAVE_GET_CYCLES
(void)XSNPRINTF(msg, sizeof(msg),
"sym,%s,%s,%lu," FLT_FMT "," FLT_FMT ",%lu,", desc,
"sym,%s,%s,%lu,%llu," FLT_FMT "," FLT_FMT ",%llu,", desc,
BENCH_DEVID_GET_NAME(useDeviceID),
bench_size,
bytes_processed, FLT_FMT_ARGS(total),
FLT_FMT_ARGS(persec), total_cycles);
#else
(void)XSNPRINTF(msg, sizeof(msg),
"sym,%s,%s,%lu," FLT_FMT "," FLT_FMT ",", desc,
"sym,%s,%s,%lu,%llu," FLT_FMT "," FLT_FMT ",", desc,
BENCH_DEVID_GET_NAME(useDeviceID),
bench_size,
bytes_processed, FLT_FMT_ARGS(total),
FLT_FMT_ARGS(persec));
#endif
Expand Down Expand Up @@ -8731,13 +8750,15 @@ void bench_sha256(int useDeviceID)
printf("InitSha256_ex failed, ret = %d\n", ret);
goto exit;
}
#ifdef WOLFSSL_PIC32MZ_HASH
wc_Sha256SizeSet(hash[i], numBlocks * bench_size);
#endif
}

bench_stats_start(&count, &start);
do {
#ifdef WOLFSSL_PIC32MZ_HASH
for (i = 0; i < BENCH_MAX_PENDING; i++) {
wc_Sha256SizeSet(hash[i], numBlocks * bench_size);
}
#endif
for (times = 0; times < numBlocks || pending > 0; ) {
bench_async_poll(&pending);

Expand Down Expand Up @@ -19153,7 +19174,7 @@ int wolfcrypt_benchmark_main(int argc, char** argv)
argc--;
argv++;
}
#endif /* MAIN_NO_ARGS */
#endif /* !MAIN_NO_ARGS */

#if defined(WOLFSSL_BENCHMARK_FIXED_CSV)
/* when defined, we'll always output CSV regardless of params.
Expand Down
14 changes: 4 additions & 10 deletions wolfcrypt/src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3548,9 +3548,6 @@ WC_ALL_ARGS_NOT_NULL static WARN_UNUSED_RESULT int wc_AesEncrypt(
{
#if defined(MAX3266X_AES)
word32 keySize;
#endif
#if defined(MAX3266X_CB)
int ret_cb;
#endif
word32 r;

Expand Down Expand Up @@ -3692,12 +3689,12 @@ WC_ALL_ARGS_NOT_NULL static WARN_UNUSED_RESULT int wc_AesEncrypt(
outBlock, (unsigned int)keySize);
}
#endif
#if defined(MAX3266X_CB) && defined(HAVE_AES_ECB) /* Can do a basic ECB block */
#if (defined(WOLFSSL_TI_AM64X) || defined(MAX3266X_CB)) && defined(HAVE_AES_ECB)
#ifndef WOLF_CRYPTO_CB_FIND
if (aes->devId != INVALID_DEVID)
#endif
{
ret_cb = wc_CryptoCb_AesEcbEncrypt(aes, outBlock, inBlock,
int ret_cb = wc_CryptoCb_AesEcbEncrypt(aes, outBlock, inBlock,
WC_AES_BLOCK_SIZE);
if (ret_cb != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
return ret_cb;
Expand Down Expand Up @@ -4424,9 +4421,6 @@ WC_ALL_ARGS_NOT_NULL static WARN_UNUSED_RESULT int wc_AesDecrypt(
{
#if defined(MAX3266X_AES)
word32 keySize;
#endif
#if defined(MAX3266X_CB)
int ret_cb;
#endif
word32 r;

Expand Down Expand Up @@ -4542,12 +4536,12 @@ WC_ALL_ARGS_NOT_NULL static WARN_UNUSED_RESULT int wc_AesDecrypt(
}
#endif

#if defined(MAX3266X_CB) && defined(HAVE_AES_ECB) /* Can do a basic ECB block */
#if (defined(WOLFSSL_TI_AM64X) || defined(MAX3266X_CB)) && defined(HAVE_AES_ECB)
#ifndef WOLF_CRYPTO_CB_FIND
if (aes->devId != INVALID_DEVID)
#endif
{
ret_cb = wc_CryptoCb_AesEcbDecrypt(aes, outBlock, inBlock,
int ret_cb = wc_CryptoCb_AesEcbDecrypt(aes, outBlock, inBlock,
WC_AES_BLOCK_SIZE);
if (ret_cb != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
return ret_cb;
Expand Down
4 changes: 4 additions & 0 deletions wolfcrypt/src/ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4410,6 +4410,10 @@ int wc_ecc_get_curve_size_from_id(int curve_id)
return ecc_sets[curve_idx].size;
}

#ifndef strcasecmp
int strcasecmp(const char *s1, const char *s2);
#endif

/* Returns the curve index that corresponds to a given curve name in
* ecc_sets[] of ecc.c
*
Expand Down
1 change: 1 addition & 0 deletions wolfcrypt/src/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ EXTRA_DIST += wolfcrypt/src/port/ti/ti-aes.c \
wolfcrypt/src/port/ti/ti-des3.c \
wolfcrypt/src/port/ti/ti-hash.c \
wolfcrypt/src/port/ti/ti-ccm.c \
wolfcrypt/src/port/ti/ti-sa2ul_port.c \
wolfcrypt/src/port/pic32/pic32mz-crypt.c \
wolfcrypt/src/port/nrf51.c \
wolfcrypt/src/port/aria/aria-crypt.c \
Expand Down
43 changes: 43 additions & 0 deletions wolfcrypt/src/port/ti/README_sa2ul.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# wolfSSL TI SA2UL Hardware Acceleration Port

wolfSSL supports hardware acceleration on the TI AM6442 via the SA2UL peripheral.

## SA2UL on the TI AM6442

The TI AM6442 is a multi-core SoC, with one dual-core Cortex-A53, two dual-core Cortex-R5F,
a Cortex-M4F, and a dedicated security core based on a Cortex-M3. This support has been
tested on the TMDS64EVM board (rev 101D).

Basic hardware acceleration supported:
- TRNG (NRBG and CTR-DRBG SP800-90A)
- AES-ECB (128, 256)
- AES-CBC (128, 256)
- AES-GCM (128, 256)
- SHA256, SHA512
- HMAC-SHA256, HMAC-SHA512
- CMAC-AES (128, 256)

Note: The wolfCrypt sa2ul support depends on the TI MCU Plus SDK. wolfBoot has
an example (ti-am64x.config) of how to compile with the MCU Plus SDK.

### wolfSSL TI AM64x Hardware Acceleration Switches

To enable all the above, with TRNG in NRBG mode, set the following build switch:

**`WOLFSSL_TI_AM64X`**

To change the TRNG to CTR-DRBG mode, then also set this switch:

**`WOLFSSL_TI_AM64X_RNG_CTR_DRBG`**

In addition, parts of the hardware acceleration can be disabled (in favor of
wolfCrypt software algorithms), with the following switches:

**`WOLFSSL_TI_AM64X_NO_AES`**

**`WOLFSSL_TI_AM64X_NO_SHA`**

## Support

For questions please email support@wolfssl.com

Loading
Loading