Noise Protocol Clients for access-protocol
This crate provides both remote and user client implementations for connecting through a proxy using the Noise Protocol.
Features
- PSK-based authentication using pairing codes
- Noise Protocol NNpsk2 pattern for secure 2-message handshake
- Session caching for reconnection without re-pairing
- Supports both classical (Curve25519) and post-quantum (Kyber768) cryptography
Remote Client Usage (untrusted device)
use ap_client::{RemoteClient, DefaultProxyClient, IdentityProvider, SessionStore};
use ap_proxy_client::ProxyClientConfig;
use tokio::sync::mpsc;
// Create proxy client
let proxy_client = Box::new(DefaultProxyClient::new(ProxyClientConfig {
proxy_url: "ws://localhost:8080".to_string(),
identity_keypair: Some(identity_provider.identity().to_owned()),
}));
let (event_tx, mut event_rx) = mpsc::channel(32);
let (response_tx, response_rx) = mpsc::channel(32);
let mut client = RemoteClient::new(
identity_provider,
session_store,
event_tx,
response_rx,
proxy_client,
).await?;
// Pair with rendezvous code
client.pair_with_handshake("ABCDEF123").await?;
let query = ap_client::CredentialQuery::Domain("example.com".to_string());
let credential = client.request_credential(&query).await?;
User Client Usage (trusted device)
use ap_client::{
DefaultProxyClient, IdentityProvider, UserClient, UserClientEvent, UserClientResponse,
};
use ap_proxy_client::ProxyClientConfig;
use tokio::sync::mpsc;
// Create proxy client
let proxy_client = Box::new(DefaultProxyClient::new(ProxyClientConfig {
proxy_url: "ws://localhost:8080".to_string(),
identity_keypair: Some(identity_provider.identity().to_owned()),
}));
let (event_tx, event_rx) = mpsc::channel(32);
let (response_tx, response_rx) = mpsc::channel(32);
let mut client = UserClient::listen(
identity_provider,
session_store,
proxy_client,
).await?;
// Enable PSK mode or rendezvous mode
client.enable_psk(event_tx, response_rx).await?;