#[non_exhaustive]pub enum EncryptionScheme {
Pbes1(Algorithm),
Pbes2(Parameters),
}Expand description
Configuration for supported PKCS#5 password-based encryption schemes.
This type should not be used to encrypt multiple plaintexts under the same IV/salt values.
Instead, new values should be randomly generated for every usage.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Pbes1(Algorithm)
Password-Based Encryption Scheme 1 as defined in RFC 8018 Section 6.1.
Pbes2(Parameters)
Password-Based Encryption Scheme 2 as defined in RFC 8018 Section 6.2.
Implementations§
Source§impl EncryptionScheme
impl EncryptionScheme
Sourcepub fn decrypt(
&self,
password: impl AsRef<[u8]>,
ciphertext: &[u8],
) -> Result<Vec<u8>>
pub fn decrypt( &self, password: impl AsRef<[u8]>, ciphertext: &[u8], ) -> Result<Vec<u8>>
Attempt to decrypt the given ciphertext, allocating and returning a byte vector containing the plaintext.
§Errors
Returns an error if the algorithm specified in this scheme’s parameters is unsupported (e.g. PBES1 is completely unsupported), or if the ciphertext is malformed (e.g. ciphertext length is not a multiple of a block mode’s padding).
Sourcepub fn decrypt_in_place<'a>(
&self,
password: impl AsRef<[u8]>,
buffer: &'a mut [u8],
) -> Result<&'a [u8]>
pub fn decrypt_in_place<'a>( &self, password: impl AsRef<[u8]>, buffer: &'a mut [u8], ) -> Result<&'a [u8]>
Attempt to decrypt the given ciphertext in-place using a key derived from the provided password and this scheme’s parameters.
§Errors
Returns an error if the algorithm specified in this scheme’s parameters is unsupported (e.g. PBES1 is completely unsupported), or if the ciphertext is malformed (e.g. not a multiple of a block mode’s padding).
Sourcepub fn encrypt(
&self,
password: impl AsRef<[u8]>,
plaintext: &[u8],
) -> Result<Vec<u8>>
pub fn encrypt( &self, password: impl AsRef<[u8]>, plaintext: &[u8], ) -> Result<Vec<u8>>
Encrypt the given plaintext, allocating and returning a vector containing the ciphertext.
§Errors
- For PBES1, simply returns
Error::NoPbes1CryptSupportunconditionally. - Returns
Error::UnsupportedAlgorithmif support for the requested algorithm has not been enabled in this crate’s features.
Sourcepub fn encrypt_in_place<'a>(
&self,
password: impl AsRef<[u8]>,
buffer: &'a mut [u8],
pos: usize,
) -> Result<&'a [u8]>
pub fn encrypt_in_place<'a>( &self, password: impl AsRef<[u8]>, buffer: &'a mut [u8], pos: usize, ) -> Result<&'a [u8]>
Encrypt the given ciphertext in-place using a key derived from the provided password and this scheme’s parameters.
§Errors
- For PBES1, simply returns
Error::NoPbes1CryptSupportunconditionally. - Returns
Error::UnsupportedAlgorithmif support for the requested algorithm has not been enabled in this crate’s features.
Sourcepub fn oid(&self) -> ObjectIdentifier
pub fn oid(&self) -> ObjectIdentifier
Get the ObjectIdentifier (a.k.a OID) for this algorithm.
Sourcepub fn pbes1(&self) -> Option<&Algorithm>
pub fn pbes1(&self) -> Option<&Algorithm>
Get pbes1::Parameters if it is the selected algorithm.
Sourcepub fn pbes2(&self) -> Option<&Parameters>
pub fn pbes2(&self) -> Option<&Parameters>
Get pbes2::Parameters if it is the selected algorithm.