Loading learning content...
In the previous page, we established why IPSec exists—to address the fundamental security deficiencies of IP networks. Now we turn to what security properties IPSec actually provides and how it achieves them.
IPSec offers four core security services, each addressing a distinct threat vector. Understanding these services—their capabilities, limitations, and cryptographic foundations—is essential for correctly deploying and evaluating IPSec solutions.
These aren't abstract concepts. Every VPN connection you've ever used, every site-to-site tunnel protecting corporate traffic, every remote worker accessing sensitive systems—all rely on these security services working correctly. A misconfiguration or misunderstanding can leave traffic completely exposed while administrators believe it's protected.
By the end of this page, you will understand: (1) how IPSec achieves confidentiality through symmetric encryption, (2) how data integrity is verified using cryptographic hash functions and MACs, (3) how data origin authentication proves packet authenticity, (4) how anti-replay protection prevents packet capture and retransmission attacks, and (5) how these services are combined in practice.
Confidentiality ensures that packet contents cannot be read by unauthorized parties. Even if an attacker captures packets in transit—through network taps, compromised routers, or Wi-Fi interception—they cannot extract meaningful information. All they see is apparently random ciphertext.
The Cryptographic Foundation: Symmetric Encryption
IPSec achieves confidentiality through symmetric-key encryption. Both communicating parties share a secret key; the sender encrypts data with this key, and the receiver decrypts using the same key. This is fundamentally different from asymmetric (public-key) encryption used in TLS handshakes—symmetric encryption is dramatically faster, enabling wire-speed encryption on high-bandwidth links.
Key Insight: Symmetric encryption's speed is why IPSec can protect multi-gigabit links with acceptable overhead. AES encryption in hardware can process 100+ Gbps. Asymmetric encryption would be orders of magnitude slower and impractical for bulk data protection.
| Algorithm | Key Size | Status | Notes |
|---|---|---|---|
| DES | 56 bits | ❌ Obsolete | Brute-forceable since 1999. Never use for new deployments. |
| 3DES (Triple DES) | 168 bits (112 effective) | ⚠️ Deprecated | Sweet32 attack (2016) limits practical security. Only for legacy compatibility. |
| AES-CBC | 128/192/256 bits | ✅ Acceptable | Widely supported. Requires separate integrity (HMAC). Vulnerable to padding oracle if misconfigured. |
| AES-CTR | 128/192/256 bits | ✅ Acceptable | Counter mode. Stream cipher properties. Used with separate MAC. |
| AES-GCM | 128/192/256 bits | ✅ Recommended | Authenticated encryption. Combines confidentiality + integrity. Hardware accelerated. |
| ChaCha20-Poly1305 | 256 bits | ✅ Recommended | High performance without hardware acceleration. Excellent for mobile/IoT. |
Understanding Encryption Modes:
Block Cipher Modes (CBC, CTR):
Block ciphers like AES encrypt fixed-size blocks (128 bits for AES). Real-world data rarely aligns perfectly with block boundaries. Modes of operation define how to apply block ciphers to arbitrary-length data:
CBC (Cipher Block Chaining): Each plaintext block is XORed with the previous ciphertext block before encryption. Requires an Initialization Vector (IV) for the first block. Sequential encryption; cannot parallelize. Vulnerable to padding oracle attacks if implementation checks padding before MAC.
CTR (Counter Mode): Encrypts sequential counter values; XORs the result with plaintext. Essentially converts block cipher to stream cipher. Parallelizable—critical for high-speed hardware. Never reuse (key, counter) pairs!
Authenticated Encryption with Associated Data (AEAD):
Modern best practice combines encryption and integrity verification in a single operation. AEAD modes like AES-GCM and ChaCha20-Poly1305 provide:
AEAD modes avoid subtle implementation vulnerabilities that plagued encrypt-then-MAC schemes and are now the recommended approach for all new IPSec deployments.
ESP supports 'NULL encryption'—authentication without confidentiality. This is useful for testing or environments where encryption is legally restricted. However, administrators sometimes accidentally deploy NULL encryption, believing traffic is encrypted when it's only authenticated. Always verify your negotiated algorithms in production systems.
Key Derivation and Key Material:
Symmetric encryption requires shared key material that:
IPSec derives encryption keys from the IKE negotiation process. The key derivation function (typically based on HMAC-SHA2) uses:
The result: fresh keys for each direction of traffic, each security association. Even if one SA's key is compromised, other SAs remain secure.
Practical Consideration: Hardware Acceleration
Modern CPUs include AES instructions (AES-NI on x86, ARMv8 Cryptography Extensions) that accelerate AES operations by 10-100x. Enterprise routers and firewalls include dedicated cryptographic accelerators. When selecting algorithms:
| Environment | Recommendation |
|---|---|
| Intel/AMD servers with AES-NI | AES-256-GCM |
| ARM devices with crypto extensions | AES-256-GCM |
| Older devices without hardware support | ChaCha20-Poly1305 |
| High-throughput links (100G+) | AES-256-GCM with hardware offload |
Data integrity ensures that packet contents have not been modified in transit. Any change—whether a single bit flip or wholesale content replacement—is detected, and the modified packet is silently discarded.
Without integrity protection, an attacker can perform man-in-the-middle attacks: intercepting packets, modifying their contents, and forwarding the modified packets. Even with encryption, an attacker might corrupt ciphertext in ways that produce meaningful changes when decrypted (bit-flipping attacks in stream ciphers and CTR mode).
The Cryptographic Foundation: Hash Functions and MACs
Integrity verification relies on two cryptographic primitives:
1. Cryptographic Hash Functions
A hash function takes arbitrary-length input and produces a fixed-size output (the 'hash' or 'digest'). Properties:
Common hash functions: SHA-256, SHA-384, SHA-512 (from the SHA-2 family)
| Algorithm | Output Size | Status | Notes |
|---|---|---|---|
| MD5 | 128 bits | ❌ Broken | Collision attacks demonstrated. Never use for security. |
| SHA-1 | 160 bits | ❌ Deprecated | Collision attacks practical (SHAttered, 2017). Avoid in new deployments. |
| SHA-256 | 256 bits | ✅ Recommended | Widely supported. No known weaknesses. Standard choice. |
| SHA-384 | 384 bits | ✅ Recommended | Higher security margin. Common in government applications. |
| SHA-512 | 512 bits | ✅ Recommended | Maximum security. Faster than SHA-256 on 64-bit processors. |
| SHA3-256/384/512 | Variable | ✅ Future-proof | Different construction (Keccak). Not yet widely deployed in IPSec. |
2. Message Authentication Codes (MACs)
A hash alone isn't sufficient for integrity protection. An attacker could modify the packet and recompute the hash. We need a keyed integrity check: a verification that only parties knowing the secret key can produce.
HMAC (Hash-based Message Authentication Code) combines a hash function with a secret key:
HMAC(key, message) = Hash((key ⊕ opad) || Hash((key ⊕ ipad) || message))
Where:
ipad = 0x36 repeated to block sizeopad = 0x5C repeated to block size|| = concatenation⊕ = XOR operationSecurity Properties of HMAC:
How Integrity Works in IPSec:
IPSec commonly uses truncated MACs (e.g., HMAC-SHA-256-128) to reduce overhead. Instead of appending the full 256-bit HMAC output, only the first 128 bits are included. This provides a security level of 2^128 operations for forgery attacks—more than sufficient. The trade-off is bandwidth efficiency vs. computational work an attacker must perform.
Authenticated Encryption: Combining Confidentiality and Integrity
Modern IPSec strongly recommends AEAD algorithms (AES-GCM, ChaCha20-Poly1305) that provide both encryption and authentication in a single operation. AEAD offers several advantages:
| Aspect | Encrypt-then-MAC | AEAD (AES-GCM) |
|---|---|---|
| Operations | Two passes (encrypt, then MAC) | Single pass |
| Performance | Higher overhead | More efficient |
| Security | Subtle ordering vulnerabilities possible | Proven secure construction |
| Implementation | Complex (correct ordering matters) | Simple API |
| Hardware support | Two separate accelerators | Single accelerator |
GCM Mode Internals:
GCM (Galois/Counter Mode) combines CTR mode encryption with Galois field multiplication for authentication:
The Additional Authenticated Data (AAD) allows authenticating unencrypted header fields (like ESP header information) alongside the encrypted payload—a perfect fit for IPSec's requirements.
Data origin authentication guarantees that packets genuinely originated from the claimed sender—not from an attacker spoofing their identity. Combined with integrity, it proves both who sent the data and that the data arrived unmodified.
Why Is This Different from Integrity?
At first glance, integrity and authentication seem identical—both use the same cryptographic MAC. The distinction is conceptual:
In practice, if you verify integrity using a key known only to legitimate parties, you implicitly verify authenticity. An attacker who doesn't know the key cannot forge a valid MAC. However, authentication encompasses additional concerns:
The Spoofing Problem:
IP packets include source addresses, but nothing prevents an attacker from inserting arbitrary addresses. Standard IP has no mechanism to verify that the source address in a packet corresponds to the actual originator. This enables:
IPSec's authentication service makes these attacks infeasible. Even if an attacker can inject packets with forged addresses, they cannot produce valid MACs without knowing the secret key.
Authentication in IKE vs. ESP/AH:
IPSec authentication operates at two levels:
1. IKE Authentication (Control Plane):
When establishing a Security Association, IKE authenticates the peer using:
IKE authentication proves identity of the communicating parties and establishes a secure channel for negotiating session keys.
2. Per-Packet Authentication (Data Plane):
ESP and AH provide per-packet authentication using symmetric MACs derived from IKE-negotiated keys. This proves each individual packet originated from the authenticated peer and hasn't been modified.
The Subtle Difference:
IKE authentication says: "I am communicating with entity X" Per-packet authentication says: "This specific packet came from entity X and hasn't been modified"
Both are necessary. Without IKE authentication, you might negotiate keys with an attacker. Without per-packet authentication, an attacker might inject packets into an authenticated session.
IPSec's symmetric-key authentication proves authenticity but NOT non-repudiation. Since both parties know the shared secret, either could have generated any message. You cannot prove to a third party that a specific party sent a message. For non-repudiation, digital signatures (asymmetric cryptography) are required—but IPSec doesn't use signatures for per-packet protection due to performance constraints.
Anti-replay protection prevents attackers from recording valid packets and retransmitting them later. Even though such packets would have valid authentication (the attacker didn't modify them), accepting them again would cause duplicate transactions, state corruption, or security bypasses.
The Replay Attack Scenario:
Example Attack:
Imagine a financial application where an authenticated IPSec-protected packet contains a "transfer $1000" instruction. An attacker captures this packet. They can't read or modify it, but they can retransmit it 100 times. Without anti-replay protection, the server would process 100 transfers—even though the legitimate user intended only one.
The IPSec Anti-Replay Mechanism:
ESP and AH include a 32-bit (or extended 64-bit) Sequence Number field that provides anti-replay protection:
Sender Behavior:
Receiver Behavior:
| Window State | Received Seq# | Action | Reason |
|---|---|---|---|
| Window: [100-163], highest=163 | 164 | ✅ Accept, advance window to [101-164] | New packet ahead of window |
| Window: [100-163], highest=163 | 150 (new) | ✅ Accept, mark 150 as received | Within window, not previously received |
| Window: [100-163], highest=163 | 150 (existed) | ❌ Reject | Replay: already processed this packet |
| Window: [100-163], highest=163 | 99 | ❌ Reject | Too old: before window start |
| Window: [100-163], highest=163 | 200 | ✅ Accept, advance window to [137-200] | Far ahead: accept, advance window |
Extended Sequence Numbers (ESN):
The original 32-bit sequence number allows 2^32 (~4.3 billion) packets per Security Association. This seems large, but on a 10 Gbps link with 1500-byte packets, you'd exhaust the counter in about 86 minutes.
To address this, IPSec supports Extended Sequence Numbers (ESN): a 64-bit counter where only the low-order 32 bits are transmitted. The high-order 32 bits are maintained locally and implicitly inferred. This allows 2^64 packets per SA—effectively unlimited.
Performance Implications:
Anti-replay requires per-packet state at the receiver:
For high-speed links (100+ Gbps) with millions of packets per second, this becomes significant. Hardware implementations typically store window state in fast SRAM or use bloom filters for approximate tracking.
If the anti-replay window is too small for your network's out-of-order delivery characteristics, legitimate packets may be rejected. High-latency links, multipath routing, and load-balanced connections can cause significant packet reordering. If you see 'replay check failed' errors, consider increasing window size (common values: 64, 128, 256, or 1024 packets).
Beyond protecting packet contents, IPSec in tunnel mode provides a fifth security service: limited traffic flow confidentiality. This partially conceals traffic patterns that could otherwise reveal sensitive information.
The Traffic Analysis Threat:
Even when packet contents are encrypted, an observer can learn valuable information from:
Traffic analysis has been used to:
How Tunnel Mode Helps:
In tunnel mode, the original IP header (containing real source/destination) is encapsulated inside the encrypted ESP payload. External observers see only:
This provides network-level anonymity: an observer can tell that Gateway A is communicating with Gateway B, but not which internal hosts are involved.
Transport Mode Visibility:
[IP Header: Src=10.0.1.5, Dst=10.0.2.7]
[ESP Header]
[Encrypted Original Payload]
[ESP Trailer + ICV]
Observer sees: Source (10.0.1.5) and destination (10.0.2.7) hosts.
Internal host addresses are exposed.
Tunnel Mode Visibility:
[New IP Header: Src=GW_A, Dst=GW_B]
[ESP Header]
[Encrypted: Original IP + Payload]
[ESP Trailer + ICV]
Observer sees: Gateway addresses only.
Internal hosts (10.0.1.5, 10.0.2.7) are hidden.
Limitations of IPSec Traffic Flow Confidentiality:
IPSec's traffic flow confidentiality is 'limited' because it doesn't fully protect against traffic analysis:
| Protected Against | Not Protected Against |
|---|---|
| Internal host addresses | Tunnel endpoint addresses |
| Internal network topology | Packet sizes |
| Direct identification of communicating hosts | Timing patterns |
| Volume analysis | |
| Fingerprinting attacks |
Advanced Protection Techniques:
For higher traffic flow confidentiality, additional measures can be applied:
These are not part of standard IPSec but can be layered on top for high-security scenarios.
ESP includes built-in padding—primarily for encryption block alignment. However, implementations can add additional padding (TFC padding) to obscure true packet sizes. RFC 4303 explicitly allows this. Enabling TFC padding adds bandwidth overhead but significantly complicates traffic analysis attacks.
In practice, IPSec security services are not deployed individually—they're combined based on security requirements. Understanding common combinations and their tradeoffs is essential for security architects.
Common Deployment Profiles:
| Profile | Confidentiality | Integrity | Authentication | Anti-Replay | Use Case |
|---|---|---|---|---|---|
| Full Protection (ESP + AEAD) | ✅ AES-GCM | ✅ GCM Tag | ✅ Implicit | ✅ Seq# | Standard VPN; recommended default |
| Authentication Only (AH) | ❌ | ✅ HMAC | ✅ | ✅ Seq# | Regulatory environments prohibiting encryption |
| ESP with NULL Encryption | ❌ | ✅ HMAC | ✅ | ✅ Seq# | Testing; export restrictions |
| ESP without Anti-Replay | ✅ | ✅ | ✅ | ❌ | Rare; multicast scenarios |
| ESP + AH (both) | ✅ ESP | ✅ Both | ✅ Both | ✅ Both | Legacy; header protection (rarely needed today) |
Modern Best Practice:
For nearly all deployments, the recommended configuration is:
ESP with AES-256-GCM-16
- 256-bit AES key for encryption
- 128-bit (16-byte) authentication tag
- Integrated confidentiality + integrity + authentication
- Anti-replay enabled with appropriate window size
- Perfect Forward Secrecy (PFS) with Diffie-Hellman group 19 or 20
Why AH Is Rarely Used Today:
Historically, AH was used when only authentication (not encryption) was required. AH authenticates the entire IP packet, including the outer header—which ESP cannot do because the outer header changes in transit (TTL decrement, etc.).
However:
Result: Modern deployments almost universally use ESP only. AH is retained for backward compatibility and niche applications.
PFS ensures that compromise of long-term keys (IKE authentication credentials) doesn't compromise past session keys. Each IKE session performs fresh Diffie-Hellman exchange, deriving ephemeral session keys. Even if attackers later obtain your private key, they cannot decrypt previously captured traffic. PFS should always be enabled for sensitive communications.
We've examined the security services that IPSec provides and the cryptographic mechanisms underlying each. Let's consolidate the key insights:
What's Next:
Now that we understand what security services IPSec provides, we'll examine how they're applied. The next page explores IPSec's two operational modes: Transport Mode (end-to-end host protection) and Tunnel Mode (gateway-to-gateway protection). Understanding these modes is essential for designing IPSec deployments that match your security architecture.
You now understand the four core security services of IPSec: confidentiality, integrity, authentication, and anti-replay—plus the limited traffic flow confidentiality provided by tunnel mode. You've seen the cryptographic primitives underlying each service and understand modern algorithm recommendations. Next, we'll explore how these services are applied through Transport and Tunnel modes.