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

Hashlib implementation #461

Merged
merged 5 commits into from Dec 16, 2014
Merged

Hashlib implementation #461

merged 5 commits into from Dec 16, 2014

Conversation

ganehag
Copy link
Contributor

@ganehag ganehag commented Dec 2, 2014

A library to handle SHA-224/256/384/512. Inspired by hashlib from Python. Currently 384/512 caused a nasty crash on the Espruino board. This is a work in progress.

@gfwilliams
Copy link
Member

Thanks! Sorry it's taken a while to get back to you. Looking at this code, it seems that there are actually quite a few memory leaks, which could be causing you problems. Basically pretty much every time you get a pointer to a JsVar, you need to call jsvUnLock - for instance when you do jsvObjectSetChild you'd need to do it on what is returned.

If you created a test that went in the tests directory, and then tested it on the standard Linux compile of Espruino ./espruino --test tests/test_sha.js then it should tell you if it thinks there are any memory leaks.

@ganehag
Copy link
Contributor Author

ganehag commented Dec 16, 2014

As far as I can see, all leaks are gone. But i can't get 384 & 512 to work. My guess is that the Espruino runs out of memory or some kind of issue with uint64 or the sha512_ctx itself.

Triggering every minute, my code has now been running for a week non-stop. Performing SHA256 HMAC on a JSON object with five 1-wire sensors.

I decided not to merge the HMAC C code. Since It only took me about 70 lines of JS code to create a working HMAC library on top of hashlib. This library will be added to EspruinoDocs if hashlib gets accepted into mainline.

@gfwilliams
Copy link
Member

Thanks! looks really good.

gfwilliams added a commit that referenced this pull request Dec 16, 2014
@gfwilliams gfwilliams merged commit 5598844 into espruino:master Dec 16, 2014
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