Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crypto library "Hash.h" conflicting with ESP866 Arduino package "Hash.h" #79

Open
arbabseyfola opened this issue May 21, 2023 · 5 comments

Comments

@arbabseyfola
Copy link

https://community.platformio.org/t/conflicting-hash-h-issue/9295

@rweather
Copy link
Owner

There's not much I can do about other libraries choosing conflicting names for their internal implementation details, without breaking compatibility with my own users that expect straightforward names in the public headers.

If WebSocketClient was to move sha1.h and similar internal headers to a subdirectory, it might resolve the conflict because subdirectories are not added to the global path by the Arduino IDE.

@arbabseyfola
Copy link
Author

There's not much I can do about other libraries choosing conflicting names for their internal implementation details, without breaking compatibility with my own users that expect straightforward names in the public headers.

If WebSocketClient was to move sha1.h and similar internal headers to a subdirectory, it might resolve the conflict because subdirectories are not added to the global path by the Arduino IDE.

The problem is with the Arduino internal library, not the websocket. Any code that uses the Crypto library and the Arduino internal Hash library at the same time will encounter this problem.

https://github.com/esp8266/Arduino/blob/master/libraries/Hash/src/Hash.h
The solution is rename Hash.h.

@rweather
Copy link
Owner

OK, sorry I missed that detail.

I believe this is issue specific to esp8266 - no other Arduino platform that I know of has a "Hash.h" or a "Hash" library in their port. Given that the only function it provides is for sha1, no one should be using that library and the maintainers should probably remove it. SHA-1 is well and truly broken.

I don't recall having this problem with esp8266 before, as I have tested Crypto on a D1 Mini in the past.

I will think about renaming Hash.h to say HashBase.h in Crypto, but it could potentially affect a lot of people on non-esp8266 platforms to work around this.

@Obsttube
Copy link

Obsttube commented Aug 5, 2023

How about adding a HashBase.h file with contents: '#include "Hash.h"'? It will not break backward compatibility but allow people using esp8266 to do #include <HashBase.h> instead of #include <Hash.h>.

I did not try it with Hash.h, but it should work. If not, then renaming Hash.h to HashBase.h and adding Hash. with contents: '#include "HashBase.h"' should work.

@Obsttube
Copy link

Obsttube commented Aug 5, 2023

I had a similar problem with Crypto.h. In v2.7.0 of esp8266 they added CryptoInterface to esp8266 core ( https://github.com/esp8266/Arduino/releases/tag/2.7.0 ), which breaks "#include <Crypto.h>" in sketches.

I created a file called "CryptoLibrary.h" in your library src dir with contents: '#include "Crypto.h"' and now when I write programs for esp8266 I just do #include <CryptoLibrary.h> instead of #include <Crypto.h> and it works. Here is a thread with someone else having that problem: https://forum.arduino.cc/t/arduinoide-ist-using-wrong-crypto-h-library-after-esp8266-board-update/660052

Would you be willing to add CryptoLibrary.h? I can make a pull request for that if you agree. It will probably help other people too as it is not possible to use your library on esp8266 since may 2020 when they added CryptoInterface to core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants