1 (edited by zaliumz92 2020-03-20 07:30:23)

Topic: wolfcrypt for Arduino

Hey everyone,

I followed the instructions from https://www.wolfssl.com/doxygen/md__Use … EADME.html

After trying to open an example for arduino for example `sketches/wolfssl_client/wolfssl_client.ino`
I get the following errors: Error compiling for board Arduino Uno. #error "Must define XGMTIME externally see porting guide"

I really don't know what to do anymore. Can someone help me to get the library working on my arduino uno board?

Share

Re: wolfcrypt for Arduino

Hi @zaliumz92,

Have you had a chance to read through the porting guide for wolfSSL here? https://www.wolfssl.com/docs/porting-gu … y34rv6vyt5 (Link to specifically the TIME section). When XGMTIME and XTIME are not defined you need to track down a library for your device that provide the "time()" and "gmtime()" functions. If there is not an existing library that provides time functionality for your device you can write your own and then add the following to user_settings.h

#define WOLFSSL_GMTIME // Use the wolfSSL GMTIME solution
 #define USER_TICKS
 extern unsigned long my_time(unsigned long* timer);
 #define XTIME my_time
// Make sure that "my_time" returns second accuracy, doesn't have to be epoch related

Re: wolfcrypt for Arduino

I am very new to these kinds of things. I know that there is a function millis() on arduino which tracks the time passed since the program was executed. I have no idea how to implement these functions tho.
Could someone maybe help me do that? It would help me so much thanks!!

Share

Re: wolfcrypt for Arduino

zaliumz92,

Can you tell us a little bit about the background of this project and what is driving the effort? Thanks!

We have an example in the user_settings.h header in wolfssl-4.3.0/IDE/GCC-ARM/Header/user_settings.h (the arduino build similarly uses a user_settings.h setup)

 /* Override Current Time */
 /* Allows custom "custom_time()" function to be used for benchmark */
 #define WOLFSSL_USER_CURRTIME
 #define WOLFSSL_GMTIME
 #define USER_TICKS
 extern unsigned long my_time(unsigned long* timer)
 #define XTIME my_time

Then implement the function "my_time(unsigned long* timer);" at the application level to return whatever the current tick-count is by calling millis() and converting the milli seconds to seconds.

int seconds = (int)((millis / 1000) % 60);
// source of function: https://stackoverflow.com/questions/17624335/converting-milliseconds-to-minutes-and-seconds

Warm Regards,

K