Computer Science › Section E · Networking and the internet › Topic E.7

Cybersecurity: encryption and authentication

Your messages cross dozens of machines run by strangers, yet your bank details stay private and you can tell a real website from a fake. Encryption keeps data secret, hashes and signatures prove it is unchanged and genuine, and authentication checks that people are who they claim to be.

Why cryptography?

Passwords control who may log in to a computer, but they cannot protect data once it leaves, because messages are relayed by routers no one can vouch for. Cryptography is the study of communicating securely in the presence of adversaries. Encryption uses an algorithm and a key to turn readable plaintext into unreadable ciphertext; decryption reverses it. Modern practice follows Kerckhoffs's principle: a system should stay secure even if everything about it except the key is public. The most trusted algorithms are open standards that experts worldwide have studied and failed to break.

Worked example: a Caesar cipher

A Caesar cipher replaces each letter with the one a fixed number of places later in the alphabet, wrapping from Z back to A. With a shift of 3: 1. A becomes D, T becomes W, C becomes F, K becomes N, N becomes Q and W becomes Z; near the end, Y would wrap round to B. 2. So ATTACK AT DAWN encrypts to DWWDFN DW GDZQ. 3. Decrypting shifts each letter back 3 places. 4. Now play the attacker: the key is a shift from 1 to 25, so trying all 25 takes seconds and the readable one stands out. Check: shifting DWWDFN DW GDZQ back by 3 restores ATTACK AT DAWN. The weakness was the tiny number of keys, not the secrecy of the method.

Key length and brute force

Trying every possible key is a brute-force attack. A key of n bits has \(2^n\) possible values, so each extra bit doubles the attacker's work, and on average the right key turns up after trying half of them. Suppose an attacker can test \(10^{12}\) keys per second. The 56-bit keys of the old DES standard number about \(7.2 \times 10^{16}\), and trying them all takes about 20 hours, which is why DES was retired. A 128-bit key has about \(3.4 \times 10^{38}\) values, and trying them all would take about \(1.1 \times 10^{19}\) years. Long keys turn a quick search into an impossible one.

Symmetric encryption

In symmetric-key encryption the same secret key both encrypts and decrypts. The Advanced Encryption Standard (AES), adopted by the US National Institute of Standards and Technology (NIST) in 2001, is the most widely used, with keys of 128, 192 or 256 bits. Symmetric ciphers are very fast, so they protect the bulk of all encrypted data, from files on a laptop to video streams. Their weakness is key distribution: both parties need the same key, and sending it across the network in the open would let any eavesdropper read everything that follows.

Public-key encryption

Public-key, or asymmetric, encryption uses a pair of related keys. The public key can be given to anyone and is used to encrypt; only the matching private key, which its owner never shares, can decrypt. If Maya publishes her public key, Leo and Priya can both send her secrets, and even if Priya intercepts Leo's message she cannot read it, although she knows exactly how it was encrypted. Whitfield Diffie and Martin Hellman published the idea in 1976, and the RSA system followed in 1977; its mathematics is the subject of the later topic Public-key cryptography. Public-key methods are much slower than symmetric ones.

Certificates and certificate authorities

Public keys raise a new problem: how do you know a key really belongs to your bank and not to an impostor? An impostor who hands out its own key, a form of spoofing, could read everything sent to the bank. The answer is a certificate, a package containing a party's name and public key, digitally signed by a certificate authority (CA), an organisation trusted to check identities. Browsers and operating systems ship with a list of trusted CAs. When a website presents its certificate, the browser checks the CA's signature and that the name matches the site it asked for.

Hashes and digital signatures

A cryptographic hash function turns any input into a short fixed-size value. SHA-256 gives 256 bits, written as 64 hexadecimal digits: hello hashes to a value beginning 2cf24dba, while Hello gives one beginning 185f8db3. A good hash is one-way, since the input cannot be worked out from the hash, and even a one-character change gives a completely different result, so hashes reveal tampering. A digital signature combines a hash with a key pair. The sender computes a value from the message's hash using their private key; anyone can check it with the sender's public key. A valid signature proves who signed and that the message has not changed since.

Worked example: opening an HTTPS connection

A browser opens https://bank.example.com. HTTPS is HTTP carried over Transport Layer Security (TLS), the successor to Netscape's Secure Sockets Layer (SSL). 1. The server sends its certificate. 2. The browser checks that a trusted CA signed it and that it names bank.example.com; if not, it shows a warning. 3. In the same opening exchange, using public-key methods, browser and server agree on a brand-new symmetric session key that an eavesdropper cannot work out. 4. All further traffic is encrypted with that key using a fast symmetric cipher such as AES, with checks that detect any tampering. Check: slow public-key work happens once, at the start, and fast symmetric encryption carries the data.

Authentication

Authentication confirms identity using something you know (a password or PIN), something you have (a phone or a hardware security key) or something you are (a fingerprint or face). Multi-factor authentication (MFA) requires two or more different kinds, so a stolen password alone is not enough. Well-run systems never store passwords themselves. They store a hash of each password combined with a salt, a random value unique to each user, using a deliberately slow hash, so a stolen database cannot be reversed quickly. Passkeys replace passwords with a key pair whose private key stays on the user's device or in their password manager. Operating systems apply the same ideas, as the topic Operating system security describes.

Looking ahead: quantum computers

The public-key systems in use today rely on mathematical problems, such as factoring very large numbers, that ordinary computers cannot solve in any reasonable time. A large enough quantum computer could solve some of them quickly, which would break RSA and similar methods. No such machine exists yet (as of 2026), but data recorded today could be decrypted later. In 2024 NIST published its first post-quantum cryptography standards, algorithms designed to resist quantum attacks, and organisations have begun moving to them. Symmetric ciphers such as AES are less affected, and longer keys keep them safe.

Common mistakes to avoid

First, thinking a secret algorithm is safer than a public one; security should rest on the key. Second, encrypting with your own private key to keep a message secret; to send a secret, use the recipient's public key. Third, assuming the padlock means a site is honest; it shows the connection is encrypted and the certificate matches the name, not that the owner is trustworthy. Fourth, calling hashing encryption; a hash cannot be decrypted. Fifth, storing passwords in plain text or unsalted. Sixth, thinking one more key bit adds one more key; it doubles them.

Key takeaways

Encryption turns plaintext into ciphertext with a key, and security should depend only on keeping the key secret. Each extra key bit doubles a brute-force search. Symmetric ciphers such as AES are fast but need a shared key; public-key systems use a public key to encrypt and a private key to decrypt, but are slow. Certificates signed by trusted CAs link public keys to names. Hashes are one-way fingerprints; digital signatures prove origin and integrity. TLS combines all of these: public-key methods agree a session key, then symmetric encryption carries the data. MFA and salted password hashes strengthen authentication.

Flashcards

Flashcard

Plaintext and ciphertext

Readable data before encryption; unreadable data after

A key turns one into the other.

Test your understanding

Question 1 of 5

The ciphertext ZRUOG was made with a Caesar cipher using a shift of 3. What is the plaintext?

Question 2 of 5

A cipher's key length is increased from 80 bits to 81 bits. What happens to the number of possible keys?

Question 3 of 5

Leo wants to send Maya a message that only Maya can read, using public-key encryption. Which key should he encrypt it with?

Question 4 of 5

How does someone check a digital signature on a document from a company?

Question 5 of 5

A website asks for a password and then a code from an app on the user's phone. Why is this stronger than a password alone?

← Previous topicNext topic →