Unverified Commit c0ef4151 authored by Steven Fackler's avatar Steven Fackler
Browse files

tag_length is 3.0.0 only

parent 3ce37772
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -92,11 +92,6 @@ cfg_if! {
        pub unsafe fn EVP_CIPHER_CTX_iv_length(ctx: *const EVP_CIPHER_CTX) -> c_int {
            EVP_CIPHER_CTX_get_iv_length(ctx)
        }

        #[inline]
        pub unsafe fn EVP_CIPHER_CTX_tag_length(ctx: *const EVP_CIPHER_CTX) -> c_int {
            EVP_CIPHER_CTX_get_tag_length(ctx)
        }
    } else {
        extern "C" {
            pub fn EVP_MD_size(md: *const EVP_MD) -> c_int;
@@ -111,7 +106,6 @@ cfg_if! {
            pub fn EVP_CIPHER_CTX_block_size(ctx: *const EVP_CIPHER_CTX) -> c_int;
            pub fn EVP_CIPHER_CTX_key_length(ctx: *const EVP_CIPHER_CTX) -> c_int;
            pub fn EVP_CIPHER_CTX_iv_length(ctx: *const EVP_CIPHER_CTX) -> c_int;
            pub fn EVP_CIPHER_CTX_tag_length(ctx: *const EVP_CIPHER_CTX) -> c_int;
        }
    }
}
+5 −2
Original line number Diff line number Diff line
@@ -411,7 +411,7 @@ impl CipherCtxRef {
        Ok(())
    }

    /// Returns the length of the authenticationt tag expected by this context.
    /// Returns the length of the authentication tag expected by this context.
    ///
    /// Returns 0 if the cipher is not authenticated.
    ///
@@ -421,11 +421,14 @@ impl CipherCtxRef {
    ///
    /// This corresponds to [`EVP_CIPHER_CTX_tag_length`].
    ///
    /// Requires OpenSSL 3.0.0 or newer.
    ///
    /// [`EVP_CIPHER_CTX_tag_length`]: https://www.openssl.org/docs/manmaster/man3/EVP_CIPHER_CTX_tag_length.html
    #[cfg(ossl300)]
    pub fn tag_length(&self) -> usize {
        self.assert_cipher();

        unsafe { ffi::EVP_CIPHER_CTX_tag_length(self.as_ptr()) as usize }
        unsafe { ffi::EVP_CIPHER_CTX_get_tag_length(self.as_ptr()) as usize }
    }

    /// Retrieves the calculated authentication tag from the context.