Key Management¶
R-VPN uses Ed25519 identity keys for authentication. This guide covers key generation and management.
Key Types¶
| Key Type | Purpose | Storage |
|---|---|---|
| Identity Key | Long-term identity | Keep secure, backup |
| Public Key | Shared with server | Can be public |
| Prekey Bundle | Initial handshake | Server-side |
Generating Keys¶
Generate Identity Key¶
# Generate client identity key
rvpn keygen --output client_identity.key
# Generate with default output (identity.key)
rvpn keygen
This creates a new Ed25519 key pair. The file format:
Extract Public Key¶
# Extract public key from identity file
rvpn pubkey --key client_identity.key --output client_public.key
# Extract with default output (public.key)
rvpn pubkey --key client_identity.key
Generate Prekey Bundle¶
For server operators:
# Generate prekey bundle from server identity
rvpn prekey-bundle --identity server_identity.key --output bundle.json
Or using the server binary:
The bundle contains:
- identity_key - Server's Ed25519 identity public key (base64)
- identity_x25519_key - Server's X25519 identity key for X3DH (base64)
- signed_prekey - X25519 signed prekey for X3DH handshake (base64)
- prekey_signature - Signature of the signed prekey (base64)
- one_time_prekey - Optional one-time prekey for enhanced forward secrecy (base64)
Obtaining Server Prekey Bundle¶
To connect to a server, you need the server's prekey bundle. This can be obtained:
- From server administrator - They generate it using the
prekey-bundlecommand - Via secure channel - Share the JSON file through a secure means
The bundle file (prekey-bundle.json) contains all information needed for the X3DH handshake.
Key Security¶
Protecting Private Keys¶
Your identity key is the core of your security:
# Set restrictive permissions
chmod 600 client_identity.key
# Store in secure location
mkdir -p ~/.rvpn/keys/
mv client_identity.key ~/.rvpn/keys/
Backing Up Keys¶
Backup your identity key securely:
# Encrypt before backup with GPG
gpg --symmetric --cipher-algo AES256 client_identity.key
# Or use passphrase-protected encryption
gpg --symmetric --armor client_identity.key
# Store in secure location
# - Password manager
# - Encrypted USB drive
# - Secure cloud storage
To restore from backup:
# Decrypt the backup
gpg --decrypt client_identity.key.gpg > client_identity.key
# Set proper permissions
chmod 600 client_identity.key
Rotating Keys¶
Periodically rotate your identity keys for enhanced security:
# Generate new key
rvpn keygen --output new_client_identity.key
# Extract new public key
rvpn pubkey --key new_client_identity.key --output new_public.key
# Update server with new public key
# (Contact your VPN provider with the new public key)
# Backup old key
mv client_identity.key client_identity.key.old
# Switch to new key
mv new_client_identity.key client_identity.key
# Securely delete old key when confirmed working
shred -u client_identity.key.old
Server Key Setup¶
Server Identity¶
# Generate server identity
rvpn-server keygen
# Or using client binary
rvpn keygen --output server_identity.key
Extract Public Key¶
Distribute server_public.key to clients for server authentication.
Prekey Bundle¶
Generate the prekey bundle for client initialization:
The server also generates a private bundle (prekey-bundle.private.json) containing the signed prekey private key, which must be kept secure on the server.
The public bundle should be served via HTTPS for clients to retrieve during connection.
Key File Formats¶
Identity Key File Format¶
Example:
Public Key File Format¶
Example:
Prekey Bundle Format (JSON)¶
{
"identity_key": "base64 encoded Ed25519 public key",
"identity_x25519_key": "base64 encoded X25519 public key",
"signed_prekey": "base64 encoded X25519 signed prekey",
"prekey_signature": "base64 encoded Ed25519 signature",
"one_time_prekey": "base64 encoded X25519 one-time prekey (optional)"
}
Troubleshooting¶
Invalid Key Format¶
Ensure the key file hasn't been corrupted:
Key Not Found¶
Verify the path in your configuration:
Permission Issues¶
Keys should have restricted permissions:
# Check current permissions
ls -la client_identity.key
# Fix permissions
chmod 600 client_identity.key
Prekey Bundle Errors¶
If you encounter handshake errors:
- Verify the bundle was generated from the correct identity key
- Check that the bundle JSON is valid and not corrupted
- Ensure the server has the corresponding private bundle
Best Practices¶
- Never share private keys - Keep identity keys secure and never transmit them
- Backup keys - Store encrypted copies in secure locations
- Rotate periodically - Generate new keys every 6-12 months
- Use strong permissions -
chmod 600on all key files - Verify signatures - Always verify server public keys before first connection
- Secure deletion - Use
shredor similar when deleting old keys - Separate keys - Use different identity keys for different servers
Next Steps¶
- Configuration - Configure your client
- Server Setup - Set up a server