Skip to content
CY-503 (C) · Data Security/Quick Revision Short Notes

Data Security (CY-503 (C)) - Unit 2 Short Notes

UNIT 2: Data Security - Comprehensive Short Notes


I. CRYPTOGRAPHIC FOUNDATIONS

A. Core Encryption Principles

Symmetric vs. Asymmetric Cryptography

Feature Symmetric Cryptography Asymmetric Cryptography
Key Usage Same key for encryption & decryption Public key for encryption, private key for decryption
Speed Fast (hardware efficient) Slow (computationally intensive)
Key Distribution Major challenge (secure channel needed) Easy (public key can be shared openly)
Examples AES, DES, RC4 RSA, ECC, Diffie-Hellman
Primary Use Bulk data encryption Key exchange, digital signatures

[!TIP] Exam Focus: Symmetric is fast but key distribution is hard. Asymmetric solves distribution but is slow. Often used together (e.g., TLS uses asymmetric to exchange a symmetric session key).

Block Ciphers vs. Stream Ciphers

Feature Block Ciphers Stream Ciphers
Unit Size Fixed-size blocks (e.g., 128 bits) Continuous stream of bits/bytes
Operation Encrypts entire block at once Encrypts one bit/byte at a time
Error Propagation One block error can corrupt entire block Error affects only corresponding plaintext bit
Examples AES, DES, 3DES RC4, ChaCha20
Use Case File/disk encryption, databases Real-time communication (TLS, WEP/WPA)

Cipher Block Modes of Operation

Used to encrypt data larger than block size, prevent pattern leakage.

Mode How it Works Merits Demerits
ECB<br>(Electronic Codebook) Each block encrypted independently Simple, parallelizable Identical plaintext blocks → identical ciphertext (pattern leakage)
CBC<br>(Cipher Block Chaining) XOR current plaintext block with previous ciphertext block Hides patterns, widely used Sequential (not parallel), requires IV, error propagation
CFB<br>(Cipher Feedback) Turns block cipher into stream cipher; XOR feedback from ciphertext No padding needed, can handle partial blocks Sequential, error propagation
OFB<br>(Output Feedback) Generates keystream independent of plaintext/ciphertext; XOR with plaintext No error propagation, can precompute keystream If keystream repeats → catastrophic failure
CTR<br>(Counter) Encrypts counter value, XOR with plaintext; counter increments Parallelizable, random access, no padding Requires unique counter for each block (nonce reuse = disaster)

[!TIP] Common Pitfall: Never reuse a nonce/counter in CTR mode. It completely breaks confidentiality.


B. Symmetric Key Algorithms

Advanced Encryption Standard (AES)

  • Block Size: 128 bits

  • Key Sizes: 128, 192, 256 bits → 10, 12, 14 rounds respectively

  • Structure: Substitution-Permutation Network (SPN)

  • Round Operations (per round except last):

    1. SubBytes (non-linear substitution via S-box)

    2. ShiftRows (permutation: shift rows cyclically)

    3. MixColumns (mixing columns via matrix multiplication)

    4. AddRoundKey (XOR with round key)

  • Final Round: No MixColumns.

  • Key Expansion: Round keys derived from initial key via Rijndael's key schedule.

Example (Conceptual):

Plaintext block = 00112233445566778899aabbccddeeff (128-bit)

Key = 000102030405060708090a0b0c0d0e0f (128-bit)

After 10 rounds of transformations → ciphertext.

RC4 Stream Cipher

  • Type: Variable key-size stream cipher (8-bit operations).

  • Components:

    • KSA (Key Scheduling Algorithm): Initialize S-box (256 bytes) using key.

    • PRGA (Pseudo-Random Generation Algorithm): Generate keystream bytes from S-box.

  • KSA Steps:

    1. Initialize S: S[i] = i for i=0..255.

    2. j = 0

    3. For i = 0 to 255:

      • j = (j + S[i] + key[i mod keylen]) mod 256

      • Swap S[i] and S[j]

  • PRGA Steps:

    1. i = (i + 1) mod 256

    2. j = (j + S[i]) mod 256

    3. Swap S[i] and S[j]

    4. t = (S[i] + S[j]) mod 256

    5. Keystream byte = S[t]

  • Encryption: Ciphertext[i] = Plaintext[i] XOR Keystream[i]

[!TIP] RC4 5-bit Key Example:

Key = [1, 2, 3, 4, 5] (5 bytes, but RC4 uses 8-bit bytes; for 5-bit, we'd mask to 5 bits).

Simplified 5-bit variant (illustrative):

  • S-box size = 32 (2^5).
  • KSA: S = [0..31], j=0. For i=0..31: j = (j + S[i] + key[i mod 5]) mod 32, swap.
  • PRGA: similar with mod 32.

Generate first 3 keystream bytes after KSA.

In exam, show KSA table swaps and first 3 PRGA iterations.


C. Asymmetric Key Algorithms

RSA Algorithm (Rivest–Shamir–Adleman)

  • Mathematical Foundation: Difficulty of factoring large integers.

  • Key Generation:

    1. Choose large primes p, q.

    2. Compute n = p * q.

    3. Compute φ(n) = (p-1)(q-1).

    4. Choose e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1.

    5. Compute d such that d * e ≡ 1 mod φ(n) (using Extended Euclidean Algorithm).

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

  • Encryption: C = M^e mod n

  • Decryption: M = C^d mod n

Worked Example (p=3, q=11):

  1. n = 3 * 11 = 33
  1. φ(n) = (3-1)(11-1) = 2*10 = 20
  1. Choose e=7 (gcd(7,20)=1)
  1. Compute d: 7d ≡ 1 mod 20 → d=3 (since 7*3=21 ≡1 mod20)
  1. Public Key: (7, 33), Private Key: (3, 33)
  1. Encrypt M=2: C = 2^7 mod 33 = 128 mod 33 = 29
  1. Decrypt C=29: M = 29^3 mod 33 = 24389 mod 33 = 2 ✓

Public Key Cryptography Principles

  • One-way Function: Easy to compute f(x), hard to invert f⁻¹(y).

  • Trapdoor Function: One-way function with secret "trapdoor" (private key) allowing easy inversion.

  • Key Distribution: Public keys can be shared openly via certificates (PKI) or web of trust (PGP).


D. Classical Ciphers (Application-Based)

Caesar Cipher

  • Type: Substitution cipher.

  • Encryption: C = (P + k) mod 26, where P = plaintext letter index (A=0), k = shift.

  • Decryption: P = (C - k) mod 26

  • Example Decryption:

    Ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ

    Shift k = 17

    Decrypt each letter:

    Z (25) → (25 - 17) mod 26 = 8 → I

    I (8) → (8 - 17) mod 26 = 17 → R

    ... continue for all letters.

    Result: I HOPE YOU ARE WELL AND GOOD HEALTH (with spaces inserted).

[!TIP] Exam Step: Always convert letters to 0-25 indices, apply formula, convert back. Show at least 3-4 letter conversions.


II. AUTHENTICATION & INTEGRITY

A. Hash Functions & Message Digests

Cryptographic Hash Functions Properties

  1. Pre-image Resistance: Given hash h, hard to find any m such that hash(m)=h.

  2. Second Pre-image Resistance: Given m1, hard to find m2≠m1 with same hash.

  3. Collision Resistance: Hard to find any two distinct messages m1, m2 with hash(m1)=hash(m2).

  4. Deterministic: Same input → same output.

  5. Fixed Output Size: e.g., SHA-512 → 512-bit digest.

  6. Avalanche Effect: Small change in input → large change in output.

SHA-512 Algorithm Steps

  1. Preprocessing:

    • Append 1 bit, then 0 bits, then 128-bit message length (in bits).

    • Result length ≡ 1024 mod 1024 (multiple of 1024-bit block).

  2. Parsing: Break message into 1024-bit blocks M¹, M², ....

  3. Initialize Hash Values (H⁰): Eight 64-bit constants from square roots of first 8 primes.

  4. For each block:

    • Prepare 80-word message schedule W[0..79] from block.

    • Initialize working variables a..h with current hash value.

    • For t=0..79:

      
      T1 = h + Σ1(e) + Ch(e,f,g) + K[t] + W[t]
      
      T2 = Σ0(a) + Maj(a,b,c)
      
      h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2
      
      
    • Update hash: H[i] = H[i-1] + variable[i] for i=0..7.

  5. Output: Concatenate final H⁷ as 512-bit digest.

[!TIP] SHA-512 Order for Same Digest: Finding collisions is computationally infeasible (birthday attack requires ~2²⁵⁶ operations). Pre-image attack requires ~2⁵¹² operations.


B. Message Authentication Codes (MACs)

MAC Definition: A short tag generated from a message and a secret key, providing integrity and authentication.

HMAC (Hash-based MAC) Construction

  • Uses a cryptographic hash function H (e.g., SHA-256).

  • Formula:

    HMAC(K, m) = H( (K⁺ ⊕ opad) ∥ H( (K⁺ ⊕ ipad) ∥ m ) )

    where:

    • K⁺ = key padded/truncated to hash block size.

    • ipad = 0x36 repeated, opad = 0x5C repeated.

    • ∥ = concatenation.

  • Steps:

    1. Pad key to block size B (e.g., 64 bytes for SHA-256).

    2. Compute inner hash: inner = H( (K⁺ ⊕ ipad) ∥ m ).

    3. Compute outer hash: HMAC = H( (K⁺ ⊕ opad) ∥ inner ).

Comparison Table

Feature Plain Hash MAC Digital Signature
Key Used No Yes (symmetric) Yes (asymmetric)
Provides Integrity only Integrity + Authentication Integrity + Authentication + Non-repudiation
Verification Anyone can compute Requires shared secret Anyone with public key can verify
Example SHA-256 HMAC-SHA256 RSA-PSS, ECDSA

C. Digital Signatures

Mechanism using Public-Key Cryptography

  1. Signing:

    • Sender computes hash of message: h = hash(m).

    • Encrypt hash with private key: sig = h^d mod n (RSA) or generate signature via ECDSA algorithm.

  2. Verification:

    • Receiver decrypts signature with public key: h' = sig^e mod n.

    • Compute hash of received message: h = hash(m).

    • If h' == h, signature valid.

Importance in Secure Communication

  • Authentication: Confirms sender identity.

  • Integrity: Any change in message invalidates signature.

  • Non-repudiation: Sender cannot deny sending (only they possess private key).

  • Used in code signing, contracts, SSL/TLS certificates.

Digital Signature Standards (DSS)

  • NIST standard: DSA (Digital Signature Algorithm) based on discrete logarithm problem.

  • Later standards: RSA-PSS, ECDSA (Elliptic Curve DSA).


III. KEY MANAGEMENT & PROTOCOLS

A. PGP (Pretty Good Privacy)

Architecture & Services

  • Confidentiality: Hybrid encryption (session key encrypted with recipient's public key).

  • Authentication: Digital signatures using sender's private key.

  • Compression: Applied before encryption (ZIP).

  • Email Integration: Works with MIME.

PGP Message Format


[Signature] (optional)

[Session Key] (encrypted with recipient's public key)

[Encrypted Data] (compressed message encrypted with session key)

DiagramCANVAS: PGP message block structure showing signature, encrypted session key, and encrypted data sections

Operations Workflow

  1. Sending:

    • Generate random session key.

    • Compress message.

    • Encrypt compressed message with session key (symmetric, e.g., AES or IDEA).

    • Encrypt session key with recipient's public key.

    • Optionally sign message hash with sender's private key.

    • Combine into PGP message.

  2. Receiving:

    • Decrypt session key with own private key.

    • Decrypt message with session key.

    • Decompress.

    • Verify signature if present using sender's public key.


B. SSL/TLS Protocol Suite

SSL Record Protocol Services

  • Confidentiality: Symmetric encryption (AES, 3DES).

  • Integrity: MAC (HMAC) or AEAD.

  • Authentication: Optional via certificates (X.509).

SSL Handshake Protocol (Step-by-Step)

  1. Client Hello: Client sends supported cipher suites, TLS version, random R_C.

  2. Server Hello: Server chooses cipher suite, sends TLS version, random R_S, certificate.

  3. Key Exchange:

    • If RSA: Client generates premaster secret, encrypts with server's public key, sends.

    • If Diffie-Hellman: Server sends DH parameters, signed.

  4. Finished:

    • Both compute master secret from premaster + R_C + R_S.

    • Derive session keys (client/server write keys, MAC keys).

    • Exchange Finished messages encrypted with session keys.

SSL Connection vs. SSL Session

SSL Session SSL Connection
Definition Negotiated security parameters (keys, cipher suite) Actual data transfer association
Lifetime Longer (can be reused) Shorter (per connection)
Components Session ID, peer cert, cipher spec, master secret Read/Write keys, sequence numbers
Reuse Yes (session resumption) No (new connection)
Role in Web Reduces handshake cost for repeated visits Each HTTP request/response may use new connection

[!TIP] Exam Distinction: Session = negotiated state (can be reused). Connection = active data flow (uses session keys).


C. IPSec (IP Security)

Goals & Services

  • Confidentiality: ESP encryption.

  • Data Integrity: AH/ESP authentication.

  • Authentication: AH/ESP.

  • Anti-replay: Sequence numbers + sliding window.

Security Associations (SA)

  • Definition: Unidirectional logical connection providing security services.

  • Parameters: SPI (Security Parameter Index), IP destination address, security protocol (AH/ESP), mode, keys.

  • Management: Manual or via IKE (Internet Key Exchange).

Authentication Header (AH)

  • Provides integrity and authentication (no encryption).

  • Transport Mode: AH protects IP payload (and selected header fields) but not IP header. Used end-to-end.

  • Tunnel Mode: AH protects entire original IP packet + new IP header. Used for gateways.

Encapsulating Security Payload (ESP)

  • Provides confidentiality, integrity, authentication.

  • Transport Mode: ESP trailer encrypts payload, authenticates payload + ESP header (but not outer IP header).

  • Tunnel Mode: Entire original IP packet encrypted and authenticated, encapsulated in new IP packet.

DiagramCANVAS: IPSec transport vs tunnel mode showing original packet, ESP/AH trailer, new IP header

D. SET (Secure Electronic Transaction)

Protocol Goals

  • Confidentiality: Payment info encrypted (only bank sees).

  • Integrity: All messages authenticated.

  • Cardholder Authentication: Via digital signature.

  • Merchant Authentication: Via certificate.

  • No merchant sees card number (critical for trust).

Participants & Roles

Participant Role
Cardholder Customer with credit card
Merchant Seller
Issuer Bank that issued card
Acquirer Merchant's bank
Payment Gateway Processes payments for merchant
Certification Authority (CA) Issues digital certificates

SET Transaction Flow with Dual Signature

  1. Cardholder obtains certificates (from CA, Issuer).

  2. Order Info (OI) + Payment Info (PI) created.

  3. Dual Signature: Sig = Sign(Priv_C, hash(OI) ∥ hash(PI)). Links OI and PI without revealing each to other parties.

  4. Cardholder sends:

    • OI (encrypted with merchant's public key)

    • PI (encrypted with payment gateway's public key)

    • Dual signature (both can verify)

  5. Merchant sees OI, verifies dual signature, forwards PI to gateway.

  6. Gateway decrypts PI, verifies dual signature, processes payment.

DiagramCANVAS: SET transaction showing dual signature linking OI and PI, separate encryption paths

IV. NETWORK SECURITY INFRASTRUCTURE

A. Firewalls

Classification & Types

Type Operation Example Advantages Disadvantages
Packet Filtering Examines packet headers (IP, port) against rule set. Stateless. iptables Fast, transparent No payload inspection, spoofable
Circuit-Level Gateway Monitors TCP handshake; creates virtual circuit. SOCKS proxy Hides internal IP, stateful for sessions No payload inspection
Application-Level Gateway (Proxy) Intercepts & inspects application-layer data. Acts as intermediary. HTTP proxy, FTP proxy Deep inspection, authentication Slow, per-application
Stateful Inspection Tracks connection state (TCP flags, sequence). Combines packet filtering with state table. Modern firewalls Better security than stateless Resource-intensive
Personal Firewall Host-based, controls apps' network access. Windows Defender Firewall Protects single host Not for network perimeter

Firewall Merits & Demerits

  • Merits: First line of defense, access control, logging, network segmentation.

  • Demerits: Cannot stop internal threats, encrypted traffic bypass, misconfiguration risks, single point of failure.

Firewall vs. Trusted Operating System

Aspect Firewall Trusted OS
Security Model Network perimeter (external threats) Mandatory Access Control (internal subjects/objects)
Enforcement Packet filtering, proxies Security kernel, reference monitor
Focus Traffic filtering Information flow control
Example iptables, Cisco ASA SELinux, Trusted Solaris

B. Intrusion Detection Systems (IDS)

Intrusion Definition: Unauthorized access or misuse of system/resources.

Network-Based IDS (NIDS) Architecture

DiagramSEARCH: network-based IDS architecture diagram showing sensors, management server, database
  • Sensors: Capture packets (promiscuous mode).

  • Management Server: Analyzes data, generates alerts.

  • Database: Stores events, signatures.

  • Operation: Sensors → Management → Alert/Log.

Host-Based IDS (HIDS)

  • Installed on individual hosts.

  • Monitors system logs, file integrity (Tripwire), process behavior.

  • Example: OSSEC, Wazuh.

IDS vs. Firewalls

Feature Firewall IDS
Action Prevent (block traffic) Detect & alert (passive)
Placement Network perimeter Network or host
Focus Known bad (blacklist) Anomaly/signature detection
Response Active (drop packets) Passive (log, alarm)

Parameter Pattern Matching

  • Detection technique: Compare packet headers/payloads against signature database.

  • Example: Snort rules matching specific byte patterns.

  • Limitation: Only detects known attacks; evadable via polymorphism.


C. Malware Defense

Types of Malicious Software

Type Behavior Propagation
Virus Attaches to executable, requires user action Human-mediated
Worm Self-replicating, exploits vulnerabilities Network-based
Trojan Disguised as legitimate software Social engineering
Ransomware Encrypts files, demands ransom Phishing, exploits
Spyware stealthy monitoring Bundled software
Rootkit Hides presence, deep system access Exploits, social engineering
Bot Turns host into zombie (botnet) Worm/virus

Role of IDS and Firewalls

  • Firewalls: Block malicious traffic (ports, IPs), prevent worm propagation.

  • IDS: Detect malware communication (C&C traffic), file integrity changes (HIDS), anomaly patterns.

  • Combined: Firewall blocks known bad; IDS alerts on suspicious activity that bypasses firewall.


V. WIRELESS & MOBILE SECURITY

A. Wireless LAN (WLAN) Security

Security Challenges

  • Open medium → eavesdropping easy.

  • Rogue access points.

  • Weak default configurations.

  • Jamming/DoS.

  • Client misassociation.

WLAN Protocol Stack & MPDU Format

DiagramSEARCH: 802.11 MAC frame structure MPDU showing frame control, duration, addresses, sequence control, payload, FCS
  • MPDU (MAC Protocol Data Unit):

    • Frame Control (type, subtype, flags)

    • Duration

    • Addresses (up to 4)

    • Sequence Control

    • Payload (LLC data)

    • FCS (CRC)

Access Point Security in Public Networks

  • Risks: Evil twin attacks, eavesdropping, captive portal bypass.

  • Mitigations:

    • WPA2-Enterprise: 802.1X with EAP (e.g., PEAP, EAP-TLS). Individual user auth.

    • Captive Portals: Web-based auth, but traffic not encrypted (use HTTPS).

    • Client Isolation: Prevent inter-client communication.

    • Rogue AP Detection: Wireless IDS/IPS.


B. Wireless Application Protocol (WAP) Security

WAP Architecture

DiagramSEARCH: WAP architecture diagram showing mobile device, WAP gateway, web server
  • Client: WAP-enabled phone.

  • WAP Gateway: Protocol conversion (WSP/WTLS → HTTP/SSL), content adaptation.

  • Web Server: Origin server.

WTLS (Wireless Transport Layer Security)

  • Analogy to SSL/TLS but optimized for wireless:

    • Smaller packet sizes (avoid fragmentation).

    • Faster handshake (optional client cert).

    • Supports datagram (UDP-like) via record layer.

  • Role: Provides confidentiality, integrity, authentication between mobile device and gateway.

  • Limitations:

    • Weak cryptography (early versions allowed export-grade RSA).

    • Gateway terminates WTLS → gap in end-to-end security (gateway sees plaintext).

    • Short certificates (for small devices).

Security Issues in WTLS

  • End-to-End Gap: Gateway decrypts, may re-encrypt with SSL → server sees gateway as client.

  • Weak Ciphers: Early WTLS allowed 40-bit RC2.

  • Certificate Handling: Limited storage on devices → often gateway stores certs.

  • Version Vulnerabilities: WTLS 1.0 had flaws (like SSL 2.0).


VI. APPLICATION & ADVANCED TOPICS

A. Virtual Private Networks (VPN)

Definition & Core Concept

  • VPN: Extends private network across public infrastructure via tunneling and encryption.

  • Tunneling: Encapsulating packets within other packets.

  • Encryption: Confidentiality (IPsec, SSL).

Types of VPNs

Type Use Case Typical Technology
Remote Access VPN Individual user to corporate network SSL VPN, PPTP, L2TP/IPsec
Site-to-Site VPN Connect two networks (e.g., branch offices) IPsec (tunnel mode), GRE over IPsec

VPN Technologies

  • PPTP: Point-to-Point Tunneling Protocol. Weak encryption (MPPE), vulnerable.

  • L2TP/IPsec: L2TP for tunneling, IPsec for encryption/authentication. More secure than PPTP.

  • SSL VPN: Uses HTTPS (TCP 443). No client software (browser-based). Granular access control.


B. Biometric & Smart Card Authentication

Biometric Authentication

  • Methods: Fingerprint, iris, face, voice, vein.

  • Process:

    1. Enrollment: Capture biometric, extract features → template (stored).

    2. Verification/Identification: Capture live sample, compare to template via matching algorithm.

  • Advantages: Hard to forget/lose, non-transferable.

  • Challenges: False accepts/rejects, template theft, privacy concerns, cost.

Smart Cards

  • Physical: Plastic card with embedded chip (contact or contactless).

  • Logical Security: Stores certificates, private keys (often in secure element).

  • Authentication Mechanism:

    • Something you have (card) + something you know (PIN) → two-factor.

    • Card performs cryptographic operations (private key never leaves card).

  • Types: Memory cards, microprocessor cards (e.g., EMV, government ID).


C. Web Traffic Security Approaches

Approach Layer How it Works Typical Use
SSL/TLS Application (HTTPS) End-to-end encryption between client & server Web browsing, email (IMAPS)
IPsec Network Encrypts entire IP packet (transport/tunnel mode) Site-to-site VPN, remote access
Application-Layer Gateway Application Proxy inspects & filters application data (e.g., HTTP proxy) Content filtering, authentication

Contextual Application:

  • SSL/TLS: When you need end-to-end security between client and server (e.g., online banking).

  • IPsec: When securing network-to-network traffic (e.g., connecting branch offices) or all traffic from a remote user.

  • Application Gateway: When you need deep inspection (e.g., blocking malicious web content, enforcing authentication).

[!TIP] Exam Comparison: SSL/TLS secures specific application (port 443). IPsec secures all IP traffic (transparent to apps). Gateway acts as intermediary for specific protocols.

Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in