Commit 19b7a64b authored by John Tyner's avatar John Tyner
Browse files

Add openssl::cipher_ctx::CipherCtx::clone

parent 99ea8a8a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
+9 −0
Original line number Diff line number Diff line
@@ -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()))?;
        }
        Ok(n)
    }
}

impl CipherCtxRef {