Application Layer · Computer Networks

Basic Concepts of Cryptography

Watch lectures
SVGVector Architecture Diagram (SVG)
COMPUTER NETWORKS · Module 5 · Application Layer★ High PriorityIT Sem 6 · Code 100602Basic Concepts of CryptographyMNEMONICCryptography = Plaintext → (key) → Ciphertext → (key) → Plaintext.CIA + Non-repudiation: Confidentiality, Integrity, Availability.Core BreakdownOverviewCryptography protects information by turning readable plaintext into unreadable ciphertext with a key.Encryption converts, decryption reverses it; the algorithm is public, the key is secret.GoalsConfidentiality (secrecy), Integrity (no change), Authentication (who), Non-repudiation (cannot deny).Availability completes the CIA triad: authorised users can always get the service.SymmetricOne shared secret key encrypts and decrypts. Examples: DES (56-bit key), 3DES, AES (128/192/256).Very fast for bulk data, but the key must be shared safely; N users need N(N-1)/2 keys.AsymmetricKey pair: public key (shared) and private key (secret). Examples: RSA, ECC, Diffie-Hellman.Slower, but no secret has to be sent first; N users need only 2N keys.Encryption UseFor secrecy: encrypt with the receiver's PUBLIC key; only the receiver's PRIVATE key decrypts.Plaintext is never sent; an eavesdropper sees only ciphertext.SignaturesDigital signature: hash the message, then sign the hash with the sender's PRIVATE key.The receiver verifies with the sender's PUBLIC key: gives authentication, integrity, non-repudiation.HashA hash function (SHA-256) maps any message to a fixed-size digest: one way and collision resistant.A tiny change in the message changes the digest completely; used for integrity checks.Hybrid/TLSHybrid: asymmetric crypto exchanges a session key, then fast symmetric AES encrypts the data.HTTPS (TLS) works this way, with certificates to prove the server's identity. Kerckhoffs: only the key is secret.Diagram: Encryption BasicsPlaintextEncryptwith keyCiphertextSymmetric: ONE shared secret key (AES, DES)Fast, bulk data. Needs a safe key exchange.Asymmetric: public + private key pair (RSA, ECC)Slow, solves key distribution; used for signatures.ConfidentialityIntegrityAvailabilityNon-repudiationDigital signature: sign with PRIVATE key, verify with PUBLIC.Hybrid (TLS): asymmetric swaps a session key, then AES.Keys for N users: symmetric N(N-1)/2 · asymmetric 2NAES: block 128 bit, key 128/192/256 · DES: 64 / 56 bitRSA: from big-prime factoring · Hash: SHA-256, one wayKerckhoffs: only the KEY is secret, not the algorithm⚠️ Exam Traps & Viva Favorites① Symmetric vs Asymmetric?Symmetric: one shared key, fast (AES).Asymmetric: public + private pair, slower(RSA), solves key distribution.② Which key signs?Sign with the sender's PRIVATE key, verifywith the PUBLIC key. To keep a messagesecret, encrypt with receiver's PUBLIC key.③ How many keys for N users?Symmetric: N(N-1)/2 pairs of keys.Asymmetric: 2N keys (N public + N private).Example N = 10: 45 vs 20.Tip: sign = private · encrypt = publicMaster Revision Table(learn it row by row!)ConceptKey(s)SpeedExamplesUsed forSymmetricOne shared secretFastAES, DES, 3DESBulk data encryptionAsymmetricPublic + private pairSlowRSA, ECC, DHKey exchange, signaturesHashNo keyVery fastSHA-256, MD5Integrity checkDigital signaturePrivate signs, public verifiesMediumRSA / ECDSAAuthentication, non-repudiationHybrid (TLS)Session key + pairFastHTTPSSecure web trafficQUICK FACTSCIA: Confidentiality · Integrity · Availability (+ Authentication, Non-repudiation)Keys for N users: symmetric N(N-1)/2 · asymmetric 2NAES block 128 bit (keys 128/192/256) · DES 64-bit block, 56-bit keyVERIFIED★ Golden rule: Symmetric is fast, asymmetric shares keys, hybrid does both.

Basic Concepts of Cryptography in Computer Networks


1. Network Security Goals: The CIA Triad

In modern interconnected computer networks, information security revolves around three fundamental security pillars (the CIA Triad), plus authentication and non-repudiation:

MermaidDiagram
Rendering diagram…
  1. Confidentiality: Ensuring that sensitive information is inaccessible to unauthorized eavesdroppers. Achieved via Encryption.
  2. Integrity: Ensuring that data has not been secretly modified, injected, or altered during transit. Achieved via Cryptographic Hash Functions and MACs.
  3. Availability: Ensuring authorized users have reliable, timely access to services without disruption from Denial of Service (DoS) attacks.
  4. Authentication: Confirming the true identity of communicating entities before granting access.
  5. Non-Repudiation: Preventing a sender from denying having sent a message. Achieved via Digital Signatures.

2. Cryptographic Terminology

  • Plaintext (PP): The original, unencrypted readable message.
  • Ciphertext (CC): The scrambled, unreadable message produced by encryption.
  • Cipher: The mathematical algorithm used to transform plaintext into ciphertext.
  • Key (KK): A mathematical secret parameter used by ciphers to control encryption and decryption.
  • Encryption (EE):
C=EK(P)C = E_K(P)
  • Decryption (DD):
