A2.4.4 — Encryption and Digital Certificates
Encryption
The process of converting plaintext into ciphertext using an algorithm and a key, preventing unauthorised access. Only someone with the correct key can decrypt and read the data.
Symmetric vs Asymmetric Cryptography
Symmetric Cryptography
The same key is used for both encryption and decryption. The key must be shared securely between both parties before communication begins.
- Fast and efficient. Suitable for encrypting large volumes of data.
- Main problem: securely exchanging the key before communication is difficult, especially at scale.
- If the key is intercepted, all encrypted data is compromised.
Example: Alice encrypts "Meet me at noon" with the shared key and sends the ciphertext. Bob decrypts it with the same key.
Asymmetric Cryptography (Public-Key Cryptography)
Uses a pair of mathematically related keys: a public key and a private key. The public key encrypts; the private key decrypts. The private key never leaves the owner.
- Solves the key distribution problem. Public keys can be freely shared.
- Slower than symmetric due to complex mathematical operations.
- Also enables digital signatures (sign with private key, verify with public key).
Example: Alice encrypts her message using Bob's public key. Only Bob can decrypt it using his private key.
Comparison Table
| Feature | Symmetric | Asymmetric |
|---|---|---|
| Keys used | One shared secret key | Public key (encrypt) and private key (decrypt) |
| Key distribution | Must be shared securely in advance | Public key can be freely distributed |
| Speed | Fast | Slower due to complex maths |
| Best used for | Encrypting large volumes of data | Key exchange, digital signatures, secure comms without prior key sharing |
| Security risk | If key is intercepted, all data is exposed | Private key must remain secret. Public key exposure is fine. |
| Computational cost | Low | High |
Digital Signatures
Used to verify the authenticity and integrity of a document or message. Proves it was signed by the claimed sender and has not been altered.
How it works
- The signer generates a hash of the document.
- The hash is encrypted with the signer's private key to produce the digital signature.
- The signature is attached to the document and sent.
- The recipient decrypts the signature using the signer's public key, revealing the original hash.
- The recipient independently hashes the received document and compares it to the decrypted hash. If they match, the document is authentic and unaltered.
Hash Functions
A hash function takes any input and produces a fixed-size output (digest) unique to that input. They are one-way: you cannot reverse a hash to find the original input.
- Even a tiny change in the input produces a completely different hash.
- Example: "Hello, world!" hashed with MD5 gives
fc3ff98e8c6a0d3087d515c0473f8677. Changing one character produces an entirely different hash. - Used for data integrity checking, password storage, and digital signatures.
Digital Certificates
An electronic document that binds a public key to an identity (a person, organisation, or device). Issued and digitally signed by a trusted Certificate Authority (CA).
How HTTPS uses digital certificates
- A website owner generates a public and private key pair.
- They submit a Certificate Signing Request (CSR) containing the public key and site info to a CA.
- The CA verifies the identity and signs the certificate with its own private key.
- The certificate is installed on the web server.
- When a user visits the site, their browser checks the certificate, trusts it (because it was signed by a known CA), and establishes an encrypted TLS connection using the public key.
Other uses of digital certificates
- SSH: Key-based authentication for secure remote login. The private key stays on the user's machine; the public key is on the server.
- Code signing: Developers sign software with their private key. Users can verify the software is genuine and unaltered using the public key in the certificate.
- VPNs: Certificates authenticate both client and server before establishing the encrypted tunnel, ensuring both parties are who they claim to be.
- Document signing: Signs PDFs and legal documents to verify the signer's identity and ensure integrity. Used in legal and financial contexts.
Encryption Key Management
The processes and policies for handling, storing, and protecting encryption keys. A key is only useful if it stays secure.
- Compromised keys make encryption worthless. Proper management prevents unauthorised access.
- Regulatory requirements such as GDPR, HIPAA and PCI DSS mandate strict key protection. Non-compliance risks fines.
- Keys must be backed up securely. Losing a key means losing access to all data encrypted with it.
- Key management must scale as organisations grow and adopt new cryptographic standards.
- Symmetric: one key, fast, problem is sharing it. Asymmetric: two keys, slow, solves the sharing problem.
- In practice: asymmetric is used to securely exchange a symmetric key, then symmetric is used for the actual data. This is how HTTPS works.
- Digital signature: sign with PRIVATE key, verify with PUBLIC key. Encryption: encrypt with PUBLIC key, decrypt with PRIVATE key. These are opposite operations.
- A CA is trusted because browsers and OSes ship with a pre-installed list of trusted CAs.