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

Support additional hashing functions #168

Open
adlerjohn opened this issue Jun 21, 2020 · 3 comments
Open

Support additional hashing functions #168

adlerjohn opened this issue Jun 21, 2020 · 3 comments

Comments

@adlerjohn
Copy link

Additional hashing algorithms should be added to implementations.

id name reason
sha-256d 2-SHA-256 Prevents length extension attacks, and can otherwise leverage the same benefits (e.g. hardware implementations) as SHA-256.
keccak-256 Keccak-256 There are concerns that the changes to Keccak when finalizing it to SHA3 made it more vulnerable.
sha3-256 SHA3-256 SHA3 is the next standard hash function, and unlike SHA2 is not known to be vulnerable to length extension attacks.
@tony-iqlusion
Copy link
Member

tony-iqlusion commented Jun 21, 2020

Note that the implementation is generic over the underlying hash function.

However, I am loathe to support a hash function zoo in any sort of official capacity (beyond enabling the possibility for those who choose to do so).

More choice in cryptographic algorithms increases implementation complexity and harms interoperability. To the extent the existing implementation is generic over the underlying hash function, the main use case is to support hardware cryptographic accelerators for SHA-256 (as one of our main use cases is embedded) as opposed to using the software implementation in the sha2 crate

Length extension attacks against Veriform are largely mitigated through its current use of nested/structured hashing. The one place where there's even a potential for length extension attacks to occur is in toplevel messages, and to me the best solution to that is to place toplevel messages into self-delimiting envelopes which include a length prefix at the beginning of the message, then computing a digest that includes the length delimiter. Not only does this fix the length extension attack potential, but self-delimiting messages are generally convenient and it's exceedingly common to wrap Protobuf messages this way already.

That said, I do like sha256d since having seen it first used in Tahoe-LAFS, and will note that they did use it in the computation of their Merkle trees (as did Bitcoin/Satoshi, probably because that's what Tahoe-LAFS did). It just feels redundant in that context.

@adlerjohn
Copy link
Author

However, I am loathe to support a hash function zoo in any sort of official capacity (beyond enabling the possibility for those who choose to do so).

You're not wrong, but that seems contradictory to officially supporting multiple languages:

NOTE: Veriform is a multi-language monorepo: all implementations in all languages within the repo are intended to implement the spec in its current state and share a consistent feature set. The progress above applies equally to all language implementations currently within the repo.

So long as a specification exists, it can be implemented in any language.

@tony-iqlusion
Copy link
Member

I would suggest implementations in other languages are similarly parameterized around the underlying hash function.

Eventually it'd be good to pick an alternative to SHA-256 as a failsafe (or potential performance optimization), but initially I think it'd be better if all implementations use SHA-256.

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