author | wenzelm |
Tue, 10 Jun 2008 19:15:19 +0200 | |
changeset 27126 | 3ede9103de8e |
parent 23925 | ee98c2528a8f |
child 42637 | 381fdcab0f36 |
permissions | -rw-r--r-- |
11248 | 1 |
% $Id$ |
11428 | 2 |
\chapter{Case Study: Verifying a Security Protocol} |
11248 | 3 |
\label{chap:crypto} |
4 |
||
11428 | 5 |
\index{protocols!security|(} |
6 |
||
11267 | 7 |
%crypto primitives |
11248 | 8 |
\def\lbb{\mathopen{\{\kern-.30em|}} |
9 |
\def\rbb{\mathclose{|\kern-.32em\}}} |
|
10 |
\def\comp#1{\lbb#1\rbb} |
|
11 |
||
12 |
Communications security is an ancient art. Julius Caesar is said to have |
|
13 |
encrypted his messages, shifting each letter three places along the |
|
14 |
alphabet. Mary Queen of Scots was convicted of treason after a cipher used |
|
11267 | 15 |
in her letters was broken. Today's postal system |
16 |
incorporates security features. The envelope provides a degree of |
|
11248 | 17 |
\emph{secrecy}. The signature provides \emph{authenticity} (proof of |
11267 | 18 |
origin), as do departmental stamps and letterheads. |
11248 | 19 |
|
20 |
Networks are vulnerable: messages pass through many computers, any of which |
|
11262 | 21 |
might be controlled by an adversary, who thus can capture or redirect |
11248 | 22 |
messages. People who wish to communicate securely over such a network can |
23 |
use cryptography, but if they are to understand each other, they need to |
|
24 |
follow a |
|
25 |
\emph{protocol}: a pre-arranged sequence of message formats. |
|
26 |
||
27 |
Protocols can be attacked in many ways, even if encryption is unbreakable. |
|
28 |
A \emph{splicing attack} involves an adversary's sending a message composed |
|
29 |
of parts of several old messages. This fake message may have the correct |
|
30 |
format, fooling an honest party. The adversary might be able to masquerade |
|
31 |
as somebody else, or he might obtain a secret key. |
|
32 |
||
33 |
\emph{Nonces} help prevent splicing attacks. A typical nonce is a 20-byte |
|
34 |
random number. Each message that requires a reply incorporates a nonce. The |
|
35 |
reply must include a copy of that nonce, to prove that it is not a replay of |
|
11267 | 36 |
a past message. The nonce in the reply must be cryptographically |
37 |
protected, since otherwise an adversary could easily replace it by a |
|
38 |
different one. You should be starting to see that protocol design is |
|
39 |
tricky! |
|
11248 | 40 |
|
41 |
Researchers are developing methods for proving the correctness of security |
|
42 |
protocols. The Needham-Schroeder public-key |
|
43 |
protocol~\cite{needham-schroeder} has become a standard test case. |
|
44 |
Proposed in 1978, it was found to be defective nearly two decades |
|
45 |
later~\cite{lowe-fdr}. This toy protocol will be useful in demonstrating |
|
46 |
how to verify protocols using Isabelle. |
|
47 |
||
48 |
||
49 |
\section{The Needham-Schroeder Public-Key Protocol}\label{sec:ns-protocol} |
|
50 |
||
11428 | 51 |
\index{Needham-Schroeder protocol|(}% |
11248 | 52 |
This protocol uses public-key cryptography. Each person has a private key, known only to |
53 |
himself, and a public key, known to everybody. If Alice wants to send Bob a secret message, she |
|
54 |
encrypts it using Bob's public key (which everybody knows), and sends it to Bob. Only Bob has the |
|
55 |
matching private key, which is needed in order to decrypt Alice's message. |
|
56 |
||
57 |
The core of the Needham-Schroeder protocol consists of three messages: |
|
58 |
\begin{alignat*}{2} |
|
59 |
&1.&\quad A\to B &: \comp{Na,A}\sb{Kb} \\ |
|
60 |
&2.&\quad B\to A &: \comp{Na,Nb}\sb{Ka} \\ |
|
61 |
&3.&\quad A\to B &: \comp{Nb}\sb{Kb} |
|
62 |
\end{alignat*} |
|
63 |
First, let's understand the notation. In the first message, Alice |
|
64 |
sends Bob a message consisting of a nonce generated by Alice~($Na$) |
|
65 |
paired with Alice's name~($A$) and encrypted using Bob's public |
|
66 |
key~($Kb$). In the second message, Bob sends Alice a message |
|
67 |
consisting of $Na$ paired with a nonce generated by Bob~($Nb$), |
|
68 |
encrypted using Alice's public key~($Ka$). In the last message, Alice |
|
69 |
returns $Nb$ to Bob, encrypted using his public key. |
|
70 |
||
71 |
When Alice receives Message~2, she knows that Bob has acted on her |
|
72 |
message, since only he could have decrypted |
|
73 |
$\comp{Na,A}\sb{Kb}$ and extracted~$Na$. That is precisely what |
|
74 |
nonces are for. Similarly, message~3 assures Bob that Alice is |
|
75 |
active. But the protocol was widely believed~\cite{ban89} to satisfy a |
|
76 |
further property: that |
|
77 |
$Na$ and~$Nb$ were secrets shared by Alice and Bob. (Many |
|
78 |
protocols generate such shared secrets, which can be used |
|
11428 | 79 |
to lessen the reliance on slow public-key operations.) |
80 |
Lowe\index{Lowe, Gavin|(} found this |
|
11248 | 81 |
claim to be false: if Alice runs the protocol with someone untrustworthy |
82 |
(Charlie say), then he can start a new run with another agent (Bob say). |
|
83 |
Charlie uses Alice as an oracle, masquerading as |
|
84 |
Alice to Bob~\cite{lowe-fdr}. |
|
85 |
\begin{alignat*}{4} |
|
11267 | 86 |
&1.&\quad A\to C &: \comp{Na,A}\sb{Kc} && |
11248 | 87 |
\qquad 1'.&\quad C\to B &: \comp{Na,A}\sb{Kb} \\ |
88 |
&2.&\quad B\to A &: \comp{Na,Nb}\sb{Ka} \\ |
|
11267 | 89 |
&3.&\quad A\to C &: \comp{Nb}\sb{Kc} && |
90 |
\qquad 3'.&\quad C\to B &: \comp{Nb}\sb{Kb} |
|
11248 | 91 |
\end{alignat*} |
92 |
In messages~1 and~3, Charlie removes the encryption using his private |
|
93 |
key and re-encrypts Alice's messages using Bob's public key. Bob is |
|
94 |
left thinking he has run the protocol with Alice, which was not |
|
95 |
Alice's intention, and Bob is unaware that the ``secret'' nonces are |
|
96 |
known to Charlie. This is a typical man-in-the-middle attack launched |
|
97 |
by an insider. |
|
98 |
||
11267 | 99 |
Whether this counts as an attack has been disputed. In protocols of this |
100 |
type, we normally assume that the other party is honest. To be honest |
|
101 |
means to obey the protocol rules, so Alice's running the protocol with |
|
102 |
Charlie does not make her dishonest, just careless. After Lowe's |
|
103 |
attack, Alice has no grounds for complaint: this protocol does not have to |
|
104 |
guarantee anything if you run it with a bad person. Bob does have |
|
105 |
grounds for complaint, however: the protocol tells him that he is |
|
106 |
communicating with Alice (who is honest) but it does not guarantee |
|
107 |
secrecy of the nonces. |
|
108 |
||
109 |
Lowe also suggested a correction, namely to include Bob's name in |
|
110 |
message~2: |
|
11248 | 111 |
\begin{alignat*}{2} |
112 |
&1.&\quad A\to B &: \comp{Na,A}\sb{Kb} \\ |
|
113 |
&2.&\quad B\to A &: \comp{Na,Nb,B}\sb{Ka} \\ |
|
114 |
&3.&\quad A\to B &: \comp{Nb}\sb{Kb} |
|
115 |
\end{alignat*} |
|
116 |
If Charlie tries the same attack, Alice will receive the message |
|
117 |
$\comp{Na,Nb,B}\sb{Ka}$ when she was expecting to receive |
|
118 |
$\comp{Na,Nb,C}\sb{Ka}$. She will abandon the run, and eventually so |
|
11267 | 119 |
will Bob. Below, we shall look at parts of this protocol's correctness |
120 |
proof. |
|
11248 | 121 |
|
11428 | 122 |
In ground-breaking work, Lowe~\cite{lowe-fdr}\index{Lowe, Gavin|)} |
123 |
showed how such attacks |
|
11248 | 124 |
could be found automatically using a model checker. An alternative, |
125 |
which we shall examine below, is to prove protocols correct. Proofs |
|
126 |
can be done under more realistic assumptions because our model does |
|
127 |
not have to be finite. The strategy is to formalize the operational |
|
128 |
semantics of the system and to prove security properties using rule |
|
11428 | 129 |
induction.% |
130 |
\index{Needham-Schroeder protocol|)} |
|
11248 | 131 |
|
132 |
||
23925
ee98c2528a8f
LaTeX code is now generated directly from theory files.
berghofe
parents:
14179
diff
changeset
|
133 |
\input{Protocol/document/Message} |
ee98c2528a8f
LaTeX code is now generated directly from theory files.
berghofe
parents:
14179
diff
changeset
|
134 |
\input{Protocol/document/Event} |
ee98c2528a8f
LaTeX code is now generated directly from theory files.
berghofe
parents:
14179
diff
changeset
|
135 |
\input{Protocol/document/Public} |
ee98c2528a8f
LaTeX code is now generated directly from theory files.
berghofe
parents:
14179
diff
changeset
|
136 |
\input{Protocol/document/NS_Public} |