Encryption
Encryption turns data into ciphertext that is meaningless without the key. Symmetric encryption uses one shared key; asymmetric encryption uses a public key to encrypt and a private key to decrypt.
WATCH IT EXPLAINED
EXPLORE IT IN 3D
The tapped line
Anu is sending Bat a message down the office network — and Eve has clipped a tap onto the cable. Encrypt it on a brass Caesar wheel, trade padlocks, and see what Eve can and can't do with her copy.
Why data is encrypted
Encryption cannot stop data being copied, but it makes a stolen copy meaningless without the key.
Data sent over a network can be intercepted: someone copies it on the way. This happens especially on the internet or Wi-Fi. Anyone with access to a cable, a router or the radio signal can make a copy.
Encryption does not stop this. It makes intercepted data meaningless to anyone who does not have the key.
So encryption protects confidential data while it is being transmitted, such as:
- passwords;
- bank details;
- personal information;
- private messages.
Plaintext, ciphertext and keys
A key turns readable plaintext into meaningless ciphertext, and a key turns it back.
| Word | Meaning |
|---|---|
| Plaintext | the original, readable data |
| Ciphertext | data that looks meaningless |
| Key | the secret value the algorithm uses |
- Encryption: an encryption algorithm uses a key to turn the plaintext into ciphertext.
- Decryption: a key turns the ciphertext back into plaintext.
Remember:The algorithm is usually public knowledge: anyone can find out how it works. What keeps the data safe is that the key is kept secret.
In the figure, give the receiver a different key, and the plaintext does not come back.
Symmetric encryption
Symmetric encryption uses one key for both jobs: the same key locks and unlocks.
Symmetric encryption uses the same key to encrypt and to decrypt.
- Sender: plaintext + key → ciphertext.
- Network: the ciphertext is sent.
- Receiver: ciphertext + the same key → plaintext. The receiver has an identical copy of the key.
The figure above works this way: the message only comes back when both ends use the same key.
Remember:Symmetric algorithms are fast. That makes them good for encrypting large amounts of data.
The key-sharing problem
The weak point of symmetric encryption is getting the key to the receiver safely.
Before symmetric encryption can be used, both people need the same key. So the key itself has to reach the receiver.
If the key is sent across the same network, it can be intercepted just like any other data. Whoever copies it can then decrypt every message that is encrypted with it.
Example:It is like posting the key to your locker. Anyone who opens the post on the way can copy the key and open the locker.
Getting the key to the receiver safely is the weakness of symmetric encryption. Asymmetric encryption, in the next note, solves this problem.
Asymmetric encryption
Asymmetric encryption locks with the receiver's public key and unlocks with the matching private key.
Asymmetric encryption uses a pair of keys that are mathematically linked. The receiver creates the pair.
| Public key | Private key | |
|---|---|---|
| Who has it | anyone who wants it | only the receiver: it is kept secret |
| Its job | the sender encrypts with it | it decrypts the message |
| Is it sent? | yes, it is shared with anyone | never |
A sender encrypts the message with the receiver's public key. The message can then only be decrypted with the matching private key.
Remember:The private key never leaves the receiver, so no secret key ever has to be sent.
Why the public key cannot unlock the message
The two keys do opposite jobs: what one key of the pair locks, only the other can unlock.
The real method, RSA, is beyond the IGCSE syllabus. But tiny numbers show the idea.
- Bat's public key is (3, 55).
- Bat's private key is (7, 55).
Example:Anu encrypts the message 7. She works out 7³ and keeps the remainder after dividing by 55. That gives 13. Using the public key again on 13 gives 52, which is useless. Only the private key turns 13 back into 7.
Real keys are hundreds of digits long. So working out the private key from the public one would take far too long.
Bat's keys: public (3, 55)
private (7, 55)
encrypt 7:
7³ = 343
343 ÷ 55 leaves remainder 13
public again:
13³ = 2197
2197 ÷ 55 leaves remainder 52 ✗
private key:
13⁷ = 62 748 517
62 748 517 ÷ 55 leaves remainder 7 ✓Using both together
Real systems use slow asymmetric encryption to share a key, then fast symmetric encryption for the rest.
Asymmetric encryption is much slower than symmetric encryption, so real systems use both. Here is what happens when a browser connects to a secure (HTTPS) website:
- At the start, asymmetric (public-key) methods are used. They set up a shared secret key without ever sending it in the open.
- After that, the faster symmetric encryption protects everything else sent in the session.
| Asymmetric | Symmetric | |
|---|---|---|
| Speed | much slower | faster |
| Job here | sharing the key safely | protecting the rest of the session |
This gives the safe key sharing of asymmetric encryption and the speed of symmetric encryption.
What encryption does not do, and why key length matters
Encryption only stops data being understood; a secret, long key makes it strong.
Encryption does not stop:
- data being intercepted, deleted or changed;
- malware.
It only stops intercepted data being understood.
Its strength depends on two things: the key being kept secret, and the key being long.
An attacker without the key can try every possible key, one after another. This is called a brute-force attack.
Remember:An n-bit key has 2ⁿ possible values. So every extra bit doubles the number of keys the attacker has to try. A 3-bit key has 8 values; a 4-bit key has 16.
Encrypt with a shift of 3
KEY TERMS
CHECK YOURSELF
1.What does encryption actually protect against?
2.In asymmetric encryption, which key does the sender use to encrypt?
3.What is the main weakness of symmetric encryption?
4.Eve copies a message encrypted with Bat's public key. She also has Bat's public key. What can she do with them?
5.In asymmetric encryption, which key is never transmitted?
6.A key is made one bit longer. What happens to the number of possible keys?