Skip to content

Split View: [컴퓨터 네트워크] 19. 네트워크 보안: 암호학부터 방화벽까지

|

[컴퓨터 네트워크] 19. 네트워크 보안: 암호학부터 방화벽까지

네트워크 보안: 암호학부터 방화벽까지

네트워크 보안은 인터넷을 통해 전송되는 데이터의 기밀성, 무결성, 인증, 가용성을 보장하는 기술입니다.

이 글에서는 암호학의 기본 개념(대칭키, 공개키), 메시지 무결성과 전자서명, 인증 프로토콜, SSL/TLS, IPsec, 방화벽, 그리고 침입 탐지 시스템(IDS)을 살펴봅니다.


1. 네트워크 보안의 4대 요소

네트워크 보안의 핵심 요소
===========================

1. 기밀성 (Confidentiality)
   - 의도된 수신자만 메시지를 읽을 수 있음
   - 구현: 암호화 (Encryption)

2. 무결성 (Integrity)
   - 메시지가 전송 중 변조되지 않았음을 보장
   - 구현: 해시, MAC, 전자서명

3. 인증 (Authentication)
   - 통신 상대방의 신원을 확인
   - 구현: 인증 프로토콜, 인증서

4. 가용성 (Availability)
   - 서비스가 정상적으로 이용 가능한 상태 유지
   - 위협: DDoS 공격

공격자의 위협:
  - 도청 (Eavesdropping): 기밀성 침해
  - 변조 (Modification): 무결성 침해
  - 위장 (Impersonation): 인증 침해
  - 서비스 거부 (DoS): 가용성 침해

2. 대칭키 암호 (Symmetric Key Cryptography)

2.1 기본 개념

송신자와 수신자가 동일한 비밀키를 공유하여 암호화와 복호화를 수행합니다.

대칭키 암호 동작
==================

      비밀키 K (양측이 공유)
         |                |
         v                v
[평문] --[암호화]--> [암호문] --[복호화]--> [평문]
 "Hello"   E_K()    "xYz!@"    D_K()    "Hello"

특징:
  - 암호화/복호화에 같은 키 사용
  - 빠른 연산 속도
  - 키 분배 문제: 양측이 안전하게 키를 공유해야 함

2.2 대표적인 대칭키 알고리즘

대칭키 알고리즘
=================

알고리즘  | 키 길이      | 블록 크기 | 상태
----------+-------------+----------+--------
DES       | 56비트      | 64비트   | 취약 (사용 금지)
3DES      | 168비트     | 64비트   | 안전하지만 느림
AES       | 128/192/256 | 128비트  | 현재 표준
RC4       | 가변        | 스트림   | 취약 (사용 금지)
ChaCha20  | 256비트     | 스트림   | 현대적, TLS 1.3

AES (Advanced Encryption Standard):
  - 2001년 NIST가 DES를 대체하여 선정
  - 블록 암호: 128비트 블록 단위로 처리
  - 라운드 수: 10/12/14 (키 길이에 따라)
  - 현재 가장 널리 사용되는 대칭키 암호

2.3 블록 암호 운용 모드

블록 암호 운용 모드
====================

1. ECB (Electronic Codebook): 각 블록 독립 암호화
   [B1] -> [E] -> [C1]
   [B2] -> [E] -> [C2]
   문제: 같은 평문 블록 -> 같은 암호문 블록 (패턴 노출)

2. CBC (Cipher Block Chaining): 이전 암호문과 XOR 후 암호화
   [B1 XOR IV] -> [E] -> [C1]
   [B2 XOR C1] -> [E] -> [C2]
   장점: 같은 평문이라도 다른 암호문 생성

3. CTR (Counter): 카운터를 암호화하여 평문과 XOR
   [CTR+0] -> [E] -> XOR [B1] -> [C1]
   [CTR+1] -> [E] -> XOR [B2] -> [C2]
   장점: 병렬 처리 가능, 스트림 암호처럼 동작

