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

Replace JS implementation of SHA1 with SubtleCrypto #1

Open
schmijos opened this issue Feb 29, 2024 · 1 comment
Open

Replace JS implementation of SHA1 with SubtleCrypto #1

schmijos opened this issue Feb 29, 2024 · 1 comment

Comments

@schmijos
Copy link
Contributor

Reimplementing the hashing algorithm in JavaScript (see Hashcash.sha1) renders this library vulnerable to one specific attack: An attacker could fork this library and use a faster implementation of SHA1 and address all users of active_hashcash.

I'd like to suggest that we replace the custom SHA1 implementation with one of the Web Crypto API. I suspect this is rather easy and would give 10-20 times more protection according to your note in the README.

The hashing function to be used would probably be the one with most widely-accessible onchip support and equal performance distribution.

If you want to dig deep, have a look at the testing distributions of SHA512. On that site I also found very interesting to look at what hash functions even exist.

@alexisbernard
Copy link
Member

Absolutely, improving the speed of SHA1 is critical.

I also thought the Crypto API should be faster than a custom SHA1, but that wasn't the case. That is why I switched here 2df3ba5. But probably I miss used the Crypto API.

I also have the idea to compile the SHA1 in wasm. If you have any experience in one of those, that would be greatly appreciated!

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

2 participants