Struct ubiq::encryption::Encryption
source · pub struct Encryption<'a> { /* private fields */ }
Expand description
Structure encompassing parameters used for encrypting data
Using this structure, a caller is able to encrypt a plaintext
by feeding it to the member functions in a piecewise fashion
(or by doing so all at once). The encryption object can be reused
to encrypt as many plaintexts as were initially specified by the
call to new()
Implementations§
source§impl Encryption<'_>
impl Encryption<'_>
pub fn new<'a>(creds: &Credentials, uses: usize) -> Result<Encryption<'a>>
sourcepub fn begin(&mut self) -> Result<Vec<u8>>
pub fn begin(&mut self) -> Result<Vec<u8>>
Begin a new encryption “session”
Encryption of a plaintext consists of a begin()
, some number
of update()
calls, and an end()
. It is an error to call
begin()
more than once without an intervening end()
.
sourcepub fn update(&mut self, pt: &[u8]) -> Result<Vec<u8>>
pub fn update(&mut self, pt: &[u8]) -> Result<Vec<u8>>
Input (some) plaintext for encryption
The update function writes data into the Encryption object. Ciphertext data may or may not be returned with each call to this function.
sourcepub fn end(&mut self) -> Result<Vec<u8>>
pub fn end(&mut self) -> Result<Vec<u8>>
End an encryption “session”
After all plaintext has been written to the object via the
update()
function, the caller must call this function to finalize
the encryption. Any remaining plaintext will be returned along
with any authentication information produced by the algorithm.