Add Zeroize impl for encoded point and scalar - #90
Conversation
Signed-off-by: maurges <git@morj.men>
| impl<E: Curve> Zeroize for EncodedPointInner<E> { | ||
| fn zeroize(&mut self) { | ||
| match self { | ||
| EncodedPointInner::Compressed(a) => a.as_mut().zeroize(), | ||
| EncodedPointInner::Uncompressed(a) => a.as_mut().zeroize(), | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Does it ever happen that an elliptic point represents a sensitive info? I don't recall any such case
There was a problem hiding this comment.
In this case, we would need a SecretPoint<E>...
There was a problem hiding this comment.
Yes, like in ECIES or ECDH when a point is fed to KDF - that's a secret info that we want to zeroize
There was a problem hiding this comment.
Right... But I see a little value in adding Zeroize to EncodedPoint, when the point itself is not Zeroize... But making a point Zeroize brings little value without adding SecretPoint...
There was a problem hiding this comment.
Ah the point is Zeroize already! Ok, then let's do Zeroize for EncodedPoint and leave SecretPoint as a thought for the future
| impl<E: Curve> Zeroize for EncodedScalar<E> { | ||
| fn zeroize(&mut self) { | ||
| self.as_mut().zeroize() | ||
| } | ||
| } |
There was a problem hiding this comment.
we might wanna add SecretScalar::{to_be_bytes, to_le_bytes} methods that return Zeroizing<Box<EncodedScalar>> (Box cuz otherwise Rust will leave copies of encoded scalar everywhere on the stack)
There was a problem hiding this comment.
Interesting idea. Right now I'm thinking about a SecretPoint and it would make a better and safer interface in this case
|
I got too excited and implemented SecretPoint, and rebased some stuff, so I'll close this MR and open a new one |
These values are sometimes used in secure contexts like KEM, and it would be useful to wrap then in Zeroizing