Skip to content

Commit 117b459

Browse files
authored
Merge pull request #2017 from johntyner/feature/cipher-ctx-clone
Add openssl::cipher_ctx::CipherCtx::clone
2 parents 99ea8a8 + d266360 commit 117b459

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

openssl-sys/src/handwritten/evp.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ const_ptr_api! {
271271
extern "C" {
272272
pub fn EVP_CIPHER_CTX_new() -> *mut EVP_CIPHER_CTX;
273273
pub fn EVP_CIPHER_CTX_free(ctx: *mut EVP_CIPHER_CTX);
274+
pub fn EVP_CIPHER_CTX_copy(dst: *mut EVP_CIPHER_CTX, src: *const EVP_CIPHER_CTX) -> c_int;
275+
274276
pub fn EVP_MD_CTX_copy_ex(dst: *mut EVP_MD_CTX, src: *const EVP_MD_CTX) -> c_int;
275277
#[cfg(ossl111)]
276278
pub fn EVP_MD_CTX_reset(ctx: *mut EVP_MD_CTX) -> c_int;

openssl/src/cipher_ctx.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ impl CipherCtx {
105105
}
106106

107107
impl CipherCtxRef {
108+
#[corresponds(EVP_CIPHER_CTX_copy)]
109+
pub fn copy(&mut self, src: &CipherCtxRef) -> Result<(), ErrorStack> {
110+
unsafe {
111+
cvt(ffi::EVP_CIPHER_CTX_copy(self.as_ptr(), src.as_ptr()))?;
112+
Ok(())
113+
}
114+
}
115+
108116
/// Initializes the context for encryption.
109117
///
110118
/// Normally this is called once to set all of the cipher, key, and IV. However, this process can be split up

0 commit comments

Comments
 (0)