Struct PrecalcSecretKey

Source
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.

You probably want to use precalc_* functions if you need to encrypt/decrypt multiple messages between the same sender and receiver. These functions save computation time by using PrecalcSecretKey instead of computing the shared secret every time.

Using precalculated secret keys is compatible with libsodium’s crypto_box_beforenm.

Implementations§

Source§

impl PrecalcSecretKey<Locked<HeapByteArray<CRYPTO_BOX_PUBLICKEYBYTES>>>

Source

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>

Available on crate feature nightly 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.

Source§

impl PrecalcSecretKey<LockedRO<HeapByteArray<CRYPTO_BOX_PUBLICKEYBYTES>>>

Source

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>

Available on crate feature nightly 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.

Source§

impl PrecalcSecretKey<StackByteArray<CRYPTO_BOX_BEFORENMBYTES>>

Source

pub fn precalculate<ThirdPartyPublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES>>( third_party_public_key: &ThirdPartyPublicKey, secret_key: &SecretKey, ) -> Self

Computes a stack-allocated shared secret key for the given third_party_public_key and secret_key.

Compatible with libsodium’s crypto_box_beforenm.

Trait Implementations§

Source§

impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> ByteArray<CRYPTO_BOX_BEFORENMBYTES> for PrecalcSecretKey<InnerKey>

Source§

fn as_array(&self) -> &[u8; 32]

Returns a reference to the underlying fixed-length byte array.
Source§

impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Bytes + Zeroize> Bytes for PrecalcSecretKey<InnerKey>

Source§

fn as_slice(&self) -> &[u8]

Returns a slice of the underlying bytes.
Source§

fn is_empty(&self) -> bool

Returns true if the array is empty.
Source§

fn len(&self) -> usize

Shorthand to retrieve the underlying length of the byte array.
Source§

impl<InnerKey: Clone + ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Clone for PrecalcSecretKey<InnerKey>

Source§

fn clone(&self) -> PrecalcSecretKey<InnerKey>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<InnerKey: Debug + ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Debug for PrecalcSecretKey<InnerKey>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> DerefMut for PrecalcSecretKey<InnerKey>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Drop for PrecalcSecretKey<InnerKey>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<InnerKey: MutByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> MutByteArray<CRYPTO_BOX_BEFORENMBYTES> for PrecalcSecretKey<InnerKey>

Source§

fn as_mut_array(&mut self) -> &mut [u8; 32]

Returns a mutable reference to the underlying fixed-length byte array.
Source§

impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize + MutBytes> MutBytes for PrecalcSecretKey<InnerKey>

Source§

fn as_mut_slice(&mut self) -> &mut [u8]

Returns a mutable slice to the underlying bytes.
Source§

fn copy_from_slice(&mut self, other: &[u8])

Copies into the underlying slice from other. Panics if lengths do not match.
Source§

impl<InnerKey: PartialEq + ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> PartialEq for PrecalcSecretKey<InnerKey>

Source§

fn eq(&self, other: &PrecalcSecretKey<InnerKey>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<InnerKey> Zeroize for PrecalcSecretKey<InnerKey>
where InnerKey: Zeroize + ByteArray<CRYPTO_BOX_BEFORENMBYTES>,

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Deref for PrecalcSecretKey<InnerKey>

Source§

type Target = InnerKey

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<InnerKey: Eq + ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> Eq for PrecalcSecretKey<InnerKey>

Source§

impl<InnerKey: ByteArray<CRYPTO_BOX_BEFORENMBYTES> + Zeroize> StructuralPartialEq for PrecalcSecretKey<InnerKey>

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> UnwindSafe for PrecalcSecretKey<InnerKey>
where InnerKey: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> RngCore for T
where T: DerefMut, <T as Deref>::Target: RngCore,

Source§

fn next_u32(&mut self) -> u32

Return the next random u32. Read more
Source§

fn next_u64(&mut self) -> u64

Return the next random u64. Read more
Source§

fn fill_bytes(&mut self, dst: &mut [u8])

Fill dest with random data. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<R> TryRngCore for R
where R: RngCore + ?Sized,

Source§

type Error = Infallible

The type returned in the event of a RNG error.
Source§

fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>

Return the next random u32.
Source§

fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>

Return the next random u64.
Source§

fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>

Fill dest entirely with random data.
Source§

fn unwrap_err(self) -> UnwrapErr<Self>
where Self: Sized,

Wrap RNG with the UnwrapErr wrapper.
Source§

fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>

Wrap RNG with the UnwrapMut wrapper.
Source§

impl<T> CryptoRng for T
where T: DerefMut, <T as Deref>::Target: CryptoRng,

Source§

impl<R> TryCryptoRng for R
where R: CryptoRng + ?Sized,