pub struct SymmetricEncryptedMessage {
pub ciphertext: Vec<u8>,
pub nonce: [u8; 12],
pub associated_data: Option<Vec<u8>>,
}Expand description
A complete encrypted message containing ciphertext and nonce
This structure packages the encrypted data with its nonce for easy serialization and transmission.
Fields§
§ciphertext: Vec<u8>The encrypted data
nonce: [u8; 12]The nonce used for encryption
associated_data: Option<Vec<u8>>Optional associated data that was authenticated
Implementations§
Source§impl EncryptedMessage
impl EncryptedMessage
Sourcepub const fn new(
ciphertext: Vec<u8>,
nonce: [u8; 12],
associated_data: Option<Vec<u8>>,
) -> EncryptedMessage
pub const fn new( ciphertext: Vec<u8>, nonce: [u8; 12], associated_data: Option<Vec<u8>>, ) -> EncryptedMessage
Create a new encrypted message
§Arguments
ciphertext- The encrypted datanonce- The nonce used for encryptionassociated_data- Optional associated data
Sourcepub fn decrypt(
&self,
cipher: &ChaCha20Poly1305Cipher,
) -> Result<Vec<u8>, SymmetricError>
pub fn decrypt( &self, cipher: &ChaCha20Poly1305Cipher, ) -> Result<Vec<u8>, SymmetricError>
Trait Implementations§
Source§impl Clone for EncryptedMessage
impl Clone for EncryptedMessage
Source§fn clone(&self) -> EncryptedMessage
fn clone(&self) -> EncryptedMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EncryptedMessage
impl Debug for EncryptedMessage
Source§impl<'de> Deserialize<'de> for EncryptedMessage
impl<'de> Deserialize<'de> for EncryptedMessage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<EncryptedMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<EncryptedMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for EncryptedMessage
impl Serialize for EncryptedMessage
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for EncryptedMessage
impl RefUnwindSafe for EncryptedMessage
impl Send for EncryptedMessage
impl Sync for EncryptedMessage
impl Unpin for EncryptedMessage
impl UnwindSafe for EncryptedMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more