coven_ssh/lib.rs
1// ABOUTME: Shared SSH authentication utilities for coven services.
2// ABOUTME: Provides key management, fingerprinting, and gRPC auth credentials.
3
4//! # coven-ssh
5//!
6//! SSH key management and authentication utilities for coven services.
7//!
8//! This crate provides a unified implementation of SSH-based authentication
9//! used by coven-agent, coven-leader, and coven-swarm to communicate with
10//! coven-gateway.
11//!
12//! ## Features
13//!
14//! - **Key Management**: Load existing SSH keys or generate new ed25519 keys
15//! - **Fingerprinting**: Compute SHA256 fingerprints compatible with Go's ssh library
16//! - **gRPC Auth**: Apply SSH authentication credentials to tonic requests
17//!
18//! ## Example
19//!
20//! ```no_run
21//! use coven_ssh::{load_or_generate_key, compute_fingerprint, SshAuthCredentials};
22//! use std::path::PathBuf;
23//!
24//! // Load or generate a key
25//! let key_path = PathBuf::from("/path/to/key");
26//! let private_key = load_or_generate_key(&key_path).expect("key should load");
27//!
28//! // Compute fingerprint for identification
29//! let fingerprint = compute_fingerprint(private_key.public_key()).expect("fingerprint should compute");
30//! println!("Key fingerprint: {}", fingerprint);
31//!
32//! // Create auth credentials for gRPC
33//! let creds = SshAuthCredentials::new(&private_key).expect("credentials should create");
34//!
35//! // Apply to a gRPC request
36//! let mut request = tonic::Request::new(());
37//! creds.apply_to_request(&mut request).expect("should apply");
38//! ```
39
40mod credentials;
41mod error;
42mod fingerprint;
43mod key;
44
45// Re-export primary types and functions
46pub use credentials::{current_timestamp, generate_nonce, sign_message, SshAuthCredentials};
47pub use error::{Result, SshError};
48pub use fingerprint::compute_fingerprint;
49pub use key::{
50 default_agent_key_path, default_client_key_path, default_swarm_key_path, generate_key,
51 load_key, load_or_generate_key, xdg_config_dir,
52};
53
54// Re-export ssh_key types for convenience
55pub use ssh_key::{PrivateKey, PublicKey};