From 82d92e6163dd72ee9be8e1adf9e7be6666eea3c9 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 19 Nov 2023 09:29:12 -0500 Subject: [PATCH] Added `update_unchecked` to `symm::Crypter` --- openssl/src/symm.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/openssl/src/symm.rs b/openssl/src/symm.rs index 1e9dc34fc6..0ff9d874e2 100644 --- a/openssl/src/symm.rs +++ b/openssl/src/symm.rs @@ -696,6 +696,27 @@ impl Crypter { self.ctx.cipher_update(input, Some(output)) } + /// Feeds data from `input` through the cipher, writing encrypted/decrypted + /// bytes into `output`. + /// + /// The number of bytes written to `output` is returned. Note that this may + /// not be equal to the length of `input`. + /// + /// # Safety + /// + /// The caller must provide an `output` buffer large enough to contain + /// correct number of bytes. For streaming ciphers the output buffer size + /// should be at least as big as the input buffer. For block ciphers the + /// size of the output buffer depends on the state of partially updated + /// blocks. + pub unsafe fn update_unchecked( + &mut self, + input: &[u8], + output: &mut [u8], + ) -> Result { + self.ctx.cipher_update_unchecked(input, Some(output)) + } + /// Finishes the encryption/decryption process, writing any remaining data /// to `output`. ///