Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add openssl::cipher_ctx::CipherCtx::clone #2017

Merged
merged 3 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 9 additions & 0 deletions openssl/src/cipher_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ impl CipherCtx {
Ok(CipherCtx::from_ptr(ptr))
}
}

#[corresponds(EVP_CIPHER_CTX_copy)]
pub fn clone(&self) -> Result<Self, ErrorStack> {
let n = CipherCtx::new()?;
unsafe {
cvt(ffi::EVP_CIPHER_CTX_copy(n.as_ptr(), self.as_ptr()))?;
johntyner marked this conversation as resolved.
Show resolved Hide resolved
}
Ok(n)
}
}

impl CipherCtxRef {
Expand Down
Loading