Computer Systems · Security

CS12 — Encryption: public and private keys, digital certificates and signatures

Lesson: CS12
Time: 1 period
Focus: keys, certificates, signatures, HTTPS
Learning intentions
Success criteria
Warm up
Recap security concepts before exploring how encryption works.
W1
What term describes data that has not been encrypted?
W2
Which of these is the main purpose of encryption?
W3
A hacker intercepts encrypted messages sent between two users. Why can they not read the content?

Key vocabulary

encryption
Converting plaintext into ciphertext using a key, making it unreadable without the correct decryption key.
symmetric encryption
An encryption method where the same key is used to both encrypt and decrypt the data.
asymmetric encryption
An encryption method that uses a matched pair of keys: a public key and a private key.
public key
A key that is shared openly and can be used by anyone to encrypt data or verify a signature.
private key
A key kept secret by its owner, used to decrypt data or create a digital signature.
digital certificate
An electronic document that links a public key to an identity, signed by a trusted Certificate Authority.
Certificate Authority (CA)
A trusted organisation that verifies identities and issues signed digital certificates.
digital signature
An encrypted value created with a private key that proves a message's authenticity and that it has not been altered.
HTTPS
A secure web protocol that uses asymmetric encryption, digital certificates and symmetric session keys to protect data in transit.

Why encryption matters

Every time you log in to a website, make an online payment, or send a message, data travels across the internet. Without protection, anyone in a position to intercept that traffic could read usernames, passwords, and financial details in plaintext. Encryption transforms data so that even if it is intercepted, it appears as meaningless characters to anyone who does not hold the correct key.

Encryption is not a single technique — there are different approaches, each with trade-offs between speed, security, and practicality. The two most important categories for Higher Computing Science are symmetric encryption and asymmetric encryption.

Symmetric encryption and its limitation

In symmetric encryption, the same key is used to both encrypt and decrypt data. This is fast and efficient, making it suitable for encrypting large amounts of data. The problem arises at the start of communication: how do two parties who have never met share the secret key securely? If Alice wants to send Bob the key over the internet, and an attacker intercepts it, the attacker can decrypt every future message. There is no safe way to exchange the key without first having a secure channel — which is exactly what you are trying to create.

Asymmetric encryption: public and private keys

Asymmetric encryption solves the key exchange problem by using two mathematically linked keys: a public key and a private key. They are generated as a pair. The critical property is:

The public key can be shared with anyone — it is designed to be public. The private key must be kept completely secret by its owner. Even knowing the public key, it is computationally infeasible to calculate the matching private key.

This elegantly solves the key exchange problem: Bob can publish his public key for anyone to see. If Alice wants to send Bob a secret message, she encrypts it with Bob's public key. Only Bob's private key can decrypt it. Even if an attacker intercepts the encrypted message, they cannot decrypt it without Bob's private key.

Asymmetric encryption is slower than symmetric encryption because the mathematics involved is more complex. In practice, systems like HTTPS use asymmetric encryption only to securely exchange a symmetric session key. Once both parties share that key, they switch to faster symmetric encryption for the bulk of the data transfer.

Digital certificates — proving identity

Asymmetric encryption solves the confidentiality problem, but it raises a new question: how does Alice know that the public key she is using actually belongs to Bob, and not to an attacker pretending to be Bob? An attacker could publish their own public key and claim it is Bob's. If Alice encrypts a message with the attacker's public key thinking it is Bob's, the attacker can read it.

A digital certificate solves this by linking a public key to a verified identity. A certificate contains:

A Certificate Authority (CA) is a trusted organisation — like DigiCert, Let's Encrypt, or GlobalSign — that verifies an organisation's identity and issues certificates. The CA signs each certificate with its own private key. Browsers and operating systems come with a built-in list of trusted CAs. When your browser visits a website, it checks that the website's certificate was signed by a trusted CA. If the signature is valid and the certificate has not expired, the browser knows the public key in the certificate genuinely belongs to the claimed domain.

This is why your browser shows a padlock icon for secure websites — it has successfully validated the digital certificate.

Digital signatures — proving authenticity and integrity

A digital signature serves a different purpose from encryption. While encryption keeps data secret, a digital signature proves two things:

A digital signature is created using the sender's private key and verified using the sender's public key. The process works in two stages:

Signing (sender)
1
Calculate a hash (a fixed-length fingerprint) of the message.
2
Encrypt the hash with the sender's private key — this is the digital signature.
3
Send the original message and the signature together.
Verifying (recipient)
1
Decrypt the signature using the sender's public key to recover the original hash.
2
Calculate a new hash of the received message independently.
3
If both hashes match → message is authentic and unaltered. ✓

The key insight is that only the sender could have created the signature, because only they hold their private key. Anyone can verify it using the freely available public key. If even one character in the message is changed after signing, the hash will be completely different, so the hashes will not match and the verification fails.

Digital signatures are used to verify software updates, email authenticity, legal documents, and the certificates issued by Certificate Authorities themselves.

How these concepts combine in HTTPS

When you visit a website using HTTPS, all three concepts work together:

  1. Your browser receives the website's digital certificate and verifies it against a trusted CA.
  2. If valid, the browser uses the website's public key (from the certificate) to encrypt a randomly generated symmetric session key.
  3. Only the website's private key can decrypt this, so only the genuine website can read it.
  4. Both sides now share the session key and switch to faster symmetric encryption for the rest of the session.
  5. Digital signatures on messages in the exchange confirm they have not been tampered with in transit.

