Skip to content

Commit

Permalink
Fix Macro Defines for Old SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
night1rider committed Jul 23, 2024
1 parent a41b459 commit ec7c4bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
15 changes: 8 additions & 7 deletions wolfcrypt/src/port/maxim/max3266x.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@

#include <wolfssl/wolfcrypt/settings.h>

#warning "Inside max3266x.c"
#if defined(WOLFSSL_MAX32665) || defined(WOLFSSL_MAX32666)
#warning "Inside max3266x.c define"


#ifdef NO_INLINE
#include <wolfssl/wolfcrypt/misc.h>
Expand Down Expand Up @@ -91,10 +88,14 @@ int wc_MXC_TPU_Init(void)
int wc_MXC_TPU_Shutdown(void)
{
/* Shutdown the TPU device */
if(MXC_TPU_Shutdown(MXC_SYS_PERIPH_CLOCK_TRNG) != EXIT_SUCCESS){
WOLFSSL_MSG("Device did not shutdown");
return RNG_FAILURE_E;
}
#if defined(WOLFSSL_MAX32665_OLD) || defined(WOLFSSL_MAX32666_OLD)
MXC_TPU_Shutdown(); /* Is a void return in older SDK */
#else
if(MXC_TPU_Shutdown(MXC_SYS_PERIPH_CLOCK_TRNG) != EXIT_SUCCESS){
WOLFSSL_MSG("Device did not shutdown");
return RNG_FAILURE_E;
}
#endif
return EXIT_SUCCESS;
}

Expand Down
34 changes: 13 additions & 21 deletions wolfssl/wolfcrypt/port/maxim/max3266x.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#if defined(WOLFSSL_MAX32665) || defined(WOLFSSL_MAX32666)

#if defined(WOLFSSL_MAX32665_OLD) || defined(WOLFSSL_MAX32666_OLD)
#if !defined(MAX3266X_RTC)
#if defined(MAX3266X_RTC)
#error Cannot use RTC Code with older sdk
#endif
#endif
Expand All @@ -58,11 +58,13 @@
#define MAX3266X_MATH
#endif

#if defined(WOLFSSL_MAX32665_OLD) || defined(WOLFSSL_MAX32666_OLD)



#if defined(WOLFSSL_MAX32665_OLD) || (WOLFSSL_MAX32666_OLD)
/* Support for older SDK Maxim provides */
#define TARGET MAX32665
#define TARGET_REV 0x4131
#include "mxc_sys.h"

#if defined(MAX3266X_RNG)
#include "trng.h" /* Provides TRNG Drivers */
#endif
Expand All @@ -74,10 +76,6 @@
#define MXC_TPU_CIPHER_AES192 TPU_CIPHER_AES192
#define MXC_TPU_CIPHER_AES256 TPU_CIPHER_AES256

#define MXC_AES_KEY_128_LEN MXC_AES_KEY_128_LEN
#define MXC_AES_KEY_192_LEN MXC_AES_KEY_192_LEN
#define MXC_AES_KEY_256_LEN MXC_AES_KEY_256_LEN

#define MXC_TPU_MODE_TYPE tpu_modesel_t
#define MXC_TPU_MODE_ECB TPU_MODE_ECB
#define MXC_TPU_MODE_CBC TPU_MODE_CBC
Expand All @@ -86,8 +84,8 @@

/* AES Functions */
#define MXC_TPU_Cipher_Config TPU_Cipher_Config
#define MXC_TPU_Cipher_AES_Encrypt TPU_Cipher_AES_Encrypt
#define MXC_TPU_Cipher_AES_Decrypt TPU_Cipher_AES_Decrypt
#define MXC_TPU_Cipher_AES_Encrypt TPU_AES_Encrypt
#define MXC_TPU_Cipher_AES_Decrypt TPU_AES_Decrypt

#endif
#if defined(MAX3266X_SHA)
Expand All @@ -109,7 +107,7 @@
#include "maa.h" /* Provides Drivers for math acceleration for */
/* ECDSA and RSA Acceleration */
/* MAA Defines */
#define MXC_TPU_MAA_TYPE mxc_tpu_maa_clcsel_t
#define MXC_TPU_MAA_TYPE tpu_maa_clcsel_t
#define WC_MXC_TPU_MAA_EXP 0b0000
#define WC_MXC_TPU_MAA_SQ 0b0010
#define WC_MXC_TPU_MAA_MUL 0b0100
Expand All @@ -127,11 +125,11 @@

/* TPU Functions */
#define MXC_TPU_Init SYS_TPU_Init
#define MXC_TPU_Shutdown SYS_TPU_Shutdown
#define MXC_TPU_Shutdown TPU_Shutdown
#define MXC_SYS_PERIPH_CLOCK_TPU SYS_PERIPH_CLOCK_TPU

#define MXC_SYS_PERIPH_CLOCK_TPU MXC_SYS_PERIPH_CLOCK_TPU
#define MXC_SYS_PERIPH_CLOCK_TRNG MXC_SYS_PERIPH_CLOCK_TRNG
#define MXC_SYS_PERIPH_CLOCK_TPU SYS_PERIPH_CLOCK_TPU
#define MXC_SYS_PERIPH_CLOCK_TRNG SYS_PERIPH_CLOCK_TRNG

#define MXC_TRNG MXC_TRNG

Expand Down Expand Up @@ -184,12 +182,6 @@ i #error Not Implemented with old SDK
#define MXC_SECS_PER_DAY (24 * MXC_SECS_PER_HR)
#endif

#include "mxc_errors.h" /* ERROR Codes */
#include "mxc_device.h"
#include "board.h"
#include "max32665.h"


/* Variable Definitions */

#ifdef __cplusplus
Expand Down Expand Up @@ -278,4 +270,4 @@ i #error Not Implemented with old SDK
#endif

#endif /* WOLFSSL_MAX32665 || WOLFSSL_MAX32666 */
#endif /* _WOLFPORT_MAX3266X_H_ */
#endif /* _WOLFPORT_MAX3266X_H_ */

0 comments on commit ec7c4bd

Please sign in to comment.