Skip to content

Commit 602d38d

Browse files
committed
Added update_unchecked to symm::Crypter
1 parent 2d9458e commit 602d38d

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

openssl/src/cipher_ctx.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,8 @@ impl CipherCtxRef {
581581
/// output size check removed. It can be used when the exact
582582
/// buffer size control is maintained by the caller.
583583
///
584-
/// SAFETY: The caller is expected to provide `output` buffer
584+
/// # Safety
585+
/// The caller is expected to provide `output` buffer
585586
/// large enough to contain correct number of bytes. For streaming
586587
/// ciphers the output buffer size should be at least as big as
587588
/// the input buffer. For block ciphers the size of the output
@@ -693,7 +694,8 @@ impl CipherCtxRef {
693694
/// This function is the same as [`Self::cipher_final`] but with
694695
/// the output buffer size check removed.
695696
///
696-
/// SAFETY: The caller is expected to provide `output` buffer
697+
/// # Safety
698+
/// The caller is expected to provide `output` buffer
697699
/// large enough to contain correct number of bytes. For streaming
698700
/// ciphers the output buffer can be empty, for block ciphers the
699701
/// output buffer should be at least as big as the block.

openssl/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
//! ```
120120
#![doc(html_root_url = "https://docs.rs/openssl/0.10")]
121121
#![warn(rust_2018_idioms)]
122-
#![allow(clippy::uninlined_format_args)]
122+
#![allow(clippy::uninlined_format_args, clippy::needless_doctest_main)]
123123

124124
#[doc(inline)]
125125
pub use ffi::init;

openssl/src/symm.rs

+21
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,27 @@ impl Crypter {
696696
self.ctx.cipher_update(input, Some(output))
697697
}
698698

699+
/// Feeds data from `input` through the cipher, writing encrypted/decrypted
700+
/// bytes into `output`.
701+
///
702+
/// The number of bytes written to `output` is returned. Note that this may
703+
/// not be equal to the length of `input`.
704+
///
705+
/// # Safety
706+
///
707+
/// The caller must provide an `output` buffer large enough to contain
708+
/// correct number of bytes. For streaming ciphers the output buffer size
709+
/// should be at least as big as the input buffer. For block ciphers the
710+
/// size of the output buffer depends on the state of partially updated
711+
/// blocks.
712+
pub unsafe fn update_unchecked(
713+
&mut self,
714+
input: &[u8],
715+
output: &mut [u8],
716+
) -> Result<usize, ErrorStack> {
717+
self.ctx.cipher_update_unchecked(input, Some(output))
718+
}
719+
699720
/// Finishes the encryption/decryption process, writing any remaining data
700721
/// to `output`.
701722
///

0 commit comments

Comments
 (0)