This combination gives confidentiality (nobody else can read the data), authentication (you know you are talking to the genuine website), and integrity (data has not been modified in transit).

Worked examples

Example 1 — Sending an encrypted message using asymmetric encryption
1
Bob generates a public/private key pair. He publishes his public key — it is available for anyone to use.
2
Alice wants to send Bob a confidential message. She obtains Bob's public key and uses it to encrypt the message, producing ciphertext.
3
The ciphertext is sent over the internet. An attacker intercepts it but cannot read it — they do not have Bob's private key.
4
Bob receives the ciphertext and decrypts it using his private key, recovering Alice's original message.
The message remained confidential throughout — only Bob's private key could decrypt it, and only Bob holds that key.
Example 2 — Verifying a digital signature
1
Alice writes a message and calculates its hash — a short, fixed-length value that represents the message content.
2
Alice encrypts the hash with her private key. This encrypted hash is her digital signature. She sends the message and signature together to Bob.
3
Bob decrypts the signature using Alice's public key, recovering the original hash Alice calculated.
4
Bob independently calculates a hash of the message he received. He compares his hash with the one he recovered from the signature.
The hashes match — the message is authentic (only Alice has her private key) and unaltered (any change would produce a different hash).
Example 3 — How a digital certificate protects a website
1
A bank applies to a Certificate Authority, providing proof that it owns the domain bank.example.com.
2
The CA verifies the bank's identity and issues a digital certificate containing the bank's public key and the CA's signature.
3
A user visits the website. The browser receives the certificate and checks the CA's signature using the CA's public key (built into the browser).
4
The signature is valid, the certificate has not expired, and the domain matches. The browser shows a padlock icon.
The user knows the public key in the certificate genuinely belongs to the bank, not to an impersonator.
Now you try

A user wants to download a software update. The developer has digitally signed the update file. Explain how the user can verify the update is genuine and has not been tampered with.

The developer calculates a hash of the update file and encrypts it with their private key to create a digital signature. The user's computer downloads both the update and the signature. Using the developer's public key, the computer decrypts the signature to recover the original hash. It then calculates a hash of the downloaded file itself. If both hashes match, the file is genuine (only the developer could have created the signature) and unaltered (any tampering would produce a different hash).

⚠️ Common mistakes — examiner feedback
📝 Exam tip

When explaining asymmetric encryption, always state which key does what: "the public key encrypts; only the matching private key can decrypt." When explaining digital signatures, state the direction: "signed with the private key, verified with the public key." Knowing the direction of key use is what earns marks — a vague answer about "keys" will not.

Task Set A — Core questions

Task Set A — Core questions
Work through all questions. Written questions reveal model answers when checked.
A1
What term describes data that has been encrypted and can no longer be read without the correct key?
A2
In asymmetric encryption, which key must always be kept secret by its owner?
A3
Alice wants to send Bob a confidential message using asymmetric encryption. Which key should she use to encrypt the message?
A4
What is the name of the trusted organisation that verifies identities and issues digital certificates?
A5
A digital certificate primarily proves which of the following?
A6
Explain how a digital signature can prove that a message has not been altered in transit.
Model answer
A7
Which type of encryption uses the same key for both encrypting and decrypting data?
A8
Explain why symmetric encryption has a problem when two parties who have never met want to communicate securely for the first time.
Model answer
A9
Describe the role of a Certificate Authority (CA).
Model answer
A10
What web protocol uses digital certificates and asymmetric encryption to create secure connections between browsers and websites?
Task Set B — Extension · Beyond the specification
Optional challenge questions. Self-assess using the model answers.
B1
Explain why HTTPS uses asymmetric encryption to start a session but switches to symmetric encryption for the main data transfer.
One possible answer
B2
Alice signs a message with her private key. Bob verifies the signature using Alice's public key. Explain why this proves the message came from Alice.
One possible answer
B3
A Certificate Authority's private key is stolen by an attacker. Explain the security implications.
One possible answer
B4
Explain how digital certificates protect against a "man-in-the-middle" attack, where an attacker intercepts communication and substitutes their own public key.
One possible answer
📁 File this in OneNote under:
Higher Computing Science → Computer Systems → CS12
📌 Teacher notes — Shift+T to toggle

Suggested timing: 5 min warm up · 10 min vocabulary · 30 min notes with diagram discussion · 10 min worked examples · 5 min now-you-try · 25 min task set · 5 min review.

Key diagram to draw on the board: Alice → (Bob's public key) → ciphertext → (Bob's private key) → Bob. Pupils consistently confuse which key does what, so a visual drill here pays dividends.

Common misconception to address: "The public key must be kept secret." It must not — it is designed to be shared. The word "public" is the clue. Spend a moment on this explicitly.

Asymmetric vs symmetric distinction: The key exam distinction is not just what they are but when they are used: asymmetric for key exchange and authentication; symmetric for bulk data. HTTPS uses both.

SQA command words covered: explain, describe, give an example.

Link to CS10/CS11: Remind pupils that the Computer Misuse Act covers unauthorised access to encrypted data. Encryption is a technical control that complements legal controls.

Privacy note: Use only generic examples. Do not discuss real security incidents involving identifiable organisations in a way that might be distressing or misleading.