A2.4.4 — Encryption and Digital Certificates

← Back to A2.4 overview

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

FeatureSymmetricAsymmetric
Keys usedOne shared secret keyPublic key (encrypt) and private key (decrypt)
Key distributionMust be shared securely in advancePublic key can be freely distributed
SpeedFastSlower due to complex maths
Best used forEncrypting large volumes of dataKey exchange, digital signatures, secure comms without prior key sharing
Security riskIf key is intercepted, all data is exposedPrivate key must remain secret. Public key exposure is fine.
Computational costLowHigh

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

  1. The signer generates a hash of the document.
  2. The hash is encrypted with the signer's private key to produce the digital signature.
  3. The signature is attached to the document and sent.
  4. The recipient decrypts the signature using the signer's public key, revealing the original hash.
  5. 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

  1. A website owner generates a public and private key pair.
  2. They submit a Certificate Signing Request (CSR) containing the public key and site info to a CA.
  3. The CA verifies the identity and signs the certificate with its own private key.
  4. The certificate is installed on the web server.
  5. 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.
Ninja Notes: