Skip to content

Commit

Permalink
Merge pull request #2017 from johntyner/feature/cipher-ctx-clone
Browse files Browse the repository at this point in the history
Add openssl::cipher_ctx::CipherCtx::clone
  • Loading branch information
sfackler authored Aug 23, 2023
2 parents 99ea8a8 + d266360 commit 117b459
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openssl-sys/src/handwritten/evp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ const_ptr_api! {
extern "C" {
pub fn EVP_CIPHER_CTX_new() -> *mut EVP_CIPHER_CTX;
pub fn EVP_CIPHER_CTX_free(ctx: *mut EVP_CIPHER_CTX);
pub fn EVP_CIPHER_CTX_copy(dst: *mut EVP_CIPHER_CTX, src: *const EVP_CIPHER_CTX) -> c_int;

pub fn EVP_MD_CTX_copy_ex(dst: *mut EVP_MD_CTX, src: *const EVP_MD_CTX) -> c_int;
#[cfg(ossl111)]
pub fn EVP_MD_CTX_reset(ctx: *mut EVP_MD_CTX) -> c_int;
Expand Down
8 changes: 8 additions & 0 deletions openssl/src/cipher_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ impl CipherCtx {
}

impl CipherCtxRef {
#[corresponds(EVP_CIPHER_CTX_copy)]
pub fn copy(&mut self, src: &CipherCtxRef) -> Result<(), ErrorStack> {
unsafe {
cvt(ffi::EVP_CIPHER_CTX_copy(self.as_ptr(), src.as_ptr()))?;
Ok(())
}
}

/// Initializes the context for encryption.
///
/// Normally this is called once to set all of the cipher, key, and IV. However, this process can be split up
Expand Down

0 comments on commit 117b459

Please sign in to comment.