Edexcel International Advanced Level Computer Science, point 3.2.2
There are two main methods of encryption, which differ in how the keys are used.
a. Symmetric encryption
Definition and operation
Symmetric encryption uses the same secret key to encrypt and to decrypt.
- The sender and receiver agree on a secret key.
- The sender encrypts the message with the key and sends the ciphertext.
- The receiver decrypts it with the same key.
Known shared key
Both parties must know the key in advance, and keep it secret. Anyone who gets the key can read everything.
Key exchange
The key exchange problem: how do the two parties share the key securely in the first place? If it is sent over the network, it could be intercepted, and then all the messages are insecure. They'd need a safe channel (meeting in person, a courier) or a different method (such as asymmetric encryption, below).
With many people, the number of keys needed grows fast: every pair of people needs their own key, so people need keys. For 100 people that's 4950 keys.
Characteristics
- Fast, because the algorithms are simple, so it is suited to large amounts of data.
- Examples: AES (the modern standard), and older ones such as DES.
Benefits
- Fast and efficient, with little processing.
- Strong with a long key (AES with 128 or 256 bits).
- Suitable for bulk data (disk encryption, streaming, VPN traffic).
Drawbacks
- Key exchange is difficult and risky.
- Lots of keys to manage for many users.
- No proof of who sent a message, since both parties have the same key.
b. Asymmetric encryption
Definition and operation
Asymmetric encryption uses a pair of different but mathematically linked keys: a public key and a private key. What one key encrypts, only the other can decrypt.
- The public key can be shared with anyone (published openly).
- The private key is kept secret by its owner, and never shared.
- The receiver generates a key pair and publishes the public key.
- The sender encrypts the message with the receiver's public key.
- Only the receiver's private key can decrypt it. Even the sender can't decrypt it, and an eavesdropper who has the public key can't either.
This solves the key exchange problem: no secret has to be sent.
Digital signatures
Asymmetric keys can also prove who sent a message. The sender encrypts (signs) with their private key, and anyone can check with the sender's public key. If it decrypts correctly, it must have come from the owner of the private key. This gives authentication, and shows the message wasn't changed. In practice, the sender signs a hash of the message (a short fingerprint of it) rather than the whole message, because asymmetric encryption is slow; 16.1.1 covers digital signatures in full.
Characteristics
- Much slower than symmetric, because it uses complex mathematics with large keys (for example RSA uses 2048 bits or more).
- Examples: RSA (12.3.2), elliptic-curve methods.
Benefits
- No need to share a secret key, so safe key exchange.
- Only one key pair per person, not one key per pair of people.
- Supports digital signatures.
Drawbacks
- Slow, so not suited to encrypting large amounts of data.
- Needs more processing power.
- You must be sure that the public key really belongs to the person (otherwise an attacker can substitute their own key). Digital certificates from trusted authorities solve this.
- If the private key is lost or stolen, the data is lost or exposed.
Comparison
| Symmetric | Asymmetric | |
|---|---|---|
| Keys | One shared secret key | A public and private key pair |
| Speed | Fast | Slow |
| Key exchange | Difficult (must be shared safely) | Easy (the public key can be sent openly) |
| Number of keys for people | pairs | |
| Key length | Usually shorter (AES: 128 or 256 bits) | Usually longer (RSA: 2048 bits or more) |
| Best for | Bulk data | Exchanging keys, signatures |
| Where used | Closed systems, such as a company network, where the key can be shared safely | Open, public systems such as the Internet, where public keys can be shared openly |
| Example | AES | RSA |
Using both together
In practice, systems combine the two (hybrid encryption), as in HTTPS (TLS):
- The browser gets the server's public key.
- It uses this to send a new symmetric key securely, encrypted.
- Both sides then use fast symmetric encryption for the rest of the session.
This gives the security of asymmetric key exchange with the speed of symmetric encryption.
Worked example
Task: Priya wants to send Sam a confidential file. (a) Describe how this works with asymmetric encryption. (b) Explain why they might use symmetric encryption for the file itself.
(a)
- Sam generates a key pair and sends Priya his public key (it doesn't matter who sees it).
- Priya encrypts the file with Sam's public key.
- She sends the ciphertext. An eavesdropper can't read it, because only Sam's private key decrypts it.
- Sam decrypts it with his private key.
(b) If the file is large, asymmetric encryption would be very slow. A better method is to:
- Priya creates a random symmetric key.
- She encrypts the file with it (fast).
- She encrypts the symmetric key with Sam's public key and sends both.
- Sam decrypts the symmetric key with his private key, then decrypts the file.
This is the hybrid method.
Exam tip: state how many keys each method uses and which key does what: with asymmetric encryption, the sender uses the receiver's public key to encrypt, and the receiver uses their private key to decrypt. Mention the key exchange problem for symmetric, and slowness for asymmetric. You may be asked to complete a diagram of the encryption and decryption process, so label the keys.
Check yourself
What is the key exchange problem?
With symmetric encryption, both people need the same secret key, but sending it over a network risks it being intercepted, so sharing it safely is difficult.
Which key does the sender use to encrypt a message for Sam with asymmetric encryption, and which key decrypts it?
The sender uses Sam's public key to encrypt. Sam uses his own private key to decrypt.
Give two advantages of symmetric encryption over asymmetric
It is much faster, and it needs less processing power, so it suits large amounts of data.
Why is asymmetric encryption not used for large files?
It is slow and needs a lot of processing, because it uses complex mathematics with large keys.
How many keys are needed for 20 people to communicate privately using symmetric encryption?
20 × 19 / 2 = 190 keys.