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

Add hashlib to WIZnet EVB-Pico Ethernet boards #8719

Closed
wants to merge 2 commits into from

Conversation

anecdata
Copy link
Member

@anecdata anecdata commented Dec 14, 2023

Issue arose in HTTPServer library in the context of websockets:
adafruit/Adafruit_CircuitPython_HTTPServer#73
The library can be improved with a flexible import that looks for either the native hashlib module or the adafruit_hashlib library (web sockets could be run on a board without hashlib, for example with an ethernet featherwing), but the native module is faster.

Awaiting testing.

addendum: oops... looks like not enough space on some builds

@jepler
Copy link
Member

jepler commented Dec 14, 2023

It looks like right now the inclusion of "mbedtls" header & library is conditional on CIRCUITPY_SSL only. This will have to be fixed in ports/raspberrypi/Makefile, selecting a different mbedtls subset when SSL is off but HASHLIB is enabled. I don't know exactly what that will end up looking like.

@anecdata
Copy link
Member Author

anecdata commented Dec 14, 2023

I'm not sure I understand. There is no TLS right now on Ethernet boards or Ethernet SPI configs (wish there was).

Should I put this in draft, or close it?

@jepler
Copy link
Member

jepler commented Dec 14, 2023

I'll try explaining again, sorry for being unclear. I was trying to offer you advice about how to fix the build errors.

I looked at the failing build. It appeared to me that this was the salient portion of the build error:

./common-hal/hashlib/Hash.h:29:10: fatal error: mbedtls/sha1.h: No such file or directory
   29 | #include "mbedtls/sha1.h"
      |          ^~~~~~~~~~~~~~~~

I believe this occurs because the Makefile only decides to include mbedtls when ssl is enabled. It needs to be changed so that it includes mbedtls (probably with different configuration options) when hashlib is enabled and ssl is not enabled.

This means editing the Makefile for ports/raspberrypi but without actually doing the work I can't say exactly what it would look like in any detail. It probably involves some new conditional block similar to the one for SSL:

ifeq ($(CIRCUITPY_SSL),1)
CFLAGS += -isystem $(TOP)/mbedtls/include
... # lots more stuff
endif

becoming

ifeq ($(CIRCUITPY_SSL),1)
CFLAGS += -isystem $(TOP)/mbedtls/include
... # lots more stuff
else ifeq ($(CIRCUITPY_HASHLIB),1)
CFLAGS += -isystem $(TOP)/mbedtls/include
... # A new block modeled after the previous block but only enabling the hash functions
endif

@anecdata
Copy link
Member Author

anecdata commented Dec 15, 2023

Thanks for the detailed explanation. I know approximately zero about makefiles (and mbedtls for that matter), so I'm not too inclined to go messing with them. I had interpreted the errors as the builds being too big in some languages (didn't look deep enough).

@anecdata
Copy link
Member Author

Closing in favor of #8749

@anecdata anecdata closed this Dec 22, 2023
@anecdata anecdata deleted the wizhash branch December 27, 2023 03:51
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

Successfully merging this pull request may close these issues.

None yet

2 participants