/* wolfcrypt_test.c * * Copyright (C) 2006-2022 wolfSSL Inc. * * This file is part of wolfSSL. * * wolfSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * wolfSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ #include #include "board.h" #include "fsl_rtc.h" #include "fsl_trng.h" #include "peripherals.h" #include "pin_mux.h" #include "clock_config.h" #include "MIMXRT685S_cm33.h" #include "fsl_debug_console.h" #include #include #include "test.h" /* start the RTC and TRNG */ static void setup() { rtc_datetime_t date; trng_config_t trngConfig; status_t status; RTC_Init(RTC); /* setup a default start date */ date.year = 2022U; date.month = 8U; date.day = 17U; date.hour = 15U; date.minute = 10; date.second = 0; RTC_EnableTimer(RTC, false); RTC_SetDatetime(RTC, &date); RTC_EnableTimer(RTC, true); TRNG_GetDefaultConfig(&trngConfig); /* Commented in example NXP TRNG as an optional, better random mode */ trngConfig.sampleMode = kTRNG_SampleModeVonNeumann; /* Initialize TRNG */ status = TRNG_Init(TRNG0, &trngConfig); if (status != kStatus_Success) { PRINTF("Issues starting TRNG\n"); } } int main(void) { volatile static int i = 0; int ret; /* Init board hardware. */ BOARD_InitBootPins(); BOARD_InitBootClocks(); BOARD_InitBootPeripherals(); #ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL /* Init FSL debug console. */ BOARD_InitDebugConsole(); #endif setup(); /* set the RTC and start the TRNG */ /* initialize wolfCrypt and run tests */ if (wolfCrypt_Init() == 0) { PRINTF("Running wolfcrypt tests....\r\n"); wolfSSL_Debugging_ON(); ret = wolfcrypt_test(NULL); PRINTF("Return of wolfcrypt_test = %d\r\n", ret); wolfCrypt_Cleanup(); } else { PRINTF("Failied to initialize wolfCrypt\r\n"); } TRNG_Deinit(TRNG0); while(1) { i++; __asm volatile ("nop"); } return 0 ; }