Skip to content

Commit

Permalink
add x25519_dalek implement
Browse files Browse the repository at this point in the history
  • Loading branch information
Mon-ius committed Feb 18, 2024
1 parent 85260e4 commit cc622f8
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 9 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
## Features

1. Implementation of `eBPF-driven` **Wireguard** in Rust
1. Implementation **Wireguard** protocol in Rust with `eBPF-driven` optimization
2. Asynchronous acquisition for WARP Plus Subscription with `tokio`
3. Invocation of the `Socks5` proxy protocol with password protection
3. Apply the `Socks5` proxy protocol with username/password authentication to enhance privacy and bypass firewalls
4. Enable `curve25519` encryption with `x25519_dalek` implementation of x25519 key exchange algorithm

## Usage

Expand Down
2 changes: 1 addition & 1 deletion rws-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rws-cli"
version = "0.1.9"
version = "0.1.11"
edition = "2021"

[dependencies]
Expand Down
5 changes: 3 additions & 2 deletions rws-cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use librws::warp::account::WClientBuilder;
use librws::account::WClientBuilder;

#[derive(Parser, Debug)]
struct Args {
Expand All @@ -21,7 +21,8 @@ fn main() {
let wclient = WClientBuilder::new()
// .w_id(&args.device_id)
.random_id()
.random_key()
// .random_key()
.wg_key()
.random_token()
.random_dev()
.random_tz()
Expand Down
3 changes: 3 additions & 0 deletions rws/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ edition = "2021"
tokio = { version = "1.36.0", features = ["full"] }
serde = { version = "1.0.196", features = ["derive"] }
rand = { version = "0.8.5" }
base64 = { version = "0.21.7" }
rand_core = { version = "0.6.4", default-features = false }
x25519-dalek = { version = "2.0.1", features = ["static_secrets"]}
chrono = { version = "0.4.34" }
chrono-tz = { version = "0.8.6", features = ["serde"] }

Expand Down
8 changes: 7 additions & 1 deletion rws/src/warp/account.rs → rws/src/account.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::random;
use crate::warp::random;
use crate::wireguard::crypto;
use serde::Deserialize;
use std::fmt;

Expand Down Expand Up @@ -87,6 +88,11 @@ impl<'w> WClientBuilder<'w> {
pub fn random_key(self) -> Self {
self.w_key(random::fake::take(43, |_c| true))
}

pub fn wg_key(self) -> Self {
self.w_key(crypto::sample())
}

pub fn random_token(self) -> Self {
self.w_token(random::fake::take(134, |_c| true))
}
Expand Down
3 changes: 2 additions & 1 deletion rws/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod warp;
pub mod wireguard;
pub mod wireguard;
pub mod account;
1 change: 0 additions & 1 deletion rws/src/warp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub mod account;
pub mod random;
pub mod log;
10 changes: 10 additions & 0 deletions rws/src/wireguard/crypto.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use rand_core::OsRng;
use x25519_dalek::{PublicKey, StaticSecret};
use base64::{engine::general_purpose::STANDARD as BASE64, Engine as _};

pub fn sample() -> &'static str{
let _pvt = StaticSecret::random_from_rng(OsRng);
let _pub = PublicKey::from(&_pvt);
let _b64 = BASE64.encode(_pub);
_b64.leak()
}
3 changes: 2 additions & 1 deletion rws/src/wireguard/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod ebpf;
pub mod ebpf;
pub mod crypto;

0 comments on commit cc622f8

Please sign in to comment.