Struct tor_llcrypto::pk::curve25519::StaticSecret
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§
§impl StaticSecret
impl StaticSecret
pub 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
.
pub fn new<T>(csprng: T) -> StaticSecret
👎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>(csprng: T) -> StaticSecret
random_from_rng
. This will be removed in 2.1.0static_secrets
only.Generate a new StaticSecret
with the supplied RNG.
pub fn random_from_rng<T>(csprng: T) -> StaticSecret
Available on crate feature static_secrets
only.
pub fn random_from_rng<T>(csprng: T) -> StaticSecret
static_secrets
only.Generate a new StaticSecret
with the supplied RNG.
Trait Implementations§
§impl AsRef<[u8]> for StaticSecret
Available on crate feature static_secrets
only.
impl AsRef<[u8]> for StaticSecret
static_secrets
only.§impl Clone for StaticSecret
impl Clone for StaticSecret
§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 more§impl<'a> From<&'a StaticSecret> for PublicKey
Available on crate feature static_secrets
only.
impl<'a> From<&'a StaticSecret> for PublicKey
static_secrets
only.§fn from(secret: &'a StaticSecret) -> PublicKey
fn from(secret: &'a StaticSecret) -> PublicKey
Given an x25519 StaticSecret
key, compute its corresponding PublicKey
.
§impl From<[u8; 32]> for StaticSecret
Available on crate feature static_secrets
only.
impl From<[u8; 32]> for StaticSecret
static_secrets
only.§fn from(bytes: [u8; 32]) -> StaticSecret
fn from(bytes: [u8; 32]) -> StaticSecret
Load a secret key from a byte array.
§impl Zeroize for StaticSecret
impl Zeroize for StaticSecret
Auto Trait Implementations§
impl Freeze for StaticSecret
impl RefUnwindSafe for StaticSecret
impl Send for StaticSecret
impl Sync for StaticSecret
impl Unpin for StaticSecret
impl UnwindSafe for StaticSecret
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> ToHex for T
impl<T> ToHex for T
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Lower case
letters are used (e.g. f9b4ca
)source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Upper case
letters are used (e.g. F9B4CA
)