Skip to content

Commit

Permalink
Merge pull request #2045 from alex/cipher-getters
Browse files Browse the repository at this point in the history
Expose CBC mode for several more (bad) ciphers
  • Loading branch information
alex committed Sep 26, 2023
2 parents 2f269c9 + 5f502a2 commit 78219ec
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions openssl-sys/src/handwritten/evp.rs
Expand Up @@ -396,23 +396,33 @@ extern "C" {
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAMELLIA")))]
pub fn EVP_camellia_128_ecb() -> *const EVP_CIPHER;
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAMELLIA")))]
pub fn EVP_camellia_128_cbc() -> *const EVP_CIPHER;
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAMELLIA")))]
pub fn EVP_camellia_192_cfb128() -> *const EVP_CIPHER;
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAMELLIA")))]
pub fn EVP_camellia_192_ecb() -> *const EVP_CIPHER;
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAMELLIA")))]
pub fn EVP_camellia_192_cbc() -> *const EVP_CIPHER;
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAMELLIA")))]
pub fn EVP_camellia_256_cfb128() -> *const EVP_CIPHER;
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAMELLIA")))]
pub fn EVP_camellia_256_ecb() -> *const EVP_CIPHER;
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAMELLIA")))]
pub fn EVP_camellia_256_cbc() -> *const EVP_CIPHER;

#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAST")))]
pub fn EVP_cast5_cfb64() -> *const EVP_CIPHER;
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAST")))]
pub fn EVP_cast5_ecb() -> *const EVP_CIPHER;
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAST")))]
pub fn EVP_cast5_cbc() -> *const EVP_CIPHER;

#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_IDEA")))]
pub fn EVP_idea_cfb64() -> *const EVP_CIPHER;
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_IDEA")))]
pub fn EVP_idea_ecb() -> *const EVP_CIPHER;
#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_IDEA")))]
pub fn EVP_idea_cbc() -> *const EVP_CIPHER;

#[cfg(not(ossl110))]
pub fn OPENSSL_add_all_algorithms_noconf();
Expand Down
25 changes: 25 additions & 0 deletions openssl/src/symm.rs
Expand Up @@ -288,6 +288,26 @@ impl Cipher {
unsafe { Cipher(ffi::EVP_rc4()) }
}

#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAMELLIA")))]
pub fn camellia_128_cbc() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_128_cbc()) }
}

#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAMELLIA")))]
pub fn camellia_192_cbc() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_192_cbc()) }
}

#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_CAMELLIA")))]
pub fn camellia_256_cbc() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_256_cbc()) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAST"))]
pub fn cast5_cbc() -> Cipher {
unsafe { Cipher(ffi::EVP_cast5_cbc()) }
}

/// Requires OpenSSL 1.1.0 or newer.
#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_CHACHA")))]
pub fn chacha20() -> Cipher {
Expand All @@ -300,6 +320,11 @@ impl Cipher {
unsafe { Cipher(ffi::EVP_chacha20_poly1305()) }
}

#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_IDEA")))]
pub fn idea_cbc() -> Cipher {
unsafe { Cipher(ffi::EVP_idea_cbc()) }
}

#[cfg(not(any(boringssl, osslconf = "OPENSSL_NO_SEED")))]
pub fn seed_cbc() -> Cipher {
unsafe { Cipher(ffi::EVP_seed_cbc()) }
Expand Down

0 comments on commit 78219ec

Please sign in to comment.