1

(11 replies, posted in wolfSSL)

thanks for bugs fixing

It works now !! smile

2

(11 replies, posted in wolfSSL)

thanks kareem

yes it says hardware RNG is supported , I am reading the manual to read more about it.

with defining WOLFSSL_GENSEED_FORTEST I managed to run Ecc with this configuration

#define ECC_KEY_SIZE  48
#define ECC_KEY_CURVE ECC_SECP256R1

when I changed it to SECP256K1

#define ECC_KEY_SIZE  48
#define ECC_KEY_CURVE ECC_SECP256K1

I received error 172 from make key function some other function send error based on this problem

make_key_Func= -172
 PrivateKey_Func= -170
 sign_Func= -170
 verify_Func=-171

based on the wolfssl manual 172 means

ECC_CURVE_OID_E    -172    Unsupported ECC OID curve type

then I tried defining these two that I found in ecc.c

#define HAVE_ECC_KOBLITZ  
#define WOLFSSL_CUSTOM_CURVES

then I received an error

error: conflicting types for 'ByteToHex'
16503 | static void ByteToHex(byte n, char* str)
      |             ^~~~~~~~~
In file included from ../Middlewares/Third_Party/wolfSSL_wolfSSL_wolfSSL/wolfssl/wolfcrypt/src/asn.c:86:
../Middlewares/Third_Party/wolfSSL_wolfSSL_wolfSSL/wolfssl/wolfcrypt/src/misc.c:438:26: note: previous definition of 'ByteToHex' was here
  438 | WC_STATIC WC_INLINE char ByteToHex(byte in)

I realized there is a definition of ByteToHex inside two files miscs.c and asn.c 
if I remove misc.c by defining NO_INLINE , I will receive an error like this