3. 공개키 암호 (Public Key Cryptography)

3.1 기본 개념

각 사용자가 공개키와 개인키 쌍을 가집니다. 공개키로 암호화하면 개인키로만 복호화할 수 있습니다.

공개키 암호 동작
==================

Bob의 키 쌍: (공개키 Kb+, 개인키 Kb-)
  - 공개키: 누구나 알 수 있음
  - 개인키: Bob만 알고 있음

Alice가 Bob에게 메시지 전송:
  [평문 m] --[Kb+로 암호화]--> [암호문] --[Kb-로 복호화]--> [평문 m]

특성:
  - Kb+(m)을 Kb-로만 복호화 가능
  - Kb-를 Kb+로부터 계산하는 것은 계산적으로 불가능
  - 키 분배 문제 해결 (공개키는 자유롭게 배포)
  - 대칭키보다 연산이 느림 (100~1000배)

3.2 RSA 알고리즘

RSA 동작 원리
===============

키 생성:
  1. 큰 소수 p, q 선택 (각 1024비트 이상)
  2. n = p x q 계산
  3. z = (p-1)(q-1) 계산
  4. z와 서로소인 e 선택 (공개키의 일부)
  5. e x d mod z = 1인 d 계산 (개인키의 일부)

공개키: (n, e)
개인키: (n, d)

암호화: c = m^e mod n
복호화: m = c^d mod n

보안 근거:
  - n으로부터 p, q를 찾는 것 = 대수 분해 문제
  - 현재 기술로 2048비트 이상의 n은 분해 불가

3.3 실제 사용: 하이브리드 암호

하이브리드 암호 시스템
========================

공개키 암호는 느리므로, 실제로는 세션키를 교환할 때만 사용

1. Alice가 랜덤 대칭키(세션키) Ks 생성
2. Alice가 Bob의 공개키로 Ks를 암호화하여 전송
   Kb+(Ks) --> Bob에게 전송
3. Bob이 개인키로 Ks 복호화
   Kb-(Kb+(Ks)) = Ks
4. 이후 양측이 Ks로 AES 대칭키 암호 사용

장점:
  - 공개키: 안전한 키 교환 (느리지만 한 번만)
  - 대칭키: 빠른 데이터 암호화 (대량 데이터)

4. 메시지 무결성

4.1 암호학적 해시 함수

해시 함수 특성
================

H(m) = 고정 길이의 해시값 (메시지 다이제스트)

