pub struct PrecalcSecretKey<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize>(/* private fields */);Expand description
Precalculated secret key for use with precalc_* functions in
crate::dryocbox::DryocBox.
Use precalc_* functions to encrypt or decrypt multiple messages between
the same sender and receiver. They reuse this shared secret instead of
repeating the public-key operation for every message.
Using precalculated secret keys is compatible with libsodium’s
crypto_box_beforenm.
Implementations§
Source§impl PrecalcSecretKey<Locked<HeapByteArray<CRYPTO_BOX_PUBLICKEYBYTES>>>
impl PrecalcSecretKey<Locked<HeapByteArray<CRYPTO_BOX_PUBLICKEYBYTES>>>
Sourcepub fn precalculate_locked<ThirdPartyPublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES>>(
third_party_public_key: &ThirdPartyPublicKey,
secret_key: &SecretKey,
) -> Result<Self, Error>
Available on crate feature protected only.
pub fn precalculate_locked<ThirdPartyPublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES>>( third_party_public_key: &ThirdPartyPublicKey, secret_key: &SecretKey, ) -> Result<Self, Error>
protected only.Computes a heap-allocated, page-aligned, locked shared secret key
for the given third_party_public_key and secret_key.
Compatible with libsodium’s crypto_box_beforenm.
§Errors
Returns an error if third_party_public_key is an unacceptable
low-order point or the protected allocation cannot be locked.
§Panics
Panics if the page-aligned allocation cannot be created or its size cannot be represented with guard pages.
Source§impl PrecalcSecretKey<LockedRO<HeapByteArray<CRYPTO_BOX_PUBLICKEYBYTES>>>
impl PrecalcSecretKey<LockedRO<HeapByteArray<CRYPTO_BOX_PUBLICKEYBYTES>>>
Sourcepub fn precalculate_readonly_locked<ThirdPartyPublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES>>(
third_party_public_key: &ThirdPartyPublicKey,
secret_key: &SecretKey,
) -> Result<Self, Error>
Available on crate feature protected only.
pub fn precalculate_readonly_locked<ThirdPartyPublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES>>( third_party_public_key: &ThirdPartyPublicKey, secret_key: &SecretKey, ) -> Result<Self, Error>
protected only.Computes a heap-allocated, page-aligned, locked, read-only shared
secret key for the given third_party_public_key and
secret_key.
Compatible with libsodium’s crypto_box_beforenm.
§Errors
Returns an error if third_party_public_key is an unacceptable
low-order point, the protected allocation cannot be locked, or its
page permissions cannot be changed to read-only.
§Panics
Panics if the page-aligned allocation cannot be created or its size cannot be represented with guard pages.
Source§impl PrecalcSecretKey<StackByteArray<CRYPTO_BOX_BEFORENMBYTES>>
impl PrecalcSecretKey<StackByteArray<CRYPTO_BOX_BEFORENMBYTES>>
Sourcepub fn precalculate<ThirdPartyPublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES>>(
third_party_public_key: &ThirdPartyPublicKey,
secret_key: &SecretKey,
) -> Result<Self, Error>
pub fn precalculate<ThirdPartyPublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES>>( third_party_public_key: &ThirdPartyPublicKey, secret_key: &SecretKey, ) -> Result<Self, Error>
Computes a stack-allocated shared secret key for the given
third_party_public_key and secret_key.
Compatible with libsodium’s crypto_box_beforenm.
§Errors
Returns an error if third_party_public_key is an unacceptable
low-order point.
Trait Implementations§
Source§impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> ByteArray<CRYPTO_BOX_BEFORENMBYTES> for PrecalcSecretKey<InnerKey>
impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> ByteArray<CRYPTO_BOX_BEFORENMBYTES> for PrecalcSecretKey<InnerKey>
Source§impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Bytes + Zeroize> Bytes for PrecalcSecretKey<InnerKey>
impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Bytes + Zeroize> Bytes for PrecalcSecretKey<InnerKey>
Source§impl<InnerKey: Clone + ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Clone for PrecalcSecretKey<InnerKey>
impl<InnerKey: Clone + ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Clone for PrecalcSecretKey<InnerKey>
Source§fn clone(&self) -> PrecalcSecretKey<InnerKey>
fn clone(&self) -> PrecalcSecretKey<InnerKey>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Debug for PrecalcSecretKey<InnerKey>
impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Debug for PrecalcSecretKey<InnerKey>
Source§impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Deref for PrecalcSecretKey<InnerKey>
impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Deref for PrecalcSecretKey<InnerKey>
Source§impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> DerefMut for PrecalcSecretKey<InnerKey>
impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> DerefMut for PrecalcSecretKey<InnerKey>
Source§impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Drop for PrecalcSecretKey<InnerKey>
impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Drop for PrecalcSecretKey<InnerKey>
impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Eq for PrecalcSecretKey<InnerKey>
Source§impl<InnerKey: MutByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> MutByteArray<CRYPTO_BOX_BEFORENMBYTES> for PrecalcSecretKey<InnerKey>
impl<InnerKey: MutByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> MutByteArray<CRYPTO_BOX_BEFORENMBYTES> for PrecalcSecretKey<InnerKey>
Source§fn as_mut_array(&mut self) -> &mut [u8; 32]
fn as_mut_array(&mut self) -> &mut [u8; 32]
Source§impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize + MutBytes> MutBytes for PrecalcSecretKey<InnerKey>
impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize + MutBytes> MutBytes for PrecalcSecretKey<InnerKey>
Source§fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Source§fn copy_from_slice(&mut self, other: &[u8])
fn copy_from_slice(&mut self, other: &[u8])
other. Panics if lengths do not
match.Auto Trait Implementations§
impl<InnerKey> Freeze for PrecalcSecretKey<InnerKey>where
InnerKey: Freeze,
impl<InnerKey> RefUnwindSafe for PrecalcSecretKey<InnerKey>where
InnerKey: RefUnwindSafe,
impl<InnerKey> Send for PrecalcSecretKey<InnerKey>where
InnerKey: Send,
impl<InnerKey> Sync for PrecalcSecretKey<InnerKey>where
InnerKey: Sync,
impl<InnerKey> Unpin for PrecalcSecretKey<InnerKey>where
InnerKey: Unpin,
impl<InnerKey> UnsafeUnpin for PrecalcSecretKey<InnerKey>where
InnerKey: UnsafeUnpin,
impl<InnerKey> UnwindSafe for PrecalcSecretKey<InnerKey>where
InnerKey: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<R> CryptoRng for R
impl<R> RngCore for Rwhere
R: Rng,
Source§impl<R> RngExt for R
impl<R> RngExt for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator of being
true. Read more