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

source

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 of CryptorContext

  • nonce - A chacha20poly1305::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.

source

pub fn decrypt( self, decryption_key: &CryptorKey ) -> Result<Encryptor, CryptoError>

Decrypts data using the provided key.

§Arguments
  • decryption_key - The key used to decrypt the data.
§Returns
  • A newly created Encryptor instance containing the decrypted data.
  • Returns an error of type [CryptoError] if the decryption process fails.

Trait Implementations§

source§

impl Clone for Decryptor

source§

fn clone(&self) -> Decryptor

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Decryptor

An implementation of the std::fmt::Debug trait for Decryptor

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Decryptor

An implementation of the std::fmt::Display trait for Decryptor

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Decryptor

Implement the PartialEq trait for the Decryptor type.

source§

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 other Decryptor instance to compare with.
§Returns

Returns true if the non-config fields are equal between the two Decryptor instances, Otherwise returns false.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Decryptor> for Vec<u8>

Implementation of the TryFrom trait for converting from Decryptor to Vec<u8>

§

type Error = CryptoError

The type returned in the event of a conversion error.
source§

fn try_from(decryptor: Decryptor) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Vec<u8>> for Decryptor

Implementation of the TryFrom trait for converting from Vec<u8> to Decryptor

§

type Error = CryptoError

The type returned in the event of a conversion error.
source§

fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Decryptor

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more