Struct lock_keeper::crypto::Decryptor
source · pub struct Decryptor {
ciphertext: Vec<u8>,
context: CryptorContext,
nonce: Nonce,
config: SensitiveInfoConfig,
}
Expand description
The Decryptor
type represents a ciphertext encrypted under the
ChaCha20Poly1305 scheme for
authenticated encryption with associated data (AEAD).
As implied by the scheme name, this uses the recommended 20 rounds and a standard 96-bit nonce. For more details, see the ChaCha20Poly1305 crate.
Fields§
§ciphertext: Vec<u8>
§context: CryptorContext
§nonce: Nonce
§config: SensitiveInfoConfig
Implementations§
source§impl Decryptor
impl Decryptor
sourcefn new(
ciphertext: Vec<u8>,
context: CryptorContext,
nonce: Nonce,
config: SensitiveInfoConfig
) -> Self
fn new( ciphertext: Vec<u8>, context: CryptorContext, nonce: Nonce, config: SensitiveInfoConfig ) -> Self
Constructs a new instance of the Decryptor
type.
§Arguments
-
ciphertext
- A vector of bytes representing the ciphertext. This is typically the result of the encrypt operation. -
context
- An instance ofCryptorContext
-
nonce
- Achacha20poly1305::Nonce
instance. This is used in the encryption process to ensure the security of the ciphertext. Every time data is encrypted, a unique nonce should be generated.
§Returns
Returns a new instance of the Decryptor
type, initialized with the
provided ciphertext
, context
, nonce
, and config
.
sourcepub fn decrypt(
self,
decryption_key: &CryptorKey
) -> Result<Encryptor, CryptoError>
pub fn decrypt( self, decryption_key: &CryptorKey ) -> Result<Encryptor, CryptoError>
Trait Implementations§
source§impl PartialEq for Decryptor
impl PartialEq for Decryptor
Implement the PartialEq
trait for the Decryptor
type.
source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Determines if two Decryptor
instances are equal.
This function compares the fields of two Decryptor
instances,
excluding the config
field because the config
field does not
affect the functional equivalence of two Decryptor
instances.
§Arguments
other
- The otherDecryptor
instance to compare with.
§Returns
Returns true
if the non-config
fields are equal between the two
Decryptor
instances, Otherwise returns false
.
source§impl TryFrom<Decryptor> for Vec<u8>
impl TryFrom<Decryptor> for Vec<u8>
Implementation of the TryFrom
trait for converting from Decryptor
to
Vec<u8>
source§impl TryFrom<Vec<u8>> for Decryptor
impl TryFrom<Vec<u8>> for Decryptor
Implementation of the TryFrom
trait for converting from Vec<u8>
to
Decryptor
impl Eq for Decryptor
Auto Trait Implementations§
impl Freeze for Decryptor
impl RefUnwindSafe for Decryptor
impl Send for Decryptor
impl Sync for Decryptor
impl Unpin for Decryptor
impl UnwindSafe for Decryptor
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request