Open FreddieRidell opened 5 years ago
Thanks heaps for this PR! Unfortunately in its current state we can't accept it, because it opens us up to timing attacks.
Keeping Blake2bResult
around was a deliberate choice, as the Eq
and PartialEq
methods are guaranteed to be constant-time. By moving the bytes over to a regular buffer we drop that property, which isn't great. (ref)
I do really like some of the ergonomics improvements introduced here; typing .as_bytes().into()
gets old fast. I wonder if perhaps we introduce some conversion traits we could achieve similar benefits without losing any (cryptographic) properties.
Thanks again so much; overall I really like this direction!
Ahh, I should have asked before I picked a TODO
to work on, is there a better place to ask in future?
It looks like like Blake2BResult
uses constant_time_eq to do its equality check, it should be pretty easy to adapt this solution to use that function. If I made that change would that make this PR acceptable?
Ahh, I should have asked before I picked a TODO to work on, is there a better place to ask in future?
Opening an issue is a good way to go about this! Otherwise I'm also around on Freenode and Discord for synchronous chat.
If I made that change would that make this PR acceptable?
Possibly! But looking at this patch I'm thinking that adding more conversion traits on the existing codebase could probably get us the closest to our intended goal with the fewest amount of changes required.
Possibly!
I've switched Hash
to manually implementing PartialEq
and Eq
using constant_time_eq
, let me know what you think?
But looking at this patch I'm thinking that adding more conversion traits on the existing codebase could probably get us the closest to our intended goal with the fewest amount of changes required.
Do you mean implementing From
for Hash
-> Blake2bResult
and stuff like that?
@yoshuawuyts sorry to bother, but I'm wondering how do you feel in regards of the new constant hash verification in this current PR.
🙋 feature
Key Changes:
crypto::hash::Hash
to contain a[u8; 32]
, rather thanBlake2bResult
storage::node::Node.hash
to be aHash
, rather than aVec<u8>