ArduinoIDE ist using wrong Crypto.h library after esp8266-Board-Update

Hallo and Thx for your help.

I did an update for the esp8266-Boards.

Okay I should not update! :confused:
Okay I should not update! :confused:

Now if I compile a sketch using the Crypto.h-Library (from Arduino Cryptography Library: Arduino Cryptography Library), I get following error:

In file included from /home/leo/Arduino/sketchbook/lorapaket_esp8266_sensorstation-V6/lorapaket_esp8266_sensorstation-V6.ino:7:0:
/home/leo/.arduino15/packages/esp8266/hardware/esp8266/2.7.1/cores/esp8266/Crypto.h:749:5: error: 'br_hkdf_context' in namespace '::' does not name a type
     ::br_hkdf_context hkdfContext;

The Compiler (or better the preprocessor) tries to use /home/leo/.arduino15/packages/esp8266/hardware/esp8266/2.7.1/cores/esp8266/Crypto.h
instead of
/home/leo/Arduino/libraries/Crypto/src/Crypto.h

The solution is easy but ugly:

Change
#include <Crypto.h>
in the sketch to
#include “/home/leo/Arduino/libraries/Crypto/src/Crypto.h”

or do a downgrade to esp8266 version 2.6.3

The error exits with esp8266 version 2.7.0 and 2.7.1.

I use
arduinoIDE version: 1.8.10

My question now:
Is there a better, more pretty solution for this problem??
(to use the newest esp8266 version and not to have the ugly long full-path include in the sketch,
which has to be changed on an other system - for example - to make the sketch work again)

Thx, thx for help
Leo

linuxtrainer:
My question now:
Is there a better, more pretty solution for this problem??
(to use the newest esp8266 version and not to have the ugly long full-path include in the sketch,
which has to be changed on an other system - for example - to make the sketch work again)

Here’s an alternative solution:

Create a file named /home/leo/Arduino/libraries/Crypto/src/CryptoLibrary.h

Open the file in a text editor.

Add the line:

#include "Crypto.h"

Save the file.

In your sketches, change this line:

#include <Crypto.h>

to

#include <CryptoLibrary.h>

Since CryptoLibrary.h is a unique filename, you will no longer have the problems with the name collision between the ESP8266 core’s Crypto.h and the Crypto library’s Crypto.h.

linuxtrainer:
The solution is easy but ugly:

Change
#include <Crypto.h>
in the sketch to
#include “/home/leo/Arduino/libraries/Crypto/src/Crypto.h”

Note that this solution will not work with most libraries (it happens to work with the Crypto library by luck). The reason is that when you do #include <Crypto.h>, it causes all source files of the Crypto library to be compiled recursively, whereas #include “/home/leo/Arduino/libraries/Crypto/src/Crypto.h” essentially just copies the contents of Cryto.h into your sketch. Most libraries rely on their source files being compiled. With the Crypto library, you also add an #include directive for the header file associated with the cryptographic algorithm you are using, so that causes the necessary source files compilation.

Hallo pert,

THX for your solutions!

I have learned something new!!

THX

Leo

You're welcome. I'm glad if I was able to be of assistance. Enjoy! Per