Syllabus coverage
- Understand the need for encryption when transmitting data
- Understand the purpose of encryption, which is to keep the contents of transmitted data confidential
- Understand how data is encrypted and decrypted using symmetric encryption, where the same key is used at both ends
- Understand how data is encrypted and decrypted using asymmetric encryption, including the use of a public key and a private key
Part of the O Level Computer Science syllabus 2210.
Why transmitted data needs protecting
Data that stays on one machine is protected by that machine's own security. Data that is transmitted is different: it leaves the device, travels through cables, routers, switches, wireless access points and servers, and arrives somewhere else. Most of that path belongs to nobody in the conversation. A message between two people may pass through a dozen pieces of equipment owned by several different organisations.
At any point on that path the data can be intercepted. On a wireless network an attacker within range can capture the radio signals without touching any cable. On a wired network, traffic can be copied at a router or a shared connection. Once captured, data sent as plain readable text can simply be read, and it may also be altered before being passed on.
The information at risk is often the most sensitive there is: passwords, card numbers, medical records, personal messages and business documents. If a password crosses a network in plain text, anyone who captures it can use it. This is why the need for encryption is not about hiding the fact that a message was sent; it is about making sure that only the intended recipient can understand what it says.
Plaintext, ciphertext and the key
Encryption is the process of converting readable data into a form that cannot be understood without the key. The readable original is called plaintext. The scrambled result is called ciphertext. Decryption is the reverse process, turning ciphertext back into plaintext.
The transformation is controlled by a key, which is a value used by the encryption algorithm. The algorithm itself is usually public and well known; the secrecy lies in the key. Anyone with the ciphertext and the correct key can recover the plaintext, and anyone without the key should not be able to do so in any practical time.
A useful way to picture it is a locked box. The plaintext goes in, the key locks it, and the locked box travels along the channel. An interceptor can see the box and can even copy it, but cannot open it. At the other end the matching key opens the box and the plaintext comes out. This is why encryption is described as protecting data in transit, and why it is used for web logins, banking, messaging and any transfer of personal details.
Two further points matter for exams. Encryption does not stop interception; it removes the value of what is intercepted. And encryption does not protect data at rest on a disk unless the disk itself is encrypted; the syllabus is concerned with data being transmitted.
Symmetric encryption: one shared key
Symmetric encryption uses the same key to encrypt and to decrypt. The sender and the receiver must both have that key before any data is exchanged. The sender encrypts the plaintext with the key, the ciphertext travels along the channel, and the receiver applies the same key to recover the plaintext.
Its great advantage is speed. Symmetric algorithms do relatively little computation per block of data, so they can encrypt large volumes, such as a video stream or a file download, without slowing the connection noticeably. The key is also short, and the same algorithm can be implemented cheaply on small devices.
Its weakness is the key distribution problem. Because one key does both jobs, it must be shared between the two parties, and it must be shared securely. If the key is sent across the same channel as the data, an interceptor who captures the key can decrypt everything, both the message in hand and every later message encrypted with that key. In a large network every pair of users would need its own shared key, and the number of keys grows very quickly, which makes management difficult.
Symmetric encryption is therefore strong and fast but depends on a safe way of getting the key to the other person. In practice the key is often delivered using asymmetric encryption, which is the subject of the next block.
| Stage | What happens |
|---|---|
| 1 | Sender and receiver agree on one shared key, and the receiver obtains it securely |
| 2 | The sender encrypts the plaintext using the shared key, producing ciphertext |
| 3 | The ciphertext is transmitted; an interceptor without the key cannot read it |
| 4 | The receiver decrypts the ciphertext using the same shared key, recovering the plaintext |
Asymmetric encryption: a public and a private key
Asymmetric encryption uses a pair of keys that are mathematically related but not derivable from one another in practice. One is the public key, which is published openly and can be given to anyone. The other is the private key, which is kept secret by its owner and never sent anywhere.
The pair works in a way that seems backwards at first. Data encrypted with a person's public key can only be decrypted with that person's private key. So if you want to send a confidential message to someone, you obtain their public key, encrypt the message with it, and send the ciphertext. Anyone can see the ciphertext and anyone can have the public key, but only the holder of the matching private key can turn it back into plaintext.
The private key is never shared, so there is no key to intercept. This is what solves the distribution problem of symmetric encryption. A person can publish a public key on a website or in a directory and receive confidential messages from strangers without ever having met them or agreed a secret in advance.
Asymmetric encryption is computationally expensive. The mathematics involves very large numbers, so it is far slower than symmetric encryption and is not used to encrypt a whole video or file. The usual arrangement is a hybrid: asymmetric encryption is used briefly to deliver a symmetric session key safely, and the bulk data is then encrypted with that symmetric key, which gives the security of asymmetric key exchange with the speed of symmetric encryption.
| Symmetric encryption | Asymmetric encryption | |
|---|---|---|
| Keys used | One key, used to encrypt and to decrypt | A pair: a public key and a private key |
| Who holds the key | Both sender and receiver must have the same key | The public key is available to anyone; the private key is held only by its owner |
| How the key is shared | The key itself must be delivered securely to the other party | The public key can be published openly; the private key is never shared |
| Speed | Fast, suitable for large amounts of data | Slow, because of the complex mathematics |
| Main weakness | Anyone who obtains the shared key can read the traffic | Slower and more processing-intensive, so used for small amounts of data such as keys |
The two keys in use
A short sequence shows how asymmetric encryption is used for a real exchange. The receiver generates a key pair and publishes the public key. The sender obtains that public key, encrypts the message with it, and transmits the ciphertext. The receiver applies the private key and reads the message. An interceptor who captured both the ciphertext and the public key still cannot decrypt, because the public key does not reverse its own encryption.
The pair can also be used the other way round, to show where data came from. If the sender encrypts with their own private key, anyone with the matching public key can decrypt it, which proves that the holder of that private key produced it. This is the basis of a digital signature, and it provides authenticity rather than confidentiality, because everyone can read the message.
That gives the two properties that matter in the syllabus. Using the recipient's public key gives confidentiality: only the recipient can read the data. Using the sender's private key gives authenticity: the recipient can tell who sent it. In practice a system may use both, and combine them with a symmetric key for the bulk of the data.
Choosing between them
The choice follows from what each method is good at. Symmetric encryption is chosen when speed matters and the two parties can share a key safely, for example within one organisation where keys can be distributed by an administrator, or for encrypting a large file before storage or transfer.
Asymmetric encryption is chosen when the two parties have no secure channel in advance, or when they have never met. Publishing a public key needs no secrecy, so a website can offer confidential communication to any visitor without prior arrangement. It is also chosen when proof of origin is needed.
Because asymmetric encryption is too slow for bulk data, the common solution combines them: asymmetric encryption carries a freshly generated symmetric key, and symmetric encryption carries the actual data. The slow mathematics is used once for a small key, and the fast algorithm handles everything else.
What encryption does and does not do
Encryption provides confidentiality: the contents cannot be read without the key. It does not prevent the data being intercepted, copied, delayed or destroyed, and it does not by itself stop an attacker from knowing that a message was sent, or to whom, or how large it was.
Encryption does not replace the other protections. A weak password can still be guessed, a compromised device can still be read before anything is encrypted, and a stolen private key defeats the whole scheme. Encryption also does not detect errors caused by interference; that is the job of parity, checksums and ARQ. Encryption and error detection solve different problems and are used together.
Nor does encryption prove that the public key belongs to the person it claims to. If an attacker can substitute their own public key, the sender will encrypt to the wrong party. Certificates and trusted authorities exist to solve that problem, but they go beyond what this syllabus requires; what matters here is knowing what the key pair does and what it does not.
- Provides confidentiality of the contents in transit.
- Does not stop interception, only makes the intercepted data useless.
- Does not detect transmission errors; parity, checksums and ARQ do that.
- Depends on the key staying secret, and on the public key genuinely belonging to its owner.
Key terms you must be able to define
- Encryption
- The process of converting readable data into an unreadable form, called ciphertext, so that it cannot be understood by anyone who does not have the key needed to decrypt it.
- Decryption
- The reverse of encryption: converting ciphertext back into readable plaintext using the correct key.
- Plaintext
- The original readable form of the data before it is encrypted.
- Ciphertext
- The scrambled output of encryption, which cannot be understood without the key.
- Key
- The value used by the encryption algorithm to convert plaintext into ciphertext and back again. Its secrecy is what protects the data.
- Symmetric encryption
- Encryption that uses the same key to encrypt and decrypt. It is fast, but the key must be delivered securely to both parties.
- Asymmetric encryption
- Encryption that uses a pair of linked keys: a public key, which anyone may have and which is used to encrypt, and a private key, which is kept secret and is the only key that can decrypt.
- Public key
- The key of an asymmetric pair that is published openly. Data encrypted with it can only be decrypted with the matching private key.
- Private key
- The key of an asymmetric pair that is kept secret by its owner and is never transmitted. It decrypts data that was encrypted with the matching public key.
- Interception
- Capturing data while it is being transmitted, for example by listening to a wireless signal or copying traffic at a router.
In context
2210 sets its questions inside systems a student already uses - a school network, a phone, a supermarket till, a vending machine, a website. These show how the theory is applied to a context you have not seen before, then you answer for the system you are given.
When you type a password into a shopping site, the connection uses HTTPS, so the form data is encrypted before it leaves the browser. The site's public key is in its certificate, so the browser can encrypt data that only the site's private key can open. Anyone capturing the wireless traffic sees ciphertext, not the password.
A messaging app sets up a session by agreeing a symmetric key with each contact, delivered using asymmetric encryption so that the key is never sent in the clear. The messages themselves are encrypted with that symmetric key, because it is fast enough for photos and video. The two methods are used together, each for the job it does best.
A cafe's wireless network is open, so anyone within range can capture the radio traffic. Unencrypted requests are readable in full. Encrypted requests still reveal which server is being contacted, but the contents, including any password or card number, are useless to the person capturing them without the key.
Traffic between two systems inside a bank may use symmetric encryption alone, because the key can be installed on both machines by an administrator over a controlled link rather than sent across the network. The gain is speed on large transfers; the risk being managed is a stolen key rather than an intercepted one.
Flashcards
Click a card to flip it. Mark honestly — the tracker uses this.
Exam-style questions
7 questions, 19 marks. Write your answer and press Mark my answer — it is marked against the scheme and tells you which points you made and what would gain the next mark. You can still reveal the scheme and mark it yourself instead.
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Exam technique for this topic
- Answer the purpose question before the mechanism question. 'Why encrypt?' is about confidentiality of data in transit; 'how?' is about keys and ciphertext.
- Never write that encryption stops interception. It does not. It makes the intercepted data meaningless without the key, and that is the mark.
- For symmetric, say one key, used by both ends, and name the weakness: the key has to be shared, so it can be intercepted or stolen.
- For asymmetric, say which key does which job: the recipient's public key encrypts, their private key decrypts, and the private key is never transmitted. Getting the direction backwards loses the marks.
- If a question asks you to compare, use the same three points for both: number of keys, how the key is shared, and speed. A table is quicker and clearer than prose.
Why students lose marks here
Where this fits in O Level Computer Science 2210
This page is one topic of Cambridge O Level Computer Science 2210. O Level Computer Science 2210 is the course home: every area and every topic in Cambridge's own order, the papers you sit and what each one tests, and the exam-practice tools. The full topic list, with each topic linked to its revision page, is on the O Level Computer Science 2210 syllabus page.