The Cryptographic Pillars of Confidentiality, Integrity, and Authenticity
In a world driven by data, protecting that data is paramount. Cryptography provides the mathematical tools to secure information against unauthorized access and modification. This module explores the three fundamental pillars of modern data protection: Encryption to ensure confidentiality, Hashing to verify integrity, and Public Key Infrastructure (PKI) to manage trust and authenticity.
Hashing: Verifying Data Integrity
Hashing is the process of taking an input of any size (from a single word to a massive file) and producing a fixed-size string of characters, known as a "hash" or "digest." This process is performed by a cryptographic hash function.
Core Properties of Hashing
- One-Way: It is computationally impossible to reverse the process—you cannot derive the original input data from its hash.
- Deterministic: The same input will always produce the exact same hash.
- Avalanche Effect: Changing even a single bit of the input data will produce a drastically different hash.
- Collision Resistant: It is computationally infeasible to find two different inputs that produce the same hash.
The Primary Use Case: Integrity Verification
Hashing's main purpose is to act as a unique digital fingerprint for data. By comparing the hash of a file before and after transmission, you can verify with certainty that the file was not altered in transit. Software download sites often provide a SHA-256 hash for their files. You can download the file, calculate its hash on your own computer, and if the hashes match, you know the file is authentic and uncorrupted.
Common Algorithms: MD5 (obsolete, insecure), SHA-1 (deprecated), SHA-256 (current standard), SHA-3.
Crucial Application - Password Storage: Websites should NEVER store user passwords in plaintext. Instead, they store the hash of the password. When a user tries to log in, the system hashes the password they entered and compares it to the stored hash. If they match, the password is correct. If the database is ever stolen, the attackers only get the hashes, which cannot be reversed to reveal the original passwords.
Encryption: Ensuring Confidentiality
If hashing is for integrity, encryption is for confidentiality. Encryption is a two-way process that transforms plaintext (readable data) into ciphertext (unreadable data) using a key. Only someone with the correct key can decrypt the ciphertext back into plaintext.
Symmetric Encryption
Uses a single, shared secret key for both encryption and decryption. Both the sender and receiver must have the same key.
Analogy: A locked safe with a physical key. Anyone with a copy of the key can open it.
Strengths: Extremely fast and efficient.
Weakness: Securely sharing the secret key with the other party is a major challenge.
Use Cases: Encrypting data at rest (e.g., BitLocker, LUKS), encrypting bulk data in network connections.
Algorithms: AES (Advanced Encryption Standard), Blowfish, 3DES.
Asymmetric Encryption
Uses a pair of mathematically linked keys: a public key and a private key.
- The Public Key can be shared with anyone. It is used to encrypt data.
- The Private Key must be kept secret. It is used to decrypt data that was encrypted with its corresponding public key.
Weakness: Much slower and more computationally expensive than symmetric encryption.
Algorithms: RSA, ECC (Elliptic Curve Cryptography).
Public Key Infrastructure (PKI): Managing Trust at Scale
Asymmetric encryption is powerful, but it has a fundamental problem: how do you know that a public key actually belongs to who it says it does? What stops an attacker from creating a key pair and claiming to be `yourbank.com`? This is the problem that PKI solves. It is the framework of hardware, software, policies, and procedures used to create, manage, distribute, and revoke digital certificates.
How it Works: Digital Certificates and CAs
A Digital Certificate is an electronic document that binds a public key to an identity (like a person or a domain name). It is like a digital passport.
This binding is verified by a trusted third party called a Certificate Authority (CA), like Let's Encrypt or DigiCert. The process works like this:
- An organization (e.g., a bank) generates a public/private key pair.
- They send their public key and proof of their identity to a CA.
- The CA verifies the organization's identity.
- The CA then creates a certificate containing the organization's public key and identity information, and digitally signs it with the CA's own private key.
The Use Case: HTTPS and Secure Browsing
This entire process is what makes the lock icon in your browser possible.
- When you connect to `https://yourbank.com`, the bank's server presents its digital certificate to your browser.
- Your browser already has a pre-installed list of trusted public keys from major CAs. It uses the appropriate CA's public key to verify the digital signature on the bank's certificate.
- If the signature is valid, your browser knows two things: 1) the certificate has not been tampered with, and 2) a trusted CA vouches that the public key in the certificate truly belongs to `yourbank.com`.
- Your browser now safely uses the bank's trusted public key to negotiate a unique, fast symmetric encryption key for the session. This hybrid approach gives you the security of asymmetric encryption for key exchange and the speed of symmetric encryption for bulk data transfer. This entire process is known as the TLS/SSL handshake.