Struct x25519_dalek::StaticSecret
source · pub struct StaticSecret(/* private fields */);
Expand description
A Diffie-Hellman secret key that can be used to compute multiple SharedSecret
s.
This type is identical to the EphemeralSecret
type, except that the
StaticSecret::diffie_hellman
method does not consume the secret key, and the type provides
serialization methods to save and load key material. This means that the secret may be used
multiple times (but does not have to be).
§Warning
If you’re uncertain about whether you should use this, then you likely
should not be using this. Our strongly recommended advice is to use
EphemeralSecret
at all times, as that type enforces at compile-time that
secret keys are never reused, which can have very serious security
implications for many protocols.
Implementations§
source§impl StaticSecret
impl StaticSecret
sourcepub fn diffie_hellman(&self, their_public: &PublicKey) -> SharedSecret
Available on crate feature static_secrets
only.
pub fn diffie_hellman(&self, their_public: &PublicKey) -> SharedSecret
static_secrets
only.Perform a Diffie-Hellman key agreement between self
and
their_public
key to produce a SharedSecret
.
sourcepub fn new<T: RngCore + CryptoRng>(csprng: T) -> Self
👎Deprecated since 2.0.0: Renamed to random_from_rng
. This will be removed in 2.1.0Available on crate feature static_secrets
only.
pub fn new<T: RngCore + CryptoRng>(csprng: T) -> Self
random_from_rng
. This will be removed in 2.1.0static_secrets
only.Generate a new StaticSecret
with the supplied RNG.
sourcepub fn random_from_rng<T: RngCore + CryptoRng>(csprng: T) -> Self
Available on crate feature static_secrets
only.
pub fn random_from_rng<T: RngCore + CryptoRng>(csprng: T) -> Self
static_secrets
only.Generate a new StaticSecret
with the supplied RNG.
sourcepub fn random() -> Self
Available on crate features static_secrets
and getrandom
only.
pub fn random() -> Self
static_secrets
and getrandom
only.Generate a new StaticSecret
.
Trait Implementations§
source§impl AsRef<[u8]> for StaticSecret
Available on crate feature static_secrets
only.
impl AsRef<[u8]> for StaticSecret
static_secrets
only.source§impl Clone for StaticSecret
impl Clone for StaticSecret
source§fn clone(&self) -> StaticSecret
fn clone(&self) -> StaticSecret
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'de> Deserialize<'de> for StaticSecret
impl<'de> Deserialize<'de> for StaticSecret
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<'a> From<&'a StaticSecret> for PublicKey
Available on crate feature static_secrets
only.
impl<'a> From<&'a StaticSecret> for PublicKey
static_secrets
only.source§fn from(secret: &'a StaticSecret) -> PublicKey
fn from(secret: &'a StaticSecret) -> PublicKey
Given an x25519 StaticSecret
key, compute its corresponding PublicKey
.