Commit 9257c55b authored by Arthur Gautier's avatar Arthur Gautier
Browse files

Expose NID from cipher

parent ad741f88
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ extern "C" {
    pub fn EVP_CIPHER_key_length(cipher: *const EVP_CIPHER) -> c_int;
    pub fn EVP_CIPHER_block_size(cipher: *const EVP_CIPHER) -> c_int;
    pub fn EVP_CIPHER_iv_length(cipher: *const EVP_CIPHER) -> c_int;
    pub fn EVP_CIPHER_nid(cipher: *const EVP_CIPHER) -> c_int;
}

cfg_if! {
+10 −0
Original line number Diff line number Diff line
@@ -90,6 +90,16 @@ impl Cipher {
        }
    }

    /// Returns the cipher's Nid.
    ///
    /// This corresponds to [`EVP_CIPHER_nid`]
    ///
    /// [`EVP_CIPHER_nid`]: https://www.openssl.org/docs/man1.0.2/crypto/EVP_CIPHER_nid.html
    pub fn nid(&self) -> Nid {
        let nid = unsafe { ffi::EVP_CIPHER_nid(self.0) };
        Nid::from_raw(nid)
    }

    pub fn aes_128_ecb() -> Cipher {
        unsafe { Cipher(ffi::EVP_aes_128_ecb()) }
    }