diff options
| author | David Lönnhager <david.l@mullvad.net> | 2022-06-13 14:39:29 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2022-06-14 12:38:44 +0200 |
| commit | d7391e94e6d167ba70669f9febb32eefd9dbd78c (patch) | |
| tree | 7f181d506a3f892f9fd0c3704104dec7236b4f78 | |
| parent | 6f359a8fd0312071b94b5664b2365af6583fc5ba (diff) | |
| download | mullvadvpn-d7391e94e6d167ba70669f9febb32eefd9dbd78c.tar.xz mullvadvpn-d7391e94e6d167ba70669f9febb32eefd9dbd78c.zip | |
Update example code for PQ PSK exchange
| -rw-r--r-- | talpid-relay-config-client/examples/psk-exchange.rs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/talpid-relay-config-client/examples/psk-exchange.rs b/talpid-relay-config-client/examples/psk-exchange.rs index de768c6964..51cb138e53 100644 --- a/talpid-relay-config-client/examples/psk-exchange.rs +++ b/talpid-relay-config-client/examples/psk-exchange.rs @@ -1,17 +1,24 @@ -use std::net::{IpAddr, Ipv4Addr}; +use std::{ + io, + net::{IpAddr, Ipv4Addr}, +}; -use talpid_types::net::wireguard::PrivateKey; +use talpid_types::net::wireguard::PublicKey; #[tokio::main] async fn main() { - let current_private_key = PrivateKey::new_from_random(); + println!("Make sure you're connected to a WireGuard peer and enter your public key: "); - let (private_key, psk) = talpid_relay_config_client::push_pq_key( - IpAddr::V4(Ipv4Addr::new(10, 64, 0, 1)), - current_private_key.public_key(), - ) - .await - .unwrap(); + let mut pubkey_s = String::new(); + io::stdin() + .read_line(&mut pubkey_s) + .expect("Failed to read from stdin"); + let pubkey = PublicKey::from_base64(pubkey_s.trim()).expect("Invalid public key"); + + let (private_key, psk) = + talpid_relay_config_client::push_pq_key(IpAddr::V4(Ipv4Addr::new(10, 64, 0, 1)), pubkey) + .await + .unwrap(); println!("private key: {:?}", private_key); println!("psk: {:?}", psk); |
