Replace ring with hmac for hmacs#139
Conversation
|
@tomaka could you clarify if the #138 applies to the current or the proposed implementation? Seems like the latter.
This seems to be different from https://briansmith.org/rustdoc/ring/hmac/struct.SigningKey.html#method.new
Maybe we should use https://docs.rs/hmac/0.7.0/hmac/trait.Mac.html#method.new_varkey? |
|
#138 applies to both. I decided to not touch the API here.
Oh, good remark. I really don't like this implicit behaviour in |
|
@tomaka I did write some compat for webassembly on most of crypto crate a while back, for your code it looks like I did use Hmac : https://github.com/cheme/parity-common/blob/crypto-compat/parity-crypto/src/hmac_alt.rs there is a test to compare both impl (the branch did keep both impl). |
|
I like @cheme's version better, because it can panic with a more meaningful message and uses static dispatch. As a downside it adds a dependency on |
There was a problem hiding this comment.
This seems to work as intended, sorry for my previous comment I did not mean to say we should use this implementation but I misunderstood the previous comment and thought it could help.
It is probably a bit late but you also got secp256 alt implementation and pbkdf2 in the same branch and also lot of compat (not everything is good and I think some are not required anymore) in my wasm-test branch.
@ordian I am not sure having the Hmac is an issue (I did find back my test in ethereum openethereum/parity-ethereum@master...cheme:wasm-tests and it does not look like the api did change except for an import (for some other things it did change a lot eg secp where I add to put some curve math in a trait).
Edit: @ordian I think I misunderstood you, it does add some additional deps indeed (could probably find a way to avoid that).
I meant the fact, that we're using |
|
|
||
| enum KeyInner { | ||
| Sha256(GenericArray<u8, U64>), | ||
| Sha512(GenericArray<u8, U128>), |
It's a bit of a painful birth because of #138, but this PR replaces
ringwithhmacfor computing HMACs.Part of #133