undefined reference to `ForceZero'.

3

(11 replies, posted in wolfSSL)

hello again

as you know I started to implement ecc with your library.
I followed the video and as I told in a previous thread I had a problem with wc_GenerateSeed()
so I defined and problem solved

#define WOLFSSL_GENSEED_FORTEST

now I have this problem

../Middlewares/Third_Party/wolfSSL_wolfSSL_wolfSSL/wolfssl/src/ssl.c:149:10: fatal error: wolfcrypt/src/evp.c: No such file or directory
  149 | #include "wolfcrypt/src/evp.c"

in this case, I think it should not ask for this file I reviewed ssl.c I didn't find any define to avoid calling evp.c

4

(11 replies, posted in wolfSSL)

hello again

in this implementation I used System Workbench for STM32 as IDE almost all guides are related to STM32Cube, so I Installed STM32Cube and start again from zero,

1- in this IDE I didn't need to link wolfssl library, so based on the video and the documentation that you mentioned
- I created a new project for STM32F446re
- added wolfssl pack to the project

2-to keep everything simple I didn't use FreeRTOS so I let wolfssl configuration be unchanged "Single Threaded" also I did not enable FreeRTOS too,

3-I sat the configurations like the guide in the documentation

4- I opened the main.c file and did not edit or put anything just I click on debug

5-  2 errors appeared 
I-

#warning Please define a hardware platform!

for this error
because my board is not listed so I think it doesn't have any hardware to accelerate crypto functions so based on the guide

#else
    #warning Please define a hardware platform!
    /* This means there is not a pre-defined platform for your board/CPU */
    /* You need to define a CPU type, HW crypto and debug UART */
    /* CPU Type: WOLFSSL_STM32F1, WOLFSSL_STM32F2, WOLFSSL_STM32F4,
        WOLFSSL_STM32F7, WOLFSSL_STM32H7, WOLFSSL_STM32L4 and WOLFSSL_STM32L5 */
    #define WOLFSSL_STM32F4

    /* Debug UART used for printf */
    /* The UART interface number varies for each board/CPU */
    /* Typically this is the UART attached to the ST-Link USB CDC UART port */
    #define HAL_CONSOLE_UART huart4

    /* Hardware Crypto - uncomment as available on hardware */
    //#define WOLFSSL_STM32_PKA
    //#define NO_STM32_RNG
    //#undef  NO_STM32_HASH
    //#undef  NO_STM32_CRYPTO
    //#define WOLFSSL_GENSEED_FORTEST
    //#define STM32_HAL_V2
#endif

I defined NO_STM32_RNG ,also these are defined by default  NO_STM32_HASH and  NO_STM32_CRYPTO
the error persisted the only way to solve it smile is to make the warning line to be a comment

II-

../Middlewares/Third_Party/wolfSSL_wolfSSL_wolfSSL/wolfssl/wolfcrypt/src/port/st/stm32.c:39:14: fatal error: wolfcrypt/src/misc.c: No such file or directory
   39 |     #include <wolfcrypt/src/misc.c>

for this error
I defined NO_INLINE and it solves it smile

then I compiled this empty project I received a new error

../Middlewares/Third_Party/wolfSSL_wolfSSL_wolfSSL/wolfssl/wolfcrypt/src/random.c:2587:6: error: #error "you need to write an os specific wc_GenerateSeed() here"
 2587 |     #error "you need to write an os specific wc_GenerateSeed() here"
      |      ^~~~~

this error comes from random.c line 2585

#elif defined(NO_DEV_RANDOM)

    #error "you need to write an os specific wc_GenerateSeed() here"

    /*
    int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
    {
        return 0;
    }
    */

what is your suggestion why it is empty and there is not any seed generation code? do you have any seed generation code suggestion that works with STM32F446RE ?

also I try to define CUSTOM_RAND_GENERATE_BLOCK it was not successful I received several undeclareds

5

(11 replies, posted in wolfSSL)

now I realized something after several tries that is this data

wolfSSL_Init() return 1
wc_InitRng() return -199
wolfSSL_Debugging_ON() return -174

there is a problem with wc_InitRng() which would be impossible

I tried to use the user setting configuration which you suggest and my MCU and board (STM32F446RE  or STM32F446XX) is not in the list

/* ------------------------------------------------------------------------- */
/* Hardware platform */
/* ------------------------------------------------------------------------- */
#define NO_STM32_HASH
#define NO_STM32_CRYPTO

#if defined(STM32WB55xx)
    #define WOLFSSL_STM32WB
    #define WOLFSSL_STM32_PKA
    #undef  NO_STM32_CRYPTO
    #define HAL_CONSOLE_UART huart1
#elif defined(STM32F407xx)
    #define WOLFSSL_STM32F4
    #define HAL_CONSOLE_UART huart2
#elif defined(STM32F437xx)
    #define WOLFSSL_STM32F4
    #undef  NO_STM32_HASH
    #undef  NO_STM32_CRYPTO
    #define STM32_HAL_V2
    #define HAL_CONSOLE_UART huart4
#elif defined(STM32F777xx)
    #define WOLFSSL_STM32F7
    #undef  NO_STM32_HASH
    #undef  NO_STM32_CRYPTO
    #define STM32_HAL_V2
    #define HAL_CONSOLE_UART huart2
#elif defined(STM32H753xx)
    #define WOLFSSL_STM32H7
    #undef  NO_STM32_HASH
    #undef  NO_STM32_CRYPTO
    #define HAL_CONSOLE_UART huart3
#elif defined(STM32L4A6xx)
    #define WOLFSSL_STM32L4
    #undef  NO_STM32_HASH
    #undef  NO_STM32_CRYPTO
    #define HAL_CONSOLE_UART hlpuart1
#elif defined(STM32L475xx)
    #define WOLFSSL_STM32L4
    #define HAL_CONSOLE_UART huart1
#elif defined(STM32L562xx)
    #define WOLFSSL_STM32L5
    #define WOLFSSL_STM32_PKA
    #undef  NO_STM32_HASH
    #undef  NO_STM32_CRYPTO
    #define HAL_CONSOLE_UART huart1
#elif defined(STM32L552xx)
    #define WOLFSSL_STM32L5
    #undef  NO_STM32_HASH
    #define HAL_CONSOLE_UART hlpuart1
#elif defined(STM32F207xx)
    #define WOLFSSL_STM32F2
    #define HAL_CONSOLE_UART huart3
#elif defined(STM32F107xC)
    #define WOLFSSL_STM32F1
    #define HAL_CONSOLE_UART huart4
    #define NO_STM32_RNG
#elif defined(STM32F401xE)
    #define WOLFSSL_STM32F4
    #define HAL_CONSOLE_UART huart2
    #define NO_STM32_RNG
    #define WOLFSSL_GENSEED_FORTEST
#elif defined(STM32G071xx)
    #define WOLFSSL_STM32G0
    #define HAL_CONSOLE_UART huart2
    #define NO_STM32_RNG
    #define WOLFSSL_GENSEED_FORTEST
#else
    #warning Please define a hardware platform!
    /* This means there is not a pre-defined platform for your board/CPU */
    /* You need to define a CPU type, HW crypto and debug UART */
    /* CPU Type: WOLFSSL_STM32F1, WOLFSSL_STM32F2, WOLFSSL_STM32F4,
        WOLFSSL_STM32F7, WOLFSSL_STM32H7, WOLFSSL_STM32L4 and WOLFSSL_STM32L5 */
    #define WOLFSSL_STM32F4

    /* Debug UART used for printf */
    /* The UART interface number varies for each board/CPU */
    /* Typically this is the UART attached to the ST-Link USB CDC UART port */
    #define HAL_CONSOLE_UART huart4

    /* Hardware Crypto - uncomment as available on hardware */
    //#define WOLFSSL_STM32_PKA
    //#define NO_STM32_RNG
    //#undef  NO_STM32_HASH
    //#undef  NO_STM32_CRYPTO
    //#define WOLFSSL_GENSEED_FORTEST
    //#define STM32_HAL_V2
#endif

so I just define WOLFSSL_STM32F4 then I always receive the error of defining hardware platform and a missing file "stm32f4xx_hal.h"

C:/02-RtosWorkplace/STM32_HelloWorld/Config/user_settings.h:181:6: warning: #warning Please define a hardware platform! [-Wcpp]
     #warning Please define a hardware platform!
      ^~~~~~~
C:/02-RtosWorkplace/STM32_HelloWorld/Config/user_settings.h:186:0: warning: "WOLFSSL_STM32F4" redefined
     #define WOLFSSL_STM32F4
 
<command-line>:0:0: note: this is the location of the previous definition
In file included from ../src/bareMetal.c:4:0:
C:/00-libs/wolfssl-m4-flag-hard2/include/wolfssl/wolfcrypt/settings.h:1296:22: fatal error: stm32f4xx_hal.h: No such file or directory
             #include "stm32f4xx_hal.h"


around line 1266 of the setting file if I define WOLFSSL_STM32F427_RNG it asks for the "stm32f427xx.h" but this is not the file that I have this is "stm32f4xx.h"

        #ifdef WOLFSSL_STM32F427_RNG
            #include "stm32f427xx.h"
        #endif

finally, is there a manual that shows how to config settings? or how to config this library for this board, or which definitions I need to use ?

6

(11 replies, posted in wolfSSL)

thanks for your help

when I tried to put wolfSSL_Init() I am needed to include ssl.h so when i include ssl.h I
received this error

C:/00-libs/wolfssl-m4-flag-hard2/include/wolfssl/wolfio.h:157:22: fatal error: sys/socket.h: No such file or directory
             #include <sys/socket.h>
                      ^~~~~~~~~~~~~~
compilation terminated.

also when defined WOLFSSL_STM32F427_RNG it asked for #include "stm32f427xx.h" which is not in my include

C:/00-libs/wolfssl-m4-flag-hard2/include/wolfssl/wolfcrypt/settings.h:1266:22: fatal error: stm32f427xx.h: No such file or directory
             #include "stm32f427xx.h"
                      ^~~~~~~~~~~~~~
compilation terminated.

do you think that I missed something?
can you give a  rng example data structure to put instead of generating and passing this function It is just a test

rng=XXXXXXXdatastructure

7

(11 replies, posted in wolfSSL)

Dear friends
I am going to implement ECC on launchpad stm32 Nucleo f446re + with FreeRTOS

First. because I am a new guy in this field what configuration I have to do before programming.

I did these configurations
1- I compiled the library for STM32 cortex m4 and linked it to my IDE
2- I defined these Items based of WOLFSSL STM32 SUPPORT
https://www.wolfssl.com/docs/stm32

WOLFSSL_STM32F4
FREERTOS
HAVE_ECC_SIGN
HAVE_ECC_VERIFY
STM32_RNG
STM32_CRYPTO
STM32

but the program gets stuck in the rng initiation function?

 wc_InitRng(&rng);

I removed all other function to find the problem you can see the code here, it is Freertos template with two tasks that I put this function in task 2

#include <stdio.h>
#include <string.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/options.h>
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/ecc.h>
#include <wolfssl/wolfcrypt/sha256.h>
#include <wolfssl/wolfcrypt/hash.h>
#include "stm32f4xx.h"
#include "FreeRTOS.h"  //provides TaskHandle_t
#include "task.h"  //to create tasks
/**define some macro for making condition in tasks***************************************/

/**define global variable **************************************************************/
TaskHandle_t xTaskHandle1=NULL;
TaskHandle_t xTaskHandle2=NULL;

WC_RNG rng;  // Data structure to keep random number
int ret = 0; // defining variable to keep status
/**prototype of functions****************************************************************/
extern void initialise_monitor_handles();  //0-to enable Semihosting -

void vTask1_handler(void *params);
void vTask2_handler(void *params);
/**main()********************************************************************************/
int main(void)
{
    //0-to enable Semihosting  exclude syscalls.c printf()
    initialise_monitor_handles();
    //project would work fine even without these two steps
    //1.Resets the RCC clock configuration to the default reset state.HSI= ON, PLL OFF, system clock = 16 MHz, cpu_clock= 16MHz
    RCC_DeInit();
    //2.update the SystemCoreClock variable
    SystemCoreClockUpdate();

    //3. lets create 2 tasks, task-1 and task-2
    xTaskCreate( vTask1_handler, "Hello_Task-1", configMINIMAL_STACK_SIZE, NULL, 2, &xTaskHandle1);
    xTaskCreate( vTask2_handler, "Hello_Task-2", configMINIMAL_STACK_SIZE, NULL, 2, &xTaskHandle2);

    printf("Start Program \n");

    //4. enable scheduler to schedule tasks to run
     vTaskStartScheduler();

    for(;;);
}



/**Task 1********************************************************************************/
void vTask1_handler(void *params)
{

    while(1)
    {
        printf("Start Task1\n");


        printf("ret is =%d",ret);
        printf("Finish Task 1 \n");
    }
}
/**Task 2********************************************************************************/
void vTask2_handler(void *params)
{
    while(1)
        {
        printf("Start Task2\n");
        ret = wc_InitRng(&rng); //Gets the seed (from OS) and key cipher for rng.
        printf("ret is =%d",ret);
        printf("Finish Task 2 \n");

        }
}

second, do you have any suggestions?

Thanks for your help.It solved

I used this instructor because I found them in the manual CHAPTER 10: WOLFCRYPT USAGE REFERENCE
https://www.wolfssl.com/docs/wolfssl-manual/ch10/

this is my code

byte md5sum[MD5_DIGEST_SIZE]; 
byte sha256sum[SHA256_DIGEST_SIZE]; 
byte buffer[1024]= "Hello"; 
Md5 md5;
Sha256 sha256;
//MD5
wc_InitMd5(&md5);
wc_Md5Update(&md5, buffer, sizeof(buffer)); 
wc_Md5Final(&md5, md5sum);
printf("MD5 is \n");
for(int i=0 ; i < MD5_DIGEST_SIZE ;i++)  printf("%x",md5sum[i]);
printf(" \n");
//SHA256
wc_InitSha256(&sha256);
wc_Sha256Update(&sha256, buffer, sizeof(buffer)); 
wc_Sha256Final(&sha256, sha256sum);
printf("SHA is \n");
for(int i=0 ; i < SHA256_DIGEST_SIZE  ;i++) printf("%x",sha256sum[i]);
printf(" \n");

I used MD5 as a test function I fill buffer like this and used printf() and %x operator to show the content of md5sum and shaa256sum as a resualt.

buffer[1024]= "Hello";
MD5 is 
e358b60a19d79e6ec8ccc18c834425 
SHA is 
7040f8eeeddf088d9d42198f8cf33be1471b2c225af4c1ab496eab9b9a89f8 

but it is a mistake because the Hash of Hello is this

Md5
8b1a9953c4611296a827abf8c47804d7
SHA256
185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969

What thing would be my mistake?

11

(3 replies, posted in wolfSSL)

i solved the problem with this configuration

./configure \
--host=arm-non-eabi \
CC=arm-none-eabi-gcc LD=arm-none-eabi-ld \
AR=arm-none-eabi-ar RANLIB=arm-none-eabi-ranlib\
STRIP=arm-none-eabi-strip \
RANLIB=arm-none-eabi-ranlib \
--prefix=/home/mohsen/wolfssl-m4-flag-hard \
CFLAGS="--specs=nosys.specs -mcpu=cortex-m4 -mthumb \
-mfloat-abi=hard -mfpu=fpv4-sp-d16 -Os \
-DNO_WOLFSSL_DIR -DHAVE_PK_CALLBACKS -DWOLFSSL_USER_IO -DNO_WRITEV" \
--disable-filesystem --enable-fastmath \
--disable-shared

12

(3 replies, posted in wolfSSL)

thanks for your answer on such short notice,I did that  also I uncomment 

#define FREERTOS

in the wolfssl/wolfcrypt/setting.h

then I receive this error

Building target: 01_Hello_library.elf
Invoking: MCU GCC Linker
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -L/home/mohsen/wolfssl-arm7/lib -specs=rdimon.specs -lc -lrdimon -T"/home/mohsen/workspace/01_Hello_library/LinkerScript.ld" -Wl,-Map=output.map -Wl,--gc-sections -o "01_Hello_library.elf" @"objects.list"  -lwolfssl -lm
/home/mohsen/Ac6/SystemWorkbench/plugins/fr.ac6.mcu.externaltools.arm-none.linux64_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld: error: 01_Hello_library.elf uses VFP register arguments, /home/mohsen/wolfssl-arm7/lib/libwolfssl.a(src_libwolfssl_la-md5.o) does not
/home/mohsen/Ac6/SystemWorkbench/plugins/fr.ac6.mcu.externaltools.arm-none.linux64_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/mohsen/wolfssl-arm7/lib/libwolfssl.a(src_libwolfssl_la-md5.o)
collect2: error: ld returned 1 exit status
make: *** [01_Hello_library.elf] Error 1

13

(3 replies, posted in wolfSSL)

Hello my friends, I am going to make an example with wolfssl library and FreeRTOS

my environment is :
Host Ubuntu
Target STM32f446 Nucleo-64 (ARM cortex M4 )
IDE System Workbench for STM32

so I realized first I need to compile the library for my environment so I installed arm-none-eabi-gcc toolchain on my ubuntu then with this configuration I tried to build the library (this configuration comes from manual section 2.6.1)

./configure --host=arm-none-eabi \
CC=arm-none-eabi-gcc LD=arm-none-eabi-ld \
AR=arm-none-eabi-ar RANLIB=arm-none-eabi-ranlib \
CFLAGS="-DNO_WOLFSSL_DIR \
-DWOLFSSL_USER_IO -DNO_WRITEV \
-mcpu=cortex-m4 -mthumb -Os \
-specs=rdimon.specs" CPPFLAGS="-I./"

So it was not successful and I received this error

 CC       wolfcrypt/test/testsuite_testsuite_test-test.o
  CC       examples/client/testsuite_testsuite_test-client.o
In file included from examples/client/client.c:47:0:
./wolfssl/test.h:143:14: fatal error: netdb.h: No such file or directory
     #include <netdb.h>
              ^~~~~~~~~
compilation terminated.
make[2]: *** [examples/client/testsuite_testsuite_test-client.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/home/mohsen/wolfssl-4.8.1'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/mohsen/wolfssl-4.8.1'
make: *** [all] Error 2

I didn't find any solution for that so I tried to use another configuration which was mentioned inspection Building with configure in github (https://github.com/wolfSSL/wolfssl/tree … DE/GCC-ARM)
also I changed the -march=armv8-a to -march=armv7-m

./configure \
--host=arm-non-eabi \
CC=arm-none-eabi-gcc \
AR=arm-none-eabi-ar \
STRIP=arm-none-eabi-strip \
RANLIB=arm-none-eabi-ranlib \
--prefix=/home/mohsen/default-wolfssl-arm7 \
CFLAGS="-march=armv7-m --specs=nosys.specs \
-DHAVE_PK_CALLBACKS -DWOLFSSL_USER_IO -DNO_WRITEV" \
--disable-filesystem --enable-fastmath \
--disable-shared

It was successful so I linked this library to my IDE but when I tried to use any wolfssl function like MD5 I received this error.

In file included from /home/mohsen/Ac6/SystemWorkbench/plugins/fr.ac6.mcu.externaltools.arm-none.linux64_1.17.0.201812190825/tools/compiler/arm-none-eabi/include/dirent.h:7:0,
                 from /home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/wc_port.h:723,
                 from /home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/types.h:35,
                 from /home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/md5.h:30,
                 from ../src/main.c:4:
/home/mohsen/Ac6/SystemWorkbench/plugins/fr.ac6.mcu.externaltools.arm-none.linux64_1.17.0.201812190825/tools/compiler/arm-none-eabi/include/sys/dirent.h:10:2: error: #error "<dirent.h> not supported"
 #error "<dirent.h> not supported"
  ^~~~~
In file included from /home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/types.h:35:0,
                 from /home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/md5.h:30,
                 from ../src/main.c:4:
/home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/wc_port.h:788:9: error: unknown type name 'DIR'
         DIR*   dir;
         ^~~
make: *** [src/main.o] Error 1

What do you think where is my mistake?