qssh 0.0.2-alpha

Experimental quantum-safe SSH using post-quantum crypto. Research project - NOT for production. See LIMITATIONS.md
Documentation
//! Example: Quantum-secure QSSH session with vault integration
//!
//! Demonstrates how QSSH uses:
//! - Quantum Vault for key management
//! - Double Ratchet for forward secrecy
//! - Lamport signatures for critical operations
//! - QKD integration when available

use qssh::{QsshClient, QsshConfig, PqAlgorithm};
use std::env;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    env_logger::init();
    
    // Configuration
    let config = QsshConfig {
        server: "quantum.example.com:22222".to_string(),
        username: "alice".to_string(),
        port_forwards: vec![],
        use_qkd: true, // Enable QKD if available
        pq_algorithm: PqAlgorithm::Falcon512,
        key_rotation_interval: 300, // Rotate keys every 5 minutes
    };
    
    // Create client with quantum vault
    let master_key = b"example-master-key-from-tpm-or-password";
    let mut client = QsshClient::new(config)
        .with_vault(master_key)
        .await?;
    
    println!("Connecting with quantum-secure vault...");
    
    // Connect - this will:
    // 1. Use Falcon-512 + SPHINCS+ for handshake
    // 2. Integrate QKD keys if available
    // 3. Store session keys in vault
    // 4. Initialize double ratchet for the session
    client.connect().await?;
    
    println!("Connected! Session secured with:");
    println!("- Post-quantum key exchange (Falcon-512)");
    println!("- Post-quantum signatures (SPHINCS+)");
    println!("- Quantum vault with key isolation");
    println!("- Double ratchet for forward secrecy");
    
    // Execute a command
    let output = client.exec("echo 'Hello from quantum-secure QSSH!'").await?;
    println!("Command output: {}", output);
    
    // The session keys are automatically ratcheted forward after each message
    // providing perfect forward secrecy - even if current keys are compromised,
    // past communications remain secure
    
    // For critical operations, QSSH can use Lamport signatures
    // (this would be internal to the protocol, not exposed in normal API)
    println!("\nSession benefits:");
    println!("- Keys are ratcheted forward after each packet");
    println!("- Compromise of current key doesn't affect past messages");
    println!("- QKD integration provides true quantum randomness");
    println!("- Lamport signatures available for one-time critical ops");
    
    // Disconnect
    client.disconnect().await?;
    
    println!("\nSession closed. All ephemeral keys destroyed.");
    
    Ok(())
}

// In QuantumHarmony integration, this would additionally:
// 1. Use QKD keys from the quantum network as root keys
// 2. Coordinate ratchet state with blockchain consensus
// 3. Use Lamport signatures for validator attestations
// 4. Store long-term keys in hardware-backed vault