요구사항:
  - 일방향성: H(m)에서 m을 역산 불가
  - 충돌 저항성: H(m) = H(m')인 서로 다른 m, m' 찾기 어려움
  - 쇄도 효과: 입력이 1비트 변해도 출력이 크게 변함

대표 알고리즘:
  MD5:    128비트 출력 (취약, 사용 금지)
  SHA-1:  160비트 출력 (취약, 사용 금지)
  SHA-256: 256비트 출력 (현재 표준)
  SHA-3:  가변 출력 (차세대 표준)

4.2 MAC (Message Authentication Code)

MAC 동작
=========

송신자 (Alice):                    수신자 (Bob):
  메시지 m                          수신: m + MAC
  비밀키 s                          비밀키 s
  MAC = H(m + s)                   MAC' = H(m + s)
  전송: m + MAC                    MAC == MAC'? --> 무결성 확인

HMAC (Hash-based MAC):
  HMAC = H(K XOR opad || H(K XOR ipad || m))

  - 단순히 H(m+s)보다 안전한 구조
  - TLS, IPsec 등에서 표준으로 사용

4.3 전자서명 (Digital Signature)

전자서명 동작
===============

서명 생성 (Alice):
  1. 메시지 m의 해시 계산: h = H(m)
  2. 개인키로 해시를 암호화: sig = Ka-(h)
  3. 전송: m + sig

서명 검증 (Bob):
  1. 메시지 m의 해시 계산: h = H(m)
  2. Alice의 공개키로 서명 복호화: h' = Ka+(sig)
  3. h == h'? --> 서명 유효

전자서명이 제공하는 것:
  - 인증: Alice가 서명했음을 확인
  - 무결성: 메시지가 변조되지 않았음
  - 부인 방지: Alice가 서명 사실을 부인할 수 없음

4.4 인증서와 CA

공개키 인증서 (PKI)
=====================

문제: Bob이 받은 공개키가 정말 Alice의 것인가?
해결: 신뢰할 수 있는 제3자(CA)가 보증

인증서 구조:
  +----------------------------------+
  | 발급 대상: alice.com              |
  | 공개키: Ka+                      |
  | 발급자: DigiCert (CA)            |
  | 유효 기간: 2026.01.01 ~ 2027.01.01 |
  | 서명: CA의 개인키로 서명됨        |
  +----------------------------------+

검증 과정:
  1. Bob이 alice.com의 인증서 수신
  2. CA의 공개키로 인증서의 서명 검증
  3. 유효하면 인증서 내의 Ka+를 신뢰

대표 CA: DigiCert, Let's Encrypt, GlobalSign

5. SSL/TLS

5.1 TLS의 역할

TLS(Transport Layer Security)는 TCP 위에서 동작하며, 웹 통신의 보안을 제공합니다. HTTPS = HTTP + TLS 입니다.

TLS의 위치
============

[HTTP, SMTP, FTP 등]
[TLS/SSL]
[TCP]
[IP]
[링크 계층]

TLS가 제공하는 보안:
  - 기밀성: 데이터 암호화 (AES 등)
  - 무결성: MAC으로 변조 검출
  - 인증: 서버 인증서로 신원 확인

5.2 TLS 핸드셰이크

TLS 1.2 핸드셰이크
====================

클라이언트                            서버
    |                                   |
    |--- ClientHello ------------------>|
    |    (지원 암호 목록, 랜덤값)        |
    |                                   |
    |<-- ServerHello -------------------|
    |    (선택된 암호, 랜덤값)           |
    |<-- Certificate -------------------|
    |    (서버 인증서)                   |
    |<-- ServerHelloDone ---------------|
    |                                   |
    |--- ClientKeyExchange ------------>|
    |    (프리마스터 시크릿, 서버 공개키로 암호화)|
    |--- ChangeCipherSpec ------------->|
    |--- Finished --------------------->|
    |                                   |
    |<-- ChangeCipherSpec --------------|
    |<-- Finished ----------------------|
    |                                   |
    |=== 암호화된 애플리케이션 데이터 ===|

TLS 1.3 개선사항:
  - 1-RTT 핸드셰이크 (TLS 1.2는 2-RTT)
  - 0-RTT 재연결 지원
  - 안전하지 않은 암호 제거
  - 더 강력한 키 교환 (ECDHE 필수)

6. IPsec과 VPN

6.1 IPsec의 역할

IPsec은 네트워크 계층에서 보안을 제공합니다. 모든 IP 트래픽을 보호할 수 있습니다.

IPsec 프로토콜
================

1. AH (Authentication Header)
   - 인증과 무결성 제공
   - 암호화 미제공
   - 잘 사용되지 않음

2. ESP (Encapsulating Security Payload)
   - 인증 + 무결성 + 암호화 모두 제공
   - 가장 많이 사용

동작 모드:
  전송 모드 (Transport Mode):
    원본: [IP 헤더][데이터]
    ESP:  [IP 헤더][ESP 헤더][데이터(암호화)][ESP 트레일러][ESP 인증]
    --> 호스트 간 직접 통신 시 사용

  터널 모드 (Tunnel Mode):
    원본: [IP 헤더][데이터]
    ESP:  [새 IP 헤더][ESP 헤더][원본 IP 헤더 + 데이터(암호화)][ESP 트레일러]
    --> VPN 게이트웨이 간 통신 시 사용

6.2 VPN (Virtual Private Network)

VPN 동작
=========

본사                                    지사
[내부 네트워크] -- [VPN GW] ===IPsec 터널=== [VPN GW] -- [내부 네트워크]
10.1.0.0/16                 인터넷          10.2.0.0/16

패킷 흐름:
  1. 10.1.0.5에서 10.2.0.10으로 패킷 전송
  2. 본사 VPN GW가 패킷을 IPsec ESP로 암호화
  3. 새 IP 헤더: 출발지=본사 GW, 목적지=지사 GW
  4. 인터넷을 통해 암호화된 패킷 전송
  5. 지사 VPN GW가 복호화하여 10.2.0.10으로 전달

IKE (Internet Key Exchange):
  - IPsec SA(Security Association) 설정을 위한 프로토콜
  - 양측 인증 및 키 교환 수행

7. 방화벽 (Firewall)

7.1 방화벽의 유형

방화벽 유형
=============

1. 패킷 필터링 (Packet Filtering)
   - IP 주소, 포트, 프로토콜 기반으로 필터링
   - 상태 비보존: 각 패킷을 독립적으로 판단
   - 빠르지만 정교한 제어 어려움

2. 상태 보존 패킷 필터링 (Stateful Packet Filtering)
   - TCP 연결 상태를 추적
   - 연결이 설정된 패킷만 허용
   - 더 정교한 보안

3. 애플리케이션 게이트웨이 (Application Gateway)
   - 애플리케이션 데이터를 검사
   - HTTP, FTP 등 프로토콜별 세밀한 제어
   - 프록시 서버로 동작

7.2 방화벽 규칙 예시

패킷 필터링 규칙 예시
========================

규칙  | 방향   | 출발지 IP    | 목적지 IP    | 프로토콜 | 포트  | 동작
------+--------+--------------+--------------+---------+------+------
  1   | 인바운드| *            | 10.1.0.0/16 | TCP     | 80   | 허용
  2   | 인바운드| *            | 10.1.0.0/16 | TCP     | 443  | 허용
  3   | 인바운드| *            | 10.1.0.5    | TCP     | 22   | 허용
  4   | 아웃바운드| 10.1.0.0/16| *           | TCP     | *    | 허용
  5   | *      | *            | *            | *       | *    | 거부

해석:
  규칙 1: 외부에서 내부 웹서버(80)로 HTTP 접속 허용
  규칙 2: 외부에서 내부 웹서버(443)로 HTTPS 접속 허용
  규칙 3: 외부에서 특정 서버로 SSH 접속 허용
  규칙 4: 내부에서 외부로 나가는 모든 TCP 허용
  규칙 5: 나머지 모두 거부 (기본 정책)

8. IDS와 IPS

8.1 침입 탐지 시스템 (IDS)

IDS 유형
==========

1. 시그니처 기반 IDS
   - 알려진 공격 패턴(시그니처)과 매칭
   - 장점: 알려진 공격에 대해 정확한 탐지
   - 단점: 새로운 공격(제로데이) 탐지 불가

2. 이상 탐지 기반 IDS
   - 정상 트래픽 패턴을 학습하고 이상 탐지
   - 장점: 새로운 공격도 탐지 가능
   - 단점: 오탐(false positive)이 높을 수 있음

배치 위치:
  인터넷 --> [방화벽] --> [IDS] --> [내부 네트워크]

IPS (Intrusion Prevention System):
  - IDS + 자동 차단 기능
  - 탐지된 공격을 실시간으로 차단

8.2 대표적인 네트워크 공격

네트워크 공격 유형
====================

1. IP 스푸핑 (Spoofing)
   - 출발지 IP 주소를 위조
   - 대응: 입구 필터링 (Ingress Filtering)

2. DoS/DDoS
   - 대량의 트래픽으로 서비스 마비
   - SYN Flood: TCP 3-way 핸드셰이크 악용
   - 대응: SYN 쿠키, 트래픽 필터링

3. 중간자 공격 (Man-in-the-Middle)
   - 통신 경로에 끼어들어 도청/변조
   - 대응: TLS, 인증서 검증

4. ARP 스푸핑
   - 가짜 ARP 응답으로 트래픽 가로채기
   - 대응: 정적 ARP 테이블, 802.1X

5. DNS 스푸핑
   - 가짜 DNS 응답으로 피싱 사이트 유도
   - 대응: DNSSEC

9. 정리

개념핵심 내용
대칭키 암호같은 키로 암호화/복호화, 빠름, 키 분배 문제
공개키 암호공개키로 암호화, 개인키로 복호화, 키 분배 해결
RSA소인수 분해의 어려움에 기반한 공개키 암호
해시 함수일방향, 고정 길이 출력, 무결성 검증
전자서명개인키로 서명, 공개키로 검증, 부인 방지
TLSTCP 위 보안 계층, HTTPS의 핵심
IPsec네트워크 계층 보안, VPN 구현 기반
방화벽패킷 필터링으로 비인가 접근 차단
IDS/IPS침입 탐지 및 자동 차단

다음 글에서는 네트워크 관리와 SNMP 프로토콜을 살펴보겠습니다.


참고 자료

  • James F. Kurose, Keith W. Ross, "Computer Networking: A Top-Down Approach", 6th Edition, Chapter 8
  • RFC 5246 - TLS Protocol Version 1.2
  • RFC 4301 - Security Architecture for the Internet Protocol (IPsec)
  • RFC 2104 - HMAC: Keyed-Hashing for Message Authentication

[Computer Networking] 19. Network Security: From Cryptography to Firewalls

Network Security: From Cryptography to Firewalls

Network security is the technology that ensures confidentiality, integrity, authentication, and availability of data transmitted over the Internet.

In this post, we examine the basic concepts of cryptography (symmetric key, public key), message integrity and digital signatures, authentication protocols, SSL/TLS, IPsec, firewalls, and Intrusion Detection Systems (IDS).


1. Four Pillars of Network Security

Core Elements of Network Security
=====================================

1. Confidentiality
   - Only intended recipients can read the message
   - Implementation: Encryption

2. Integrity
   - Ensures message was not altered in transit
   - Implementation: Hash, MAC, Digital Signatures

3. Authentication
   - Verifies the identity of communication partner
   - Implementation: Authentication protocols, Certificates

4. Availability
   - Maintains normal service operation
   - Threat: DDoS attacks

Attacker Threats:
  - Eavesdropping: Confidentiality breach
  - Modification: Integrity breach
  - Impersonation: Authentication breach
  - Denial of Service (DoS): Availability breach

2. Symmetric Key Cryptography

2.1 Basic Concept

Sender and receiver share the same secret key for both encryption and decryption.

Symmetric Key Encryption
===========================

      Secret Key K (shared by both)
         |                |
         v                v
[Plaintext] --[Encrypt]--> [Ciphertext] --[Decrypt]--> [Plaintext]
 "Hello"      E_K()       "xYz!@"        D_K()       "Hello"

Characteristics:
  - Same key used for encryption/decryption
  - Fast computation speed
  - Key distribution problem: both sides must securely share the key

2.2 Representative Symmetric Key Algorithms

Symmetric Key Algorithms
===========================

Algorithm | Key Length    | Block Size | Status
----------+--------------+-----------+--------
DES       | 56 bits      | 64 bits   | Weak (do not use)
3DES      | 168 bits     | 64 bits   | Secure but slow
AES       | 128/192/256  | 128 bits  | Current standard
RC4       | Variable     | Stream    | Weak (do not use)
ChaCha20  | 256 bits     | Stream    | Modern, TLS 1.3

AES (Advanced Encryption Standard):
  - Selected by NIST in 2001 to replace DES
  - Block cipher: Processes 128-bit blocks
  - Rounds: 10/12/14 (depending on key length)
  - Most widely used symmetric cipher today

2.3 Block Cipher Modes of Operation

Block Cipher Modes
====================

1. ECB (Electronic Codebook): Each block encrypted independently
   [B1] -> [E] -> [C1]
   [B2] -> [E] -> [C2]
   Problem: Same plaintext block -> same ciphertext block (pattern exposed)

2. CBC (Cipher Block Chaining): XOR with previous ciphertext then encrypt
   [B1 XOR IV] -> [E] -> [C1]
   [B2 XOR C1] -> [E] -> [C2]
   Advantage: Same plaintext produces different ciphertext

3. CTR (Counter): Encrypt counter and XOR with plaintext
   [CTR+0] -> [E] -> XOR [B1] -> [C1]
   [CTR+1] -> [E] -> XOR [B2] -> [C2]
   Advantage: Parallelizable, operates like stream cipher

3. Public Key Cryptography

3.1 Basic Concept

Each user has a public key and private key pair. Encrypting with the public key can only be decrypted with the private key.

Public Key Encryption
========================

Bob's Key Pair: (Public Key Kb+, Private Key Kb-)
  - Public key: Known by anyone
  - Private key: Known only by Bob

Alice sends message to Bob:
  [Plaintext m] --[Encrypt with Kb+]--> [Ciphertext] --[Decrypt with Kb-]--> [Plaintext m]

Properties:
  - Kb+(m) can only be decrypted with Kb-
  - Computing Kb- from Kb+ is computationally infeasible
  - Solves key distribution problem (public key freely distributed)
  - Slower than symmetric key (100~1000x)

3.2 RSA Algorithm

RSA Operating Principle
=========================

Key Generation:
  1. Choose large primes p, q (each 1024+ bits)
  2. Compute n = p x q
  3. Compute z = (p-1)(q-1)
  4. Choose e coprime to z (part of public key)
  5. Compute d where e x d mod z = 1 (part of private key)

Public Key: (n, e)
Private Key: (n, d)

Encryption: c = m^e mod n
Decryption: m = c^d mod n

Security Basis:
  - Finding p, q from n = integer factorization problem
  - Currently infeasible to factor n of 2048+ bits

3.3 Practical Use: Hybrid Cryptography

Hybrid Cryptosystem
======================

Public key crypto is slow, so in practice only used for session key exchange

1. Alice generates random symmetric key (session key) Ks
2. Alice encrypts Ks with Bob's public key and sends
   Kb+(Ks) --> Send to Bob
3. Bob decrypts Ks with private key
   Kb-(Kb+(Ks)) = Ks
4. Both sides then use Ks for AES symmetric encryption

Advantages:
  - Public key: Secure key exchange (slow but only once)
  - Symmetric key: Fast data encryption (bulk data)

4. Message Integrity

4.1 Cryptographic Hash Functions

Hash Function Properties
===========================

H(m) = Fixed-length hash value (message digest)

Requirements:
  - One-way: Cannot reverse H(m) to find m
  - Collision resistance: Hard to find different m, m' where H(m) = H(m')
  - Avalanche effect: 1-bit change in input produces drastically different output

