Enum p2p::CryptoContext [−][src]
pub enum CryptoContext { Null, Authenticated { their_pk: PublicKey, our_sk: SecretKey, }, AnonymousDecrypt { our_pk: PublicKey, our_sk: SecretKey, }, AnonymousEncrypt { their_pk: PublicKey, }, }
Simplifies encryption/decryption by holding the necessary context - encryption keys. Allows "null" encryption where data is only serialized. See: null object pattern.
Variants
Null
No encryption.
Authenticated
Encryption + authentication
Fields of Authenticated
their_pk: PublicKey | Their public key. |
our_sk: SecretKey | Our secret key. |
AnonymousDecrypt
No message authentication. Only decrypt operation is allowed.
Fields of AnonymousDecrypt
our_pk: PublicKey | Our private key. |
our_sk: SecretKey | Our secret key. |
AnonymousEncrypt
No message authentication. Only encrypt operation is allowed.
Fields of AnonymousEncrypt
their_pk: PublicKey | Their public key. |
Methods
impl CryptoContext
[src]
impl CryptoContext
pub fn authenticated(their_pk: PublicKey, our_sk: SecretKey) -> Self
[src]
pub fn authenticated(their_pk: PublicKey, our_sk: SecretKey) -> Self
Construct crypto context that encrypts and authenticate messages.
pub fn null() -> Self
[src]
pub fn null() -> Self
Contructs "null" encryption context which actually does no encryption. In this case data is simply serialized but not encrypted.
pub fn anonymous_decrypt(our_pk: PublicKey, our_sk: SecretKey) -> Self
[src]
pub fn anonymous_decrypt(our_pk: PublicKey, our_sk: SecretKey) -> Self
Constructs crypto context that is only meant for unauthenticated deryption.
pub fn anonymous_encrypt(their_pk: PublicKey) -> Self
[src]
pub fn anonymous_encrypt(their_pk: PublicKey) -> Self
Constructs crypto context that is only meant for unauthenticated encryption.
pub fn encrypt<T: Serialize>(&self, msg: &T) -> Result<BytesMut, CryptoError>
[src]
pub fn encrypt<T: Serialize>(&self, msg: &T) -> Result<BytesMut, CryptoError>
Serialize given structure and encrypt it.
pub fn decrypt<T>(&self, msg: &[u8]) -> Result<T, CryptoError> where
T: Serialize + DeserializeOwned,
[src]
pub fn decrypt<T>(&self, msg: &[u8]) -> Result<T, CryptoError> where
T: Serialize + DeserializeOwned,
Decrypt given buffer and deserialize into structure.
Trait Implementations
impl Clone for CryptoContext
[src]
impl Clone for CryptoContext
fn clone(&self) -> CryptoContext
[src]
fn clone(&self) -> CryptoContext
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for CryptoContext
[src]
impl Debug for CryptoContext
Auto Trait Implementations
impl Send for CryptoContext
impl Send for CryptoContext
impl Sync for CryptoContext
impl Sync for CryptoContext