Struct safe_crypto::SharedSecretKey [−][src]
pub struct SharedSecretKey { /* fields omitted */ }
Precomputed shared secret key. Can be created from a pair of our secret key and the recipient's public key. As a result, we'll get the same key as the recipient with their secret key and our public key.
Methods
impl SharedSecretKey
[src]
impl SharedSecretKey
pub fn encrypt_bytes(
&self,
plaintext: &[u8]
) -> Result<Vec<u8>, EncryptionError>
[src]
pub fn encrypt_bytes(
&self,
plaintext: &[u8]
) -> Result<Vec<u8>, EncryptionError>
Encrypts bytestring plaintext
using authenticated encryption.
With authenticated encryption the recipient will be able to verify the authenticity
of the sender using a sender's public key.
If you want to use anonymous encryption, use the functions provided by PublicId
and SecretId
.
Returns ciphertext in case of success.
Can return an EncryptionError
in case of a serialisation error.
pub fn encrypt<T>(&self, plaintext: &T) -> Result<Vec<u8>, EncryptionError> where
T: Serialize,
[src]
pub fn encrypt<T>(&self, plaintext: &T) -> Result<Vec<u8>, EncryptionError> where
T: Serialize,
Encrypts serialisable plaintext
using authenticated encryption.
With authenticated encryption the recipient will be able to verify the authenticity
of the sender using a sender's public key.
If you wish to encrypt bytestring plaintext, use encrypt_bytes
.
If you want to use anonymous encryption, use the functions provided by PublicId
and SecretId
.
Returns ciphertext in case of success.
Can return an EncryptionError
in case of a serialisation error.
pub fn decrypt_bytes(&self, encoded: &[u8]) -> Result<Vec<u8>, EncryptionError>
[src]
pub fn decrypt_bytes(&self, encoded: &[u8]) -> Result<Vec<u8>, EncryptionError>
Decrypts bytestring encoded
encrypted using authenticated encryption.
With authenticated encryption we will be able to verify the authenticity of the sender using a sender's public key.
Returns plaintext in case of success.
Can return EncryptionError
in case of a deserialisation error, if the ciphertext
is not valid, or if it can not be decrypted.
pub fn decrypt<T>(&self, ciphertext: &[u8]) -> Result<T, EncryptionError> where
T: Serialize + DeserializeOwned,
[src]
pub fn decrypt<T>(&self, ciphertext: &[u8]) -> Result<T, EncryptionError> where
T: Serialize + DeserializeOwned,
Decrypts serialised ciphertext
encrypted using authenticated encryption.
With authenticated encryption we will be able to verify the authenticity of the sender using a sender's public key.
Returns deserialised type T
in case of success.
Can return EncryptionError
in case of a deserialisation error, if the ciphertext
is not valid, or if it can not be decrypted.
Trait Implementations
impl Debug for SharedSecretKey
[src]
impl Debug for SharedSecretKey
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for SharedSecretKey
[src]
impl PartialEq for SharedSecretKey
fn eq(&self, other: &SharedSecretKey) -> bool
[src]
fn eq(&self, other: &SharedSecretKey) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &SharedSecretKey) -> bool
[src]
fn ne(&self, other: &SharedSecretKey) -> bool
This method tests for !=
.
impl Eq for SharedSecretKey
[src]
impl Eq for SharedSecretKey
impl Clone for SharedSecretKey
[src]
impl Clone for SharedSecretKey
fn clone(&self) -> SharedSecretKey
[src]
fn clone(&self) -> SharedSecretKey
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
Auto Trait Implementations
impl Send for SharedSecretKey
impl Send for SharedSecretKey
impl Sync for SharedSecretKey
impl Sync for SharedSecretKey