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

Expose a few more (bad) ciphers in cipher::Cipher #2084

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 13 additions & 0 deletions openssl-sys/src/handwritten/evp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ extern "C" {
pub fn EVP_des_ecb() -> *const EVP_CIPHER;
pub fn EVP_des_ede3() -> *const EVP_CIPHER;
pub fn EVP_des_ede3_cbc() -> *const EVP_CIPHER;
pub fn EVP_des_ede3_ecb() -> *const EVP_CIPHER;
pub fn EVP_des_ede3_cfb64() -> *const EVP_CIPHER;
pub fn EVP_des_ede3_cfb8() -> *const EVP_CIPHER;
pub fn EVP_des_ede3_ofb() -> *const EVP_CIPHER;
pub fn EVP_des_cbc() -> *const EVP_CIPHER;
#[cfg(not(osslconf = "OPENSSL_NO_RC4"))]
pub fn EVP_rc4() -> *const EVP_CIPHER;
Expand Down Expand Up @@ -398,31 +401,41 @@ extern "C" {
#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn EVP_camellia_128_cbc() -> *const EVP_CIPHER;
#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn EVP_camellia_128_ofb() -> *const EVP_CIPHER;
#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn EVP_camellia_192_cfb128() -> *const EVP_CIPHER;
#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn EVP_camellia_192_ecb() -> *const EVP_CIPHER;
#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn EVP_camellia_192_cbc() -> *const EVP_CIPHER;
#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn EVP_camellia_192_ofb() -> *const EVP_CIPHER;
#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn EVP_camellia_256_cfb128() -> *const EVP_CIPHER;
#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn EVP_camellia_256_ecb() -> *const EVP_CIPHER;
#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn EVP_camellia_256_cbc() -> *const EVP_CIPHER;
#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn EVP_camellia_256_ofb() -> *const EVP_CIPHER;

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

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

#[cfg(not(ossl110))]
pub fn OPENSSL_add_all_algorithms_noconf();
Expand Down
25 changes: 25 additions & 0 deletions openssl/src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ impl Cipher {
unsafe { CipherRef::from_ptr(ffi::EVP_camellia_128_ecb() as *mut _) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia128_cbc() -> &'static CipherRef {
unsafe { CipherRef::from_ptr(ffi::EVP_camellia_128_cbc() as *mut _) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia192_cfb128() -> &'static CipherRef {
unsafe { CipherRef::from_ptr(ffi::EVP_camellia_192_cfb128() as *mut _) }
Expand All @@ -398,6 +403,11 @@ impl Cipher {
unsafe { CipherRef::from_ptr(ffi::EVP_camellia_192_ecb() as *mut _) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia192_cbc() -> &'static CipherRef {
unsafe { CipherRef::from_ptr(ffi::EVP_camellia_192_cbc() as *mut _) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia256_cfb128() -> &'static CipherRef {
unsafe { CipherRef::from_ptr(ffi::EVP_camellia_256_cfb128() as *mut _) }
Expand All @@ -408,6 +418,11 @@ impl Cipher {
unsafe { CipherRef::from_ptr(ffi::EVP_camellia_256_ecb() as *mut _) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia256_cbc() -> &'static CipherRef {
unsafe { CipherRef::from_ptr(ffi::EVP_camellia_256_cbc() as *mut _) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAST"))]
pub fn cast5_cfb64() -> &'static CipherRef {
unsafe { CipherRef::from_ptr(ffi::EVP_cast5_cfb64() as *mut _) }
Expand All @@ -418,6 +433,11 @@ impl Cipher {
unsafe { CipherRef::from_ptr(ffi::EVP_cast5_ecb() as *mut _) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAST"))]
pub fn cast5_cbc() -> &'static CipherRef {
unsafe { CipherRef::from_ptr(ffi::EVP_cast5_cbc() as *mut _) }
}

#[cfg(not(osslconf = "OPENSSL_NO_IDEA"))]
pub fn idea_cfb64() -> &'static CipherRef {
unsafe { CipherRef::from_ptr(ffi::EVP_idea_cfb64() as *mut _) }
Expand All @@ -428,6 +448,11 @@ impl Cipher {
unsafe { CipherRef::from_ptr(ffi::EVP_idea_ecb() as *mut _) }
}

#[cfg(not(osslconf = "OPENSSL_NO_IDEA"))]
pub fn idea_cbc() -> &'static CipherRef {
unsafe { CipherRef::from_ptr(ffi::EVP_idea_cbc() as *mut _) }
}

#[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_CHACHA")))]
pub fn chacha20() -> &'static CipherRef {
unsafe { CipherRef::from_ptr(ffi::EVP_chacha20() as *mut _) }
Expand Down
89 changes: 89 additions & 0 deletions openssl/src/symm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,25 @@ impl Cipher {
unsafe { Cipher(ffi::EVP_des_ede3_cbc()) }
}

pub fn des_ede3_ecb() -> Cipher {
unsafe { Cipher(ffi::EVP_des_ede3_ecb()) }
}

#[cfg(not(boringssl))]
pub fn des_ede3_cfb64() -> Cipher {
unsafe { Cipher(ffi::EVP_des_ede3_cfb64()) }
}

#[cfg(not(boringssl))]
pub fn des_ede3_cfb8() -> Cipher {
unsafe { Cipher(ffi::EVP_des_ede3_cfb8()) }
}

#[cfg(not(boringssl))]
pub fn des_ede3_ofb() -> Cipher {
unsafe { Cipher(ffi::EVP_des_ede3_ofb()) }
}

#[cfg(not(osslconf = "OPENSSL_NO_RC4"))]
pub fn rc4() -> Cipher {
unsafe { Cipher(ffi::EVP_rc4()) }
Expand All @@ -293,21 +307,81 @@ impl Cipher {
unsafe { Cipher(ffi::EVP_camellia_128_cbc()) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia_128_ecb() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_128_ecb()) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia_128_ofb() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_128_ofb()) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia_128_cfb128() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_128_cfb128()) }
}

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

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia_192_ecb() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_192_ecb()) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia_192_ofb() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_192_ofb()) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia_192_cfb128() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_192_cfb128()) }
}

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

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia_256_ecb() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_256_ecb()) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia_256_ofb() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_256_ofb()) }
}

#[cfg(not(osslconf = "OPENSSL_NO_CAMELLIA"))]
pub fn camellia_256_cfb128() -> Cipher {
unsafe { Cipher(ffi::EVP_camellia_256_cfb128()) }
}

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

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

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

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

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

#[cfg(not(osslconf = "OPENSSL_NO_IDEA"))]
pub fn idea_ecb() -> Cipher {
unsafe { Cipher(ffi::EVP_idea_ecb()) }
}

#[cfg(not(osslconf = "OPENSSL_NO_IDEA"))]
pub fn idea_ofb() -> Cipher {
unsafe { Cipher(ffi::EVP_idea_ofb()) }
}

#[cfg(not(osslconf = "OPENSSL_NO_IDEA"))]
pub fn idea_cfb64() -> Cipher {
unsafe { Cipher(ffi::EVP_idea_cfb64()) }
}

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