Skip to content

Commit c96aaf1

Browse files
committed
add optional features for less used algorithms
This commit disables by default a few of the weaker cryptographical algorithms into a "weak-crypto" feature as well as some of the less used algorithms into their own specific features. These algorithms are not directly exposed through the rust-openssl crate. The compilation of these can be re-enabled by selecting the desired features. This should slightly reduce build time and library size. Signed-off-by: Petre Eftime <[email protected]>
1 parent 9713ad8 commit c96aaf1

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

.github/workflows/main.yml

+4
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ jobs:
131131
if: startsWith(matrix.os, 'windows')
132132
name: Run tests (Windows)
133133
shell: cmd
134+
- run: |
135+
cargo test --manifest-path testcrate/Cargo.toml --target ${{ matrix.target }} --all-features
136+
if: matrix.thing == 'stable'
137+
name: Build all features (stable)
134138
135139
rustfmt:
136140
name: Rustfmt

Cargo.toml

+15
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ exclude = [
1616
'openssl/test/*',
1717
]
1818

19+
[features]
20+
default = []
21+
# Enables compilation of some older algorithms: md2 (hash), rc5 (block cypher) and enabled use of
22+
# some weaker algorithms in SSL connections. These are generally not recommended for use.
23+
weak-crypto = []
24+
# Enables compilation of the Camellia symmetric key block cypher. Since hardware acceleration for
25+
# it is not available on most systems, this is not as used as AES.
26+
camellia = []
27+
# Enables compilation of International Data Encryption Algorithm (IDEA), a symmetric key block
28+
# cypher sometimes used as an AES128 alternative.
29+
idea = []
30+
# Enables compilation of SEED, a symmetric key block cypher mostly used in South Korea, but
31+
# otherwise not widely supported.
32+
seed = []
33+
1934
[workspace]
2035
members = ['testcrate']
2136

ci/run.sh

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ target=$1
22
set -ex
33
cargo test --manifest-path testcrate/Cargo.toml --target $1 -vv
44
cargo test --manifest-path testcrate/Cargo.toml --target $1 -vv --release
5+
if [ "$1" = "x86_64-unknown-linux-gnu" ] ; then
6+
cargo test --manifest-path testcrate/Cargo.toml --target $1 -vv --all-features
7+
fi

src/lib.rs

+19
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ impl Build {
104104
.arg("no-zlib")
105105
.arg("no-zlib-dynamic");
106106

107+
if cfg!(not(feature = "weak-crypto")) {
108+
configure
109+
.arg("no-md2")
110+
.arg("no-rc5")
111+
.arg("no-weak-ssl-ciphers");
112+
}
113+
114+
if cfg!(not(feature = "camellia")) {
115+
configure.arg("no-camellia");
116+
}
117+
118+
if cfg!(not(feature = "idea")) {
119+
configure.arg("no-idea");
120+
}
121+
122+
if cfg!(not(feature = "seed")) {
123+
configure.arg("no-seed");
124+
}
125+
107126
if target.contains("musl") || target.contains("windows") {
108127
// This actually fails to compile on musl (it needs linux/version.h
109128
// right now) but we don't actually need this most of the time.

0 commit comments

Comments
 (0)