google / mundane

Mundane is a Rust cryptography library backed by BoringSSL that is difficult to misuse, ergonomic, and performant (in that order).
MIT License
1.07k stars 46 forks source link

Implement core::hash::Hasher for Hasher, Hmac #20

Closed joshlf closed 5 years ago

joshlf commented 5 years ago

It would be useful to be able to use Hashers and Hmacs in order to hash values that implement the core's Hash trait. In order to do that, Mundane's Hasher trait and Hmac type should implement the core's Hasher trait.

I suspect that, since our Hasher trait is not Clone and its finish method takes self by value, we can't just do a blanket impl - impl<H: Hasher> core::hash::Hasher for H { ... }. There would be no way to implement that trait's finish method, which takes self by immutable reference. Instead, we'll likely need to add a core::hash::Hasher bound to our Hasher trait.

For the Hmac type, it should be more straightforward.