mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-07 20:50:39 +00:00
Use ZeroizeOnDrop exclusively (#723)
This commit is contained in:
parent
868d614020
commit
fbf1fb5339
1 changed files with 5 additions and 9 deletions
|
|
@ -20,7 +20,7 @@ use rand_core::CryptoRng;
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
|
|
||||||
#[cfg(feature = "zeroize")]
|
#[cfg(feature = "zeroize")]
|
||||||
use zeroize::Zeroize;
|
use zeroize::{Zeroize, ZeroizeOnDrop};
|
||||||
|
|
||||||
/// A Diffie-Hellman public key
|
/// A Diffie-Hellman public key
|
||||||
///
|
///
|
||||||
|
|
@ -70,8 +70,7 @@ impl AsRef<[u8]> for PublicKey {
|
||||||
/// are no serialization methods defined. This means that [`EphemeralSecret`]s can only be
|
/// are no serialization methods defined. This means that [`EphemeralSecret`]s can only be
|
||||||
/// generated from fresh randomness where the compiler statically checks that the resulting
|
/// generated from fresh randomness where the compiler statically checks that the resulting
|
||||||
/// secret is used at most once.
|
/// secret is used at most once.
|
||||||
#[cfg_attr(feature = "zeroize", derive(Zeroize))]
|
#[cfg_attr(feature = "zeroize", derive(Zeroize, ZeroizeOnDrop))]
|
||||||
#[cfg_attr(feature = "zeroize", zeroize(drop))]
|
|
||||||
pub struct EphemeralSecret(pub(crate) [u8; 32]);
|
pub struct EphemeralSecret(pub(crate) [u8; 32]);
|
||||||
|
|
||||||
impl EphemeralSecret {
|
impl EphemeralSecret {
|
||||||
|
|
@ -131,8 +130,7 @@ impl<'a> From<&'a EphemeralSecret> for PublicKey {
|
||||||
/// secret keys are never reused, which can have very serious security
|
/// secret keys are never reused, which can have very serious security
|
||||||
/// implications for many protocols.
|
/// implications for many protocols.
|
||||||
#[cfg(feature = "reusable_secrets")]
|
#[cfg(feature = "reusable_secrets")]
|
||||||
#[cfg_attr(feature = "zeroize", derive(Zeroize))]
|
#[cfg_attr(feature = "zeroize", derive(Zeroize, ZeroizeOnDrop))]
|
||||||
#[cfg_attr(feature = "zeroize", zeroize(drop))]
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ReusableSecret(pub(crate) [u8; 32]);
|
pub struct ReusableSecret(pub(crate) [u8; 32]);
|
||||||
|
|
||||||
|
|
@ -192,8 +190,7 @@ impl<'a> From<&'a ReusableSecret> for PublicKey {
|
||||||
/// implications for many protocols.
|
/// implications for many protocols.
|
||||||
#[cfg(feature = "static_secrets")]
|
#[cfg(feature = "static_secrets")]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[cfg_attr(feature = "zeroize", derive(Zeroize))]
|
#[cfg_attr(feature = "zeroize", derive(Zeroize, ZeroizeOnDrop))]
|
||||||
#[cfg_attr(feature = "zeroize", zeroize(drop))]
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct StaticSecret([u8; 32]);
|
pub struct StaticSecret([u8; 32]);
|
||||||
|
|
||||||
|
|
@ -270,8 +267,7 @@ impl AsRef<[u8]> for StaticSecret {
|
||||||
///
|
///
|
||||||
/// Each party computes this using their [`EphemeralSecret`] or [`StaticSecret`] and their
|
/// Each party computes this using their [`EphemeralSecret`] or [`StaticSecret`] and their
|
||||||
/// counterparty's [`PublicKey`].
|
/// counterparty's [`PublicKey`].
|
||||||
#[cfg_attr(feature = "zeroize", derive(Zeroize))]
|
#[cfg_attr(feature = "zeroize", derive(Zeroize, ZeroizeOnDrop))]
|
||||||
#[cfg_attr(feature = "zeroize", zeroize(drop))]
|
|
||||||
pub struct SharedSecret(pub(crate) MontgomeryPoint);
|
pub struct SharedSecret(pub(crate) MontgomeryPoint);
|
||||||
|
|
||||||
impl SharedSecret {
|
impl SharedSecret {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue