mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
Merge remote-tracking branch 'spacejam/tyler_optimize_compilation' into main
This commit is contained in:
commit
ce37a8a047
2 changed files with 14 additions and 5 deletions
|
|
@ -30,7 +30,7 @@ rand_core = { version = "0.5", default-features = false, optional = true }
|
||||||
serde_crate = { package = "serde", version = "1.0", default-features = false, optional = true }
|
serde_crate = { package = "serde", version = "1.0", default-features = false, optional = true }
|
||||||
serde_bytes = { version = "0.11", optional = true }
|
serde_bytes = { version = "0.11", optional = true }
|
||||||
sha2 = { version = "0.9", default-features = false }
|
sha2 = { version = "0.9", default-features = false }
|
||||||
zeroize = { version = "1", default-features = false, features = ["zeroize_derive"] }
|
zeroize = { version = "1", default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
hex = "^0.4"
|
hex = "^0.4"
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,14 @@ use crate::signature::*;
|
||||||
///
|
///
|
||||||
/// Instances of this secret are automatically overwritten with zeroes when they
|
/// Instances of this secret are automatically overwritten with zeroes when they
|
||||||
/// fall out of scope.
|
/// fall out of scope.
|
||||||
#[derive(Zeroize)]
|
|
||||||
#[zeroize(drop)] // Overwrite secret key material with null bytes when it goes out of scope.
|
|
||||||
pub struct SecretKey(pub(crate) [u8; SECRET_KEY_LENGTH]);
|
pub struct SecretKey(pub(crate) [u8; SECRET_KEY_LENGTH]);
|
||||||
|
|
||||||
|
impl Drop for SecretKey {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
self.0.zeroize()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Debug for SecretKey {
|
impl Debug for SecretKey {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||||
write!(f, "SecretKey: {:?}", &self.0[..])
|
write!(f, "SecretKey: {:?}", &self.0[..])
|
||||||
|
|
@ -235,13 +239,18 @@ impl<'d> Deserialize<'d> for SecretKey {
|
||||||
// same signature scheme, and which both fail in exactly the same way. For a
|
// same signature scheme, and which both fail in exactly the same way. For a
|
||||||
// better-designed, Schnorr-based signature scheme, see Trevor Perrin's work on
|
// better-designed, Schnorr-based signature scheme, see Trevor Perrin's work on
|
||||||
// "generalised EdDSA" and "VXEdDSA".
|
// "generalised EdDSA" and "VXEdDSA".
|
||||||
#[derive(Zeroize)]
|
|
||||||
#[zeroize(drop)] // Overwrite secret key material with null bytes when it goes out of scope.
|
|
||||||
pub struct ExpandedSecretKey {
|
pub struct ExpandedSecretKey {
|
||||||
pub(crate) key: Scalar,
|
pub(crate) key: Scalar,
|
||||||
pub(crate) nonce: [u8; 32],
|
pub(crate) nonce: [u8; 32],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for ExpandedSecretKey {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
self.key.zeroize();
|
||||||
|
self.nonce.zeroize()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a SecretKey> for ExpandedSecretKey {
|
impl<'a> From<&'a SecretKey> for ExpandedSecretKey {
|
||||||
/// Construct an `ExpandedSecretKey` from a `SecretKey`.
|
/// Construct an `ExpandedSecretKey` from a `SecretKey`.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue