mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
Merge pull request #306 from isislovecruft/feature/236-merge-rebase
Implement Zeroize for Scalar and MontgomeryPoint
This commit is contained in:
commit
77203aa1cb
2 changed files with 18 additions and 2 deletions
|
|
@ -61,6 +61,8 @@ use subtle::Choice;
|
||||||
use subtle::ConditionallySelectable;
|
use subtle::ConditionallySelectable;
|
||||||
use subtle::ConstantTimeEq;
|
use subtle::ConstantTimeEq;
|
||||||
|
|
||||||
|
use zeroize::Zeroize;
|
||||||
|
|
||||||
/// Holds the \\(u\\)-coordinate of a point on the Montgomery form of
|
/// Holds the \\(u\\)-coordinate of a point on the Montgomery form of
|
||||||
/// Curve25519 or its twist.
|
/// Curve25519 or its twist.
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
|
@ -91,6 +93,12 @@ impl PartialEq for MontgomeryPoint {
|
||||||
|
|
||||||
impl Eq for MontgomeryPoint {}
|
impl Eq for MontgomeryPoint {}
|
||||||
|
|
||||||
|
impl Zeroize for MontgomeryPoint {
|
||||||
|
fn zeroize(&mut self) {
|
||||||
|
self.0.zeroize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl MontgomeryPoint {
|
impl MontgomeryPoint {
|
||||||
/// View this `MontgomeryPoint` as an array of bytes.
|
/// View this `MontgomeryPoint` as an array of bytes.
|
||||||
pub fn as_bytes<'a>(&'a self) -> &'a [u8; 32] {
|
pub fn as_bytes<'a>(&'a self) -> &'a [u8; 32] {
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,8 @@ use subtle::Choice;
|
||||||
use subtle::ConditionallySelectable;
|
use subtle::ConditionallySelectable;
|
||||||
use subtle::ConstantTimeEq;
|
use subtle::ConstantTimeEq;
|
||||||
|
|
||||||
|
use zeroize::Zeroize;
|
||||||
|
|
||||||
use backend;
|
use backend;
|
||||||
use constants;
|
use constants;
|
||||||
|
|
||||||
|
|
@ -522,6 +524,12 @@ impl From<u128> for Scalar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Zeroize for Scalar {
|
||||||
|
fn zeroize(&mut self) {
|
||||||
|
self.bytes.zeroize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Scalar {
|
impl Scalar {
|
||||||
/// Return a `Scalar` chosen uniformly at random using a user-provided RNG.
|
/// Return a `Scalar` chosen uniformly at random using a user-provided RNG.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue