2424
2525#if LT_USE_TREZOR_CRYPTO
2626#include "libtropic_trezor_crypto.h"
27+ #define CRYPTO_CTX_TYPE lt_ctx_trezor_crypto_t
2728#elif LT_USE_MBEDTLS_V4
2829#include "libtropic_mbedtls_v4.h"
2930#include "psa/crypto.h"
31+ #define CRYPTO_CTX_TYPE lt_ctx_mbedtls_v4_t
32+ #elif LT_USE_WOLFCRYPT
33+ #include "libtropic_wolfcrypt.h"
34+ #include "wolfssl/wolfcrypt/error-crypt.h"
35+ #include "wolfssl/wolfcrypt/wc_port.h"
36+ #define CRYPTO_CTX_TYPE lt_ctx_wolfcrypt_t
3037#endif
3138
3239/** @addtogroup STM32F4xx_HAL_Examples
@@ -162,6 +169,12 @@ int main(void)
162169 LT_LOG_ERROR ("PSA Crypto initialization failed, status=%d (psa_status_t)" , status );
163170 return -1 ;
164171 }
172+ #elif LT_USE_WOLFCRYPT
173+ int ret = wolfCrypt_Init ();
174+ if (ret != 0 ) {
175+ LT_LOG_ERROR ("WolfCrypt initialization failed, ret=%d (%s)" , ret , wc_GetErrorString (ret ));
176+ return ret ;
177+ }
165178#endif
166179
167180 /* Libtropic handle initialization */
@@ -187,12 +200,7 @@ int main(void)
187200 lt_handle .l2 .device = & device ;
188201
189202 /* Crypto abstraction layer (CAL) context (selectable). */
190- #if LT_USE_TREZOR_CRYPTO
191- lt_ctx_trezor_crypto_t
192- #elif LT_USE_MBEDTLS_V4
193- lt_ctx_mbedtls_v4_t
194- #endif
195- crypto_ctx ;
203+ CRYPTO_CTX_TYPE crypto_ctx ;
196204 lt_handle .l3 .crypto_ctx = & crypto_ctx ;
197205
198206 /* Test code (correct test function is selected automatically per binary)
@@ -203,6 +211,12 @@ int main(void)
203211 /* Cryptographic function provider deinitialization. */
204212#if LT_USE_MBEDTLS_V4
205213 mbedtls_psa_crypto_free ();
214+ #elif LT_USE_WOLFCRYPT
215+ ret = wolfCrypt_Cleanup ();
216+ if (ret != 0 ) {
217+ LT_LOG_ERROR ("WolfCrypt cleanup failed, ret=%d (%s)" , ret , wc_GetErrorString (ret ));
218+ return ret ;
219+ }
206220#endif
207221
208222 /* Inform the test runner that the test finished */
0 commit comments