Symmetric vs Asymmetric Cryptography

Cryptography Fundamentals

Understanding the difference between symmetric and asymmetric cryptography is crucial for IPsec implementation and security analysis.

Symmetric Cryptography

Symmetric cryptography uses the same key for both encryption and decryption. It's fast and efficient but requires secure key distribution.

Advantages

  • Speed: Very fast encryption/decryption
  • Efficiency: Low computational overhead
  • Scalability: Suitable for large data volumes
  • Resource Usage: Minimal CPU and memory

Disadvantages

  • Key Distribution: Challenge of secure key sharing
  • Key Management: n(n-1)/2 keys for n users
  • Non-repudiation: Cannot prove message origin
  • Initial Setup: Requires pre-shared secrets

Asymmetric Cryptography

Asymmetric cryptography uses a pair of keys: a public key for encryption and a private key for decryption. It solves the key distribution problem but is computationally expensive.

Advantages

  • Key Distribution: No need for shared secrets
  • Scalability: Only 2n keys for n users
  • Non-repudiation: Digital signatures possible
  • Authentication: Can verify sender identity

Disadvantages

  • Speed: 100-10,000x slower than symmetric
  • Resource Usage: High CPU and memory requirements
  • Key Size: Requires much larger key sizes
  • Complexity: More complex implementation

IPsec Hybrid Approach

Component Cryptography Type Purpose Reason
IKE Key Exchange Asymmetric Initial authentication & key agreement Solves key distribution problem
Data Encryption Symmetric Bulk data protection Performance and efficiency
Digital Signatures Asymmetric Authentication and non-repudiation Prove identity and message integrity

Cryptographic Algorithms

Symmetric Encryption Algorithms

IPsec supports various symmetric encryption algorithms for protecting data confidentiality.

AES (Advanced Encryption Standard)

AES-128
High Security

Key Size: 128 bits

Performance: Excellent

Security Level: 128-bit

Recommended: Yes

AES-192
High Security

Key Size: 192 bits

Performance: Good

Security Level: 192-bit

Recommended: Yes

AES-256
Highest Security

Key Size: 256 bits

Performance: Good

Security Level: 256-bit

Recommended: Yes

Legacy Algorithms

Deprecated Algorithms

These algorithms should be avoided in new deployments due to security vulnerabilities:

  • DES: 56-bit key, easily broken
  • 3DES: Triple DES, slow and limited security
  • RC4: Stream cipher with known weaknesses
  • Blowfish: 64-bit block size vulnerability

Encryption Modes

Mode Description Parallel Processing Error Propagation IPsec Usage
CBC Cipher Block Chaining Decryption only Single block Traditional ESP
CTR Counter Mode Full parallel None Modern ESP
GCM Galois/Counter Mode Full parallel None AEAD ESP

Hash Functions

Integrity Protection

Hash functions provide data integrity by creating a unique "fingerprint" of the message. Any change to the data will result in a completely different hash value.

Hash Function Properties

Required Properties

  • Deterministic: Same input always produces same output
  • Fixed Output: Always produces same-size hash
  • Fast Computation: Quick to calculate
  • Avalanche Effect: Small input change = big output change

Security Properties

  • Pre-image Resistant: Hard to find input for given hash
  • Second Pre-image Resistant: Hard to find different input with same hash
  • Collision Resistant: Hard to find two inputs with same hash

Common Hash Algorithms

SHA-256
Recommended

Output Size: 256 bits

Security Level: 128-bit

Performance: Good

Status: Secure

SHA-384
Recommended

Output Size: 384 bits

Security Level: 192-bit

Performance: Good

Status: Secure

SHA-512
Recommended

Output Size: 512 bits

Security Level: 256-bit

Performance: Good

Status: Secure

SHA-1
Deprecated

Output Size: 160 bits

Security Level: Broken

Performance: Fast

Status: Avoid

HMAC (Hash-based Message Authentication Code)

HMAC combines a hash function with a secret key to provide both integrity and authentication.

HMAC Construction

HMAC(K, m) = H((K ⊕ opad) || H((K ⊕ ipad) || m))

Where:
- K = secret key
- m = message
- H = hash function (e.g., SHA-256)
- opad = outer padding (0x5c repeated)
- ipad = inner padding (0x36 repeated)
- || = concatenation
- ⊕ = XOR operation

Digital Certificates

PKI Authentication

Digital certificates provide scalable authentication for IPsec by using Public Key Infrastructure (PKI) to verify identities without requiring pre-shared keys.

Certificate Components

Field Description Example
Subject Identity of certificate owner CN=vpn.company.com
Issuer Certificate Authority that signed cert CN=Company Root CA
Public Key Subject's public key RSA 2048-bit key
Validity Period Certificate lifetime Valid from/to dates
Digital Signature CA's signature over certificate RSA-SHA256 signature

Certificate Validation Process

1. Receive peer certificate
2. Check certificate validity period
3. Verify certificate chain to trusted CA
4. Check Certificate Revocation List (CRL)
5. Validate certificate signature
6. Accept or reject certificate

IPsec Certificate Authentication Benefits

Advantages

  • Scalability: No pre-shared keys needed
  • Security: Strong cryptographic authentication
  • Management: Centralized certificate authority
  • Revocation: Can revoke compromised certificates
  • Non-repudiation: Digital signatures provide proof

Considerations

  • Complexity: Requires PKI infrastructure
  • Management: Certificate lifecycle management
  • Overhead: Larger certificate exchanges
  • Dependencies: Relies on CA availability
  • Cost: CA services and management tools

Certificate-based IKE Configuration Example

# Cisco ASA Certificate Authentication
crypto ca trustpoint COMPANY-CA
 enrollment url http://ca.company.com/certsrv
 subject-name CN=ASA-VPN-Gateway,OU=IT,O=Company
 keypair-name VPN-KEYPAIR

crypto ikev2 policy 10
 encryption aes-256
 integrity sha256
 group 14
 prf sha256

crypto ikev2 profile CERT-PROFILE
 match identity remote any
 identity local dn
 authentication remote rsa-sig
 authentication local rsa-sig
 pki trustpoint COMPANY-CA