Using the Wolfssl library with a new project

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the Wolfssl library with a new project

139 Views
Contributor II

I have been using the frdmkl82z_wolfssl_benchmark example project to see how to utilize the Wolfssl Library and hardware accelerators for the KL82. I have been trying to use the same library in my own project by creating a project through the new project wizard and then copying and pasting the "wolfssl" folder into the project directory. After doing this, making sure the folder was not being excluded from the build (right clicking the folder -> properties -> C/C++ Build and unchecking "Exclude resource from build"), and then building, I get errors (25 total) all along the lines of "fatal error: wolfssl/wolfcrypt/settings.h: No such file or directory". The file structure is very similar to the example projects, so I think there is something else I am missing. 

Has anyone had success using the wolfssl library for their project?

Labels (1)
0 Kudos
5 Replies

116 Views
NXP TechSupport
NXP TechSupport

Hi Ronald,

Did you add the include paths to your new project? You can do this in Properties > C/C++ Build > MCU C Compiler > Includes.

Also, you need to add the folders to Source Location, please check Properties > C/C++ General > Paths and Symbols > Source Location and then click Add Folder.

Best regards,

Felipe

-------------------------------------------------------------------------------

Note:

- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored.

Please open a new thread and refer to the closed one, if you have a related question at a later point in time.

------------------------------------------------------------------------------ 

0 Kudos

111 Views
Contributor II

That seems to have worked, but I am still having an issue with using an important function. It seems I am unable to use the CRYPTO_InitHardware() function. The console says there is an undefined reference to it. When I right-click on the function and open the declaration, it takes me to the ksdk_port.h file where it is declared but not the ksdk_port.c file where it is defined.

0 Kudos

93 Views
NXP TechSupport
NXP TechSupport

Hi Ronald,

Please double check that the Includes, Preprocessor symbols, files and optimization settings are the same as in the SDK example. I just tried to do it and it compiles correctly on my side.

Best regards,

Felipe

0 Kudos

83 Views
Contributor II

Are you able to use that function in your main method, CRYPTO_InitHardware()? What were the steps you took to create the new project and add the wolfssl library. I created the project through the new project wizard and added the library through that. I still had to add to add the preprocessor macro "WOLFSSL_USER_SETTINGS" to get it to build, but I am still unable to use that function.

Update 1: The project I was creating was in C++. I tried creating a project in C to to see what the differences might be and I still had to add the WOLFSSL_USER_SETTINGS preprocessor macro inside the project settings. However, I finally was able to use the Crypto_InitHardware function and was also able to hash some data! I am obviously doing something wrong with my C++ project to be able to use the library but I'm sure there is a correct way to use it.

Update 2: After creating a C file to contain all of my wolfssl libraries and functionality, I am still having issues using it. I have a header file that includes the following:

#include "nxp/ksdk_port.h"
#include "fsl_device_registers.h"
#include <wolfssl/wolfcrypt/settings.h>
#include <string.h>
#include <stdio.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/wolfcrypt/des3.h>
#include <wolfssl/wolfcrypt/arc4.h>
#include <wolfssl/wolfcrypt/hc128.h>
#include <wolfssl/wolfcrypt/rabbit.h>
#include <wolfssl/wolfcrypt/chacha.h>
#include <wolfssl/wolfcrypt/chacha20_poly1305.h>
#include <wolfssl/wolfcrypt/aes.h>
#include <wolfssl/wolfcrypt/poly1305.h>
#include <wolfssl/wolfcrypt/camellia.h>
#include <wolfssl/wolfcrypt/md5.h>
#include <wolfssl/wolfcrypt/sha.h>
#include <wolfssl/wolfcrypt/sha256.h>
#include <wolfssl/wolfcrypt/sha512.h>
#include <wolfssl/wolfcrypt/rsa.h>
#include <wolfssl/wolfcrypt/asn.h>
#include <wolfssl/wolfcrypt/ripemd.h>
#include <wolfssl/wolfcrypt/cmac.h>
#include <wolfssl/wolfcrypt/hmac.h>
#include <wolfssl/wolfcrypt/ecc.h>
#include <wolfssl/wolfcrypt/curve25519.h>
#include <wolfssl/wolfcrypt/ed25519.h>
#include <wolfssl/wolfcrypt/dh.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/certs_test.h>
#include "wolfssl/wolfcrypt/mem_track.h"

I am not sure I need all of them, but I am just grabbing them from the "wolfssl_benchmark.c" example file (that runs perfectly fine for me). I am then prototyping a few other functions to use the wolfssl functions.

For example, and in particular:

-----------

uint32_t generateHmac(uint8_t * plain, uint8_t length)
{
Hmac hmac;
uint32_t ret;

wc_HmacSetKey(&hmac, SHA256, m_key, sizeof(m_key));

wc_HmacUpdate(&hmac, plain, sizeof(plain));

wc_HmacFinal(&hmac, m_digest);


memcpy(&ret, m_digest, sizeof(m_digest));

return ret;
}

---------

wc_HmacSetKey() seems to work fine, and it is not until using the second function, wc_HmacUpdate(), that my debugger goes into hardfault. It is pretty deep inside this function that the failure occurs and I am not sure specifically where.

This leads me to believe that there is still something wrong with using the Crypto_InitHardware function. When I hover over the function and see where it is declared, it shows me the prototype but not the actual definition of the function. With other functions this is not the case- it shows me the actual definition.

I hope someone can help point me in the right direction with this information!

 

0 Kudos

49 Views
NXP TechSupport
NXP TechSupport

Hi Ronald,

Could you please clarify what are the issues you are seeing? What errors are displayed in MCUXpresso? As I have mentioned before I copied the wolfssl folder from the example to a new project and then adapt Includes, Preprocessor symbols, files and optimization settings according to the example. The project compiles correctly and there is no error using Crypto_InitHardware function.

Best regards,

Felipe

0 Kudos