[][src]Enum asuran::repository::Encryption

pub enum Encryption {
    NoEncryption,
    AES256CBC {
        iv: [u8; 16],
    },
    AES256CTR {
        iv: [u8; 16],
    },
    ChaCha20 {
        iv: [u8; 12],
    },
}

Tag for the encryption algorthim and IV used by a particular chunk

Variants

NoEncryption
AES256CBC

Fields of AES256CBC

iv: [u8; 16]
AES256CTR

Fields of AES256CTR

iv: [u8; 16]
ChaCha20

Fields of ChaCha20

iv: [u8; 12]

Methods

impl Encryption[src]

pub fn new_aes256cbc() -> Encryption[src]

Creates an AES256CBC with a random, securely generated IV

pub fn new_aes256ctr() -> Encryption[src]

Creates a new AES256CTR with a random securely generated IV

pub fn new_chacha20() -> Encryption[src]

Creates a new ChaCha20 with a random securely generated IV

pub fn key_length(&self) -> usize[src]

Returns the key length of this encryption method in bytes

NoEncryption has a key length of 16 bytes, as some things rely on a non-zero key length.

pub fn encrypt(&self, data: &[u8], key: &Key) -> Vec<u8>[src]

Encrypts a bytestring using the algrothim specified in the tag, and the given key.

Still requires a key in the event of no encryption, but it does not read this key, so any value can be used. Will pad key with zeros if it is too short

Panics

Will panic if the user selects an encryption algorithm for which support has not been compiled in, or if encryption otherwise fails.

pub fn encrypt_bytes(&self, data: &[u8], key: &[u8]) -> Vec<u8>[src]

Internal method that does the actual encryption, please use the encrypt method to avoid key confusion

Panics:

Panics if the user selects an encryption algorithm that support was not compiled in for.

pub fn decrypt(
    &self,
    data: &[u8],
    key: &Key
) -> Result<Vec<u8>, EncryptionError>
[src]

Decrypts a bytestring with the given key

Still requires a key in the event of no encryption, but it does not read this key, so any value can be used. Will pad key with zeros if it is too short.

Errors

Will return Err if decryption fails

Panics

Panics if the user selects an encryption method for which support has not been compiled in.

pub fn decrypt_bytes(
    &self,
    data: &[u8],
    key: &[u8]
) -> Result<Vec<u8>, EncryptionError>
[src]

pub fn new_iv(self) -> Encryption[src]

Conviencence function to get a new tag from an old one, specifying the same algorithim, but with a new, securely generated IV

Trait Implementations

impl Clone for Encryption[src]

impl Copy for Encryption[src]

impl Debug for Encryption[src]

impl<'de> Deserialize<'de> for Encryption[src]

impl Eq for Encryption[src]

impl Hash for Encryption[src]

impl PartialEq<Encryption> for Encryption[src]

impl Serialize for Encryption[src]

impl StructuralEq for Encryption[src]

impl StructuralPartialEq for Encryption[src]

Auto Trait Implementations

impl RefUnwindSafe for Encryption

impl Send for Encryption

impl Sync for Encryption

impl Unpin for Encryption

impl UnwindSafe for Encryption

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

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

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

impl<T> WithSubscriber for T[src]