f6bd511599
* merging georgio/lp-psqv2-integration * use authenicator on the responder's side * nym-lp crate compiling * moved the e2e test to nym-lp * move key generation to peer * moved principal generation * update KKTResponder * encapsulation key parsing * Adding concrete types within KKT exchange * initiator side of the full handshake * responder side of the handshake and full e2e test * fixed unit-tests within nym-kkt * LpSession cleanup * helpers for Transport * revamp of the transport traits and initial work on client-side transport * compiling nym-crypto * 'working' client-entry dvpn reg * Fix key conversion * Slightly reduce use of rand08 * reverted back to libcrux repo refs * intial telescoping reg * removing dead code * wip * moved data encryption into the state machine * restoring nym-lp tests * update lp api model * Add receiver index derivation * Add receiver index derivation * use derived receiver index * feat: add kem key generation to nodes * generate fresh x25519, mlkem768 and mceliece keys on config migration * add lp peer config * nym-node startup cleanup * removed dependency on pre-rand09 from nym-lp * re-expose LP information on the http API * fixed tests compilation * add peer config happy path tests * formatting * add more tests and fix bug * better docs * clippy and formatting issues * return error on mceliece within NestedSession * wasm fixes * removed legacy nym-vpn-lib-wasm * fixing wasm for real this time * additional fixes * add payload to kkt * make clippy happy * moved LP to nym-node crate * cargo fmt * integrate lpconfig payload * fix response size trait impl * Migrate receiver index * Change receiver index to u32 and regorganize crates * clippy * hopefully final wasm fixes * simple conversion method from semver to ciphersuite * updated nym-node config template * chore: remove duplicated code --------- Co-authored-by: Georgio Nicolas <me@georgio.xyz>
100 lines
2.8 KiB
Rust
100 lines
2.8 KiB
Rust
// Copyright 2025 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// fine in test code
|
|
#![allow(clippy::unwrap_used)]
|
|
|
|
use crate::traits::Timeboxed;
|
|
use nym_bin_common::logging::tracing_subscriber::EnvFilter;
|
|
use nym_bin_common::logging::tracing_subscriber::layer::SubscriberExt;
|
|
use nym_bin_common::logging::tracing_subscriber::util::SubscriberInitExt;
|
|
use nym_bin_common::logging::{default_tracing_fmt_layer, tracing_subscriber};
|
|
use rand_chacha::rand_core::SeedableRng;
|
|
use rand_chacha09::rand_core::SeedableRng as SeedableRng09;
|
|
use std::future::Future;
|
|
use std::sync::{Arc, Mutex};
|
|
use tokio::task::JoinHandle;
|
|
use tokio::time::error::Elapsed;
|
|
|
|
// 'current' rand crate
|
|
pub use rand_chacha::ChaCha20Rng as DeterministicRng;
|
|
pub use rand_chacha::rand_core::{CryptoRng, RngCore};
|
|
|
|
// rand09 compat
|
|
pub use rand_chacha09::ChaChaRng as DeterministicRng09;
|
|
pub use rand_chacha09::rand_core::{CryptoRng as CryptoRng09, RngCore as RngCore09};
|
|
|
|
pub fn leak<T>(val: T) -> &'static mut T {
|
|
Box::leak(Box::new(val))
|
|
}
|
|
|
|
pub fn spawn_timeboxed<F>(fut: F) -> JoinHandle<Result<F::Output, Elapsed>>
|
|
where
|
|
F: Future + Send + 'static,
|
|
<F as Future>::Output: Send,
|
|
{
|
|
tokio::spawn(async move { fut.timeboxed().await })
|
|
}
|
|
|
|
pub struct DeterministicRng09Send(Arc<Mutex<DeterministicRng09>>);
|
|
|
|
impl DeterministicRng09Send {
|
|
pub fn new(deterministic_rng09: DeterministicRng09) -> Self {
|
|
Self(Arc::new(Mutex::new(deterministic_rng09)))
|
|
}
|
|
}
|
|
|
|
impl CryptoRng09 for DeterministicRng09Send {}
|
|
|
|
// unwraps are perfectly fine in test code
|
|
impl RngCore09 for DeterministicRng09Send {
|
|
fn next_u32(&mut self) -> u32 {
|
|
self.0.lock().unwrap().next_u32()
|
|
}
|
|
|
|
fn next_u64(&mut self) -> u64 {
|
|
self.0.lock().unwrap().next_u64()
|
|
}
|
|
|
|
fn fill_bytes(&mut self, dst: &mut [u8]) {
|
|
self.0.lock().unwrap().fill_bytes(dst)
|
|
}
|
|
}
|
|
|
|
pub fn deterministic_rng_09() -> DeterministicRng09 {
|
|
seeded_rng_09([42u8; 32])
|
|
}
|
|
|
|
pub fn deterministic_rng() -> DeterministicRng {
|
|
seeded_rng([42u8; 32])
|
|
}
|
|
|
|
pub fn seeded_rng(seed: [u8; 32]) -> DeterministicRng {
|
|
DeterministicRng::from_seed(seed)
|
|
}
|
|
|
|
pub fn seeded_rng_09(seed: [u8; 32]) -> DeterministicRng09 {
|
|
DeterministicRng09::from_seed(seed)
|
|
}
|
|
|
|
pub fn u64_seeded_rng(seed: u64) -> DeterministicRng {
|
|
DeterministicRng::seed_from_u64(seed)
|
|
}
|
|
|
|
pub fn u64_seeded_rng_09(seed: u64) -> DeterministicRng09 {
|
|
DeterministicRng09::seed_from_u64(seed)
|
|
}
|
|
|
|
// test logger to use during debugging
|
|
#[allow(clippy::unwrap_used)]
|
|
pub fn setup_test_logger() {
|
|
tracing_subscriber::registry()
|
|
.with(default_tracing_fmt_layer(std::io::stderr))
|
|
.with(
|
|
EnvFilter::new("trace"),
|
|
// .add_directive("nym_sdk::client_pool=info".parse().unwrap())
|
|
// .add_directive("nym_sdk::tcp_proxy_client=debug".parse().unwrap()),
|
|
)
|
|
.init();
|
|
}
|