Representative Algorithms:
  MD5:     128-bit output (weak, do not use)
  SHA-1:   160-bit output (weak, do not use)
  SHA-256: 256-bit output (current standard)
  SHA-3:   Variable output (next-generation standard)

4.2 MAC (Message Authentication Code)

MAC Operation
===============

Sender (Alice):                    Receiver (Bob):
  Message m                         Received: m + MAC
  Secret key s                      Secret key s
  MAC = H(m + s)                   MAC' = H(m + s)
  Send: m + MAC                    MAC == MAC'? --> Integrity verified

HMAC (Hash-based MAC):
  HMAC = H(K XOR opad || H(K XOR ipad || m))

  - More secure structure than simple H(m+s)
  - Standard in TLS, IPsec, etc.

4.3 Digital Signatures

Digital Signature Operation
==============================

Signature Generation (Alice):
  1. Compute hash of message m: h = H(m)
  2. Encrypt hash with private key: sig = Ka-(h)
  3. Send: m + sig

Signature Verification (Bob):
  1. Compute hash of message m: h = H(m)
  2. Decrypt signature with Alice's public key: h' = Ka+(sig)
  3. h == h'? --> Signature valid

What Digital Signatures Provide:
  - Authentication: Confirms Alice signed it
  - Integrity: Message was not altered
  - Non-repudiation: Alice cannot deny signing

