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

add optional features for less used algorithms #68

Merged
merged 1 commit into from
Jul 20, 2020
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
15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ exclude = [
'openssl/test/*',
]

[features]
default = []
# Enables compilation of some older algorithms: md2 (hash), rc5 (block cypher) and enabled use of
# some weaker algorithms in SSL connections. These are generally not recommended for use.
weak-crypto = []
# Enables compilation of the Camellia symmetric key block cypher. Since hardware acceleration for
# it is not available on most systems, this is not as used as AES.
camellia = []
# Enables compilation of International Data Encryption Algorithm (IDEA), a symmetric key block
# cypher sometimes used as an AES128 alternative.
idea = []
# Enables compilation of SEED, a symmetric key block cypher mostly used in South Korea, but
# otherwise not widely supported.
seed = []
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add comments to each of these features indicating what they enable? (I'm not sure what "camellia", "seed", or "idea" are)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in Cargo.toml, but maybe these features should be documented in the README as well?


[workspace]
members = ['testcrate']

Expand Down
3 changes: 3 additions & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ target=$1
set -ex
cargo test --manifest-path testcrate/Cargo.toml --target $1 -vv
cargo test --manifest-path testcrate/Cargo.toml --target $1 -vv --release
if [ "$1" = "x86_64-unknown-linux-gnu" ] ; then
cargo test --manifest-path testcrate/Cargo.toml --target $1 -vv --all-features
fi
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ impl Build {
.arg("no-zlib")
.arg("no-zlib-dynamic");

if cfg!(not(feature = "weak-crypto")) {
configure
.arg("no-md2")
.arg("no-rc5")
.arg("no-weak-ssl-ciphers");
}

if cfg!(not(feature = "camellia")) {
configure.arg("no-camellia");
}

if cfg!(not(feature = "idea")) {
configure.arg("no-idea");
}

if cfg!(not(feature = "seed")) {
configure.arg("no-seed");
}

if target.contains("musl") || target.contains("windows") {
// This actually fails to compile on musl (it needs linux/version.h
// right now) but we don't actually need this most of the time.
Expand Down