main.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* main.c
  2. *
  3. * Copyright (C) 2006-2022 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <wolfssl/wolfcrypt/settings.h>
  25. #include <stdio.h>
  26. #include <time.h>
  27. #if defined(WOLFSSL_CMSIS_RTOS)
  28. #include "cmsis_os.h"
  29. #elif defined(WOLFSSL_CMSIS_RTOSv2)
  30. #include "cmsis_os2.h"
  31. #endif
  32. /* Dummy definition for test RTC */
  33. #define RTC_YEAR 2019
  34. #define RTC_MONTH 1
  35. #define RTC_DAY 1
  36. #if defined(STM32F7xx)
  37. #include "stm32f7xx_hal.h"
  38. #elif defined(STM32F4xx)
  39. #include "stm32f4xx_hal.h"
  40. #elif defined(STM32F2xx)
  41. #include "stm32f2xx_hal.h"
  42. #endif
  43. #warning "write MPU specific Set ups\n"
  44. static void SystemClock_Config (void) {
  45. }
  46. static void MPU_Config (void) {
  47. }
  48. static void CPU_CACHE_Enable (void) {
  49. }
  50. #if defined(WOLFSSL_CMSIS_RTOS)
  51. extern uint32_t os_time;
  52. #endif
  53. uint32_t HAL_GetTick(void) {
  54. #if defined(WOLFSSL_CMSIS_RTOS)
  55. return os_time;
  56. #elif defined(WOLFSSL_CMSIS_RTOSv2)
  57. return osKernelGetTickCount();
  58. #endif
  59. }
  60. static time_t epochTime;
  61. time_t time(time_t *t){
  62. return epochTime ;
  63. }
  64. void setTime(time_t t){
  65. epochTime = t;
  66. }
  67. /*-----------------------------------------------------------------------------
  68. * Initialize a Flash Memory Card
  69. *----------------------------------------------------------------------------*/
  70. #if !defined(NO_FILESYSTEM)
  71. #include "rl_fs.h" /* FileSystem definitions */
  72. static void init_filesystem (void) {
  73. int32_t retv;
  74. retv = finit ("M0:");
  75. if (retv == fsOK) {
  76. retv = fmount ("M0:");
  77. if (retv == fsOK) {
  78. printf ("Drive M0 ready!\n");
  79. }
  80. else {
  81. printf ("Drive M0 mount failed(%d)!\n", retv);
  82. }
  83. }
  84. else {
  85. printf ("Drive M0 initialization failed!\n");
  86. }
  87. }
  88. #endif
  89. /*-----------------------------------------------------------------------------
  90. * mian entry
  91. *----------------------------------------------------------------------------*/
  92. void wolfcrypt_test(void *arg) ;
  93. int main()
  94. {
  95. void * arg = NULL ;
  96. MPU_Config();
  97. CPU_CACHE_Enable();
  98. HAL_Init(); /* Initialize the HAL Library */
  99. SystemClock_Config(); /* Configure the System Clock */
  100. #if !defined(NO_FILESYSTEM)
  101. init_filesystem ();
  102. #endif
  103. setTime((RTC_YEAR-1970)*365*24*60*60 + RTC_MONTH*30*24*60*60 + RTC_DAY*24*60*60);
  104. printf("=== Start: Crypt test === \n") ;
  105. wolfcrypt_test(arg) ;
  106. printf("=== End: Crypt test ===\n") ;
  107. }