Skip to content

Commit

Permalink
Addressing PR comments typos and cleanup and support HAVE_AES_ECB, Sh…
Browse files Browse the repository at this point in the history
…a1, and Sha224
  • Loading branch information
night1rider committed Aug 5, 2024
1 parent 7ca3d03 commit 2b77227
Show file tree
Hide file tree
Showing 8 changed files with 291 additions and 89 deletions.
1 change: 1 addition & 0 deletions wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -14243,6 +14243,7 @@ void bench_sphincsKeySign(byte level, byte optim)

double current_time(int reset)
{
(void)reset;
return wc_MXC_RTC_Time();
}

Expand Down
42 changes: 42 additions & 0 deletions wolfcrypt/src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -11506,6 +11506,48 @@ int wc_AesGetKeySize(Aes* aes, word32* keySize)
#elif defined(WOLFSSL_RISCV_ASM)
/* implemented in wolfcrypt/src/port/riscv/riscv-64-aes.c */

#elif defined(MAX3266X_AES)

int wc_AesEcbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
{
int status;
word32 keySize;

if ((in == NULL) || (out == NULL) || (aes == NULL))
return BAD_FUNC_ARG;

status = wc_AesGetKeySize(aes, &keySize);
if (status != 0) {
return status;
}

status = wc_MXC_TPU_AesEncrypt(in, aes->reg, aes->key, MXC_TPU_MODE_ECB,
sz, out, keySize);

return status;
}

#ifdef HAVE_AES_DECRYPT
int wc_AesEcbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
{
int status;
word32 keySize;

if ((in == NULL) || (out == NULL) || (aes == NULL))
return BAD_FUNC_ARG;

status = wc_AesGetKeySize(aes, &keySize);
if (status != 0) {
return status;
}

status = wc_MXC_TPU_AesDecrypt(in, aes->reg, aes->key, MXC_TPU_MODE_ECB,
sz, out, keySize);

return status;
}
#endif /* HAVE_AES_DECRYPT */

#elif defined(WOLFSSL_SCE) && !defined(WOLFSSL_SCE_NO_AES)

/* Software AES - ECB */
Expand Down
10 changes: 5 additions & 5 deletions wolfcrypt/src/port/maxim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ wolfSSL using Analog Devices MAXQ1065, MAX1080, MAX32665 or MAX32666
wolfSSL can be configured to use the MAXQ1065 or MAX1080 cryptographic
controllers. wolfSSL can also be configure to utilize the TPU
(crypto accelerator), MAA (math accelerator), and TRNG available on select
MAX32665 and MAX32666 microcontrollers.
MAX32665 and MAX32666 microcontroller.

Product datasheets, user guides and other resources can be found at
Analog Devices website:
Expand Down Expand Up @@ -41,7 +41,7 @@ all other operations will use the default software implementations.
The other prerequisite is that a change needs to be made to the Maxim SDK. This
is to use the MAA Math Accelerator, this change only needs to be made if you are
using `#define WOLFSSL_MAX3266X` or `define WOLFSSL_MAX3266X_OLD` by themselves
or you are specifing `#define MAX3266X_MATH`.
or you are specifying `#define MAX3266X_MATH`.

In the SDK you will need to find the underlying function that
`MXC_TPU_MAA_Compute()` from `tpu.h` compute calls in the newer SDK. In the
Expand All @@ -68,7 +68,7 @@ if you want to know more details on the issue.


## Supported Algos
Using these defines will replace software implentations with a call to the
Using these defines will replace software implementations with a call to the
hardware.

`#define MAX3266X_RNG`
Expand All @@ -95,7 +95,7 @@ like RSA and ECC key generation):

## Extra Information
For more Verbose info you can use `#define DEBUG_WOLFSSL` in combination with
`#define MAX3266X_VERBOSE` to see if errors are occuring during the hardware
`#define MAX3266X_VERBOSE` to see if errors are occurring during the hardware
setup/

To reproduce benchmark numbers you can use `#define MAX3266X_RTC`.
Expand All @@ -104,7 +104,7 @@ Do note that this will only work with `#define WOLFSSL_MAX3266X` and not
and not for any other application. Please implement your own rtc/time code for
anything else.

For more infromation about the TPU, MAA, and TRNG please refer to the
For more information about the TPU, MAA, and TRNG please refer to the
[MAX32665/MAX32666 User Guide: UG6971](https://www.analog.com/media/en/technical-documentation/user-guides/max32665max32666-user-guide.pdf)

# MAXQ1065/MAX1080
Expand Down
Loading

0 comments on commit 2b77227

Please sign in to comment.