Trait serde_encrypt_core::key::as_shared_key::AsSharedKey
source · [−]pub trait AsSharedKey {
type R: RngSingleton;
fn from_array(key: [u8; 32]) -> Self
where
Self: Sized;
fn as_slice(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
;
fn generate() -> Self
where
Self: Sized,
{ ... }
fn to_chacha_key(&self) -> &ChaChaKey { ... }
}
Expand description
32-byte key shared among sender and receiver secretly.
The reason why this is not a struct but a trait is:
- shared key should be serialized and encrypted in order to be shared among peers
- but this -core trait is serialization agnostic.
So, implementators of this trait is expected to have serde::{Serialize, Deserialize}
and SerdeSerializePublicKey
trait bounds.
Required Associated Types
type R: RngSingleton
type R: RngSingleton
RNG singleton
Required Methods
Provided Methods
Generates secure random key.
Random number generator which implements CryptRng
is used internally.
fn to_chacha_key(&self) -> &ChaChaKey
fn to_chacha_key(&self) -> &ChaChaKey
Makes chacha20poly1305::Key