4.4 Certificates and CAs

Public Key Certificates (PKI)
================================

Problem: Is the public key Bob received really Alice's?
Solution: Trusted third party (CA) vouches for it

Certificate Structure:
  +----------------------------------+
  | Subject: alice.com               |
  | Public Key: Ka+                  |
  | Issuer: DigiCert (CA)           |
  | Valid: 2026.01.01 ~ 2027.01.01  |
  | Signature: Signed by CA's        |
  |            private key           |
  +----------------------------------+

Verification Process:
  1. Bob receives alice.com's certificate
  2. Verifies certificate signature with CA's public key
  3. If valid, trusts Ka+ in the certificate

Major CAs: DigiCert, Let's Encrypt, GlobalSign

5. SSL/TLS

5.1 Role of TLS

TLS (Transport Layer Security) operates on top of TCP, providing security for web communications. HTTPS = HTTP + TLS.

TLS Position
===============

[HTTP, SMTP, FTP, etc.]
[TLS/SSL]
[TCP]
[IP]
[Link Layer]

Security TLS Provides:
  - Confidentiality: Data encryption (AES, etc.)
  - Integrity: Tamper detection via MAC
  - Authentication: Server identity via certificates

5.2 TLS Handshake

TLS 1.2 Handshake
====================

Client                              Server
    |                                   |
    |--- ClientHello ------------------>|
    |    (Supported ciphers, random)    |
    |                                   |
    |<-- ServerHello -------------------|
    |    (Selected cipher, random)      |
    |<-- Certificate -------------------|
    |    (Server certificate)           |
    |<-- ServerHelloDone ---------------|
    |                                   |
    |--- ClientKeyExchange ------------>|
    |    (Pre-master secret, encrypted  |
    |     with server public key)       |
    |--- ChangeCipherSpec ------------->|
    |--- Finished --------------------->|
    |                                   |
    |<-- ChangeCipherSpec --------------|
    |<-- Finished ----------------------|
    |                                   |
    |=== Encrypted Application Data ====|

