Merge pull request #348 from isislovecruft/develop

Merge #346 and restructure Zeroize implementations slightly
This commit is contained in:
isis agora lovecruft 2021-03-25 02:12:51 +00:00 committed by GitHub
commit 2a45241382
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 6 deletions

View file

@ -105,6 +105,8 @@ use subtle::ConditionallyNegatable;
use subtle::ConditionallySelectable;
use subtle::ConstantTimeEq;
use zeroize::Zeroize;
use constants;
use field::FieldElement;
@ -367,6 +369,28 @@ impl Default for EdwardsPoint {
}
}
// ------------------------------------------------------------------------
// Zeroize implementations for wiping points from memory
// ------------------------------------------------------------------------
impl Zeroize for CompressedEdwardsY {
/// Reset this `CompressedEdwardsY` to the compressed form of the identity element.
fn zeroize(&mut self) {
self.0.zeroize();
self.0[0] = 1;
}
}
impl Zeroize for EdwardsPoint {
/// Reset this `CompressedEdwardsPoint` to the identity element.
fn zeroize(&mut self) {
self.X.zeroize();
self.Y = FieldElement::one();
self.Z = FieldElement::one();
self.T.zeroize();
}
}
// ------------------------------------------------------------------------
// Validity checks (for debugging, not CT)
// ------------------------------------------------------------------------

View file

@ -177,6 +177,8 @@ use subtle::ConditionallySelectable;
use subtle::ConditionallyNegatable;
use subtle::ConstantTimeEq;
use zeroize::Zeroize;
use edwards::EdwardsBasepointTable;
use edwards::EdwardsPoint;
@ -200,8 +202,6 @@ use backend::serial::scalar_mul;
))]
use backend::vector::scalar_mul;
use zeroize::Zeroize;
// ------------------------------------------------------------------------
// Compressed points
// ------------------------------------------------------------------------
@ -1092,10 +1092,7 @@ impl Zeroize for CompressedRistretto {
impl Zeroize for RistrettoPoint {
fn zeroize(&mut self) {
self.0.X.zeroize();
self.0.Y.zeroize();
self.0.Z.zeroize();
self.0.T.zeroize();
self.0.zeroize();
}
}