Security
A distributed system's messages cross networks that anyone can listen to and write on. This Part shows what an attacker can do to those messages, the cryptographic tools that stop each attack, and how those tools are assembled into the real protocols the exam asks you to trace: Needham–Schroeder, Kerberos and TLS.
- You willtell a policy from a mechanism, a threat from an attack, and name the five methods of attack with a picture of each.
- You willexplain secret-key and public-key cryptography, digests, signatures, MACs and certificates, and work a small RSA example by hand.
- You willtrace Needham–Schroeder, Kerberos and the TLS handshake message by message, and say what each message proves.
- You willmatch every attack to the mechanism that defeats it, the way 5-mark exam questions expect.
Why Security, and Policy vs Mechanism
On one computer, the operating system can keep users apart: it owns the memory, the disk and the keyboard. A distributed system has no such single guardian. Its resources are scattered across many machines and its messages cross networks that the system does not control. This section sets out why that makes security hard, the model the textbook uses to describe the danger, and the first distinction every exam answer on security needs: policy versus mechanism.
Why a distributed system is hard to secure
The guide gives four related reasons. Each one follows from the very things that make a system distributed.
- Many entry points. The resources are spread over many computers, and every one of those computers is a door an attacker can try.
- Exposed channels. Messages travel over networks where attackers can read them, copy them or change them.
- Sharing. Many users share the resources, so the system has to decide who may do what. The textbook (CDK) puts it as: the need for security "arises from the desire to share resources".
- Propagation. Once one service is compromised, the damage can spread to the other parts of the system that trust it.
The security model: principals and the enemy
CDK's security model (first met in Part II) describes the setting in a few words. Processes encapsulate resources: a server process holds some data (files, bank accounts, grades) and lets other processes use it only through the operations in its interface. Each request is made on behalf of someone.
A principal is a user or a process that has the authority (rights) to perform operations on resources. A request is always made by, or on behalf of, some principal.
The enemy (also called the adversary or attacker) is assumed to be able to copy any message sent across the network, and to inject any message to any destination while claiming any source.
That is a very capable enemy, and it is deliberately so: if your design survives an enemy who can see and forge everything on the wire, it survives a weaker one too. Against such an enemy, protection needs three things, marked on the figure below: secure channels (so that copying and injecting achieve nothing), access control (so that even a genuine principal can do only what it is allowed to do), and endpoint security (so that the machines at each end are not themselves compromised).
Security policies vs mechanisms exam
When people say "this system is secure", they mean two different things at once: that it allows the right things, and that it actually stops the wrong ones. The course separates them.
A security policy states what is allowed: who may access which resources, and what protection is required. It is independent of any particular technology.
A security mechanism is how the system enforces a policy: the concrete technique, such as a password check, an access list or an encryption algorithm.
The course example: the policy is "Only authorised teaching staff may change students' grades." Two mechanisms enforce it. First the system verifies the user's identity at sign-in (authentication), and then it checks that user's permissions, for example against an access control list (ACL, a list stored with a resource saying who may do what to it), before allowing the change.
A lock on a door is a mechanism. It does not secure a building on its own: someone needs a policy for using it, such as "lock it whenever nobody is guarding the entrance". A locked door with nobody deciding when to lock it is just a door.
The two are kept separate for two reasons. Without a policy you cannot judge whether a system is secure at all, because "secure" only means "enforces its policy". And the same mechanism can serve many different policies: one ACL mechanism can enforce a grades policy, a payroll policy and a file-sharing policy.
Check yourselfSelf-test Q1: distinguish a security policy from a security mechanism, with an example.
A policy states what is allowed (who may access which resources, and what protection is required), independent of technology. A mechanism is how the system enforces the policy. Example: the policy "only authorised staff may change grades" is enforced by the mechanisms of authentication at sign-in plus a permission check against an ACL.
Check yourselfWhich of these is a policy rather than a mechanism?- Every request carries a MAC computed with a session key.
- Students may read, but not modify, their own enrolment records.
- Passwords are hashed before they are stored.
- The server checks the UNIX rwx bits before opening a file.
B. It says who may do what and names no technique. A, C and D are all techniques (a MAC, hashing, permission bits) that could enforce some policy, so they are mechanisms.
- Distributed systems are hard to secure: many entry points, exposed channels, sharing and propagation.
- Principals act on resources through interfaces; the enemy can copy any message and inject any message with any source. Defence needs secure channels, access control and endpoint security.
- A policy says what is allowed; a mechanism is how it is enforced. Keep them separate.
Threats and Attacks
Before you can defend a system you have to name what you are defending it against. This section gives the course's vocabulary for that: what a threat is, the three classes of threat, and the five methods of attack, each with a picture. These definitions are asked for almost word for word in exams.
A threat is a potential danger: a way in which a security policy could be violated. An attack is the actual execution of a threat.
Some threats are obvious. Anyone who can sniff (passively read the traffic on) a shared local network can collect the passwords that cross it. Others are subtle: if clients never check who the server is, an impostor can set itself up as the official file server and collect everything clients send it. Attacks can even target the security mechanisms themselves. A replay attack, which resends an old message, can defeat a naive authentication scheme that only checks that a message was encrypted with the right key.
Three classes of threat exam
The acquisition of information by unauthorised recipients. Someone learns what they should not.
The unauthorised alteration of information. Something is changed that should not be.
Interference with the proper operation of a system without gain to the perpetrator. The point is the damage itself.
Five methods of attack exam
Every method of attack needs a channel: either access to an existing channel, or a new channel that masquerades as an authorised one. The table gives the five methods with the guide's definitions; the pictures after it show each one happening. In all of them Alice is blue, Bob (or the server) is green, and the attacker is red.
| Attack | Definition | Example |
|---|---|---|
| Eavesdropping | Obtaining copies of messages without authority | Packet sniffing |
| Masquerading | Sending or receiving messages using another principal's identity without authority | Spoofed address, fake server |
| Message tampering | Intercepting messages and altering them (or substituting others) before passing them on | Man-in-the-middle |
| Replaying | Storing intercepted messages and sending them later | Resend "pay Bob $100", so Bob is paid twice |
| Denial of service | Flooding a channel or other resource to deny access to others | Saturating a server |
Some attacks in more detail
Man-in-the-middle (MITM)
A man-in-the-middle attack is the most dangerous form of tampering. Mallory intercepts the first messages of a key exchange and substitutes his own keys. From then on he decrypts each message, reads or alters it, re-encrypts it with the correct key and forwards it, while both ends believe the channel is secure. Step through it below. (A public key is a key anyone may know that encrypts messages only the matching private key can decrypt; 10.4 explains these properly.)
- Alice wants to send Bob a secret. She needs Bob's public key first. Mallory controls the path between them.
- Message 1. Alice asks for Bob's public key. Mallory intercepts the request; Bob never sees it.
- Message 2. Mallory asks Bob for his public key himself, so that he will be able to talk to Bob later.
- Message 3. Bob replies with his genuine public key KBpub, to Mallory.
- Message 4. Mallory sends Alice his own public key KMpub, claiming it is Bob's. Nothing in the message lets Alice tell the difference. This substitution in the first messages is the whole attack.
- Message 5. Alice encrypts her message with what she thinks is Bob's key. Mallory decrypts it with his private key KMpriv, reads it, and can alter it to M′.
- Message 6. Mallory re-encrypts M′ with Bob's real key and forwards it. Bob decrypts it successfully.
- Both ends believe the channel is secure, and every message is read (and perhaps changed) by Mallory. The defence: public keys authenticated by certificates that chain to a root key obtained over a trusted path (10.6). Then message 4 would fail Alice's check.
Trust-on-first-use carries exactly this risk. SSH, for example, asks you to accept the server's key the first time you connect, and remembers it afterwards. No certification authority (CA, a trusted third party that vouches for keys) binds that key to the server's identity, so a man in the middle who is present at the very first connection is trusted from then on. This was a real exam question.
Past exam2016 Q7(a) · 2 marks Some systems, such as secure shell, require the user to explicitly trust a public key provided by the server when connecting for the first time. Name the security risk and explain why it is a risk.
- The risk is a man-in-the-middle attack, which is the weakness of trust-on-first-use.
- It is a risk because no certificate from a trusted CA binds the key to the server's identity, so the user cannot tell whether the key really belongs to the server.
- An attacker who intercepts the first connection can therefore present his own public key. The user accepts it, and from then on the attacker can decrypt, read or alter, re-encrypt and forward all traffic.
- After that, the wrong key is cached and trusted. The defence is to verify the key's fingerprint out of band, or to use CA-signed certificates.
Replay, and the idea of freshness
Replay works even against messages that are encrypted and authenticated, because the attacker never needs to read or forge anything: he copies bits and sends them again later. The receiver decrypts them perfectly. What is missing is freshness, some evidence that a message is new rather than a recording.
- A nonce ("number used once") is a random value that the receiver generates and expects to see in the reply. A recorded reply carries an old nonce, so it is rejected.
- A timestamp records when a message was made; the receiver rejects messages that are too old.
- A sequence number counts messages on a connection; a replayed number is a duplicate.
Denial of service (the lecturer's notes)
In a denial-of-service (DoS) attack, the attacker makes excessive, pointless invocations that overload the network bandwidth or the server's CPU. The lecturer's example: a building's electronic door locks can be disabled by flooding their controller with invalid requests, so that genuine card swipes are never processed. A firewall cannot stop such a flood, because the flood arrives through the very entrance legitimate traffic uses; the remedy has to be applied upstream, by quality-of-service (QoS) throttling.
Threats from mobile code
Mobile code is code downloaded from elsewhere and run locally, such as a Java applet. It runs inside the host process, so it can use anything the host can. That makes it a potential Trojan horse: code that claims an innocent purpose but uses resources that are available to the host and not to the code's author. The Java sandbox defends against this in four ways, numbered in the figure.
Information leakage and traffic analysis
Encrypting the contents of messages is not enough to stop leakage. Who talks to whom, when and how much still reveal information, and exploiting that is called traffic analysis. A sudden flood of messages to a stock dealer reveals heavy trading even if every message is encrypted; an anonymous user who always connects on Thursday afternoons can be identified by that habit. The countermeasure is to attach security levels to information and to channels, so that high-level information never flows into lower-level channels. This is the Bell–LaPadula model.
Check yourselfSelf-test Q2: distinguish a threat from an attack, and list and explain the three classes of threat.
A threat is a potential violation of policy; an attack is the actual execution of a threat. The three classes of threat are: (1) leakage, the unauthorised acquisition of information; (2) tampering, the unauthorised alteration of information; (3) vandalism, interfering with a system's operation without gain to the attacker.
Check yourselfSelf-test Q3: list and explain the methods of attack, and describe man-in-the-middle.
The five methods: eavesdropping (obtaining copies of messages without authority), masquerading (sending or receiving messages using another principal's identity without authority), message tampering (intercepting messages and altering them before passing them on), replaying (storing intercepted messages and sending them later; note that replay works even on encrypted messages) and denial of service (flooding a channel or resource to deny access to others).
In a man-in-the-middle attack, the attacker intercepts the first key exchange and substitutes his own keys, then decrypts, re-encrypts and forwards each message. It is defeated by certificate-authenticated keys.
Check yourselfAn attacker floods a building's door-lock controller with invalid requests. Which class of threat is this, which method of attack, and why won't the building's firewall help?
It is vandalism (interference without gain to the attacker) carried out by denial of service. A firewall forwards authorised-looking traffic through the normal entrance, and the flood arrives through that same entrance, so the firewall cannot separate it from genuine requests; the remedy is QoS throttling upstream.
Check yourselfTrue or false: if every message is encrypted with a strong key, an attacker learns nothing from the traffic.
False. Traffic analysis still reveals who talks to whom, when and how much (the stock-dealer and Thursday-afternoon examples). The countermeasure is information-flow control with security levels (Bell–LaPadula), not stronger encryption.
- A threat is a potential policy violation; an attack executes one. Threat classes: leakage, tampering, vandalism.
- Five methods of attack: eavesdropping, masquerading, message tampering, replaying, denial of service. MITM is tampering with the first key exchange; replay beats encryption, so freshness is needed.
- Mobile code is countered by the Java sandbox; traffic analysis by information-flow control, not encryption.
Secure Transactions and Secure Design
Knowing the attacks, we can ask two practical questions. What exactly must be protected when someone buys something online? And how do you go about designing a system so that it resists attacks you have not even thought of yet? The answers are a list of requirements and a list of worst-case assumptions, and both are favourite exam material.
Requirements for web purchases exam
Email, purchases, banking and micro-transactions all depend on security. For a purchase over the web, the guide lists four security requirements.
- Authenticate the vendor to the buyer. The buyer must know they are dealing with the intended vendor's server, not an impostor.
- Protect the buyer's payment details. They must be kept from third parties and delivered unaltered.
- Protect the vendor's responses. Goods (for example, downloads) and confirmations must reach the buyer unaltered and undisclosed.
- Support first-time buyers. No prior contact, shared secret or third party should be needed. The slide calls this a policy; CDK calls it a system requirement, imposed by the scale of the Internet.
Banking adds two more requirements: authentication of the account holder (the bank must know who is asking), and non-repudiation, which means the account holder cannot later deny having taken part in a transaction. TLS (10.11) meets requirements 1–4; non-repudiation needs digital signatures (10.8).
Designing secure systems
Complete security is hard to guarantee, much as bug-free software is. So the design method is not "make it perfect" but: list the threats, then show that each one is prevented by a mechanism, either by informal argument or by logical proof. The table in 10.12 is exactly such a list.
Auditing backs this up, because something will be missed. The system keeps a secure log of sensitive actions, such as failed sign-ins and permission changes, and the log is analysed for unusual trends. Each record holds four things:
Security also has to be weighed against other concerns. You balance cost against risk, considering the potential damage, the cost of protection and the effort an attacker would need. And you keep the system usable: security measures must not obstruct legitimate users, or they will be bypassed.
Worst-case assumptions and design guidelines exam
Secure design starts from worst-case assumptions about the environment. Each assumption leads directly to a guideline, and there are six.
Interfaces are exposed
Interfaces must be open to new clients (a public socket is like a front door), so assume any message can be sent to any interface.Networks are insecure
Messages can be read, copied and falsified; sources can be faked and addresses spoofed.Limit lifetime and scope of each secret
Keys and passwords break given time. The longer a secret is used and the more widely it is shared, the riskier it is, so use session keys and expiry.Algorithms and code are available to attackers
So publish algorithms for scrutiny (open source helps) and rely only on the secrecy of the keys.Attackers may have large resources
Assume they have the most powerful computers of the system's lifetime, plus a few orders of magnitude.Minimise the trusted base
Every component that enforces security, and everything it relies on, must be trusted, and any bug there is a weakness. So keep that trusted base small."List and explain worst-case assumptions" wants each item with its one-line reason, not just the name. In Tutorial 10 (official answers) the tutors gave four of the six: networks are insecure, the source code is known to the attacker, interfaces are exposed, and the attacker has unlimited computing resources (10.12). A full answer to the guide's Self-test Q4 adds the method: list the threats and show each one is countered, keep audit logs, and balance cost and usability.
Check yourselfSelf-test Q4: what are the worst-case assumptions and design guidelines for a secure system?
The six: interfaces are exposed (any message can reach any interface); networks are insecure (messages read, copied, falsified, sources faked); limit the lifetime and scope of each secret (use session keys and expiry); algorithms and code are available to attackers (publish algorithms, rely only on secret keys); attackers may have large resources (the biggest computers of the system's lifetime, plus a few orders of magnitude); minimise the trusted base (every trusted component is a potential weakness). Also say that you list the threats and show each is countered, keep audit logs, and balance cost against risk and usability.
Check yourselfWhich of these is not one of the course's secure-design guidelines?- Keep the trusted computing base small.
- Keep the encryption algorithm secret so attackers cannot study it.
- Use short-lived session keys.
- Assume any message can be sent to any interface.
B. The guideline is the opposite: assume algorithms and code are available to attackers, publish the algorithm for scrutiny, and rely only on the secrecy of the keys. "Secret algorithms" is listed among the common pitfalls.
Check yourselfWhy is "support first-time buyers" the requirement that makes web commerce hard, and what does the guide note about its name?
Because the buyer and vendor share no secret and have no prior contact, so the shared-key techniques of 10.5 cannot be bootstrapped; something like public-key certificates is needed. The slide calls it a policy, while CDK calls it a system requirement, imposed by the scale of the Internet.
- Web purchases: authenticate the vendor, protect payment details, protect responses, support first-time buyers. Banking adds account-holder authentication and non-repudiation.
- Design method: list threats, show each is prevented; keep a secure audit log; balance cost, risk and usability.
- Six guidelines: exposed interfaces, insecure networks, limit secrets' lifetime and scope, public algorithms, powerful attackers, small trusted base.
Cryptography Fundamentals
Almost every defence in this Part is built from cryptography: the science of transforming messages so that only the right people can read them, or so that changes to them can be detected. Before the protocols, you need the cast of characters, the notation the protocols are written in, and the two families of keys.
The cast and the notation
Security protocols are written as conversations between named people. The names are a convention from CDK (Fig 11.1), and they tell you each participant's role at a glance.
| Notation | Meaning |
|---|---|
| KA, KB | Alice's and Bob's secret keys (in protocols with a server, each is shared only with that trusted server) |
| KAB | A secret key shared by Alice and Bob |
| KApriv, KApub | Alice's private key (known only to Alice) and public key (published by Alice for anyone to read) |
| {M}K | Message M encrypted with key K |
| [M]K | Message M signed with key K |
Encryption, decryption and keys exam
Encryption is encoding a message so as to hide its contents; the result is ciphertext. The original readable message is the plaintext. Decryption is recovering the plaintext from the ciphertext. A key is a parameter of the encryption algorithm such that the encryption cannot be reversed without knowing the key.
In symbols: {M}K = E(K, M) and M = D(K, {M}K). The slide writes E(M, k), which means the same thing.
What each kind of key gives you
The slide sets out what each kind of key gives you, and this table of three cases is the foundation of everything that follows. Read each row as "who can undo this?".
In every case, secret keys and private keys must be stored securely. And there is a cost: public-key algorithms need 100–1000× the processing of secret-key ones.
Symmetric vs asymmetric cryptography exam
There are two families. In secret-key (symmetric) cryptography, one key both encrypts and decrypts, so the two parties must share it. In public-key (asymmetric) cryptography, each party has a pair of keys: what one key encrypts, only the other can decrypt. The lecturer's image for a key pair is a sheet of paper torn in half: the two halves match each other and nothing else.
The table compares the two families. Notice the tension between the speed row and the key-distribution row: each family is good at exactly what the other is bad at, which is why real protocols use both (10.7).
| Secret-key (symmetric) | Public-key (asymmetric) | |
|---|---|---|
| Keys | One shared key: D(K, E(K, M)) = M | A pair: D(Kd, E(Ke, M)) = M, and one key cannot feasibly be derived from the other |
| Basis | One-way function (XOR, shifts, transpositions) | Trap-door function on large numbers (factoring, elliptic curves) |
| Speed | Fast, used for bulk data | 100–1000× slower, used for keys and digests |
| Key distribution | Hard: needs a secure channel or trusted server per pair | Easy: publish the key, but it must be authenticated by a certificate |
| Signatures | MACs only, no non-repudiation | Signatures with non-repudiation |
| Examples | TEA, DES, 3DES, IDEA, AES | RSA, elliptic curve |
- A one-way function is one where FK(M) is easy to compute but its inverse is infeasible to compute.
- Brute force means trying keys until one works. An N-bit key has 2N possible values, so on average an attacker needs 2N−1 tries: cracking time is exponential in key length, and every extra bit doubles it.
- A trap-door function is a one-way function with a secret exit: its inverse is easy only if you know the secret. Public-key cryptography is built on these.
Confusion and diffusion exam
How does a cipher actually hide a message? Claude Shannon named two properties that concealment relies on, together with the secrecy of the keys (never of the algorithm).
- Confusion combines each block with the key by non-destructive operations, such as XOR and circular shift. This obscures the relationship between M and {M}K and defeats character-frequency analysis (counting which letters are common). Enigma used single-letter blocks, and it fell to exactly that kind of statistical analysis.
- Diffusion works by transposing parts of each block, to dissipate the patterns and redundancy in the plaintext. Cipher block chaining (CBC, 10.7) spreads the redundancy further, across blocks. Stream ciphers cannot diffuse, since they have no blocks.
Check yourselfAlice encrypts a message with her own private key KApriv and sends it. Who can read it, and what has she achieved?
Anyone holding KApub can decrypt it, and KApub is public, so there is no secrecy. What she has achieved is proof that the message came from her, because only she holds KApriv. This is the basis of digital signatures. To send Bob a secret she should encrypt with Bob's public key instead.
Check yourselfDES uses a 56-bit key. On average, how many keys must a brute-force attacker try, and what happens to that number if the key grows by one bit?
An N-bit key takes 2N−1 tries on average, so 255 for DES. Each extra bit doubles the key space and therefore doubles the average work: cracking time is exponential in key length.
Check yourselfSelf-test Q5 (part): compare symmetric and asymmetric cryptography in three dimensions.
Speed: symmetric is fast; asymmetric is 100–1000× slower. Key distribution: symmetric needs a secure channel or trusted server per pair; asymmetric just publishes the public key (authenticated by a certificate). Signatures: symmetric gives only MACs, without non-repudiation; asymmetric gives true signatures with non-repudiation. (Also: symmetric is based on one-way functions, asymmetric on trap-door functions.) The "why hybrids" half of Q5 is in 10.7.
Check yourselfWhich property, confusion or diffusion, did Enigma lack enough of, and how was it broken?
Enigma encrypted single-letter blocks, so the relationship between plaintext and ciphertext letters kept the statistics of the language; it fell to statistical (character-frequency) analysis. Confusion with larger blocks obscures that relationship, and diffusion spreads patterns across a block.
- {M}K = E(K, M); M = D(K, {M}K). The algorithm is public; only the key is secret.
- {M}KAB: only Alice or Bob. {M}KApriv: anyone, so no secrecy but proof of origin. {M}KApub: only Alice.
- Symmetric: fast, hard key distribution. Asymmetric: 100–1000× slower, easy key distribution, real signatures.
- Ciphers rely on confusion (XOR, shifts with the key) and diffusion (transposition).
The Four Basic Scenarios exam
Cryptography is a set of tools; this section shows them used. CDK gives four short scenarios, each a tiny protocol. Each one solves one problem and leaves another open, and the open problems are exactly what the big protocols later in this Part (Needham–Schroeder, Kerberos, TLS) were built to close. So read each scenario asking two questions: what does it achieve, and what can still go wrong?
First, the four uses of cryptography the scenarios demonstrate:
- Secrecy prevents eavesdropping.
- Integrity detects tampering, using redundancy such as a checksum placed inside the encryption, or a MAC (message authentication code, 10.8).
- Authentication works because successful decryption with a key known only to two parties proves that the sender knew that key.
- Digital signatures give authentication, integrity and non-repudiation together.
Scenario 1: secret communication with a shared key
The simplest case: Alice and Bob already share a secret key KAB. Alice encrypts each message Mi with it, and Bob decrypts. If the decrypted result contains an agreed value, such as a checksum, Bob knows the message is from Alice (only she has the key) and has not been altered (any change would break the checksum). Step through it, including what Mallory can still do.
- Alice and Bob both hold KAB (the gold keys). For now, don't ask how Bob got his copy.
- Message 1. Alice encrypts Mi with E(KAB, Mi) and sends {Mi}KAB. It passes Mallory on the way.
- Bob decrypts with D(KAB, ·). The result contains the agreed checksum, so he knows the message is from Alice and unaltered. Secrecy, integrity and authentication, all from one shared key.
- But Mallory has recorded a copy of the ciphertext. He cannot read it, and he does not need to.
- Message 2. Later, Mallory replays the same bits. Bob decrypts them perfectly, the checksum is fine, and he acts again: if Mi was "pay Mallory $100", Bob pays twice.
- Two problems remain. Problem 1, key distribution: how does KAB reach Bob securely in the first place? Problem 2, freshness: nothing distinguishes an old message from a new one. Scenarios 2 and 3 attack problem 1; nonces and timestamps attack problem 2.
Scenario 2: an authentication server
To solve key distribution, bring in a trusted server, Sara. Sara knows a secret key for every principal: KA, derived from Alice's password, and KB, the key of Bob, who here is a file server. Sara never hands out these long-term keys; she hands out tickets. This is a simplified version of the Needham–Schroeder protocol of 10.9.
A ticket is an encrypted item, issued by an authentication server, that contains the identity of the principal it was issued to and a session key. It is encrypted with the key of the server it is meant for, so the holder can pass it on but cannot read or alter it.
A session key is a fresh secret key created for one conversation and thrown away afterwards (guideline 3: limit the lifetime of secrets).
- Three principals. Alice's key KA is derived from her password; Bob is a file server with key KB; Sara knows both.
- Message 1. Alice asks Sara for a ticket for Bob. It is sent unencrypted: it contains no secrets.
- Message 2. Sara replies with {{Ticket}KB, KAB}KA: a ticket sealed under Bob's key, plus a fresh session key KAB, all wrapped in Alice's key.
- Step 3. Alice decrypts the reply with KA, derived from her password. Only the real Alice can do this, so the password never had to be sent. She keeps KAB and the ticket, which she cannot read or alter because it is encrypted with KB.
- Message 4. Alice sends Bob {Ticket}KB, Alice, R: the sealed ticket, her name, and her request R.
- Step 5. Bob decrypts the ticket with KB. It is {KAB, Alice}KB, so it was made by Sara (only she shares KB). He checks the name against "Alice" and keeps KAB. From then on his replies are encrypted with KAB.
- Two weaknesses. No replay protection: nothing in message 4 is fresh, so Mallory can record and resend it. Needham–Schroeder fixes this with nonces, Kerberos with timestamps. And Sara must know everyone's key in advance, which works inside one organisation but does not scale to e-commerce.
Alice and Bob trust an authentication server, Sara. Bob shares a secret key KB with Sara, and Sara securely provides Alice with a session key KAB and a ticket for Bob. Alice sends Bob the ticket {Alice, KAB}KB together with the message {Alice}KAB. (a) Explain how Bob decrypts these two items and checks Alice's claimed identity. (3 marks) (b) Identify an attack that this exchange is vulnerable to, and explain how an attacker could carry it out without knowing either secret key. (2 marks)
This is Scenario 2's ticket. Staff released no solutions to the practice exam, so what follows is the guide's worked answer.
(a) Bob checks Alice's claim in three steps.
- He decrypts the ticket with KB, which only he and Sara know. It decrypts to a sensible result, a name and a key, so it must have been made by Sara, whom he trusts. From it he learns the session key KAB, and that Sara issued it for Alice.
- He decrypts the second item with the KAB he has just obtained, and gets the name "Alice".
- He compares the two names. They match, and only someone who knows KAB could have produced {Alice}KAB. Apart from Sara, the only party who knows KAB is Alice, because Sara delivered it to her securely. So Bob concludes that the sender is Alice, and he uses KAB for the rest of the session.
The second item plays the part of a Kerberos authenticator (10.10), but without a timestamp.
(b) The exchange is open to a replay attack, because neither item contains anything fresh: no nonce, timestamp or sequence number. Mallory eavesdrops and copies both encrypted items as Alice sends them, along with the request that follows. Later he resends the copies unchanged to Bob. Bob decrypts them exactly as before, the names match, and he accepts the sender as Alice, so Mallory masquerades as Alice and makes Bob repeat whatever Alice's request did, such as a payment. He needs neither KB nor KAB, because he never decrypts or alters anything. He cannot read Bob's replies, but by then the damage is done. The defence is freshness: a timestamp in the authenticator and a lifetime in the ticket, as in Kerberos, or a nonce challenge from Bob, {NB}KAB answered by {NB − 1}KAB, as in Needham–Schroeder.
Challenge–response exam
Scenario 2 hides a clever idea in message 2: Alice proved she knows her password without ever sending it. That idea has a name, and it appeared on the 2016 exam.
A way for one party to prove it knows a secret (a password or key) without sending the secret. First the verifier issues a challenge: a fresh nonce, or data encrypted under the secret. Then only someone who knows the secret can produce the correct response.
Because each challenge is fresh, a recorded response is useless later, which defeats replay. Because the secret never crosses the network, eavesdropping is defeated too.
The course gives four examples, and you will meet three of them again in this Part:
- Message 2 of Scenario 2. The reply is encrypted in Alice's password-derived key, so only the real Alice can use it. This was Needham–Schroeder's key insight: passwords need not be sent to be checked.
- Needham–Schroeder messages 4–5 (10.9): B sends {NB}KAB and A replies {NB − 1}KAB.
- Kerberos message 2 and its authenticators (10.10) work the same way.
- So does WEP when a device joins a wireless base station.
Past exam2016 Q7(b) · 3 marks Explain what is meant by challenge-response and give an example.
- Definition. Challenge–response is an authentication technique in which a party proves knowledge of a secret (a key or password) without transmitting the secret. The verifier sends a fresh challenge, either a nonce or data encrypted under the secret, and only someone who knows the secret can compute the correct response. Because the challenge is fresh, a recorded response cannot be replayed, and eavesdroppers never see the secret.
- Example (Needham–Schroeder). B sends {NB}KAB, and A proves it holds KAB by returning {NB − 1}KAB.
- Example (Kerberos login). The AS replies with {KCT, n}KC, encrypted under the password-derived key KC. Only the real user can decrypt it, and the password never crosses the network.
Scenario 3: public keys deliver a shared key (hybrid)
Scenario 2 needs a server that knows everyone's secret, which is impossible on the open Internet. Public keys avoid that: Bob can publish KBpub, and anyone can use it to send him a secret. But public-key operations are slow, so they are used only once, to deliver a fast symmetric session key. The tutors' Tutorial 10 version of this (T10-5) calls the third party a key distribution service.
- Bob has a key pair; KBpriv never leaves him. A trusted authority vouches for KBpub.
- Step 1. Alice obtains a certificate for Bob's public key KBpub, signed by a trusted authority. (A certificate is a signed statement binding a name to a key; 10.6.)
- Alice checks the certificate's signature, takes KBpub out of it, and creates a new session key KAB. The tutors' answer only says "take KpubB from the certificate"; in an exam, add the signature check, because without it a man in the middle could hand her his own key.
- Step 2. Alice sends keyname, {KAB}KBpub. Step 3. Bob decrypts with KBpriv. Only Bob holds KBpriv, so only Bob can recover KAB.
- From now on, the slow public-key operation is finished and the fast symmetric key KAB carries the data. This combination is called a hybrid scheme.
- The problem is MITM (the highlighted reply): Mallory can intercept Alice's request for Bob's certificate and return his own key instead. The defence is that the certificate must be signed by a key Alice obtained totally securely. That raises the slide's question: how does Alice trust the authority, and how does she know its key is genuine? The answer is certificate chains (10.6).
Scenario 4: digital signature
The last scenario is about proof of origin rather than secrecy. Alice publishes a message M together with {Digest(M)}KApriv, and Bob verifies it with KApub. A digest (or secure hash) is a short, fixed-length fingerprint of a message; 10.8 covers digests and signatures in full.
- Alice has a message M that she wants to sign. It need not be secret.
- She computes Digest(M), a short fixed-length fingerprint of M.
- She encrypts the digest with her private key: {Digest(M)}KApriv. Only she can make this, because only she holds KApriv.
- She publishes M together with the signature. M itself is in the clear.
- Bob decrypts the signature with Alice's public key KApub, giving h1, the digest Alice signed.
- Bob computes Digest(M) himself from the M he received, giving h2.
- If h1 = h2, the signature is genuine and M is unaltered: only KApriv could produce something that decrypts correctly with KApub, and any change to M would change its digest.
Check yourselfIn Scenario 2, why can't Alice read or change the ticket, and why does that matter to Bob?
The ticket is encrypted with KB, which only Bob and Sara know. Alice can forward it but cannot open it or forge a different one. That matters because Bob trusts the ticket's contents (the name "Alice" and KAB) precisely because only Sara could have made it.
Check yourselfMatch each scenario to the problem it leaves open: Scenario 1, Scenario 2, Scenario 3.
Scenario 1 (shared key): key distribution and freshness (replay). Scenario 2 (authentication server): no replay protection, and the server must know everyone's key, so it does not scale to e-commerce. Scenario 3 (public key carries the session key): man-in-the-middle, unless the certificate is signed by a key obtained totally securely, which leads to certificate chains.
Check yourselfAn MCQ near-miss: in Scenario 3, Alice sends {KAB}KBpub. Which is true?- Anyone with Bob's public key can recover KAB.
- Only Bob can recover KAB, provided KBpub really is Bob's.
- It proves to Bob that the message came from Alice.
- It must be repeated for every message, because KAB is slow.
B. Encryption with Bob's public key can be undone only with KBpriv. A is the mistake of confusing the two halves; C is false because anyone can encrypt with Bob's public key, so it says nothing about the sender; D has it backwards, since KAB is the fast symmetric key and the public-key step happens once. The proviso in B is the MITM problem.
- Scenario 1 (shared key) gives secrecy, integrity and authentication but leaves key distribution and freshness open.
- Scenario 2 (authentication server, tickets) solves distribution inside an organisation, but has no replay protection and does not scale.
- Scenario 3 (hybrid) uses a certified public key once to deliver KAB; its danger is MITM, answered by certificate chains. Scenario 4 signs a digest with the private key.
- Challenge–response proves knowledge of a secret without sending it, defeating both replay and eavesdropping.
Certificates and Access Control
Scenario 3 ended with a question: how does Alice know that a public key really belongs to Bob? Certificates are the answer, and they are how the man-in-the-middle attack is defeated. The second half of this section turns to what happens after a principal has been identified: deciding what it may do (access control), what evidence it presents (credentials), and the coarse outer wall many organisations add (firewalls).
What a certificate is exam
A certificate is a statement, signed by an appropriate authority. A public-key certificate is the commonest kind: a statement binding a name to a public key, signed by an authority the reader trusts.
CDK's example (Fig 11.3) is not about keys at all, which makes the idea clearer: Alice's bank issues a certificate saying that account 6262626 belongs to Alice, so that Alice can prove it to a vendor, Carol.
So Carol needs a public-key certificate for Bob's Bank, signed by an authority she trusts more, for example "Fred, the Bankers Federation". But then Carol must also know Fred's key authentically, so the trust problem is recursive. The recursion has to stop somewhere, and it stops by getting the top key out of band: handed over in person, or pre-installed with the software.
Certificate chains
That recursion, written down, is a certificate chain. At the top is the root: a self-signed certificate (one signed with its own private key) that is widely distributed, for example with the operating system or browser, and trusted by fiat. Its private key must be closely guarded. Below the root, each certificate is signed by the issuer above it. For example, Sara certifies Carol's key and Carol certifies Bob's. If Alice already trusts Carol, she can verify Bob's certificate directly; otherwise she first verifies Carol's using Sara's certificate.
Issues and requirements. Chains bring their own problems. You have to choose whom to trust as the root, and trust depends on purpose (a bank root for banking, say). Private keys can be compromised. And long chains are fragile, since each extra link is another place the chain can break. To make chains work there must be a standard format, and agreed rules for building chains, including what counts as a trusted authority.
Expiry and revocation. Certificates also need a way to stop being valid. Each one carries a validity period, and expired certificates are rejected. Revocation invalidates a certificate before it expires, for example after its private key is compromised. Revocation is cumbersome, because every holder of a copy must be told, through revocation lists or online checks. That is why expiry dates are the usual mechanism.
X.509
X.509 is the standard certificate format. It is part of the X.500 directory standard (Part IX) and is used in TLS. An X.509 certificate binds a public key to a subject by the issuer's signature, and certification authorities (CAs) such as Verisign issue them. Its fields fall into five groups:
To verify an X.509 certificate, you first obtain the CA's certificate from a reliable source, and then validate the signature with the CA's public key.
A certificate binds a name to a key. It does not vouch for honesty. A valid certificate for evil-shop.com proves only that you are talking to whoever owns that name.
Access control
Authentication establishes who is asking; access control then decides what they may do. Requests take the form <op, principal, resource>, and the server first authenticates the principal, then checks its rights for that operation on that resource.
Rights are grouped by protection domain: an execution environment shared by processes, holding a set of <resource, rights> pairs. A domain is usually created per principal at login; in UNIX, a process's domain comes from its user and group IDs. A protection domain is an abstraction, and it is implemented in one of two ways:
- With capabilities, each process holds unforgeable tokens of the form <resource id, permitted operations, authentication code (signature)>, and requests take the form <op, userid, capability>.
- With access control lists (ACLs), each resource stores <domain, operations> entries. The UNIX rwx bits for owner, group and others are an example.
The table compares the two. Notice how they trade off: ACLs give immediate revocation, while capabilities are fast to check and easy to delegate, but hard to revoke and dangerous if stolen.
| ACL | Capability | |
|---|---|---|
| Stored with | The resource | The principal |
| Check | Authenticate, then search the list | Validate the token, check op is in its set (fast) |
| Revocation | Immediate (edit the list) | Hard (needs expiry or revocation lists) |
| Theft | Must steal an identity | A stolen token works for the thief |
| Delegation | Awkward | Easy (pass the token) |
Credentials, delegation and firewalls
Credentials are the evidence a principal presents when requesting access, for example a certificate of identity that the server checks against an ACL. A credential "speaks for" its principal: a request signed with a user's private key is treated as coming from that user. Credentials can also be combined, which allows two-person rules (two signatures needed), role-based credentials (rights given to "lecturer" rather than to a named person), and so on.
Delegation is needed when a server must act for a user. For example, a print server needs to read the user's protected file in order to print it. The user gives it a signed delegation certificate (or a capability). The delegation is limited to a subset of the user's rights, and it is time-limited.
Firewalls intercept all external traffic and forward only authorised traffic. They have clear limits: they give no protection against insiders, they are coarse-grained, and they are ineffective against DoS floods.
Check yourselfSelf-test Q9: explain certificates and certificate chains.
A certificate is a statement signed by an authority, binding a key to a name. In a chain, each certificate is verified with its issuer's public key, all the way up to a pre-installed, self-signed root. The problems are choosing the root, key compromise, long chains and revocation.
Check yourselfSelf-test Q13: compare ACLs and capabilities.
An ACL is stored with the resource; the server authenticates the principal and searches the list; revocation is immediate (edit the list); a thief must steal an identity; delegation is awkward. A capability is held by the principal; checking is fast (validate the token, check the operation is in its set); revocation is hard (needs expiry or revocation lists); a stolen token works for the thief; delegation is easy (pass the token). In one line: ACLs give immediate revocation, capabilities give fast checks and easy delegation but are vulnerable to theft and hard to revoke.
Check yourselfWhy do most systems rely on expiry dates rather than revocation, and when is revocation still needed?
Revocation is cumbersome: every holder of a copy of the certificate must be told, through revocation lists or online checks. Expiry needs no communication at all; the certificate simply stops being accepted after its Not After date. Revocation is still needed when a certificate must die before it expires, typically because its private key has been compromised.
Check yourselfA company firewall blocks all inbound connections except to its web server. Name two threats it still does not address.
Any two of: insiders (they are already inside the wall); DoS floods against the web server (the flood arrives through the allowed entrance); anything finer-grained than the firewall's coarse rules, such as a legitimate-looking request from an outsider that abuses the web server itself.
- A certificate is a statement signed by an authority; a public-key certificate binds a name to a key. Trust recurses up a chain to a self-signed root obtained out of band.
- Chains need a standard format (X.509) and agreed rules; their problems are choosing the root, compromised keys, fragile long chains and revocation. Expiry is the usual way certificates die.
- Access control: ACLs (with the resource, instant revocation) vs capabilities (with the principal, fast, easy delegation, hard to revoke). Delegation is a subset of rights for a limited time. Firewalls miss insiders and floods.
Cryptographic Algorithms
So far, "encrypt with K" has been a black box. This section opens it a little: how a cipher handles a message longer than one block, which symmetric algorithms exist and which are broken, how RSA (the standard public-key algorithm) works with numbers small enough to do by hand, and why real protocols combine the two families. Remember the exam is closed book with no calculator, so the RSA example is worth practising on paper.
Block ciphers and cipher block chaining
A block cipher splits the message into fixed-size blocks (often 64 bits), pads the last block to full size, and encrypts each block. Encrypting the blocks independently has two drawbacks: it shows repeated patterns (identical plaintext blocks give identical ciphertext blocks), and it gives no integrity check (an attacker can delete, reorder or repeat whole blocks unnoticed).
Cipher block chaining (CBC) exam links the blocks together. Each plaintext block is XORed with the previous ciphertext block before it is encrypted:
Ci = E(K, Pi ⊕ Ci−1) and to decrypt Pi = D(K, Ci) ⊕ Ci−1
Decryption works because XOR is its own inverse: (X ⊕ C) ⊕ C = X. An initialisation vector (IV), for example a timestamp, is used as the "previous block" for the first block, so that identical messages encrypt differently. CDK points out one limitation: CBC needs a reliable channel, because losing a block breaks the decryption of the block after it.
Stream ciphers
Some data cannot wait for a full block: voice, for example. Stream ciphers are used for such real-time data. A keystream generator produces a stream of bits, for example a random-number sequence from an agreed seed, encrypted with the shared key. The ciphertext is plaintext ⊕ keystream, and the receiver, running the same generator, XORs the same keystream to decrypt. This is secure only if the keystream is never reused.
Symmetric algorithms
The table compares the symmetric algorithms by key and block size. The one to remember as a warning is DES, whose 56-bit key was brute-forced.
| Algorithm | Key / block (bits) | Notes |
|---|---|---|
| TEA | 128 / 64 | 32 rounds of add, XOR and shift. Tiny; shows confusion and diffusion |
| DES | 56 / 64 | 16 rounds, US standard 1977. Brute-forced in 1997 (~14,000 PCs, ~12 weeks); EFF 1998: ~3 days. Obsolete |
| 3DES | 112 effective / 64 | E(K1, D(K2, E(K1, M))). Strong but slow |
| IDEA | 128 / 64 | 8 rounds, ~3× DES speed, used in PGP |
| RC4 | ≤ 2048 / stream | Fast, used in WEP, later broken |
| AES (Rijndael) | 128/192/256 / 128+ | NIST winner in 2000, efficient, the current standard |
RSA exam
RSA is a public-key algorithm whose trap-door function is based on factoring large numbers: multiplying two big primes is easy, but recovering them from the product is infeasible. Key generation takes three steps:
- Choose large primes P and Q, and compute N = PQ and Z = (P−1)(Q−1).
- Choose d so that it has no common factor with Z.
- Find e with e·d ≡ 1 (mod Z). In practice, take the first of Z+1, 2Z+1, 3Z+1, … that is divisible by d, and divide it by d.
The public key Ke = ⟨e, N⟩ is published, and the private key Kd = ⟨d, N⟩ is kept secret. To encrypt, compute c = Me mod N; to decrypt, compute M = cd mod N. ("x mod N" is the remainder after dividing x by N.) The message is split into blocks of k bits, which must satisfy 2k < N so that each block is a number smaller than N.
RSA's security rests on the fact that finding d requires Z, and finding Z requires factoring N. That is infeasible for N > 10200, but 512-bit keys have fallen. CDK recommends keys of at least 768 bits, and 2048 is common.
147² = 21609 = 97·221 + 172, so 147² ≡ 172. Then 172² = 29584 = 133·221 + 191, so 147⁴ ≡ 191. Finally 191·147 = 28077 = 127·221 + 10, so 147⁵ ≡ 10. Each step only ever multiplies two numbers below 221.
Check yourselfSelf-test Q6: RSA with P = 5, Q = 11, d = 3. Find N, Z and e, and encrypt M = 2.
N = PQ = 55, and Z = (P−1)(Q−1) = 4·10 = 40. Next, e must satisfy 3e ≡ 1 (mod 40). Try Z+1 = 41 (not divisible by 3), then 2Z+1 = 81 = 3·27, so e = 27.
To encrypt, c = 227 mod 55. Since 220 ≡ 1 (mod 55), this reduces to c ≡ 27 = 128 ≡ 18. As a check, decrypting gives 183 = 5832 ≡ 2 (mod 55). ✓
Check yourselfIn RSA, which number must stay secret for the scheme to be safe, and why is publishing N not enough to give it away?
d (with N it forms the private key). Finding d requires Z = (P−1)(Q−1), and finding Z requires factoring N into P and Q, which is infeasible for large N (N > 10200). So publishing N and e reveals nothing usable, provided the key is long enough: 512-bit keys have fallen, CDK recommends at least 768 bits, and 2048 is common.
Hybrid protocols exam
Public-key cryptography makes key distribution easy, but it is too slow for bulk data. So hybrid protocols use public keys to authenticate the parties and exchange a secret session key, and then let symmetric encryption carry the data. TLS is one example; PGP is another (RSA, then IDEA or 3DES).
Check yourselfSelf-test Q5: compare symmetric and asymmetric cryptography, and explain why hybrids are used.
Symmetric cryptography is fast, but key distribution is hard and it gives no non-repudiation. Asymmetric cryptography is 100–1000× slower, but key distribution is easy (with certificates) and it supports real signatures. A hybrid combines the two: it uses public keys to authenticate and exchange a session key, then symmetric encryption for the data, as TLS does.
Cryptography pragmatics
A few practical figures explain the design choices above.
Symmetric ciphers run at tens of MB/s (AES fastest, 3DES slowest), and hashes are faster still. An RSA-1024 signature takes about 5 ms. So public keys are used only for signing and key exchange.
40-bit keys (the old US export limit) and 56-bit DES keys are breakable. Symmetric keys of at least 128 bits are safe; RSA needs at least 768 bits; hashes need at least 128 bits.
Check yourselfWrite the CBC encryption and decryption equations, and say why CBC needs an IV and a reliable channel.
Ci = E(K, Pi ⊕ Ci−1) and Pi = D(K, Ci) ⊕ Ci−1. The IV acts as C0 so that identical messages encrypt differently. A reliable channel is needed because decrypting block i needs block i−1; if a block is lost, decryption breaks.
Check yourselfWhy is DES described as obsolete, and what replaced it?
Its 56-bit key is too short: it was brute-forced in 1997 (about 14,000 PCs over about 12 weeks), and the EFF did it in about 3 days in 1998. 3DES strengthened it (112 effective bits) but is slow; AES (Rijndael), the NIST winner in 2000, is the current standard.
- Block ciphers encrypt fixed blocks; CBC chains them, Ci = E(K, Pi ⊕ Ci−1), with an IV, hiding repeats but needing a reliable channel. Stream ciphers XOR a never-reused keystream.
- DES (56-bit) is broken; AES is the standard. RSA: N = PQ, Z = (P−1)(Q−1), e·d ≡ 1 mod Z, c = Me mod N, M = cd mod N.
- Hybrids use public keys once (authenticate, exchange a session key) and symmetric keys for the data.
Digital Signatures and MACs
A handwritten signature ties a person to a document. A digital document can be copied perfectly, so a digital signature has to be tied to the exact bits of the document, in a way nobody else can reproduce. This section covers what a signature must achieve, the hash functions that make signatures practical, the two ways to sign (with a private key, or with a shared key as a MAC) and when each is enough.
What a signature must be exam
It shows that the signer deliberately signed, and that the document is unaltered.
The signature cannot be copied onto another document.
The signer cannot credibly deny having signed.
Because digital documents are trivial to copy, the signer's secret must be bound to the whole bit sequence: change one bit and the signature must fail. Even so, signatures have limits. A signature does not prove when something was signed, and a signer who deliberately leaks the private key can later deny signing ("someone stole my key").
Secure digest (hash) functions exam
A secure digest function (or secure hash) H produces a short, fixed-length value h = H(M) from a message of any length. To be useful for signatures it must satisfy three properties:
- It is easy to compute h from M.
- It is hard to compute M from h, so the function is one-way.
- It is hard to find M′ ≠ M with H(M′) = H(M). Otherwise a signature on M would also be valid for M′.
The reason to sign the digest rather than the message itself is cost: the digest is short and fixed-size, so the expensive public-key operation is done once on a few bytes, whatever the length of M.
The birthday attack
This attack targets property 3. Alice prepares a fair contract M and an unfair one M′, then makes many invisible variants of each (an extra space here, a different line break there) until one variant of each has the same hash. Bob signs the fair variant; Alice then swaps in the unfair one, and Bob's signature still verifies. Because collisions among many candidates are far likelier than hitting one particular hash (as with two people in a room sharing a birthday), a 64-bit hash needs only about 232 variants. So hashes must be at least 128 bits.
Algorithms. The common hash algorithms are MD5 (128 bits, very fast), SHA-1 (160 bits) and SHA-2 (224–512 bits, the slide's example). CDK calls MD5 and SHA-1 adequate, but both now have practical collision attacks, so use SHA-2.
Signing with public keys exam
A public-key signature is made and checked in four steps:
- A publishes Kpub, in a certificate.
- A computes the digest h = H(M) and the signature S = {h}Kpriv.
- A sends M, S.
- B decrypts S with Kpub to get h′, computes H(M) itself, and accepts if h = h′.
This works because only the holder of Kpriv can make an S that decrypts correctly, and any change to M changes H(M). It therefore gives authentication, integrity and non-repudiation, provided the key stays private and the certificate is trusted. Notice the contrast with secrecy: for secrecy you encrypt with the recipient's public key, but for signing you encrypt with the signer's private key.
Signing with a shared key: MACs exam
A MAC (message authentication code) does a similar job with a shared secret key, in three steps:
- A distributes a random key K to B over a secure channel.
- A sends M, h, where h = H(M + K), the hash of M concatenated with K.
- B computes H(M + K) itself and compares it with h.
Trade-offs. The advantage of a MAC is speed: there is no encryption, and hashing is 3–10× faster than symmetric ciphers. MACs are used in TLS. The drawback is that a MAC provides authentication and integrity but not non-repudiation, because both parties know K and either of them could have made h. In addition, only key holders can verify a MAC, and K must be distributed securely.
| Public-key signature | MAC | |
|---|---|---|
| Made with | Signer's private key | Shared key |
| Verifiable by | Anyone | Key holders only |
| Non-repudiation | Yes | No |
| Cost | High | Low |
What is a digital signature? What is the role of the certificate chain in authenticating an individual's identity? (Staff released no solutions; this is the guide's worked answer, condensed.)
Digital signature. It binds a signer's identity to a document in a way that is authentic, unforgeable and non-repudiable. The signer computes a secure digest h = H(M) with a one-way, collision-resistant hash such as SHA-2, encrypts it with their private key, S = {h}Kpriv, and sends M with S. The verifier decrypts S with the signer's public key, computes H(M) itself, and accepts only if the two match. Only the holder of Kpriv could have made S (authentication, non-repudiation); any change to M changes H(M) (integrity); signing the short digest keeps the slow public-key step cheap.
Role of the certificate chain. Verifying a signature only means something if the verifier has the signer's genuine public key; otherwise an impostor could sign with his own key and publish it under the individual's name. A certificate binds a name to a public key and is signed by an issuer; checking it needs the issuer's key, which comes in a certificate signed by a higher authority, and so on up to a root CA whose self-signed certificate was obtained out of band (pre-installed) and is trusted by fiat. The verifier checks each signature with the key from the certificate above it, plus validity dates and revocation status, up to the root. If every link verifies, the name really is bound to that key, so a signature verified with it really identifies the individual. This is what defeats a man in the middle. The weak points: the choice of root, compromised private keys, long fragile chains and revocation.
Check yourselfSelf-test Q7: explain how a public-key digital signature is made and verified.
The signer sends M, {H(M)}Kpriv. The verifier decrypts the signature with Kpub, recomputes H(M) and compares the two. This gives authenticity, integrity and non-repudiation. For it to be secure, the hash must be one-way, collision-resistant and at least 128 bits long (because of the birthday attack), for example SHA-2.
Check yourselfSelf-test Q8: MAC vs signature.
A MAC is h = H(M + K), made with a shared key. It is cheap, but it gives no non-repudiation, because either party could have made it, and only key holders can verify it. A signature uses a private key, so anyone can verify it and it gives non-repudiation, but it costs more.
Check yourselfA bank needs records that a customer cannot later deny having authorised. Is a MAC enough?- Yes, because the MAC proves integrity.
- Yes, if the MAC key is at least 128 bits.
- No: the bank also knows the MAC key, so it could have made the MAC itself.
- No, because MACs cannot be verified at all.
C. Non-repudiation needs something only the customer could have produced: a signature with the customer's private key. A true-but-irrelevant point (integrity, key length) does not fix that, and D is false, since key holders can verify a MAC.
Check yourselfWhy must a hash used for signatures be at least 128 bits, when nobody is trying to invert it?
Because of the birthday attack on collision resistance: the attacker only needs some pair of fair and unfair variants with the same hash, and for an n-bit hash that takes about 2n/2 variants. A 64-bit hash falls to about 232, which is feasible.
- Signatures must be authentic, unforgeable and non-repudiable. Sign the digest: S = {H(M)}Kpriv; verify by decrypting with Kpub and comparing with a fresh H(M).
- Hashes must be easy forwards, one-way, and collision-resistant; the birthday attack means at least 128 bits. Prefer SHA-2.
- A MAC, H(M + K), is fast and gives authentication and integrity, but no non-repudiation and only key holders can verify it.
Needham–Schroeder exam
Scenario 2 had no replay protection. The Needham–Schroeder secret-key protocol is the full form of that authentication-server idea, with nonces added so that each party can tell a fresh message from a recording. It is the ancestor of Kerberos, and it is examined message by message, so learn the five messages exactly as written here.
The authentication server S holds a ⟨name, secret key⟩ pair for every principal; for a user, the key is derived from the password. A nonce is a value used only once (typically a random number), included in a message to prove that the message is fresh: a reply that contains the nonce you just chose cannot be a recording of an older reply.
The five messages
| # | Message | Purpose |
|---|---|---|
| 1 | A → S: A, B, NA | A asks for a key to talk to B |
| 2 | S → A: {NA, B, KAB, {KAB, A}KB}KA | Only S knows KA, so this is from S. NA shows the message is fresh. It contains the new KAB and a ticket for B |
| 3 | A → B: {KAB, A}KB | A forwards the ticket |
| 4 | B → A: {NB}KAB | B challenges A |
| 5 | A → B: {NB − 1}KAB | Proves A holds KAB |
- A wants to talk to B. Each shares a long-term secret key with the authentication server S: KA and KB. A and B share nothing yet.
- Message 1: A → S: A, B, NA. A asks for a key to talk to B, and includes a fresh nonce NA that it has just made up. Sent in the clear: it contains no secrets.
- Message 2: S → A: {NA, B, KAB, {KAB, A}KB}KA. Only S knows KA, so this is from S. Because it contains A's nonce NA, it is a reply to this request, not a recording. It carries the new session key KAB and a ticket for B, {KAB, A}KB, which A cannot read. The name B inside tells A which principal the key is for.
- Message 3: A → B: {KAB, A}KB. A forwards the ticket. B decrypts it with KB and learns KAB and that S issued it for A.
- Message 4: B → A: {NB}KAB. B challenges A with its own fresh nonce, encrypted under the new key. This is challenge–response.
- Message 5: A → B: {NB − 1}KAB. A decrypts NB, subtracts 1 and re-encrypts. This proves A actually holds KAB (see below for why it is NB − 1).
- The weakness: nothing in message 3 (highlighted) is fresh, so B cannot tell whether it is new. The fix is a timestamp in the ticket, {KAB, A, t}KB, so that B can check that t is recent. Kerberos uses this fix.
Why NB − 1 and not NB?
Message 4 is {NB}KAB. If A simply sent it back unchanged, the reply could equally have come from an attacker who merely reflects message 4 back to B, without knowing KAB at all. Returning a transformed value, which needs decrypting, changing and re-encrypting, proves that A can actually use KAB.
The weakness, and the fix exam
The protocol's weakness is that B cannot tell whether message 3 is fresh: B's own nonce only appears from message 4 onwards, and the ticket contains nothing B can check for age. So an intruder who obtains an old KAB (keys break given time) and the ticket that went with it can replay message 3, answer the challenge in messages 4–5, and so impersonate A.
Fix. Put a timestamp in the ticket, making it {KAB, A, t}KB, so that B can check that t is recent. Kerberos uses exactly this fix. (CDK misprints the key here as KBpub; it is B's secret key KB.)
The public-key variant (brief)
There is also a public-key version, which needs no server holding everyone's secrets. Instead the two parties exchange nonces under each other's public keys:
Check yourselfSelf-test Q10: describe the Needham–Schroeder protocol, its weakness and the fix.
The five messages: (1) A → S: A, B, NA; (2) S → A: {NA, B, KAB, {KAB, A}KB}KA; (3) A → B: {KAB, A}KB; (4) B → A: {NB}KAB; (5) A → B: {NB − 1}KAB. NA proves that message 2 is fresh, and NB − 1 proves that A holds KAB. The weakness is that message 3 can be replayed by someone holding an old KAB. The fix is to add a timestamp, {KAB, A, t}KB, as Kerberos does.
Check yourselfIn message 2, what does each part prove or deliver to A?
Encryption under KA proves it came from S (only S and A know KA). NA proves it is fresh, a reply to this request. B confirms which principal the key is for. KAB is the new session key. {KAB, A}KB is the ticket for A to forward to B.
Check yourselfWhy does B send {NB}KAB and expect {NB − 1}KAB back, rather than {NB}KAB?
An attacker who knows nothing could simply reflect {NB}KAB back to B. Returning a transformed value requires decrypting NB, changing it and re-encrypting, which only a holder of KAB can do.
- Five messages: A, B, NA · {NA, B, KAB, {KAB, A}KB}KA · {KAB, A}KB · {NB}KAB · {NB − 1}KAB.
- Nonces give freshness: NA for message 2, NB for the challenge. NB − 1 defeats reflection.
- Weakness: message 3 is not fresh, so an old KAB plus its ticket allows impersonation. Fix: {KAB, A, t}KB, as in Kerberos.
Kerberos exam
Kerberos is Needham–Schroeder made practical for a real organisation. It provides authentication and key distribution for an intranet (a single management domain), following Needham–Schroeder but using timestamps as nonces, which closes the message-3 hole. It came from MIT's Project Athena, is specified as RFC 4120, and is the default in Windows. The basic arrangement: passwords are known only to the user and Kerberos, and each server's key is known only to that server and Kerberos.
Architecture: a KDC with two services
At the centre is a Key Distribution Centre (KDC), which contains an Authentication Service (AS) and a Ticket-Granting Service (TGS) that share a database of keys. Splitting the KDC in two means the user's password is used only once per login: after that, the client talks to the TGS using a session key instead. A client goes through three steps, each at a different frequency.
- Step A, once per login session: the AS issues a TGS ticket.
- Step B, once per server session: the TGS issues a server ticket.
- Step C, once per transaction: the client makes a request to the server.
Security objects: ticket, authenticator, session key
Kerberos uses three kinds of security object. Getting the difference between the first two right is a classic exam point.
- A ticket, {C, S, t1, t2, KCS}KS, is issued for a particular server and shows that the client was recently authenticated by Kerberos. It holds a validity period (t1 to t2) and a session key, and the client name inside it stops an impostor from using a stolen ticket. A ticket is reusable until it expires.
- An authenticator, {C, t}KCS, is built by the client to prove its identity and its freshness. It is used only once.
- A session key is a random key for each client–server pair. It encrypts authenticators, and data where required.
In the protocol, ticket(C, S) stands for the ticket's contents and {ticket(C, S)}KS for the sealed ticket; likewise auth(C) is the authenticator's contents and {auth(C)}KCS the sealed authenticator. The TGS is itself treated as a server called T, so ticket(C, T) holds the session key KCT between the client and the TGS.
The protocol, message by message
The table traces the full protocol: steps A to C are the three above, and the optional step D adds mutual authentication. In it, n is a nonce.
| Step | Message | Explanation |
|---|---|---|
| A | 1. C → AS: C, T, n | Plaintext; no password is sent |
| 2. AS → C: {KCT, n}KC, {ticket(C,T)}KT | A challenge: only someone holding KC (derived from the password) can extract KCT. n proves freshness | |
| B | 3. C → TGS: {auth(C)}KCT, {ticket(C,T)}KT, S, n | Asks for a ticket for S |
| 4. TGS → C: {KCS, n}KCT, {ticket(C,S)}KS | The TGS decrypts the ticket, checks the authenticator's name and time, and creates KCS | |
| C | 5. C → S: {auth(C)}KCS, {ticket(C,S)}KS, request, n | S decrypts the ticket with KS, then checks the authenticator is fresh and unused |
| D (optional) | 6. S → C: {n}KCS | Server authenticates itself to the client (mutual authentication) |
- Four parties. The client's key KC is derived from the user's password; the TGS (called T in messages) and the server have keys KT and KS. The AS and TGS share the KDC's key database. Letters A–D on the left mark the steps.
- Step A, message 1: C → AS: C, T, n. The client names itself, the service it wants a ticket for (the TGS, T) and a nonce n. It is plaintext: no password is sent.
- Message 2: AS → C: {KCT, n}KC, {ticket(C,T)}KT. Two parts: a new session key KCT (client to TGS) with the nonce, sealed under the client's key; and a TGS ticket, sealed under the TGS's key, which the client cannot read. This is a challenge: only someone holding KC can extract KCT.
- At the client: the user's typed password gives KC, which decrypts the first part. The client checks that n is its own nonce (freshness), keeps KCT and the TGS ticket, and erases the password, which never crossed the network.
- Step B, message 3: C → TGS: {auth(C)}KCT, {ticket(C,T)}KT, S, n. The client asks for a ticket for server S. It sends a fresh authenticator (its name and the current time, under KCT), the TGS ticket, the server's name and a new nonce.
- At the TGS: it decrypts the ticket with KT, which gives KCT; uses KCT to open the authenticator; checks the authenticator's name matches the ticket and its time is recent; and creates a new session key KCS. Message 4: TGS → C: {KCS, n}KCT, {ticket(C,S)}KS.
- Step C, message 5: C → S: {auth(C)}KCS, {ticket(C,S)}KS, request, n. The client sends a fresh authenticator under KCS, the server ticket, its actual request, and a nonce.
- At the server: S decrypts the ticket with its own key KS, which gives KCS and the client's name; opens the authenticator with KCS; and checks that the authenticator is fresh and unused and that the ticket is within its lifetime. If so, it performs the request.
- Step D (optional), message 6: S → C: {n}KCS. The server proves it could open the ticket (only the real S has KS, so only it knows KCS): the server authenticates itself to the client, giving mutual authentication.
The 2026 practice exam (Q9, in 10.5) asked you to trace a ticket exchange and find its weakness. For each message, say four things: who sends it to whom, what it contains, which key seals each part (and therefore who can read it), and what the receiver checks. Then name what provides freshness. In Kerberos the answer to that last point is the authenticator's timestamp, plus the ticket's lifetime.
Why timestamps, and how a user logs in
The timestamps do two jobs. They block replay of old messages, or of tickets left in memory; and they give tickets a lifetime, which is what lets rights be revoked: once a ticket expires, the user has to ask the KDC again, and can be refused.
Logging in is step A seen from the user's side:
- The login program sends the user's name to the AS.
- It decrypts the AS's reply with the typed password, and checks the nonce.
- It keeps the session key and the TGS ticket, and erases the password, which never crossed the network.
Using a service (e.g. rlogin). To use a service such as rlogin (remote login), the client gets a ticket for the rlogind server from the TGS, then sends that ticket together with a fresh authenticator. rlogind decrypts the ticket with its own key, checks the ticket's lifetime, and checks that the authenticator is fresh.
Use in NFS (Part VIII). Per-request Kerberos was too costly for stateless NFS, so NFS uses it differently: the user is authenticated with Kerberos at mount time, and the server records the user ID and client address. Each later request is checked against them, which assumes one user per client machine.
Tickets last about 12 hours, and each realm (administrative domain) has its own KDC.
Limitations exam
Loosely synchronised clocks
Timestamps only work if clocks roughly agree, and the clock-synchronisation protocol must itself be secure.Lists of recent nonces
Servers must keep lists of recent nonces (authenticators already seen) to reject reuse, which is hard to do across failures.Ticket lifetime trade-off
Long lifetimes let revoked users keep access; short ones interrupt users with re-authentication.Single domain only
Every key must be pre-registered, so it is unsuitable for open e-commerce between strangers.The KDC holds every key
So it must be physically secure. It is also a bottleneck and a single point of failure, though replication mitigates this.In Kerberos, it is the authenticator that proves freshness, not the ticket. The ticket is reusable for hours, so a copied ticket on its own proves nothing about now; the once-only, timestamped authenticator does.
Check yourselfSelf-test Q11: explain Kerberos: its steps, ticket vs authenticator, and its limitations.
Kerberos runs in up to four steps. In step A, the AS issues a TGS ticket and KCT. In step B, the TGS issues a server ticket and KCS. In step C, the client sends the ticket, an authenticator and its request to the server. In the optional step D, the server authenticates itself to the client.
A ticket is reusable until it expires, whereas an authenticator is used once and proves freshness. The limitations: loosely synchronised (and securely synchronised) clocks; servers must keep lists of recent nonces, hard across failures; the ticket-lifetime trade-off; a single domain with pre-registered keys, unsuitable for open e-commerce; and the KDC holds every key, so it must be physically secure and is a bottleneck and single point of failure (replication helps).
Check yourselfWhich statement about Kerberos is correct?- The password is sent to the AS, encrypted with KT.
- The client can read its TGS ticket, because it holds KCT.
- A ticket can be reused until it expires; an authenticator is used once.
- Step B happens once per transaction.
C. A is wrong: the password never crosses the network (message 1 is plaintext C, T, n). B is wrong: the TGS ticket is sealed under KT, which the client does not have. D is wrong: step B is once per server session; step C is once per transaction.
Check yourselfAn attacker copies message 5 from the network and replays it to S ten minutes later. What stops it?
The authenticator {auth(C)}KCS. It carries a timestamp and may be used only once; S keeps a list of recently seen authenticators and rejects a repeat (and rejects one whose time is no longer recent). The ticket inside message 5 is still valid, but that alone is not enough. The attacker cannot make a new authenticator, because that needs KCS.
Check yourselfHow does Kerberos fix the Needham–Schroeder weakness, and what new requirement does the fix introduce?
It uses timestamps as nonces: tickets carry a validity period and authenticators carry the current time, so a replayed old ticket with an old key is rejected (this is the {KAB, A, t}KB fix). The new requirement is loosely synchronised clocks, with a secure clock protocol.
- KDC = AS + TGS sharing a key database. Step A once per login (TGS ticket), B once per server session (server ticket), C once per transaction, D optional mutual authentication.
- Ticket {C, S, t1, t2, KCS}KS is reusable until expiry; authenticator {C, t}KCS is used once and proves freshness.
- Messages: C, T, n · {KCT, n}KC, {ticket(C,T)}KT · {auth(C)}KCT, {ticket(C,T)}KT, S, n · {KCS, n}KCT, {ticket(C,S)}KS · {auth(C)}KCS, {ticket(C,S)}KS, request, n · {n}KCS.
- Limitations: clocks, replay lists, lifetime trade-off, single domain, the KDC.
TLS / SSL exam
Kerberos works inside one organisation, where every key can be registered in advance. On the open web, a buyer and a shop have never met, which was requirement 4 of 10.3. TLS (Transport Layer Security) is the protocol that solves that case, and it is what the padlock in your browser means. It brings together nearly everything in this Part: certificates and chains, public-key key exchange, symmetric encryption, and MACs.
What it is, and its design features
SSL (Secure Sockets Layer) came from Netscape in 1994 and was standardised as TLS (RFC 2246). It secures HTTPS, Telnet, FTP and more. TLS is a hybrid protocol: it uses public keys for authentication and key exchange, and symmetric keys for the data.
- Negotiable algorithms. You cannot assume that all parties have the same software, so the algorithms are agreed in the handshake.
- Bootstrapped. No prior negotiation or third-party help is needed at connection time. Communication starts unencrypted, then moves to public-key cryptography, then to secret-key cryptography. Each switch is optional and negotiated, and each direction can be encrypted, authenticated, both, or neither.
- The only requirement is certificates issued by an authority that both sides recognise.
Two layers: record and handshake
TLS is organised in two layers. The Record protocol implements the secure channel itself, over TCP. Above it, the handshake layer contains three protocols: Handshake negotiates the cipher suite and exchanges certificates and keys; Change Cipher Spec switches to the newly agreed specification; and Alert reports errors. Applications such as HTTP sit beside them and send their data through the record layer. Session IDs can be cached, so that a later connection can resume a session without a full handshake.
The Record protocol takes outgoing data through five stages, and the receiver reverses them:
Cipher suites
A cipher suite is one choice of each of three things. One side lists the suites it supports and the other picks one. The sources differ on which side is which: CDK says the server offers and the client picks, whereas in the RFC the client offers and the server picks (which is what the handshake below shows).
The handshake
The handshake runs in eight steps. The message labels in the stepper carry the step numbers from this list.
- ClientHello / ServerHello. The two sides agree the version, session ID, cipher suite and compression, and exchange random values.
- The server sends its Certificate (an X.509 chain), an optional CertificateRequest, and then ServerHelloDone.
- The client checks the server's certificate. It checks that the certificate chains to a root CA key pre-installed in the browser, that its dates are valid, and that the domain name matches the server being contacted.
- The client sends its own Certificate, but only if one was requested.
- The client sends a random pre-master secret, encrypted with the server's public key. Only the real server can decrypt it, which implicitly authenticates the server.
- If the client has a certificate, it sends CertificateVerify, which is a signature made with its private key.
- Both sides derive the write keys (one per direction) and the MAC secrets.
- Each side sends ChangeCipherSpec + Finished. Finished is a MAC over the whole handshake, so it detects tampering. From here on, everything is encrypted and MACed.
- A browser (client) connects to a server it has never talked to. They share no key; all the client has is a set of root CA keys pre-installed in the browser.
- ClientHello (step 1): the client proposes a protocol version, sends a random value, and lists the cipher suites it supports.
- ServerHello (step 1): the server picks one cipher suite, sends its own random value and a session ID (which can be cached so that a later connection can resume without a full handshake).
- Step 2: the server sends its Certificate, an X.509 chain; optionally a CertificateRequest asking the client for one; and ServerHelloDone.
- Step 3: the client checks that the chain leads to a pre-installed root CA key, that the dates are valid, and that the domain name in the certificate matches the server it meant to contact. This is the MITM defence.
- Step 4: the client sends its own Certificate, but only if one was requested (most web clients have none).
- Step 5: the client makes a random pre-master secret and sends it encrypted with the server's public key from the certificate. Only the real server, holding the matching private key, can decrypt it: this implicitly authenticates the server.
- Step 6: if the client sent a certificate, it also sends CertificateVerify, a signature with its private key, proving it owns that certificate.
- Step 7: both sides independently derive the same write keys (one per direction) and MAC secrets. Nothing is sent in this step.
- Step 8, client: ChangeCipherSpec (switch to the new keys now) and Finished, a MAC over the whole handshake so far.
- Step 8, server: the same. If Mallory had altered any handshake message (for example, removing the strong suites from ClientHello), the Finished MACs would not match.
- From here on, all application data is encrypted and MACed by the record protocol with the symmetric keys from step 7.
What TLS gives, and what it does not
MITM defence. TLS defends against MITM in two ways: the root CA keys arrive by a separate channel (they are built into browsers), and the domain name is in the certificate, so Mallory's certificate (even a valid one for his own name) fails the name check.
- Secrecy, from symmetric encryption.
- Integrity, from a MAC on every record. The MAC includes a sequence number, so replays are detected as well.
- Authentication of the server by certificate, and optionally of the client.
It meets all four e-commerce requirements of 10.3.
- Non-repudiation (records are MACed, not signed).
- Endpoint security (it protects the channel, not the machines at each end).
- Protection against DoS or traffic analysis.
Tutorial 9: the tutors' version official
The second half of Tutorial 9 introduced TLS informally, before an SSL code demo. Its framing makes a good opening sentence for an exam answer, which you can then follow with the full handshake above. The tutors described TLS as handling secure communication on the Internet for you, and noted that most traffic, such as HTTPS, uses it. A certificate, in their words, says: "here is my public key, and here is a signature from a trusted authority saying it really belongs to me." They told the handshake as a four-message story:
A lesson from WEP (brief)
802.11 WEP, the original Wi-Fi security, shows what happens when the design guidelines of 10.3 are broken. It used one key shared by all users (the opposite of limiting a secret's scope), did not authenticate base stations (so a fake one could masquerade), reused the keystream (fatal for a stream cipher), used 40-bit keys (breakable) and had a hard-wired cipher (no way to negotiate a better one, unlike TLS). It was replaced by WPA2, which uses AES.
Check yourselfSelf-test Q12: describe TLS's layers and handshake, and how it stops MITM.
TLS has a record layer (the secure channel over TCP: fragment, compress, MAC, encrypt, transmit) and a handshake layer (Handshake, Change Cipher Spec and Alert protocols). In the handshake, the Hellos negotiate the suite and exchange random values, the server sends its certificate, the client sends a pre-master secret under the server's public key, both sides derive keys, and each sends ChangeCipherSpec and Finished. MITM is stopped by the certificate chain to a pre-installed root, the name check, and the Finished MAC.
Check yourselfHow is the server authenticated in TLS, given that the certificate is public and anyone could resend it?
Sending the certificate proves nothing by itself. The client encrypts the pre-master secret with the public key in the certificate; only the holder of the matching private key can decrypt it and so derive the same keys. If the server then produces a correct Finished MAC, it must hold the private key: this is the "implicit" server authentication of step 5.
Check yourselfWhich of these does TLS not protect against?- An eavesdropper reading credit-card numbers.
- A replayed record within a connection.
- A customer later denying they placed an order.
- A man in the middle presenting his own certificate.
C. TLS gives no non-repudiation: records are protected with MACs, and both ends know the MAC secrets. A is stopped by encryption, B by the sequence number in each record's MAC, D by the chain to a pre-installed root and the domain-name check.
- TLS is hybrid, negotiable and bootstrapped; it needs only certificates from a commonly recognised authority.
- Record protocol: fragment → compress → MAC → encrypt → transmit. Handshake layer: Handshake, Change Cipher Spec, Alert.
- Handshake: Hellos (suite, randoms) · Certificate, [CertificateRequest], ServerHelloDone · client checks chain, dates, name · [client Certificate] · {pre-master secret}KSpub · [CertificateVerify] · derive keys · ChangeCipherSpec + Finished each way.
- Gives secrecy, integrity (with replay detection) and authentication; not non-repudiation, endpoint security, or DoS/traffic-analysis protection.
Review: Defences, Pitfalls and Tutorials
This last section pulls the Part together. First the table that answers "how would you defend against X?", which is the shape of many 5-mark questions. Then the mistakes that most often cost marks, and finally the tutors' official answers to Tutorial 10, with the Week 11 Ed quiz.
Which mechanism defeats which attack exam
For each of the five methods of attack from 10.2, one family of mechanism is the main answer:
The full table adds the other threats from this Part.
| Attack / threat | Defence | Course example |
|---|---|---|
| Eavesdropping | Encryption | TLS records |
| Masquerading | Authentication: challenges, certificates, signatures | Kerberos, TLS server certificate |
| Tampering | MAC or digital signature | TLS record MAC |
| Man-in-the-middle | Certificates chained to a root key obtained out of band; name in certificate | TLS / X.509 |
| Replay | Nonces, timestamps, sequence numbers, one-time authenticators, expiry | Needham–Schroeder, Kerberos |
| Denial of service | Upstream filtering and QoS, replication (firewalls are weak here) | — |
| Traffic analysis | Information-flow control, padding (encryption is not enough) | Bell–LaPadula |
| Malicious mobile code | Sandbox, bytecode verification, protection domains | Java |
| Repudiation | Public-key signatures (not MACs) | Signed bank records |
| Unauthorised operations | Access control: ACLs, capabilities | UNIX permissions |
| Password sniffing | Challenge–response; the password is never sent | Kerberos login |
| Stolen key or ticket | Limited lifetime and scope, revocation | Session keys, ticket expiry |
Common pitfalls
- Encrypting with your private key gives no secrecy, because anyone with the public key can read the result.
- MACs do not give non-repudiation, because both parties hold the key and either could have made the MAC.
- Encryption alone does not stop replay. To stop replay you need freshness.
- A certificate binds a name to a key. It does not vouch for honesty.
- In Kerberos, it is the authenticator that proves freshness, not the ticket.
- Secret algorithms are bad practice. Publish the algorithm, and keep only the keys secret.
Check yourselfA system encrypts every request with a strong session key. Name two attacks from the table it is still open to, and the fix for each.
Any two of: replay (fix: freshness, such as nonces, timestamps or sequence numbers); repudiation (fix: public-key signatures); traffic analysis (fix: information-flow control, padding); denial of service (fix: upstream filtering, QoS, replication); masquerading, if the session key was never tied to an authenticated identity (fix: authentication with certificates or challenge–response).
Tutorial 10 (Week 11): official answers official
These are the tutors' official answers from Ed, condensed; staff have confirmed tutorial content is examinable. Most restate material from earlier in this Part, but in the tutors' own words, which are the closest thing to what markers expect, so reuse them. Two parts go beyond the earlier sections: the field-by-field layout of an X.509 certificate (T10-7) and the steps for obtaining a certificate (T10-8). (The tutorial opened with a Q&A on Assignment 2, which is left out here.)
T10-1 · officialWhat are the different security threats and methods of attack in a distributed system?
The three broad classes of threat: leakage, the acquisition of information by unauthorised recipients; tampering, the unauthorised alteration of information; and vandalism, interference with the proper operation of a system. The five methods of attack:
- Eavesdropping is a form of leakage: obtaining private or secret information, or copies of messages, without authority.
- Masquerading is a form of impersonation: sending or receiving messages using the identity of another principal without their authority.
- Message tampering alters the content of messages in transit. The tutors equate it with the man-in-the-middle attack, which tampers with the secure-channel mechanism itself.
- Replaying means storing secure messages and sending them again at a later date.
- Denial of service is vandalism by flooding a channel or other resource, so that others are denied access to it.
T10-2 · officialList and briefly explain some worst-case assumptions when designing a secure system.
The tutors give four of the six guidelines of 10.3:
- Networks are insecure. Messages can be looked at, copied, modified and retransmitted; attackers can obtain information they should not have and pretend to be a legitimate party.
- The source code is known to the attacker, and knowing it helps the attacker discover vulnerabilities.
- Interfaces are exposed. Communication interfaces must be open so that clients can reach them, so attackers can send messages to any interface.
- The attacker has unlimited computing resources. Assume they have access to the largest and most powerful computers projected in the lifetime of the system.
T10-3 · officialDefine encryption and describe the two main types of keys used by encryption algorithms.
Encryption is the process of encoding a message in such a way as to hide its contents. With shared secret keys (symmetric), the sender and the recipient share knowledge of one key, and it must not be revealed to anyone else. With public/private key pairs (asymmetric), the sender encrypts with a public key, namely the recipient's, and the recipient decrypts with the matching private key; only the recipient can decrypt the message, because only they hold the private key. The price is speed: public-key algorithms typically need 100 to 1000 times as much processing power as secret-key ones.
T10-4 · officialHow can Alice authenticate and communicate secretly with Bob, assuming there is an authentication server that knows Alice's and Bob's secret keys?
This is Scenario 2 of 10.5, in five steps:
- Alice sends the server her name and a ticket request, in the clear.
- The server replies with {{Ticket}KB, KAB}KA.
- Alice decrypts the reply with KA and stores the new shared key KAB. She cannot read the ticket, because it is encrypted with Bob's key.
- Alice sends Bob {Ticket}KB, her name and her request.
- Bob decrypts the ticket with KB. It contains Alice's identity and the shared key KAB, and from then on the two communicate using KAB.
Keep the weakness in mind: nothing in the ticket is fresh, so the exchange can be replayed. Question 9 of the 2026 practice exam turns on exactly this point.
T10-5 · officialAssuming Bob has a public/private key pair, how can Alice and Bob establish a shared key to communicate secretly using a Key Distribution Service?
This is the hybrid approach of Scenario 3, which the tutors draw in six steps:
It works because only Bob holds KprivB, so only Bob can recover KAB. The slow public-key operation is used just once, to carry the key, and the fast symmetric key KAB then carries the data.
T10-6 · officialExplain how digital signatures work.
The tutors tell it as six steps between Bob, the signer, and Alice, the verifier. Their word "compress" means computing a secure digest (hash) of the document.
- Bob compresses the message into a short digest.
- Bob encrypts the digest with his private key. The result is the digital signature.
- Bob appends the signature to the document. All the data that went into the digest has now been signed.
- Bob sends the document to Alice.
- Alice decrypts the signature with Bob's public key, which turns it back into a message digest.
- Alice compresses the document herself. If her digest is the same as the decrypted one, she knows that the signed data has not been changed and that Bob signed it, because only Bob has his private key.
Their diagram is the same loop as the signing figure in 10.8.
T10-7 · officialWhat is a digital certificate and why do we need it?
A digital certificate is a digital form of identification, like a passport: it provides information about the identity of an entity. It is issued by a Certification Authority (CA), such as Verisign or Entrust, and the CA guarantees the validity of the information in it. We need certificates because distributing public keys is a big problem: they have to be distributed in a way that is both scalable and truthful. Without a trusted signature binding a key to its owner, anyone could publish a key under someone else's name, which is the man-in-the-middle problem.
Public Key Infrastructure (PKI) is the set of protocols, standards and services that lets users authenticate each other using certificates issued by CAs. A certificate is only useful if it is structured in a standard way, so that its information can be retrieved and understood whoever issued it. X.509, its PKI profile (PKIX) and the Public Key Cryptography Standards (PKCS) are the building blocks that define these formats and their use. The tutors lay out an X.509 certificate field by field:
Next comes a public-key certificate in CDK's five-field format (compare Alice's bank-account certificate in 10.6), with the tutors' three questions about it:
- What is the certificate saying? That Sara certifies that Bob's public key is KBpub.
- Why can't Sara deny that she attested to this? Because if the signature decrypts correctly with KSpub, only someone who held KSpriv could have made it. This is non-repudiation.
- What must anyone checking the certificate know? KSpub. They must also know it authentically, which is the recursion that a certificate chain ends at a trusted root.
Their last picture shows how a certificate is made: the CA verifies the subject's identity, then signs the subject's identity information and public key with its own private key. The certificate is that information, a validity period and the CA's signature.
T10-8 · officialWhat is the process to obtain a digital certificate?
The tutors give seven steps between User-A and the CA:
- Generate a key pair. User-A generates a public/private key pair, or is assigned one by an authority in her organisation.
- Request the CA's certificate. User-A asks the CA server for its certificate.
- The CA certificate is issued. The CA responds with its certificate, which contains its public key and its digital signature, made with its private key.
- Gather information. User-A gathers everything the CA needs to be certain she is who she claims to be, such as her email address or fingerprints.
- Send a certificate request. User-A sends the CA a request made up of her public key and the additional information.
- The CA verifies User-A. The CA checks her identity and generates a certificate binding her identity to her public key. The CA's signature is what makes the certificate verifiable.
- The CA issues the certificate to User-A.
The slide for step 5 says the request is "signed by CA's Public Key", but a signature is always made with a private key. Read it as one of two standard practices: either the request is encrypted with the CA's public key, so that only the CA can read it, or, as in a standard certificate signing request (PKCS #10), it is signed with User-A's own private key, which proves that she holds the key she wants certified.
Code demo. The tutorial ended with a demo of a client and server encrypting their messages with AES under a shared secret key, the symmetric case of T10-3. The demo code was a separate Ed workspace and is not reproduced here.
Ed practice quiz (Week 11)
Ed does not show the answers to its practice quizzes, so these answers are worked out from the course material; they are not official.
Ed quiz Q1An attacker steals Alice's login credentials and submits a funds-transfer request that the bank's server believes comes from Alice. Which method of attack?
Masquerading: sending messages under another principal's identity without authority. The request is new rather than altered or copied, so it is neither tampering nor replay.
Ed quiz Q2An attacker captures an encrypted "transfer $500" message and, without decrypting or changing it, resends it a day later, so the server makes a second transfer. Which attack?
Replaying. The attacker never needs the key, which is why encryption alone does not stop replay; freshness (nonces, timestamps or sequence numbers) does.
Ed quiz Q3Priya and Sam use one key both to encrypt and to decrypt, so if it leaks, every past and future message is readable. What kind of encryption is this, and what is its core requirement?
Symmetric encryption, whose core requirement is that the shared secret key is never revealed to anyone else (T10-3). A new key per message is not the defining requirement, and the 100–1000× cost belongs to asymmetric algorithms.
Ed quiz Q4The authentication server gives Alice a ticket she cannot read and a separately encrypted new key that only she can open, and she forwards the ticket to Bob. What is true of the ticket?
The ticket is encrypted with Bob's key and contains the new shared key; Alice forwards it, and Bob decrypts it with his own key to recover the shared key (T10-4). Alice never learns KB.
Ed quiz Q5Sam wants Priya to be sure a document came from him and was not altered, but does not need it kept secret. What should he do?
Sam encrypts a digest of the document with his own private key; Priya decrypts it with Sam's public key and compares it with a digest she computes herself (T10-6). Encrypting with Priya's public key gives secrecy, not proof of origin, and a plaintext digest can be recomputed by anyone who alters the document.
- Encryption stops reading; authentication stops masquerading; MACs and signatures stop tampering; certificates chained to an out-of-band root stop MITM; freshness stops replay; only upstream measures help against DoS.
- Pitfalls: private-key encryption is not secrecy; MACs are not non-repudiation; encryption is not freshness; certificates bind names, not honesty; the authenticator, not the ticket, proves freshness; never rely on secret algorithms.
- The Tutorial 10 answers are official and examinable; reuse their wording.