TLS 1.3 Improvements:
  - 1-RTT handshake (TLS 1.2 is 2-RTT)
  - 0-RTT reconnection support
  - Removed insecure ciphers
  - Stronger key exchange (ECDHE mandatory)

6. IPsec and VPN

6.1 Role of IPsec

IPsec provides security at the network layer. It can protect all IP traffic.

IPsec Protocols
==================

1. AH (Authentication Header)
   - Provides authentication and integrity
   - No encryption
   - Rarely used

2. ESP (Encapsulating Security Payload)
   - Provides authentication + integrity + encryption
   - Most widely used

Modes:
  Transport Mode:
    Original: [IP Header][Data]
    ESP:      [IP Header][ESP Header][Data(encrypted)][ESP Trailer][ESP Auth]
    --> Used for direct host-to-host communication

  Tunnel Mode:
    Original: [IP Header][Data]
    ESP:      [New IP Header][ESP Header][Original IP Header + Data(encrypted)][ESP Trailer]
    --> Used for VPN gateway-to-gateway communication

6.2 VPN (Virtual Private Network)

VPN Operation
===============

HQ                                    Branch
[Internal Net] -- [VPN GW] ===IPsec Tunnel=== [VPN GW] -- [Internal Net]
10.1.0.0/16                 Internet          10.2.0.0/16