P=DK(C)P = D_K(C)
  • Cryptanalysis: The science of breaking ciphers and decrypting data without knowledge of the secret key.
  • Kerckhoffs's Principle: A cryptosystem must remain secure even if everything about the system (the algorithm) is public knowledge, as long as the Key itself remains secret.

3. Symmetric Key Cryptography (Secret-Key)

In Symmetric Key Cryptography, the exact same secret key is used for both encryption and decryption:

MermaidDiagram
Rendering diagram…

Classification of Symmetric Ciphers:

  1. Stream Ciphers: Encrypts plaintext bit-by-bit or byte-by-byte continuously (e.g., RC4, ChaCha20).
  2. Block Ciphers: Divides plaintext into fixed-size blocks (typically 64 or 128 bits) and encrypts each block:
    • DES (Data Encryption Standard): 56-bit key, 64-bit block size. Obsolete (cracked via brute-force in hours).
    • 3DES (Triple DES): Applies DES three times (168168-bit key). Phased out due to slow performance.
    • AES (Advanced Encryption Standard - Rijndael): The global gold standard. Fixed 128-bit block size with key lengths of 128, 192, or 256 bits.

The Key Distribution Problem:

For a network with NN users, every pair of users requires a distinct shared key:

Total Secret Keys Needed=N(N−1)2=O(N2)\text{Total Secret Keys Needed} = \frac{N(N - 1)}{2} = O(N^2)

In a network of 1,0001{,}000 users, nearly 500,000500{,}000 secret keys must be securely distributed and stored!


4. Asymmetric Key Cryptography (Public-Key)

To solve the key distribution nightmare, Whitfield Diffie and Martin Hellman introduced Public-Key Cryptography in 1976. Each user possesses a mathematically linked Key Pair:

  1. Public Key (KpubK_{\text{pub}}): Freely published and known to the entire world.
  2. Private Key (KprivK_{\text{priv}}): Kept strictly secret by the owner.
MermaidDiagram
Rendering diagram…

Mathematical Foundations:

Based on One-Way Trapdoor Functions—problems that are easy to compute in the forward direction but computationally infeasible to invert without special knowledge (the trapdoor):

  • RSA (Rivest-Shamir-Adleman): Security relies on the extreme computational difficulty of factoring large prime numbers (2048−4096 bits2048 - 4096\text{ bits}).
  • Diffie-Hellman / ECC (Elliptic Curve Cryptography): Security relies on the Discrete Logarithm Problem. ECC provides the same security as RSA with vastly smaller keys (256-bit ECC ≈\approx 3072-bit RSA).

5. Digital Signatures and Message Digests

Asymmetric cryptography also provides Authentication and Non-Repudiation through Digital Signatures:

MermaidDiagram
Rendering diagram…
  • Cryptographic Hash Functions (SHA-256): One-way, fixed-size output, collision-resistant (impossible to find two different inputs that produce the same hash output).
  • Digital Certificates & PKI (X.509): Trusted third-party Certificate Authorities (CAs) digitally sign and bind public keys to domain identities (e.g., Let's Encrypt, DigiCert) for HTTPS web browsing.

6. Hybrid Cryptography (The Real-World Solution)

  • Symmetric encryption is 1,000×1{,}000\times faster than asymmetric encryption.
  • Asymmetric encryption solves key distribution.
  • The Modern Standard (TLS / SSL / HTTPS) combines both:
    1. Handshake Phase: Uses Asymmetric Cryptography (ECDH / RSA) to authenticate the server and securely exchange a temporary Symmetric Session Key.
    2. Data Transfer Phase: Uses Symmetric Cryptography (AES-256-GCM) with the negotiated session key to encrypt bulk data at wire speed!

7. Comprehensive Comparison: Symmetric vs. Asymmetric

Parameter Symmetric Encryption Asymmetric Encryption
Number of Keys 1 shared secret key 2 mathematically linked keys (Public & Private)
Key Distribution Difficult (O(N2)O(N^2) secret channels) Simple (O(N)O(N) public keys)
Computational Speed Extremely Fast (Hardware accelerated) Slow (Heavy modular exponentiation)
Cipher Text Size Same as or slightly larger than plaintext Significantly larger than plaintext
Primary Algorithms AES, DES, 3DES, ChaCha20, Blowfish RSA, ECC, Diffie-Hellman, DSA
Primary Use Cases Bulk file encryption, database storage Key exchange, Digital Signatures, TLS handshakes

Frequently Asked Questions

QState Kerckhoffs's Principle.

A cryptographic system must be designed to remain secure even if everything about the design and algorithms are publicly known, provided the specific key remains secret.

QWhy is Hybrid Cryptography used in HTTPS/TLS rather than pure asymmetric encryption?

Asymmetric encryption involves heavy mathematical operations that are too slow for high-speed web traffic. HTTPS uses asymmetric cryptography only for initial key exchange and authentication, then switches to fast symmetric encryption (AES) for the actual webpage payload.

QWhat two properties are guaranteed by a Digital Signature?

Authentication / Non-Repudiation (proves the message was signed by the holder of the unique private key) and Integrity (proves the message was not modified in transit).

QHow many keys are needed for N users with symmetric cryptography?

Every pair of users needs a distinct shared key, so N(N−1)2\frac{N(N-1)}{2} keys are required, which is O(N2)O(N^2). For 1,000 users that is nearly 500,000 keys.

AI LearningWeb Platform

Coursify — Personal AI Course Generator

Struggling with a difficult subject or concept? Turn any engineering topic into a structured course with interactive lessons, quizzes, and research-backed explanations.

← All Computer Networks modules