summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSebastian Holmin <sebastian.holmin@mullvad.net>2025-01-08 18:48:58 +0100
committerSebastian Holmin <sebastian.holmin@mullvad.net>2025-01-09 15:13:10 +0100
commitb824d79cd8293d45fc08de6cac60aa0b00096ac3 (patch)
tree1296b2bbd4379b961d349bd32a97073985eec64b
parent094196aa4a5356750e0ae1e13945326a1060b8d1 (diff)
downloadmullvadvpn-b824d79cd8293d45fc08de6cac60aa0b00096ac3.tar.xz
mullvadvpn-b824d79cd8293d45fc08de6cac60aa0b00096ac3.zip
Spawn key pair worker on launch
-rw-r--r--talpid-core/src/tunnel_state_machine/mod.rs1
-rw-r--r--talpid-tunnel-config-client/src/classic_mceliece.rs6
-rw-r--r--talpid-tunnel-config-client/src/lib.rs2
3 files changed, 5 insertions, 4 deletions
diff --git a/talpid-core/src/tunnel_state_machine/mod.rs b/talpid-core/src/tunnel_state_machine/mod.rs
index 6f4dc33218..06588392e9 100644
--- a/talpid-core/src/tunnel_state_machine/mod.rs
+++ b/talpid-core/src/tunnel_state_machine/mod.rs
@@ -25,6 +25,7 @@ use talpid_routing::RouteManagerHandle;
#[cfg(target_os = "macos")]
use talpid_tunnel::TunnelMetadata;
use talpid_tunnel::{tun_provider::TunProvider, TunnelEvent};
+use talpid_tunnel_config_client::classic_mceliece::{spawn_keypair_worker, BUFSIZE, KEYPAIR_RX};
#[cfg(target_os = "macos")]
use talpid_types::ErrorExt;
diff --git a/talpid-tunnel-config-client/src/classic_mceliece.rs b/talpid-tunnel-config-client/src/classic_mceliece.rs
index da6024f713..3d29e1997c 100644
--- a/talpid-tunnel-config-client/src/classic_mceliece.rs
+++ b/talpid-tunnel-config-client/src/classic_mceliece.rs
@@ -10,7 +10,7 @@ const STACK_SIZE: usize = 2 * 1024 * 1024;
/// Number of McEliece key pairs to buffer. Note that, using the below algorithm, they take up around
/// 537 kB each. We therefore only buffer two, which is the largest useful amount, in case of multihop.
-const BUFSIZE: usize = 2;
+pub const BUFSIZE: usize = 2;
/// Use the smallest CME variant with NIST security level 3. This variant has significantly smaller
/// keys than the larger variants, and is considered safe.
@@ -18,14 +18,14 @@ pub const ALGORITHM_NAME: &str = "Classic-McEliece-460896f-round3";
type KeyPair = (PublicKey<'static>, SecretKey<'static>);
-static KEYPAIR_RX: OnceLock<Mutex<mpsc::Receiver<KeyPair>>> = OnceLock::new();
+pub static KEYPAIR_RX: OnceLock<Mutex<mpsc::Receiver<KeyPair>>> = OnceLock::new();
/// Spawn a worker that pre computes `bufsize` McEliece key pairs in a separate thread, which can be
/// fetched asynchronously using the returned channel.
///
/// As it can take upwards of 200 ms to generate McEliece key pairs, it needs to be done before we
/// start connecting to the tunnel.
-fn spawn_keypair_worker(bufsize: usize) -> mpsc::Receiver<KeyPair> {
+pub fn spawn_keypair_worker(bufsize: usize) -> mpsc::Receiver<KeyPair> {
// As one of the key pairs will be buffered by the stack of the spawned thread, we reduce the
// capacity of the channel by one
let bufsize = bufsize.checked_sub(1).expect("bufsize must be at least 1");
diff --git a/talpid-tunnel-config-client/src/lib.rs b/talpid-tunnel-config-client/src/lib.rs
index bfa3deb292..381bc65a53 100644
--- a/talpid-tunnel-config-client/src/lib.rs
+++ b/talpid-tunnel-config-client/src/lib.rs
@@ -12,7 +12,7 @@ use tonic::transport::Endpoint;
use tower::service_fn;
use zeroize::Zeroize;
-mod classic_mceliece;
+pub mod classic_mceliece;
mod ml_kem;
#[cfg(not(target_os = "ios"))]
mod socket;