Packet Flow:
  1. 10.1.0.5 sends packet to 10.2.0.10
  2. HQ VPN GW encrypts packet with IPsec ESP
  3. New IP Header: src=HQ GW, dst=Branch GW
  4. Encrypted packet sent across Internet
  5. Branch VPN GW decrypts and delivers to 10.2.0.10

IKE (Internet Key Exchange):
  - Protocol for establishing IPsec SA (Security Association)
  - Performs mutual authentication and key exchange

7. Firewalls

7.1 Types of Firewalls

Firewall Types
================

1. Packet Filtering
   - Filters based on IP address, port, protocol
   - Stateless: Each packet judged independently
   - Fast but limited sophisticated control

2. Stateful Packet Filtering
   - Tracks TCP connection state
   - Allows only packets from established connections
   - More sophisticated security

3. Application Gateway
   - Inspects application data
   - Fine-grained control per protocol (HTTP, FTP)
   - Operates as proxy server

7.2 Firewall Rule Example

Packet Filtering Rule Example
================================

Rule | Direction | Src IP        | Dst IP        | Protocol| Port | Action
-----+-----------+---------------+---------------+---------+------+-------
  1  | Inbound   | *             | 10.1.0.0/16   | TCP     | 80   | Allow
  2  | Inbound   | *             | 10.1.0.0/16   | TCP     | 443  | Allow
  3  | Inbound   | *             | 10.1.0.5      | TCP     | 22   | Allow
  4  | Outbound  | 10.1.0.0/16  | *              | TCP     | *    | Allow
  5  | *         | *             | *              | *       | *    | Deny

