Security
Symmetric and asymmetric encryption, digital signatures and certificates, secure connections, and quantum cryptography.
Plaintext, ciphertext and keys
Encryption uses a key to turn readable data into nonsense. Only the right key turns it back.
| Word | Meaning |
|---|---|
| Plaintext | the original, readable data |
| Ciphertext | the data after encryption; it means nothing to anyone without the right key |
| Encryption | uses an algorithm and a key to turn plaintext into ciphertext |
| Decryption | uses the algorithm and a key to turn the ciphertext back into plaintext |
Watch out:Encryption does not stop data being intercepted (caught on its way). It makes intercepted data useless.
The algorithm is usually public, so all the security is in the key. It is like a padlock: everyone can see how it works, but only the key opens it.
Each extra bit in a key doubles the number of possible keys. So a longer key takes an attacker far longer to find by trying every value.
| Key length | Possible keys |
|---|---|
| 8 bits | 2⁸ = 256 keys |
| 128 bits | 2¹²⁸ ≈ 3.4 × 10³⁸ keys |
Symmetric encryption and the key problem
Symmetric encryption uses one shared secret key. It is fast, but both sides must get the key safely first.
In symmetric encryption, the same secret key both encrypts and decrypts. It is like one door key that both locks and unlocks.
- Strength: the methods are simple and quick to carry out. So symmetric encryption is used for large amounts of data.
- Weakness: key distribution. Both ends must have the key before they start.
Watch out:If the key is sent across a network and someone intercepts it, they can read every message sent with it.
Asymmetric encryption exists to solve exactly this problem.
In the figure, change the receiver's key to see a wrong key fail. Then give Eve the key.
Asymmetric encryption: a pair of keys
In asymmetric encryption, each person has two matching keys. What one key locks, only the other key can unlock.
In asymmetric encryption, each person has two keys, made together as a pair.
| Public key | Private key | |
|---|---|---|
| Who has it | anyone: it is published for anyone to use | only its owner: it is kept secret and never sent to anyone |
Remember:Whatever one key of a pair encrypts, only the other key of the same pair can decrypt.
- The key that encrypted it cannot undo it, and nor can anyone else's key.
- Working out the private key from the public key is impossible in practice.
- Asymmetric encryption is much slower than symmetric, because its maths is far more complex.
A private message to one person
To send a secret to Bob, encrypt it with Bob's public key. Only Bob's private key can decrypt it.
To send a message that only Bob can read, encrypt it with Bob's public key.
- Anyone may have Bob's public key.
- But the only key that decrypts the ciphertext is Bob's private key, and only Bob holds it.
It is like a post box: anyone can drop a letter in, but only the owner can open it.
This is how a member of the public can send private data to one person or organisation, such as a bank or a shop. They do not need to agree a secret with them first.
Example:In the figure, Bob's public key turns 8 into 315. Only Bob's private key turns 315 back into 8.
A verified message to everyone
If Bob encrypts a message with his private key, anyone can read it, and everyone knows it came from Bob.
To send a message that everyone can read, but that could only have come from Bob, Bob encrypts it with his own private key.
- Anyone can decrypt it with Bob's public key, so it is not secret.
- But it decrypts correctly only if it was made with Bob's private key.
- Only Bob holds that key. So the message proves that Bob sent it.
| Goal | Encrypt with | Decrypt with |
|---|---|---|
| a private message to Bob | Bob's public key | Bob's private key |
| a verified message from Bob | Bob's private key | Bob's public key |
Example:In the figure, Bob's private key turns 8 into 9, and Bob's public key turns 9 back into 8.
Digital signatures are built on this idea.
Digital signatures
A digital signature is the message's digest, encrypted with the sender's private key. It proves who sent it and that nothing changed.
A hashing algorithm turns a message into a short, fixed-length message digest. It works like a fingerprint of the message.
The sender:
- puts the message through the hashing algorithm to get the digest
- encrypts the digest with their own private key: this is the digital signature
- sends the message and the signature.
The receiver:
- decrypts the signature with the sender's public key, which gives back the digest that was sent (digest A)
- hashes the message that arrived with the same algorithm (digest B)
- compares the two digests.
| Result | Meaning |
|---|---|
| A = B | the message was not altered, and it came from the owner of the private key |
| A ≠ B | the message was changed or forged |
For secrecy too, the message and signature can also be encrypted with the receiver's public key.
Digital certificates: trusting a public key
A digital certificate proves that a public key really belongs to its owner. A trusted Certificate Authority signs it.
A signature proves something only if the public key really belongs to the sender. Otherwise an attacker could publish their own key under a bank's name.
A digital certificate binds a public key to its owner, like an ID card for the key. It is issued by a Certificate Authority (CA) that everyone trusts.
How an organisation gets one:
- It sends the CA its identity details and its public key.
- The CA checks the identity.
- If it is genuine, the CA creates the certificate and signs it with its own private key.
How a browser uses it:
- It checks the certificate with the CA's public key, which is built in.
- It can then trust the key inside to check that owner's signatures.
SSL/TLS: setting up a secure connection
TLS uses slow asymmetric encryption once, to agree a fast symmetric session key that then protects all the data.
SSL, and TLS which replaced it, are protocols (sets of rules both sides follow). They give client-server communication three things:
| It gives | so that |
|---|---|
| encryption | nobody else can read the data |
| authentication | the client knows it has the real server |
| integrity | any change is detected |
Each session starts with a handshake:
- The client lists the versions and encryption methods it supports.
- The server picks one and sends its digital certificate.
- The client checks it and takes out the server's public key.
- Asymmetric encryption agrees a symmetric session key.
- That fast key then encrypts all the data.
Remember:Use TLS whenever private data crosses a network: banking, shopping, logins, email and any HTTPS website.
Quantum cryptography
Quantum cryptography sends a key as single particles of light. Anyone who spies on the key disturbs it and is found.
Quantum cryptography uses the physics of light to exchange a key. The key is sent as single photons (tiny particles of light). Each photon is polarised at an angle that stands for 0 or 1.
Measuring a photon can change it. So an eavesdropper (someone secretly listening) disturbs the key. The two ends find this by comparing part of the key.
Benefits:
- security rests on the laws of physics, not on a hard maths problem
- eavesdropping is detected
- long keys can be exchanged.
Drawbacks:
- the equipment is expensive
- it works only over relatively short distances
- error rates are high
- polarisation can change in transit
- it gives only a key, not signatures.
Encrypt with a shift of 3
KEY TERMS
CHECK YOURSELF
1.In a digital signature, which key does the SENDER use?
2.Why do real systems use asymmetric encryption to agree a symmetric key?