Skip to content

Commit 070fd55

Browse files
Merge pull request #192 from expressvpn/CVPN-1554-remove-liboqs-and-use-new-wolfssl
CVPN-1554 Remove liboqs and use WolfSSL's implementations
2 parents 8366f61 + ab01e98 commit 070fd55

10 files changed

+3600
-209
lines changed

Cargo.lock

Lines changed: 5 additions & 140 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deny.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ wildcards = "allow"
3131
highlight = "all"
3232
workspace-default-features = "allow"
3333
external-default-features = "allow"
34-
skip = [
35-
{ name = "bindgen", version = "0.68.1" },
36-
]
3734

3835
[sources]
3936
unknown-registry = "deny"

wolfssl-sys/Cargo.toml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,10 @@ bindgen = "0.70"
1616
autotools = "0.2"
1717
build-target = "0.4.0"
1818

19-
[dependencies.oqs-sys]
20-
version = "0.9.1"
21-
default-features = false
22-
features = ["kyber"]
23-
optional = true
24-
2519
[features]
26-
default = []
20+
default = ["postquantum"]
2721
debug = []
28-
postquantum = ["dep:oqs-sys"]
29-
30-
31-
[package.metadata.cargo-all-features]
32-
# Not an actual feature
33-
denylist = ["oqs-sys"]
22+
postquantum = []
3423

3524
[[example]]
3625
name = "connect_pq"

wolfssl-sys/build.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ fn copy_wolfssl(dest: &Path) -> std::io::Result<PathBuf> {
4343
}
4444

4545
const PATCH_DIR: &str = "patches";
46-
const PATCHES: &[&str] = &["disable-falcon-dilithium.patch"];
46+
const PATCHES: &[&str] = &[
47+
"include-private-key-fields-for-kyber.patch",
48+
"make-kyber-mlkem-available.patch",
49+
"fix-kyber-mlkem-benchmark.patch",
50+
"fix-mlkem-get-curve-name.patch",
51+
"fix-kyber-get-curve-name.patch",
52+
];
4753

4854
/**
4955
* Apply patch to wolfssl-src
@@ -90,6 +96,8 @@ fn build_wolfssl(wolfssl_src: &Path) -> PathBuf {
9096
.disable_shared()
9197
// Disable sys ca certificate store
9298
.disable("sys-ca-certs", None)
99+
// Disable dilithium
100+
.disable("dilithium", None)
93101
// Enable AES bitsliced implementation (cache attack safe)
94102
.enable("aes-bitsliced", None)
95103
// Enable Curve25519
@@ -118,7 +126,7 @@ fn build_wolfssl(wolfssl_src: &Path) -> PathBuf {
118126
.enable("supportedcurves", None)
119127
// Enable TLS/1.3
120128
.enable("tls13", None)
121-
// Enable liboqs, etc
129+
// Enable kyber, etc
122130
.enable("experimental", None)
123131
// CFLAGS
124132
.cflag("-g")
@@ -137,21 +145,10 @@ fn build_wolfssl(wolfssl_src: &Path) -> PathBuf {
137145
}
138146

139147
if cfg!(feature = "postquantum") {
140-
// Post Quantum support is provided by liboqs
141-
if let Some(include) = std::env::var_os("DEP_OQS_ROOT") {
142-
let oqs_path = Path::new(&include);
143-
conf.cflag(format!(
144-
"-I{}",
145-
oqs_path.join("build/include/").to_str().unwrap()
146-
));
147-
conf.ldflag(format!(
148-
"-L{}",
149-
oqs_path.join("build/lib/").to_str().unwrap()
150-
));
151-
conf.with("liboqs", None);
152-
} else {
153-
panic!("Post Quantum requested but liboqs appears to be missing?");
154-
}
148+
// Enable Kyber
149+
conf.enable("kyber", Some("all,original"))
150+
// SHA3 is needed for using WolfSSL's implementation of Kyber/ML-KEM
151+
.enable("sha3", None);
155152
}
156153

157154
match build_target::target_arch().unwrap() {
@@ -291,10 +288,6 @@ fn main() -> std::io::Result<()> {
291288
// Tell cargo to tell rustc to link in WolfSSL
292289
println!("cargo:rustc-link-lib=static=wolfssl");
293290

294-
if cfg!(feature = "postquantum") {
295-
println!("cargo:rustc-link-lib=static=oqs");
296-
}
297-
298291
println!(
299292
"cargo:rustc-link-search=native={}",
300293
wolfssl_install_dir.join("lib").to_str().unwrap()

wolfssl-sys/patches/disable-falcon-dilithium.patch

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)