Interpretation:
  Rule 1: Allow external HTTP access to internal web server (80)
  Rule 2: Allow external HTTPS access to internal web server (443)
  Rule 3: Allow external SSH access to specific server
  Rule 4: Allow all outbound TCP from internal network
  Rule 5: Deny everything else (default policy)

8. IDS and IPS

8.1 Intrusion Detection System (IDS)

IDS Types
===========

1. Signature-based IDS
   - Matches against known attack patterns (signatures)
   - Advantage: Accurate detection of known attacks
   - Disadvantage: Cannot detect new attacks (zero-day)

2. Anomaly-based IDS
   - Learns normal traffic patterns and detects anomalies
   - Advantage: Can detect novel attacks
   - Disadvantage: May have high false positives

Deployment:
  Internet --> [Firewall] --> [IDS] --> [Internal Network]

IPS (Intrusion Prevention System):
  - IDS + automatic blocking capability
  - Blocks detected attacks in real-time

8.2 Representative Network Attacks

Network Attack Types
======================

1. IP Spoofing
   - Forges source IP address
   - Defense: Ingress Filtering

2. DoS/DDoS
   - Overwhelms service with massive traffic
   - SYN Flood: Exploits TCP 3-way handshake
   - Defense: SYN cookies, traffic filtering

3. Man-in-the-Middle
   - Intercepts communication path for eavesdropping/modification
   - Defense: TLS, certificate verification

4. ARP Spoofing
   - Fake ARP responses to intercept traffic
   - Defense: Static ARP tables, 802.1X

5. DNS Spoofing
   - Fake DNS responses redirect to phishing sites
   - Defense: DNSSEC

9. Summary

ConceptKey Points
Symmetric KeySame key for encrypt/decrypt, fast, key distribution issue
Public KeyEncrypt with public key, decrypt with private key, solves distribution
RSABased on difficulty of integer factorization
Hash FunctionOne-way, fixed-length output, integrity verification
Digital SignatureSign with private key, verify with public key, non-repudiation
TLSSecurity layer above TCP, core of HTTPS
IPsecNetwork layer security, basis for VPN
FirewallBlocks unauthorized access via packet filtering
IDS/IPSIntrusion detection and automatic blocking

In the next post, we will examine network management and the SNMP protocol.


References

  • James F. Kurose, Keith W. Ross, "Computer Networking: A Top-Down Approach", 6th Edition, Chapter 8
  • RFC 5246 - TLS Protocol Version 1.2
  • RFC 4301 - Security Architecture for the Internet Protocol (IPsec)
  • RFC 2104 - HMAC: Keyed-Hashing for Message Authentication