Trait serde_encrypt::AsSharedKey [−][src]
pub trait AsSharedKey {
type R: RngSingleton;
fn from_array(key: [u8; 32]) -> Self;
fn as_slice(&self) -> &[u8];
fn generate() -> Self { ... }
fn to_chacha_key(
&self
) -> &GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>> { ... }
}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.
Associated Types
type R: RngSingleton[src]
type R: RngSingleton[src]RNG singleton
Required methods
fn from_array(key: [u8; 32]) -> Self[src]
fn from_array(key: [u8; 32]) -> Self[src]Constructor from secret bytes.
Provided methods
Generates secure random key.
Random number generator which implements CryptRng is used internally.
fn to_chacha_key(
&self
) -> &GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>[src]
fn to_chacha_key(
&self
) -> &GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>[src]Makes chacha20poly1305::Key