# Encryption Standards & Cryptographic Protocols

### Overview of the Cryptographic Stack

Anon VPN uses a **hybrid cryptographic model**, where:

* **Symmetric encryption** is used for high-speed data transfer after the tunnel is established.
* **Asymmetric encryption** is used for secure key exchanges and authentication.
* **Hash functions** verify data integrity and ensure secure message authentication.

#### Key Protocols and Libraries Used:

| Layer          | Technology / Protocol   | Library / Standard  |
| -------------- | ----------------------- | ------------------- |
| Symmetric      | AES-256-GCM             | OpenSSL / Libsodium |
| Asymmetric     | ECDHE, RSA-4096         | OpenSSL / BoringSSL |
| Key Exchange   | ECDH / Curve25519       | NaCl / Libsodium    |
| Hashing        | SHA-512, BLAKE2, SHA-2  | FIPS 180-4          |
| Authentication | HMAC, ChaCha20-Poly1305 | RFC 8439, RFC 7634  |
| Handshake      | TLS 1.3, Noise Protocol | WireGuard, OpenVPN  |

***

### 2. Symmetric Encryption

#### AES-256-GCM (Galois/Counter Mode)

* **Purpose:** Encrypts the payload of VPN traffic after session key establishment.
* **Block Size:** 128 bits
* **Key Size:** 256 bits
* **Mode:** GCM ensures authenticated encryption with associated data (AEAD).
* **Advantages:** High throughput, resistance to timing attacks, and secure even on untrusted hardware.

> All OpenVPN-based connections in Anon VPN are encrypted using AES-256-GCM unless the client explicitly requests an alternative.

***

#### ChaCha20-Poly1305

* **Used in:** WireGuard and fallback modes on mobile.
* **Advantages:** Fast on low-power devices (e.g., ARM), constant-time operations.
* **Nonce Size:** 96 bits
* **Key Size:** 256 bits

***

### 3. Key Exchange Protocols

#### ECDHE (Elliptic-Curve Diffie–Hellman Ephemeral)

* **Purpose:** Establishes shared secrets between clients and servers without transmitting private keys.
* **Curve Used:** secp384r1 or Curve25519 depending on protocol.
* **Ephemeral Keys:** Regenerated per session to enable **Perfect Forward Secrecy (PFS)**.

***

#### X25519 (WireGuard’s Key Exchange)

* **Advantages:**
  * Highly performant
  * Small key sizes
  * Resistant to several known attacks
* **Library:** Libsodium’s implementation of ECDH over Curve25519

***

### 4. Message Authentication

#### HMAC (Hash-based Message Authentication Code)

* **Used in:** OpenVPN and TLS 1.2/1.3
* **Hash Function:** SHA-2 (SHA-256 or SHA-512)
* **Purpose:** Ensures the authenticity and integrity of each packet and handshake message.

#### Poly1305 MAC

* Used in combination with ChaCha20 for authenticated encryption in WireGuard.
* Provides integrity and authenticity guarantees with minimal overhead.

***

### 5. Hash Functions

Anon VPN uses strong cryptographic hash functions for message integrity and pseudo-random key derivation:

| Algorithm | Usage                                      |
| --------- | ------------------------------------------ |
| SHA-512   | HMAC, integrity checks, signature schemes  |
| BLAKE2s   | Lightweight hashing for embedded platforms |
| SHA-256   | TLS/SSL negotiation, key derivation        |

***

### 6. TLS and Handshake Protocols

#### TLS 1.3 (Transport Layer Security)

* **Usage:** Utilized during OpenVPN session negotiation.
* **Benefits:**
  * Reduced handshake round trips
  * Eliminates weak cipher suites
  * Supports only AEAD (authenticated encryption)

TLS 1.3 handshakes are further hardened by:

* Enforcing minimum key sizes (2048-bit RSA, 256-bit ECDSA)
* Enabling **certificate pinning** for internal servers

***

### 7. Forward Secrecy (PFS)

Perfect Forward Secrecy ensures that even if a long-term key is compromised, previous session keys remain secure.

#### How Anon VPN enforces PFS:

* All key exchanges are ephemeral (ECDHE / X25519)
* Session keys are regenerated every 15–30 minutes
* Key material is never written to disk

***

### 8. Post-Quantum Cryptography (PQC) Readiness

Anon VPN is actively testing integration of **quantum-resistant algorithms**, particularly:

| Algorithm | Type                              | Status     |
| --------- | --------------------------------- | ---------- |
| Kyber-768 | KEM (Key Encapsulation Mechanism) | Under test |
| Dilithium | Digital Signatures                | Planned    |

These will be deployed in hybrid mode with current algorithms to future-proof communications while maintaining backward compatibility.

***

### 9. Encrypted Metadata & Obfuscation

While VPN protocols often expose metadata (e.g., handshake sizes, timing), Anon VPN addresses this via:

* **TLS Record Padding:** Prevents fingerprinting of handshake packets.
* **Pluggable Transports (future):** Will use obfs4, Shadowsocks, and meek to disguise traffic as normal HTTPS.

***

### 10. Protocol-Specific Security Summary

| Protocol    | Encryption         | Handshake               | Auth & Integrity     | Forward Secrecy |
| ----------- | ------------------ | ----------------------- | -------------------- | --------------- |
| OpenVPN     | AES-256-GCM        | TLS 1.3 + ECDHE         | HMAC-SHA-512         | Yes             |
| WireGuard   | ChaCha20-Poly1305  | Noise Protocol (IKpsk2) | Poly1305, Curve25519 | Yes             |
| IKEv2/IPSec | AES-256-CBC or GCM | Diffie–Hellman Groups   | HMAC-SHA2            | Yes             |

***

### Conclusion

Anon VPN employs cutting-edge cryptographic standards rooted in proven mathematical rigor and industry-recognized protocols. From ephemeral key exchanges and authenticated encryption to PQC-readiness, every cryptographic component in Anon VPN is optimized for:

* High performance
* Strong privacy guarantees
* Resilience against present and future adversaries

This foundation enables Anon VPN to meet the demands of privacy-conscious users, developers, enterprises, and censorship-resilient applications.
