]> git.lizzy.rs Git - plan9front.git/blob - sys/doc/auth.ms
xd: use new bio magic to make -u more efficient
[plan9front.git] / sys / doc / auth.ms
1 .HTML "Security in Plan 9
2 .de SS
3 .NH 2
4 ..
5 .EQ
6 delim $#
7 .EN
8 .TL
9 Security in Plan 9
10 .AU
11 Russ Cox, MIT LCS
12 .br
13 Eric Grosse, Bell Labs
14 .br
15 Rob Pike, Bell Labs
16 .br
17 Dave Presotto, Avaya Labs and Bell Labs
18 .br
19 Sean Quinlan, Bell Labs
20 .br
21 .CW {rsc,ehg,rob,presotto,seanq}@plan9.bell-labs.com
22 .AB
23 The security architecture of the Plan 9™
24 operating system has recently been redesigned
25 to address some technical shortcomings.
26 This redesign provided an opportunity also to make the system more
27 convenient to use securely.
28 Plan 9 has thus improved in two ways not usually seen together:
29 it has become more secure
30 .I and
31 easier to use.
32 .LP
33 The central component of the new architecture is a per-user
34 self-contained agent called
35 .CW factotum .
36 .CW Factotum
37 securely holds a
38 copy of the user's keys and negotiates authentication protocols, on
39 behalf of the user, with secure services around the network.
40 Concentrating security code in a single program offers several
41 advantages including: ease of update or repair to broken security
42 software and protocols; the ability to run secure services at a lower
43 privilege level; uniform management of keys for all services; and an
44 opportunity to provide single sign on, even to unchanged legacy
45 applications.
46 .CW  Factotum
47 has an unusual architecture: it is implemented
48 as a Plan 9 file server.
49 .FS
50 Appeared, in a slightly different form, in
51 .I
52 Proc. of the 2002 Usenix Security Symposium,
53 .R
54 San Francisco.
55 .FE
56 .AE
57 .NH 1
58 Introduction
59 .LP
60 Secure computing systems face two challenges:
61 first, they must employ sophisticated technology that is difficult to design
62 and prove correct; and second,
63 they must be easy for regular people to use.
64 The question of ease of use is sometimes neglected, but it is essential:
65 weak but easy-to-use security can be more effective than strong but
66 difficult-to-use security if it is more likely to be used.
67 People lock their front doors when they leave the house, knowing
68 full well that a burglar is capable of picking the lock (or avoiding
69 the door altogether); yet few would accept the cost and
70 awkwardness of a bank vault door on the
71 house even though that might reduce the probability of a robbery.
72 A related point is that users need a clear model of how the security
73 operates (if not how it actually provides security) in order to use it
74 well; for example, the clarity of a lock icon on a web browser
75 is offset by the confusing and typically insecure
76 steps for installing X.509 certificates.
77 .LP
78 The security architecture of the Plan 9
79 operating system
80 [Pike95]
81 has recently been redesigned to make it both more secure
82 and easier to use.
83 By
84 .I security
85 we mean three things:
86 first, the business of authenticating users and services;
87 second, the safe handling, deployment, and use of keys
88 and other secret information; and
89 third, the use of encryption and integrity checks
90 to safeguard communications
91 from prying eyes.
92 .LP
93 The old security architecture of Plan 9
94 had several engineering problems in common with other operating systems.
95 First, it had an inadequate notion of security domain.
96 Once a user provided a password to connect to a local file store,
97 the system required that the same password be used to access all the other file
98 stores.
99 That is, the system treated all network services as
100 belonging to the same security domain. 
101 .LP
102 Second, the algorithms and protocols used in authentication,
103 by nature tricky and difficult to get right, were compiled into the
104 various applications, kernel modules, and file servers.
105 Changes and fixes to a security protocol
106 required that all components using that protocol needed to be recompiled,
107 or at least relinked, and restarted.
108 .LP
109 Third, the file transport protocol, 9P
110 [Pike93],
111 that forms the core of
112 the Plan 9 system, had its authentication protocol embedded in its design.
113 This meant that fixing or changing the authentication used by 9P
114 required deep changes to the system.
115 If someone were to find a way to break the protocol, the system would
116 be wide open and very hard to fix.
117 .LP
118 These and a number of lesser problems, combined with a desire
119 for more widespread use of encryption in the system, spurred us to
120 rethink the entire security architecture of Plan 9.
121 .LP
122 The centerpiece of the new architecture is an agent,
123 called
124 .CW factotum ,
125 that handles the user's keys and negotiates all security
126 interactions with system services and applications.
127 Like a trusted assistant with a copy of the owner's keys,
128 .CW factotum
129 does all the negotiation for security and authentication.
130 Programs no longer need to be compiled with cryptographic
131 code; instead they communicate with
132 .CW factotum
133 agents
134 that represent distinct entities in the cryptographic exchange,
135 such as a user and server of a secure service.
136 If a security protocol needs to be added, deleted, or modified,
137 only
138 .CW factotum
139 needs to be updated for all system services
140 to be kept secure.
141 .LP
142 Building on
143 .CW factotum ,
144 we modified
145 secure services in the system to move
146 user authentication code into
147 .CW factotum ;
148 made authentication a separable component of the file server protocol;
149 deployed new security protocols;
150 designed a secure file store,
151 called
152 .CW secstore ,
153 to protect our keys but make them easy to get when they are needed;
154 designed a new kernel module to support transparent use of 
155 Transport Layer Security (TLS)
156 [RFC2246];
157 and began using encryption for all communications within the system.
158 The overall architecture is illustrated in Figure 1a.
159 .if h .B1 10 60
160 .KF
161 .EQ
162 gsize 9
163 .EN
164 .PS 3i
165
166 # Secstore
167 Sec:  box "Secstore" wid 1.3i ht .5i
168
169 # Terminal
170 Term0: box invis ht .1i with .e at Sec.e + (-1.1i, -.5i)
171 Term:  box wid 1.1i ht 1i with .nw at Term0.ne
172 Termlab: "\s-2Terminal\s+2" at Term.s + (0, -.15i)
173 FT: ellipse "$ F sub  T#" wid .40i ht .30i with .ne at Term.ne + (-.1i, -.1i)
174 PT: ellipse "$ P sub  T#" wid .6i ht .45i with .sw at Term.sw + (.2i, .2i)
175
176 # CPU
177 Cpu0: box invis ht .1i with .w at Term0.w + (3i, 0)
178 Cpu:  box wid 1.1i ht 1i with .nw at Cpu0.ne
179 Cpulab: "\s-2CPU Server\s+2" at Cpu.s + (0, -.15i)
180 FC: ellipse "$ F sub  C#" wid .40 ht .30i with .nw at Cpu.nw + (.1i, -.1i)
181 PC: ellipse "$ P sub  C#" wid .6i ht .45i with .se at Cpu.se + (-.2i, .2i)
182
183 # Authentication Server
184 Auth:  box dashed "Auth Server" wid 1.3i ht .5i with .e at Sec.e + (0, -2.3i)
185
186 # File Server
187 File0: box invis ht .1i with .w at Cpu0.w + (0, -1.5i)
188 File:  box wid 1.1i ht 1i with .nw at File0.ne
189 Filelab: "\s-2File Server\s+2" at File.s + (0, -.15i)
190 FF: ellipse "$ F sub  F#" wid .40i ht .30i with .nw at File.nw + (.1i, -.1i)
191 PF: ellipse "$ P sub  F#" wid .6i ht .45i with .se at File.se + (-.2i, .2i)
192
193 # Connections
194 line from PT.e + (0, +0.05i) to PC.w  + (0, +0.05i)
195 spline from PT.e + (0, -0.05i) right 1i then down 1.5i right .5i then right to PF.w + (0, -0.05i)
196 spline from PC.w + (0, -0.05i) left 1.1i then down 1.4i then right to PF.w + (0, 0.05i)
197 line <-> from FC.se to PC.nw
198 line <-> from FT.sw to PT.ne
199 line <-> from FF.se to PF.nw
200 spline <-> from Sec.e right .5i then down .655i then left to FT.e
201 #spline from Auth.e + (0, 0.05i) right .5i then up 1i then to FT.se
202 #spline from Auth.e + (0, 0.00i) right .7i then up 1i then to FC.sw
203 #spline from Auth.e + (0, -0.05i) right .5i then to FF.w
204 .PE
205 .LP
206 .ps 9
207 .vs 10
208 Figure 1a.  Components of the security architecture.
209 Each box is a (typically) separate machine; each ellipse a process.
210 The ellipses labeled $F sub X#
211 are
212 .CW factotum
213 processes; those labeled
214 $P sub X#
215 are the pieces and proxies of a distributed program.
216 The authentication server is one of several repositories for users' security information
217 that
218 .CW factotum
219 processes consult as required.
220 .CW Secstore
221 is a shared resource for storing private information such as keys;
222 .CW factotum
223 consults it for the user during bootstrap.
224 .sp
225 .KE
226 .if h .B2
227 .EQ
228 gsize 11
229 .EN
230 .LP
231 Secure protocols and algorithms are well understood
232 and are usually not the weakest link in a system's security.
233 In practice, most security problems arise from buggy servers,
234 confusing software, or administrative oversights.
235 It is these practical problems that we are addressing.
236 Although this paper describes the algorithms and protocols we are using,
237 they are included mainly for concreteness.
238 Our main intent is to present a simple security architecture built
239 upon a small trusted code base that is easy to verify (whether by manual or
240 automatic means), easy to understand, and easy to use.
241 .LP
242 Although it is a subjective assessment,
243 we believe we have achieved our goal of ease of use.
244 That we have achieved
245 our goal of improved security is supported by our plan to
246 move our currently private computing environment onto the Internet
247 outside the corporate firewall.
248 The rest of this paper explains the architecture and how it is used,
249 to explain why a system that is easy to use securely is also safe
250 enough to run in the open network.
251 .NH 1
252 An Agent for Security
253 .LP
254 One of the primary reasons for the redesign of the Plan 9
255 security infrastructure was to remove the authentication
256 method both from the applications and from the kernel.
257 Cryptographic code
258 is large and intricate, so it should
259 be packaged as a separate component that can be repaired or
260 modified without altering or even relinking applications
261 and services that depend on it.
262 If a security protocol is broken, it should be trivial to repair,
263 disable, or replace it on the fly.
264 Similarly, it should be possible for multiple programs to use
265 a common security protocol without embedding it in each program.
266 .LP
267 Some systems use dynamically linked libraries (DLLs) to address these configuration issues.
268 The problem with this approach is that it leaves
269 security code in the same address space as the program using it.
270 The interactions between the program and the DLL
271 can therefore accidentally or deliberately violate the interface,
272 weakening security.
273 Also, a program using a library to implement secure services
274 must run at a privilege level necessary to provide the service;
275 separating the security to a different program makes it possible
276 to run the services at a weaker privilege level, isolating the
277 privileged code to a single, more trustworthy component.
278 .LP
279 Following the lead of the SSH agent
280 [Ylon96],
281 we give each user
282 an agent process responsible
283 for holding and using the user's keys.
284 The agent program is called
285 .CW factotum
286 because of its similarity to the proverbial servant with the
287 power to act on behalf of his master because he holds the
288 keys to all the master's possessions.  It is essential that
289 .CW factotum
290 keep the keys secret and use them only in the owner's interest.
291 Later we'll discuss some changes to the kernel to reduce the possibility of
292 .CW factotum
293 leaking information inadvertently.
294 .LP
295 .CW Factotum
296 is implemented, like most Plan 9 services, as a file server.
297 It is conventionally mounted upon the directory
298 .CW /mnt/factotum ,
299 and the files it serves there are analogous to virtual devices that provide access to,
300 and control of, the services of the
301 .CW factotum .
302 The next few sections describe the design of
303 .CW factotum
304 and how it operates with the other pieces of Plan 9 to provide
305 security services.
306 .SS
307 Logging in
308 .LP
309 To make the discussions that follow more concrete,
310 we begin with a couple of examples showing how the
311 Plan 9 security architecture appears to the user.
312 These examples both involve a user
313 .CW gre
314 logging in after booting a local machine.
315 The user may or may not have a secure store in which
316 all his keys are kept.
317 If he does,
318 .CW factotum
319 will prompt him for the password to the secure store
320 and obtain keys from it, prompting only when a key
321 isn't found in the store.
322 Otherwise,
323 .CW factotum
324 must prompt for each key.
325 .LP
326 In the typescripts, \f6\s9\en\s0\fP
327 represents a literal newline
328 character typed to force a default response.
329 User input is in italics, and
330 long lines are folded and indented to fit.
331 .LP
332 This first example shows a user logging in without
333 help from the secure store.
334 First,
335 .CW factotum
336 prompts for a user name that the local kernel
337 will use:
338 .P1
339 user[none]: \f6\s9gre\s0\fP
340 .P2
341 (Default responses appear in square brackets.)
342 The kernel then starts accessing local resources
343 and requests, through
344 .CW factotum ,
345 a user/password pair to do so:
346 .P1
347 !Adding key: dom=cs.bell-labs.com
348     proto=p9sk1
349 user[gre]: \f6\s9\en\s0\fP
350 password: \f6****\fP
351 .P2
352 Now the user is logged in to the local system, and
353 the mail client starts up:
354 .P1
355 !Adding key: proto=apop
356     server=plan9.bell-labs.com
357 user[gre]: \f6\s9\en\s0\fP
358 password: \f6****\fP
359 .P2
360 .CW Factotum
361 is doing all the prompting and the applications
362 being started are not even touching the keys.
363 Note that it's always clear which key is being requested.
364 .LP
365 Now consider the same login sequence, but in the case where
366 .CW gre
367 has a secure store account:
368 .P1
369 user[none]: \f6\s9gre\s0\fP
370 secstore password: \f6*********\fP
371 STA PIN+SecurID: \f6*********\fP
372 .P2
373 That's the last
374 .CW gre
375 will hear from
376 .CW factotum
377 unless an attempt is made to contact
378 a system for which no key is kept in the secure store.
379 .SS
380 The factotum
381 .LP
382 Each computer running Plan 9 has one user id that owns all the
383 resources on that system \(em the scheduler, local disks,
384 network interfaces, etc.
385 That user, the
386 .I "host owner" ,
387 is the closest analogue in Plan 9 to a Unix
388 .CW root
389 account (although it is far weaker;
390 rather than having special powers, as its name implies the host owner
391 is just a regular user that happens to own the
392 resources of the local machine).
393 On a single-user system, which we call a terminal,
394 the host owner is the id of the terminal's user.
395 Shared servers such as CPU servers normally have a pseudo-user
396 that initially owns all resources.
397 At boot time, the Plan 9 kernel starts a
398 .CW factotum
399 executing as, and therefore with the privileges of,
400 the host owner.
401 .LP
402 New processes run as
403 the same user as the process which created them.
404 When a process must take on the identity of a new user,
405 such as to provide a login shell
406 on a shared CPU server,
407 it does so by proving to the host owner's
408 .CW factotum
409 that it is
410 authorized to do so.
411 This is done by running an
412 authentication protocol with
413 .CW factotum
414 to
415 prove that the process has access to secret information
416 which only the new user should possess.
417 For example, consider the setup in Figure 1a.
418 If a user on the terminal
419 wants to log in to the CPU server using the
420 Plan 9
421 .CW cpu
422 service
423 [Pike93],
424 then
425 $P sub T#
426 might be the
427 .CW cpu
428 client program and
429 $P sub C#
430 the
431 .CW cpu
432 server.
433 Neither $P sub C# nor $P sub T#
434 knows the details of the authentication.
435 They
436 do need to be able to shuttle messages back and
437 forth between the two
438 .CW factotums ,
439 but this is
440 a generic function easily performed without
441 knowing, or being able to extract, secrets in
442 the messages.
443 $P sub T#
444 will make a network connection to $P sub C#.
445 $P sub T#
446 and
447 $P sub C#
448 will then relay messages between
449 the
450 .CW factotum
451 owned by the user, $F sub T#,
452 and the one owned by the CPU server, $F sub C#,
453 until mutual authentication has been established.
454 Later
455 sections describe the RPC between
456 .CW factotum
457 and
458 applications and the library functions to support proxy operations.
459 .LP
460 The kernel always uses a single local instance of
461 .CW factotum ,
462 running as the
463 host owner, for
464 its authentication purposes, but
465 a regular user may start other
466 .CW factotum
467 agents.
468 In fact, the
469 .CW factotum
470 representing the user need not be
471 running on the same machine as its client.
472 For instance, it is easy for a user on a CPU server,
473 through standard Plan 9 operations,
474 to replace the
475 .CW /mnt/factotum
476 in the user's private file name space on the server
477 with a connection to the
478 .CW factotum
479 running on the terminal.
480 (The usual file system permissions prevent interlopers
481 from doing so maliciously.)
482 This permits secure operations on the CPU server to be
483 transparently validated by the user's own
484 .CW factotum ,
485 so
486 secrets need never leave the user's terminal.
487 The SSH agent
488 [Ylon96]
489 does much the
490 same with special SSH protocol messages, but
491 an advantage to making our agent a file system
492 is that we need no new mechanism to access our remote
493 agent; remote file access is sufficient.
494 .LP
495 Within
496 .CW factotum ,
497 each protocol is implemented as a state
498 machine with a generic interface, so protocols are in
499 essence pluggable modules, easy to add, modify, or drop.
500 Writing a message to and reading a message from
501 .CW factotum
502 each require a separate RPC and result in
503 a single state transition.
504 Therefore
505 .CW factotum
506 always runs to completion on every RPC and never blocks
507 waiting for input during any authentication.
508 Moreover, the number of simultaneous
509 authentications is limited only by the amount of memory we're
510 willing to dedicate to representing the state machines.
511 .LP
512 Authentication protocols are implemented only
513 within
514 .CW factotum ,
515 but adding and removing
516 protocols does require relinking the binary, so
517 .CW factotum
518 processes (but no others)
519 need to be restarted in order to take advantage of
520 new or repaired protocols.
521 .LP
522 At the time of writing, 
523 .CW factotum
524 contains authentication
525 modules for the Plan 9 shared key protocol (p9sk1),
526 SSH's RSA authentication, passwords in the clear, APOP, CRAM, PPP's CHAP,
527 Microsoft PPP's MSCHAP, and VNC's challenge/response.
528 .SS
529 Local capabilities
530 .LP
531 A capability system, managed by the kernel, is used to empower
532 .CW factotum
533 to grant permission to another process to change its user id.
534 A
535 kernel device driver
536 implements two files,
537 .CW /dev/caphash
538 and
539 .CW /dev/capuse .
540 The write-only file
541 .CW /dev/caphash
542 can be opened only by the host owner, and only once.
543 .CW Factotum
544 opens this file immediately after booting.
545 .LP
546 To use the files,
547 .CW factotum
548 creates a string of the form
549 .I userid1\f(CW@\fPuserid2\f(CW@\fPrandom-string ,
550 uses SHA1 HMAC to hash
551 .I userid1\f(CW@\fPuserid2
552 with key
553 .I random-string ,
554 and writes that hash to
555 .CW /dev/caphash .
556 .CW Factotum
557 then passes the original string to another
558 process on the same machine, running
559 as user
560 .I userid1 ,
561 which
562 writes the string to
563 .CW /dev/capuse .
564 The kernel hashes the string and looks for
565 a matching hash in its list.
566 If it finds one,
567 the writing process's user id changes from
568 .I userid1
569 to
570 .I userid2 .
571 Once used, or if a timeout expires,
572 the capability is discarded by the kernel.
573 .LP
574 The capabilities are local to the machine on which they are created.
575 Hence a
576 .CW factotum
577 running on one machine cannot pass capabilities
578 to processes on another and expect them to work.
579 .SS
580 Keys
581 .LP
582 We define the word
583 .I key
584 to mean not only a secret, but also a description of the
585 context in which that secret is to be used: the protocol,
586 server, user, etc. to which it applies.
587 That is,
588 a key is a combination of secret and descriptive information
589 used to authenticate the identities of parties
590 transmitting or receiving information.
591 The set of keys used
592 in any authentication depends both on the protocol and on
593 parameters passed by the program requesting the authentication.
594 .LP
595 Taking a tip from SDSI
596 [RiLa],
597 which represents security information as textual S-expressions,
598 keys in Plan 9 are represented as plain UTF-8 text.
599 Text is easily
600 understood and manipulated by users.
601 By contrast,
602 a binary or other cryptic format
603 can actually reduce overall security.
604 Binary formats are difficult for users to examine and can only be
605 cracked by special tools, themselves poorly understood by most users.
606 For example, very few people know or understand what's inside
607 their X.509 certificates.
608 Most don't even know where in the system to
609 find them.
610 Therefore, they have no idea what they are trusting, and why, and
611 are powerless to change their trust relationships.
612 Textual, centrally stored and managed keys are easier to use and safer.
613 .LP
614 Plan 9 has historically represented databases as attribute/value pairs,
615 since they are a good foundation for selection and projection operations.
616 .CW Factotum
617 therefore represents
618 the keys in the format
619 .I attribute\f(CW=\fPvalue ,
620 where
621 .I attribute
622 is an identifier, possibly with a single-character prefix, and
623 .I value
624 is an arbitrary quoted string.
625 The pairs themselves are separated by white space.
626 For example, a Plan 9 key and an APOP key
627 might be represented like this:
628 .P1
629 dom=bell-labs.com proto=p9sk1 user=gre
630         !password='don''t tell'
631 proto=apop server=x.y.com user=gre
632         !password='open sesame'
633 .P2
634 If a value is empty or contains white space or single quotes, it must be quoted;
635 quotes are represented by doubled single quotes.
636 Attributes that begin with an exclamation mark
637 .CW ! ) (
638 are considered
639 .I secret .
640 .CW Factotum
641 will never let a secret value escape its address space
642 and will suppress keyboard echo when asking the user to type one.
643 .LP
644 A program requesting authentication selects a key
645 by providing a
646 .I query ,
647 a list of elements to be matched by the key.
648 Each element in the list is either an
649 .I attribute\f(CW=\fPvalue
650 pair, which is satisfied by keys with
651 exactly that pair;
652 or an attribute followed by a question mark,
653 .I attribute\f(CW? ,
654 which is satisfied by keys with some pair specifying
655 the attribute.
656 A key matches a query if every element in the list
657 is satisfied.
658 For instance, to select the APOP key in the previous example,
659 an APOP client process might specify the query
660 .P1
661 server=x.y.com proto=apop
662 .P2
663 Internally,
664 .CW factotum 's
665 APOP module would add the requirements of
666 having
667 .CW user
668 and
669 .CW !password
670 attributes, forming the query
671 .P1
672 server=x.y.com proto=apop user? !password?
673 .P2
674 when searching for an appropriate key.
675 .LP
676 .CW Factotum
677 modules expect keys to have some well-known attributes.
678 For instance, the
679 .CW proto
680 attribute specifies the protocol module
681 responsible for using a particular key,
682 and protocol modules may expect other well-known attributes
683 (many expect keys to have
684 .CW !password
685 attributes, for example).
686 Additional attributes can be used as comments or for
687 further discrimination without intervention by 
688 .CW factotum ; 
689 for example, the APOP and IMAP mail clients conventionally
690 include a
691 .CW server
692 attribute to select an appropriate key for authentication.
693 .LP
694 Unlike in SDSI,
695 keys in Plan 9 have no nested structure.  This design
696 keeps the representation simple and straightforward.
697 If necessary, we could add a nested attribute
698 or, in the manner of relational databases, an attribute that
699 selects another tuple, but so far the simple design has been sufficient.
700 .LP
701 A simple common structure for all keys makes them easy for users
702 to administer,
703 but the set of attributes and their interpretation is still
704 protocol-specific and can be subtle.
705 Users may still
706 need to consult a manual to understand all details.
707 Many attributes
708 .CW proto , (
709 .CW user ,
710 .CW password ,
711 .CW server )
712 are self-explanatory and our short experience
713 has not uncovered any particular difficulty in handling keys.
714 Things
715 will likely get messier, however,
716 when we grapple with public
717 keys and their myriad components.
718 .SS
719 Protecting keys
720 .LP
721 Secrets must be prevented from escaping
722 .CW factotum .
723 There are a number of ways they could leak:
724 another process might be able to debug the agent process, the
725 agent might swap out to disk, or the process might willingly
726 disclose the key.
727 The last is the easiest to avoid:
728 secret information in a key is marked
729 as such, and
730 whenever
731 .CW factotum
732 prints keys or queries for new
733 ones, it is careful to avoid displaying secret information.
734 (The only exception to this is the
735 ``plaintext password'' protocol, which consists
736 of sending the values of the
737 .CW user
738 and
739 .CW !password
740 attributes.
741 Only keys tagged with
742 .CW proto=pass
743 can have their passwords disclosed by this mechanism.)
744 .LP
745 Preventing the first two forms of leakage
746 requires help from the kernel.
747 In Plan 9, every process is
748 represented by a directory in the
749 .CW /proc
750 file system.
751 Using the files in this directory,
752 other processes could (with appropriate access permission) examine
753 .CW factotum 's
754 memory and registers.
755 .CW Factotum
756 is protected from processes of other users
757 by the default access bits of its
758 .CW /proc
759 directory.
760 However, we'd also like to protect the
761 agent from other processes owned by the same user,
762 both to avoid honest mistakes and to prevent
763 an unattended terminal being
764 exploited to discover secret passwords.
765 To do this, we added a control message to
766 .CW /proc
767 called
768 .CW private .
769 Once the
770 .CW factotum
771 process has written
772 .CW private
773 to its
774 .CW /proc/\f2pid\fP/ctl
775 file, no process can access
776 .CW factotum 's
777 memory
778 through
779 .CW /proc .
780 (Plan 9 has no other mechanism, such as
781 .CW /dev/kmem ,
782 for accessing a process's memory.)
783 .LP
784 Similarly, the agent's address space should not be
785 swapped out, to prevent discovering unencrypted
786 keys on the swapping media.
787 The
788 .CW noswap
789 control message in
790 .CW /proc
791 prevents this scenario.
792 Neither
793 .CW private
794 nor
795 .CW noswap
796 is specific to
797 .CW factotum .
798 User-level file servers such as
799 .CW dossrv ,
800 which interprets FAT file systems,
801 could use
802 .CW noswap
803 to keep their buffer caches from being
804 swapped to disk.
805 .LP
806 Despite our precautions, attackers might still
807 find a way to gain access to a process running as the host
808 owner on a machine.
809 Although they could not directly
810 access the keys, attackers could use the local
811 .CW factotum
812 to perform authentications for them.
813 In the case
814 of some keys, for example those locking bank
815 accounts, we want a way to disable or at least
816 detect such access.
817 That is the role of the
818 .CW confirm
819 attribute in a key.
820 Whenever a key with a
821 .CW confirm
822 attribute is accessed, the local user must
823 confirm use of the key via a local GUI.
824 The next section describes the actual mechanism.
825 .LP
826 We have not addressed leaks possible as a result of
827 someone rebooting or resetting a machine running
828 .CW factotum .
829 For example, someone could reset a machine
830 and reboot it with a debugger instead of a kernel,
831 allowing them to examine the contents of memory
832 and find keys.  We have not found a satisfactory
833 solution to this problem.
834 .SS
835 Factotum transactions
836 .LP
837 External programs manage
838 .CW factotum 's
839 internal key state
840 through its file interface,
841 writing textual
842 .CW key
843 and
844 .CW delkey
845 commands to the
846 .CW /mnt/factotum/ctl
847 file.
848 Both commands take a list of attributes as an argument.
849 .CW Key
850 creates a key with the given attributes, replacing any
851 extant key with an identical set of public attributes.
852 .CW Delkey
853 deletes all keys that match the given set of attributes.
854 Reading the 
855 .CW ctl
856 file returns a list of keys, one per line, displaying only public attributes.
857 The following example illustrates these interactions.
858 .P1
859 % cd /mnt/factotum
860 % ls -l
861 -lrw------- gre gre 0 Jan 30 22:17 confirm
862 --rw------- gre gre 0 Jan 30 22:17 ctl
863 -lr-------- gre gre 0 Jan 30 22:17 log
864 -lrw------- gre gre 0 Jan 30 22:17 needkey
865 --r--r--r-- gre gre 0 Jan 30 22:17 proto
866 --rw-rw-rw- gre gre 0 Jan 30 22:17 rpc
867 % cat >ctl
868 key dom=bell-labs.com proto=p9sk1 user=gre
869     !password='don''t tell'
870 key proto=apop server=x.y.com user=gre
871     !password='bite me'
872 ^D
873 % cat ctl
874 key dom=bell-labs.com proto=p9sk1 user=gre
875 key proto=apop server=x.y.com user=gre
876 % echo 'delkey proto=apop' >ctl
877 % cat ctl
878 key dom=bell-labs.com proto=p9sk1 user=gre
879
880 .P2
881 (A file with the
882 .CW l
883 bit set can be opened by only one process at a time.)
884 .LP
885 The heart of the interface is the
886 .CW rpc
887 file.
888 Programs authenticate with
889 .CW factotum
890 by writing a request to the
891 .CW rpc
892 file
893 and reading back the reply; this sequence is called an RPC
894 .I transaction .
895 Requests and replies have the same format:
896 a textual verb possibly followed by arguments,
897 which may be textual or binary.
898 The most common reply verb is
899 .CW ok ,
900 indicating success.
901 An RPC session begins with a
902 .CW start
903 transaction; the argument is a key query as described
904 earlier.
905 Once started, an RPC conversation usually consists of 
906 a sequence of
907 .CW read
908 and
909 .CW write
910 transactions.
911 If the conversation is successful, an
912 .CW authinfo
913 transaction will return information about
914 the identities learned during the transaction.
915 The
916 .CW attr
917 transaction returns a list of attributes for the current
918 conversation; the list includes any attributes given in
919 the 
920 .CW start
921 query as well as any public attributes from keys being used.
922 .LP
923 As an example of the
924 .CW rpc
925 file in action, consider a mail client
926 connecting to a mail server and authenticating using
927 the POP3 protocol's APOP challenge-response command.
928 There are four programs involved: the mail client $P sub C#, the client
929 .CW factotum
930 $F sub C#, the mail server $P sub S#, and the server
931 .CW factotum
932 $F sub S#.
933 All authentication computations are handled by the
934 .CW factotum
935 processes.
936 The mail programs' role is just to relay messages.
937 .LP
938 At startup, the mail server at
939 .CW x.y.com
940 begins an APOP conversation
941 with its
942 .CW factotum
943 to obtain the banner greeting, which
944 includes a challenge:
945 .P1
946 $P sub S -> F sub S#: start proto=apop role=server
947 $F sub S -> P sub S#: ok
948 $P sub S -> F sub S#: read
949 $F sub S -> P sub S#: ok +OK POP3 \f2challenge\fP
950 .P2
951 Having obtained the challenge, the server greets the client:
952 .P1
953 $P sub S -> P sub C#: +OK POP3 \f2challenge\fP
954 .P2
955 The client then uses an APOP conversation with its
956 .CW factotum
957 to obtain a response:
958 .P1
959 $P sub C -> F sub C#: start proto=apop role=client
960             server=x.y.com
961 $F sub C -> P sub C#: ok
962 $P sub C -> F sub C#: write +OK POP3 \f2challenge\fP
963 $F sub C -> P sub C#: ok
964 $P sub C -> F sub C#: read
965 $F sub C -> P sub C#: ok APOP gre \f2response\fP
966 .P2
967 .CW Factotum
968 requires that
969 .CW start
970 requests include a 
971 .CW proto
972 attribute, and the APOP module requires an additional
973 .CW role
974 attribute, but the other attributes are optional and only
975 restrict the key space.
976 Before responding to the
977 .CW start
978 transaction, the client
979 .CW factotum
980 looks for a key to
981 use for the rest of the conversation.
982 Because of the arguments in the
983 .CW start
984 request, the key must have public attributes
985 .CW proto=apop
986 and
987 .CW server=x.y.com ;
988 as mentioned earlier,
989 the APOP module additionally requires that the key have
990 .CW user
991 and
992 .CW !password
993 attributes.
994 Now that the client has obtained a response
995 from its
996 .CW factotum ,
997 it echoes that response to the server:
998 .P1
999 $P sub C -> P sub S#: APOP gre \f2response\fP
1000 .P2
1001 Similarly, the server passes this message to
1002 its
1003 .CW factotum
1004 and obtains another to send back.
1005 .P1
1006 $P sub S -> F sub S#: write APOP gre \f2response\fP
1007 $F sub S -> P sub S#: ok
1008 $P sub S -> F sub S#: read
1009 $F sub S -> P sub S#: ok +OK welcome
1010
1011 $P sub S -> P sub C#: +OK welcome
1012 .P2
1013 Now the authentication protocol is done, and
1014 the server can retrieve information
1015 about what the protocol established.
1016 .P1
1017 $P sub S -> F sub S#: authinfo
1018 $F sub S -> P sub S#: ok client=gre
1019             capability=\f2capability\fP
1020 .P2
1021 The
1022 .CW authinfo
1023 data is a list of
1024 .I attr\f(CW=\fPvalue
1025 pairs, here a client user name and a capability.
1026 (Protocols that establish shared secrets or provide
1027 mutual authentication indicate this by adding
1028 appropriate
1029 .I attr\f(CW=\fPvalue
1030 pairs.)
1031 The capability can be used by the server to change its
1032 identity to that of the client, as described earlier.
1033 Once it has changed its identity, the server can access and serve
1034 the client's mailbox.
1035 .LP
1036 Two more files provide hooks for a graphical
1037 .CW factotum
1038 control interface.
1039 The first, 
1040 .CW confirm ,
1041 allows the user detailed control over the use of certain keys.
1042 If a key has a
1043 .CW confirm=
1044 attribute, then the user must approve each use of the key.
1045 A separate program with a graphical interface reads from the
1046 .CW confirm
1047 file to see when a confirmation is necessary.
1048 The read blocks until a key usage needs to be approved, whereupon
1049 it will return a line of the form
1050 .P1
1051 confirm tag=1 \f2attributes\fP
1052 .P2
1053 requesting permission to use the key with those public attributes.
1054 The graphical interface then prompts the user for approval
1055 and writes back
1056 .P1
1057 tag=1 answer=yes
1058 .P2
1059 (or
1060 .CW answer=no ).
1061 .LP
1062 The second file,
1063 .CW needkey ,
1064 diverts key requests.
1065 In the APOP example, if a suitable key had not been found
1066 during the
1067 .CW start
1068 transaction,
1069 .CW factotum
1070 would have indicated failure by
1071 returning a response indicating
1072 what key was needed:
1073 .P1
1074 $F sub C -> P sub C#: needkey proto=apop
1075     server=x.y.com user? !password?
1076 .P2
1077 A typical client would then prompt the user for the desired
1078 key information, create a new key via the
1079 .CW ctl
1080 file, and then reissue the 
1081 .CW start
1082 request.
1083 If the
1084 .CW needkey
1085 file is open,
1086 then instead of failing, the transaction
1087 will block, and the next read from the
1088 .CW /mnt/factotum/needkey
1089 file will return a line of the form
1090 .P1
1091 needkey tag=1 \f2attributes\f2
1092 .P2
1093 The graphical interface then prompts the user for the needed
1094 key information, creates the key via the
1095 .CW ctl
1096 file, and writes back
1097 .CW tag=1
1098 to resume the transaction.
1099 .LP
1100 The remaining files are informational and used for debugging.
1101 The
1102 .CW proto
1103 file contains a list of supported protocols (to see what protocols the
1104 system supports,
1105 .CW cat
1106 .CW /mnt/factotum/proto ),
1107 and the
1108 .CW log
1109 file contains a log of operations and debugging output
1110 enabled by a
1111 .CW debug
1112 control message.
1113 .LP
1114 The next few sections explain how
1115 .CW factotum
1116 is used by system services.
1117 .NH 1
1118 Authentication in 9P
1119 .LP
1120 Plan 9 uses a remote file access protocol, 9P
1121 [Pike93],
1122 to connect to resources such as the
1123 file server and remote processes.
1124 The original design for 9P included special messages at the start of a conversation
1125 to authenticate the user.
1126 Multiple users can share a single connection, such as when a CPU server
1127 runs processes for many users connected to a single file server,
1128 but each must authenticate separately.
1129 The authentication protocol, similar to that of Kerberos
1130 [Stei88],
1131 used a sequence of messages passed between client, file server, and authentication
1132 server to verify the identities of the user, calling machine, and serving machine.
1133 One major drawback to the design was that the authentication method was defined by 9P
1134 itself and could not be changed.  
1135 Moreover, there was no mechanism to relegate
1136 authentication to an external (trusted) agent,
1137 so a process implementing 9P needed, besides support for file service,
1138 a substantial body of cryptographic code to implement a handful of startup messages
1139 in the protocol.
1140 .LP
1141 A recent redesign of 9P
1142 addressed a number of file service issues outside the scope of this paper.
1143 On issues of authentication, there were two goals:
1144 first, to remove details about authentication from the
1145 protocol itself; second, to allow an external program to execute the authentication
1146 part of the protocol.
1147 In particular, we wanted a way to quickly incorporate
1148 ideas found in other systems such as SFS
1149 [Mazi99].
1150 .LP
1151 Since 9P is a file service protocol, the solution involved creating a new type of file
1152 to be served: an
1153 .I authentication
1154 .I file .
1155 Connections to a 9P service begin in a state that
1156 allows no general file access but permits the client
1157 to open an authentication file
1158 by sending a special message, generated by the new
1159 .CW fauth
1160 system call:
1161 .P1
1162 afd = fauth(int fd, char *servicename);
1163 .P2
1164 Here
1165 .CW fd
1166 is the user's file descriptor for the established network connection to the 9P server
1167 and
1168 .CW servicename
1169 is the name of the desired service offered on that server, typically the file subsystem
1170 to be accessed.
1171 The returned file descriptor,
1172 .CW afd ,
1173 is a unique handle representing the authentication file
1174 created for this connection to authenticate to
1175 this service; it is analogous to a capability.
1176 The authentication file represented by
1177 .CW afd
1178 is not otherwise addressable on the server, such as through
1179 the file name hierarchy.
1180 In all other respects, it behaves like a regular file;
1181 most important, it accepts standard read and write operations.
1182 .LP
1183 To prove its identity, the user process (via
1184 .CW factotum )
1185 executes the authentication protocol,
1186 described in the next section of this paper,
1187 over the
1188 .CW afd
1189 file descriptor with ordinary reads and writes.
1190 When client and server have successfully negotiated, the authentication file
1191 changes state so it can be used as evidence of authority in
1192 .CW mount .
1193 .LP
1194 Once identity is established, the process presents the (now verified)
1195 .CW afd
1196 as proof of identity to the
1197 .CW mount
1198 system call:
1199 .P1
1200 mount(int fd, int afd, char *mountpoint,
1201       int flag, char *servicename)
1202 .P2
1203 If the
1204 .CW mount
1205 succeeds, the user now
1206 has appropriate permissions for the file hierarchy made
1207 visible at the mount point.
1208 .LP
1209 This sequence of events has several advantages.
1210 First, the actual authentication protocol is implemented using regular reads and writes,
1211 not special 9P messages, so
1212 they can be processed, forwarded, proxied, and so on by
1213 any 9P agent without special arrangement.
1214 Second, the business of negotiating the authentication by reading and writing the
1215 authentication file can be delegated to an outside agent, in particular
1216 .CW factotum ;
1217 the programs that implement the client and server ends of a 9P conversation need
1218 no authentication or cryptographic code.
1219 Third,
1220 since the authentication protocol is not defined by 9P itself, it is easy to change and
1221 can even be negotiated dynamically.
1222 Finally, since
1223 .CW afd
1224 acts like a capability, it can be treated like one:
1225 handed to another process to give it special permissions;
1226 kept around for later use when authentication is again required;
1227 or closed to make sure no other process can use it.
1228 .LP
1229 All these advantages stem from moving the authentication negotiation into
1230 reads and writes on a separate file.
1231 As is often the case in Plan 9,
1232 making a resource (here authentication) accessible with a file-like interface
1233 reduces
1234 .I a
1235 .I priori
1236 the need for special interfaces.
1237 .LP
1238 .SS
1239 Plan 9 shared key protocol
1240 .LP
1241 In addition to the various standard protocols supported by
1242 .CW factotum ,
1243 we use a shared key protocol for native
1244 Plan 9 authentication.
1245 This protocol provides backward compatibility with
1246 older versions of the system.  One reason for the new
1247 architecture is to let us replace such protocols
1248 in the near future with more cryptographically secure ones.
1249 .LP
1250 .I P9sk1
1251 is a shared key protocol that uses tickets much like those
1252 in the original Kerberos.
1253 The difference is that we've
1254 replaced the expiration time in Kerberos tickets with
1255 a random nonce parameter and a counter.
1256 We summarize it here:
1257 .P1
1258 $C -> S: ~~ "nonce" sub C#
1259 $S -> C: ~~ "nonce" sub S , "uid" sub S , "domain" sub S#
1260
1261 $C -> A: ~~ "nonce" sub S , "uid" sub S , "domain" sub S , "uid" sub C ,#
1262          $"factotum" sub C#
1263 $A -> C: ~~ K sub C roman "{" "nonce" sub S , "uid" sub C , "uid" sub S, K sub n roman "}",#
1264          $K sub S roman "{" "nonce" sub S , "uid" sub C , "uid" sub S, K sub n roman "}"#
1265
1266 $C -> S: ~~ K sub S roman "{" "nonce" sub S , "uid" sub C , "uid" sub S , K sub n roman "}",#
1267          $K sub n roman "{" "nonce" sub S , "counter" roman "}"#
1268 $S -> C: ~~ K sub n roman "{" "nonce" sub C , "counter" roman "}"#
1269 .P2
1270 (Here $K roman "{" x roman "}"# indicates $x# encrypted with
1271 DES key $K#.)
1272 The first two messages exchange nonces and server identification.
1273 After this initial exchange, the client contacts the authentication
1274 server to obtain a pair of encrypted tickets, one encrypted with
1275 the client key and one with the server key.
1276 The client relays the server ticket to the server.
1277 The server believes that the ticket is new
1278 because it contains
1279 $"nonce" sub S#
1280 and that the ticket is from the authentication
1281 server because it is encrypted in the server key $K sub S#.
1282 The ticket is basically a statement from the authentication
1283 server that now $"uid" sub C# and $"uid" sub S# share a
1284 secret $K sub n#.
1285 The authenticator $K sub n roman "{" "nonce" sub S , "counter" roman "}"#
1286 convinces the server that the client knows $K sub n# and thus
1287 must be $"uid" sub C#.
1288 Similarly, authenticator $K sub n roman "{" "nonce" sub C , "counter" roman "}"#
1289 convinces the client that the server knows $K sub n# and thus
1290 must be $"uid" sub S#.
1291 Tickets can be reused, without contacting the authentication
1292 server again, by incrementing the counter before each
1293 authenticator is generated.
1294 .LP
1295 In the future we hope to introduce a public key version of
1296 p9sk1,
1297 which would allow authentication even
1298 when the authentication server is not available.
1299 .SS
1300 The authentication server
1301 .LP
1302 Each Plan 9 security domain has an authentication server (AS)
1303 that all users trust to keep the complete set of shared keys.
1304 It also offers services for users and administrators to manage the
1305 keys, create and disable accounts, and so on.
1306 It typically runs on
1307 a standalone machine with few other services.
1308 The AS comprises two services,
1309 .CW keyfs
1310 and
1311 .CW authsrv .
1312 .LP
1313 .CW Keyfs
1314 is a user-level file system that manages an
1315 encrypted database of user accounts.
1316 Each account is represented by a directory containing the
1317 files
1318 .CW key ,
1319 containing the Plan 9 key for p9sk1;
1320 .CW secret
1321 for the challenge/response protocols (APOP, VNC, CHAP, MSCHAP,
1322 CRAM);
1323 .CW log
1324 for authentication outcomes;
1325 .CW expire
1326 for an expiration time; and
1327 .CW status .
1328 If the expiration time passes,
1329 if the number of successive failed authentications
1330 exceeds 50, or if
1331 .CW disabled
1332 is written to the status file,
1333 any attempt to access the
1334 .CW key
1335 or
1336 .CW secret
1337 files will fail.
1338 .LP
1339 .CW Authsrv
1340 is a network service that brokers shared key authentications
1341 for the protocols p9sk1, APOP, VNC, CHAP, MSCHAP,
1342 and CRAM.  Remote users can also call
1343 .CW authsrv
1344 to change their passwords.
1345 .LP
1346 The
1347 p9sk1
1348 protocol was described in the previous
1349 section.
1350 The challenge/response protocols differ
1351 in detail but all follow the general structure:
1352 .P1
1353 $C -> S: ~~ "nonce" sub C#
1354 $S -> C: ~~ "nonce" sub S , "uid" sub S ,"domain" sub S#
1355 $C -> A: ~~ "nonce" sub S , "uid" sub S , "domain" sub S ,#
1356          $"hostid" sub C , "uid" sub C#
1357 $A -> C: ~~ K sub C roman "{" "nonce" sub S , "uid" sub C , "uid" sub S, K sub n roman "}",#
1358          $K sub S roman "{" "nonce" sub S , "uid" sub C , "uid" sub S, K sub n roman "}"#
1359 $C -> S: ~~ K sub S roman "{" "nonce" sub S , "uid" sub C , "uid" sub S, K sub n roman "}",#
1360          $K sub n roman "{" "nonce" sub S roman "}"#
1361 $S -> C: ~~ K sub n roman "{" "nonce" sub C roman "}"#
1362 .P2
1363 The password protocol is:
1364 .P1
1365 $C -> A: ~~ "uid" sub C#
1366 $A -> C: ~~ K sub c roman "{" K sub n roman "}"#
1367 $C -> A: ~~ K sub n roman "{" "password" sub "old" , "password" sub "new" roman "}"#
1368 $A -> C: ~~ OK#
1369 .P2
1370 To avoid replay attacks, the pre-encryption
1371 clear text for each of the protocols (as well as for p9sk1) includes
1372 a tag indicating the encryption's role in the
1373 protocol.  We elided them in these outlines.
1374 .SS
1375 Protocol negotiation
1376 .LP
1377 Rather than require particular protocols for particular services,
1378 we implemented a negotiation metaprotocol,
1379 .I p9any ,
1380 which chooses the actual authentication protocol to use.
1381 P9any
1382 is used now by all native services on Plan 9.
1383 .LP
1384 The metaprotocol is simple.  The callee sends a
1385 null-terminated string of the form:
1386 .P1
1387 v.$n# $proto sub 1#@$domain sub 1# $proto sub 2#@$domain sub 2# ...
1388 .P2
1389 where
1390 .I n
1391 is a decimal version number, $proto sub k#
1392 is the name of a protocol for which the
1393 .CW factotum
1394 has a key, and $domain sub k#
1395 is the name of the domain in which the key is
1396 valid.
1397 The caller then responds
1398 .P1
1399 \f2proto\fP@\f2domain\fP
1400 .P2
1401 indicating its choice.
1402 Finally the callee responds
1403 .P1
1404 OK
1405 .P2
1406 Any other string indicates failure.
1407 At this point the chosen protocol commences.
1408 The final fixed-length reply is used to make it easy to
1409 delimit the I/O stream should the chosen protocol
1410 require the caller rather than the callee to send the first message.
1411 .LP
1412 With this negotiation metaprotocol, the underlying
1413 authentication protocols used for Plan 9 services
1414 can be changed under any application just
1415 by changing the keys known by the
1416 .CW factotum
1417 agents at each end.
1418 .LP
1419 P9any is vulnerable to man in the middle attacks
1420 to the extent that the attacker may constrain the
1421 possible choices by changing the stream.  However,
1422 we believe this is acceptable since the attacker
1423 cannot force either side to choose algorithms
1424 that it is unwilling to use.
1425 .NH 1
1426 Library Interface to Factotum
1427 .LP
1428 Although programs can access
1429 .CW factotum 's
1430 services through its file system interface,
1431 it is more common to use a C library that
1432 packages the interaction.
1433 There are a number of routines in the library,
1434 not all of which are relevant here, but a few
1435 examples should give their flavor.
1436 .LP
1437 First, consider the problem of mounting a remote file server using 9P.
1438 An earlier discussion showed how the
1439 .CW fauth
1440 and
1441 .CW mount
1442 system calls use an authentication file,
1443 .CW afd ,
1444 as a capability,
1445 but not how
1446 .CW factotum
1447 manages
1448 .CW afd .
1449 The library contains a routine,
1450 .CW amount
1451 (authenticated mount), that is used by most programs in preference to
1452 the raw
1453 .CW fauth
1454 and
1455 .CW mount
1456 calls.
1457 .CW Amount
1458 engages
1459 .CW factotum
1460 to validate
1461 .CW afd ;
1462 here is the complete code:
1463 .P1
1464 .ta 3n +3n +3n +3n
1465 int
1466 amount(int fd, char *mntpt,
1467         int flags, char *aname)
1468 {
1469         int afd, ret;
1470         AuthInfo *ai;
1471
1472         afd = fauth(fd, aname);
1473         if(afd >= 0){
1474                 ai = auth_proxy(afd, amount_getkey,
1475                         "proto=p9any role=client");
1476                 if(ai != NULL)
1477                         auth_freeAI(ai);
1478         }
1479         ret = mount(fd, afd, mntpt,
1480                 flags, aname);
1481         if(afd >= 0)
1482                 close(afd);
1483         return ret;
1484 }
1485 .P2
1486 where parameter
1487 .CW fd
1488 is a file descriptor returned by
1489 .CW open
1490 or
1491 .CW dial
1492 for a new connection to a file server.
1493 The conversation with
1494 .CW factotum
1495 occurs in the call to
1496 .CW auth_proxy ,
1497 which specifies, as a key query,
1498 which authentication protocol to use
1499 (here the metaprotocol
1500 .CW p9any )
1501 and the role being played
1502 .CW client ). (
1503 .CW Auth_proxy
1504 will read and write the
1505 .CW factotum
1506 files, and the authentication file descriptor
1507 .CW afd ,
1508 to validate the user's right to access the service.
1509 If the call is successful, any auxiliary data, held in an
1510 .CW AuthInfo
1511 structure, is freed.
1512 In any case, the
1513 .CW mount
1514 is then called with the (perhaps validated)
1515 .CW afd.
1516 A 9P server can cause the
1517 .CW fauth
1518 system call to fail, as an indication that authentication is
1519 not required to access the service.
1520 .LP
1521 The second argument to
1522 .CW auth_proxy
1523 is a function, here
1524 .CW amount_getkey ,
1525 to be called if secret information such as a password or
1526 response to a challenge is required as part of the authentication.
1527 This function, of course, will provide this data to
1528 .CW factotum
1529 as a
1530 .CW key
1531 message on the
1532 .CW /mnt/factotum/ctl
1533 file.
1534 .LP
1535 Although the final argument to
1536 .CW auth_proxy
1537 in this example is a simple string, in general
1538 it can be a formatted-print specifier in the manner of
1539 .CW printf ,
1540 to enable the construction of more elaborate key queries.
1541 .LP
1542 As another example, consider the Plan 9
1543 .CW cpu
1544 service, which exports local devices to a shell process on
1545 a remote machine, typically
1546 to connect the local screen and keyboard to a more powerful computer.
1547 At heart,
1548 .CW cpu
1549 is a superset of a service called
1550 .CW exportfs
1551 [Pike93],
1552 which allows one machine to see an arbitrary portion of the file name space
1553 of another machine, such as to
1554 export the network device to another machine
1555 for gatewaying.
1556 However,
1557 .CW cpu
1558 is not just
1559 .CW exportfs
1560 because it also delivers signals such as interrupt
1561 and negotiates the initial environment
1562 for the remote shell.
1563 .LP
1564 To authenticate an instance of
1565 .CW cpu
1566 requires
1567 .CW factotum
1568 processes on both ends: the local, client
1569 end running as the user on a terminal
1570 and the remote, server
1571 end running as the host owner of the server machine.
1572 Here is schematic code for the two ends:
1573 .P1
1574 .ta 3n +3n +3n +3n
1575 /* client */
1576 int
1577 p9auth(int fd)
1578 {
1579         AuthInfo *ai;
1580
1581         ai = auth_proxy(fd, auth_getkey,
1582                 "proto=p9any role=client");
1583         if(ai == NULL)
1584                 return -1;
1585
1586         /* start cpu protocol here */
1587 }
1588
1589 /* server */
1590 int
1591 srvp9auth(int fd, char *user)
1592 {
1593         AuthInfo *ai;
1594
1595         ai = auth_proxy(fd, NULL,
1596                 "proto=p9any role=server");
1597         if(ai == NULL)
1598                 return -1;
1599         /* set user id for server process */
1600         if(auth_chuid(ai, NULL) < 0)
1601                 return -1;
1602
1603         /* start cpu protocol here */
1604 }
1605 .P2
1606 .CW Auth_chuid
1607 encapsulates the negotiation to change a user id using the
1608 .CW caphash
1609 and
1610 .CW capuse
1611 files of the (server) kernel.
1612 Note that although the client process may ask the user for new keys, using
1613 .CW auth_getkey ,
1614 the server machine, presumably a shared machine with a pseudo-user for
1615 the host owner, sets the key-getting function to
1616 .CW NULL .
1617 .NH 1
1618 Secure Store
1619 .LP
1620 .CW Factotum
1621 keeps its keys in volatile memory, which must somehow be
1622 initialized at boot time.
1623 Therefore,
1624 .CW factotum
1625 must be
1626 supplemented by a persistent store, perhaps
1627 a floppy disk containing a key file of commands to be copied into
1628 .CW /mnt/factotum/ctl
1629 during bootstrap.
1630 But removable media are a nuisance to carry and
1631 are vulnerable to theft.
1632 Keys could be stored encrypted on a shared file system, but
1633 only if those keys are not necessary for authenticating to
1634 the file system in the first place.
1635 Even if the keys are encrypted under a user
1636 password, a thief might well succeed with a dictionary attack.
1637 Other risks of local storage are loss of the contents
1638 through mechanical mishap or dead batteries.
1639 Thus for convenience and
1640 safety we provide a
1641 .CW secstore
1642 (secure store) server in the network to hold each user's permanent list of keys, a
1643 .I key
1644 .I file .
1645 .LP
1646 .CW Secstore
1647 is a file server for encrypted data,
1648 used only during bootstrapping.
1649 It must provide strong
1650 authentication and resistance to passive and active protocol attacks
1651 while assuming nothing more from the client than a password.
1652 Once
1653 .CW factotum
1654 has loaded the key file, further encrypted or authenticated
1655 file storage can be accomplished by standard mechanisms.
1656 .EQ
1657 define mod % ~ roman "mod" ~ %
1658 define sha1 % "sha1" %
1659 .EN
1660 .LP
1661 The cryptographic technology that enables
1662 .CW secstore
1663 is a form of encrypted
1664 key exchange
1665 called PAK
1666 [Boyk00],
1667 analogous to
1668 EKE
1669 [Bell93],
1670 SRP
1671 [Wu98],
1672 or
1673 SPEKE
1674 [Jabl].
1675 PAK was chosen
1676 because it comes with a proof of equivalence in strength to
1677 Diffie-Hellman; subtle flaws in some earlier encrypted key exchange
1678 protocols and implementations have encouraged us to take special care.
1679 In outline, the PAK protocol is:
1680 .P1
1681 $C -> S:~ C, g sup x H#
1682 $S -> C:~ S, g sup y , hash(g sup xy , C, S)#
1683 $C -> S:~ hash(g sup xy , S, C)#
1684 .P2
1685 where $H# is a preshared secret between client $C# and server $S#.
1686 There are several variants of PAK, all presented in papers
1687 mainly concerned with proofs of cryptographic properties.
1688 To aid implementers, we have distilled a description of the specific
1689 version we use into an Appendix to this paper.
1690 The Plan 9 open source license provides for use of Lucent's
1691 encrypted key exchange patents in this context.
1692 .LP
1693 As a further layer of defense against password theft,
1694 we provide (within the encrypted channel $C -> S#)
1695 information that is validated at a RADIUS server,
1696 such as the digits from a hardware token
1697 [RFC2138].
1698 This provides two-factor authentication, which potentially
1699 requires tricking two independent administrators in any attack by
1700 social engineering.
1701 .LP
1702 The key file stored on the server is encrypted with AES (Rijndael) using CBC
1703 with a 10-byte initialization vector and trailing authentication padding.
1704 All this is invisible to the user of
1705 .CW secstore .
1706 For that matter, it is invisible to the
1707 .CW secstore
1708 server as well;
1709 if the AES Modes of Operation are standardized and a new encryption format
1710 designed, it can be implemented by a client without change to the server.
1711 The
1712 .CW secstore
1713 is deliberately not backed up;  the user is expected to
1714 use more than one
1715 .CW secstore
1716 or save the key file on removable media
1717 and lock it away.
1718 The user's password is hashed to create the $H# used
1719 in the PAK protocol;  a different hash of the password is used as
1720 the file encryption key.
1721 Finally, there is a command (inside the authenticated,
1722 encrypted channel between client and
1723 .CW secstore )
1724 to change passwords by sending
1725 a new $H#; 
1726 for consistency, the client process must at the same time fetch and re-encrypt all files.
1727 .LP
1728 When
1729 .CW factotum
1730 starts, it dials the local
1731 .CW secstore
1732 and checks whether the user has an account.
1733 If so,
1734 it prompts for the user's
1735 .CW secstore
1736 password and fetches the key file.
1737 The PAK protocol
1738 ensures mutual authentication and prevents dictionary attacks on the password
1739 by passive wiretappers or active intermediaries.
1740 Passwords saved in
1741 the key file can be long random strings suitable for
1742 simpler challenge/response authentication protocols.
1743 Thus the user need only remember
1744 a single, weaker password to enable strong, ``single sign on'' authentication to
1745 unchanged legacy applications scattered across multiple authentication domains.
1746 .NH 1
1747 Transport Layer Security
1748 .LP
1749 Since the Plan 9 operating system is designed for use in network elements
1750 that must withstand direct attack, unguarded by firewall or VPN, we seek
1751 to ensure that all applications use channels with appropriate mutual
1752 authentication and encryption.
1753 A principal tool for this is TLS 1.0
1754 [RFC2246].
1755 (TLS 1.0 is nearly the same as SSL 3.0,
1756 and our software is designed to interoperate
1757 with implementations of either standard.)
1758 .LP
1759 TLS defines a record layer protocol for message integrity and privacy
1760 through the use of message digesting and encryption with shared secrets.
1761 We implement this service as a kernel device, though it could
1762 be performed at slightly higher cost by invoking a separate program.
1763 The library interface to the TLS kernel device is:
1764 .P1
1765 int pushtls(int fd, char *hashalg,
1766     char *cryptalg, int isclient,
1767     char *secret, char *dir);
1768 .P2
1769 Given a file descriptor, the names of message digest and
1770 encryption algorithms, and the shared secret,
1771 .CW pushtls
1772 returns a new file descriptor for the encrypted connection.
1773 (The final argument
1774 .CW dir
1775 receives the name of the directory in the TLS device that
1776 is associated with the new connection.)
1777 The function is named by analogy with the ``push'' operation
1778 supported by the stream I/O system of Research Unix and the
1779 first two editions of Plan 9.
1780 Because adding encryption is as simple as replacing one
1781 file descriptor with another, adding encryption to a particular
1782 network service is usually trivial.
1783 .LP
1784 The Plan 9 shared key authentication protocols establish a shared 56-bit secret
1785 as a side effect.
1786 Native Plan 9 network services such as
1787 .CW cpu
1788 and
1789 .CW exportfs
1790 use these protocols for authentication and then invoke 
1791 .CW pushtls
1792 with the shared secret.
1793 .LP
1794 Above the record layer, TLS specifies a handshake protocol using public keys
1795 to establish the session secret.
1796 This protocol is widely used with HTTP and IMAP4
1797 to provide server authentication, though with client certificates it could provide
1798 mutual authentication.  The library function
1799 .P1
1800 int tlsClient(int fd, TLSconn *conn)
1801 .P2
1802 handles the initial handshake and returns the result of
1803 .CW pushtls .
1804 On return, it fills the
1805 .CW conn
1806 structure with the session ID used
1807 and the X.509 certificate presented by the
1808 server, but makes no effort to verify the certificate.
1809 Although the original design intent of X.509 certificates expected
1810 that they would be used with a Public Key Infrastructure,
1811 reliable deployment has been so long delayed and problematic
1812 that we have adopted the simpler policy of just using the
1813 X.509 certificate as a representation of the public key,
1814 depending on a locally-administered directory of SHA1 thumbprints
1815 to allow applications to decide which public keys to trust
1816 for which purposes.
1817 .NH 1
1818 Related Work and Discussion
1819 .LP
1820 Kerberos, one of the earliest distributed authentication
1821 systems, keeps a set of authentication tickets in a temporary file called
1822 a ticket cache.  The ticket cache is protected by Unix file permissions.
1823 An environment variable containing the file name of the ticket cache
1824 allows for different ticket caches in different simultaneous login sessions.
1825 A user logs in by typing his or her Kerberos password.
1826 The login program uses the Kerberos password to obtain a temporary
1827 ticket-granting ticket from the authentication server, initializes the
1828 ticket cache with the ticket-granting ticket, and then forgets the password.
1829 Other applications can use the ticket-granting ticket to sign tickets
1830 for themselves on behalf of the user during the login session.
1831 The ticket cache is removed when the user logs out
1832 [Stei88].
1833 The ticket cache relieves the user from typing a password
1834 every time authentication is needed.
1835 .LP
1836 The secure shell SSH develops this idea further, replacing the
1837 temporary file with a named Unix domain socket connected to
1838 a user-level program, called an agent.
1839 Once the SSH agent is started and initialized with one or
1840 more RSA private keys, SSH clients can employ it
1841 to perform RSA authentications on their behalf.
1842 In the absence of an agent, SSH typically uses RSA keys
1843 read from encrypted disk files or uses passphrase-based
1844 authentication, both of which would require prompting the user
1845 for a passphrase whenever authentication is needed
1846 [Ylon96].
1847 The self-certifying file system SFS uses a similar agent
1848 [Kami00],
1849 not only for moderating the use of client authentication keys 
1850 but also for verifying server public keys
1851 [Mazi99].
1852 .LP
1853 .CW Factotum
1854 is a logical continuation of this evolution,
1855 replacing the program-specific SSH or SFS agents with
1856 a general agent capable of serving a wide variety of programs.
1857 Having one agent for all programs removes the need
1858 to have one agent for each program.
1859 It also allows the programs themselves to be protocol-agnostic,
1860 so that, for example, one could build an SSH workalike
1861 capable of using any protocol supported by
1862 .CW factotum ,
1863 without that program knowing anything about the protocols.
1864 Traditionally each program needs to implement each
1865 authentication protocol for itself, an $O(n sup 2 )# coding
1866 problem that
1867 .CW factotum
1868 reduces to $O(n)#.
1869 .LP
1870 Previous work on agents has concentrated on their use by clients
1871 authenticating to servers.
1872 Looking in the other direction, Sun Microsystem's 
1873 pluggable authentication module (PAM) is one
1874 of the earliest attempts to 
1875 provide a general authentication mechanism for Unix-like 
1876 operating systems
1877 [Sama96].
1878 Without a central authority like PAM, system policy is tied
1879 up in the various implementations of network services.
1880 For example, on a typical Unix, if a system administrator
1881 decides not to allow plaintext passwords for authentication,
1882 the configuration files for a half dozen different servers \(em
1883 .CW rlogind ,
1884 .CW telnetd ,
1885 .CW ftpd ,
1886 .CW sshd ,
1887 and so on \(em
1888 need to be edited.
1889 PAM solves this problem by hiding the details of a given
1890 authentication mechanism behind a common library interface.
1891 Directed by a system-wide configuration file,
1892 an application selects a particular authentication mechanism
1893 by dynamically loading the appropriate shared library.
1894 PAM is widely used on Sun's Solaris and some Linux distributions.
1895 .LP
1896 .CW Factotum
1897 achieves the same goals
1898 using the agent approach.
1899 .CW Factotum
1900 is the only process that needs to create
1901 capabilities, so all the network servers can run as 
1902 untrusted users (e.g.,
1903 Plan 9's
1904 .CW none
1905 or Unix's
1906 .CW nobody ),
1907 which greatly reduces the harm done if a server is buggy
1908 and is compromised.
1909 In fact, if
1910 .CW factotum
1911 were implemented on Unix along with
1912 an analogue to the Plan 9 capability device, venerable
1913 programs like
1914 .CW su
1915 and
1916 .CW login
1917 would no longer need to be installed ``setuid root.''
1918 .LP
1919 Several other systems, such as Password Safe [Schn],
1920 store multiple passwords in an encrypted file,
1921 so that the user only needs to remember one password.
1922 Our
1923 .CW secstore
1924 solution differs from these by placing the storage in
1925 a hardened location in the network, so that the encrypted file is
1926 less liable to be stolen for offline dictionary attack and so that
1927 it is available even when a user has several computers.
1928 In contrast, Microsoft's Passport system
1929 [Micr]
1930 keeps credentials in
1931 the network, but centralized at one extremely-high-value target.
1932 The important feature of Passport, setting up trust relationships
1933 with e-merchants, is outside our scope.
1934 The
1935 .CW secstore
1936 architecture is almost identical to
1937 Perlman and Kaufman's
1938 [Perl99]
1939 but with newer EKE technology.
1940 Like them, we chose to defend mainly against outside attacks
1941 on
1942 .CW secstore ;
1943 if additional defense of the files on the server
1944 itself is desired, one can use distributed techniques
1945 [Ford00].
1946 .LP
1947 We made a conscious choice of placing encryption, message integrity,
1948 and key management at the application layer
1949 (TLS, just above layer 4) rather than at layer 3, as in IPsec.
1950 This leads to a simpler structure for the network stack, easier
1951 integration with applications and, most important, easier network
1952 administration since we can recognize which applications are misbehaving
1953 based on TCP port numbers.  TLS does suffer (relative to IPsec) from
1954 the possibility of forged TCP Reset, but we feel that this is adequately
1955 dealt with by randomized TCP sequence numbers.
1956 In contrast with other TLS libraries, Plan 9 does not
1957 require the application to change
1958 .CW write
1959 calls to
1960 .CW sslwrite
1961 but simply to add a few lines of code at startup
1962 [Resc01].
1963 .NH 1
1964 Conclusion
1965 .LP
1966 Writing safe code is difficult.
1967 Stack attacks,
1968 mistakes in logic, and bugs in compilers and operating systems
1969 can each make it possible for an attacker
1970 to subvert the intended execution sequence of a
1971 service.
1972 If the server process has the privileges
1973 of a powerful user, such as
1974 .CW root
1975 on Unix, then so does the attacker.
1976 .CW Factotum
1977 allows us
1978 to constrain the privileged execution to a single
1979 process whose core is a few thousand lines of code.
1980 Verifying such a process, both through manual and automatic means,
1981 is much easier and less error prone
1982 than requiring it of all servers.
1983 .LP
1984 An implementation of these ideas is in Plan 9 from Bell Labs, Fourth Edition,
1985 freely available from \f(CWhttp://\%plan9.bell-labs.com/\%plan9\fP.
1986 .SH
1987 Acknowledgments
1988 .LP
1989 William Josephson contributed to the implementation of password changing in
1990 .CW secstore .
1991 We thank Phil MacKenzie and Martín Abadi for helpful comments on early parts
1992 of the design.
1993 Chuck Blake,
1994 Peter Bosch,
1995 Frans Kaashoek,
1996 Sape Mullender,
1997 and
1998 Lakshman Y. N.,
1999 predominantly Dutchmen, gave helpful comments on the paper.
2000 Russ Cox is supported by a fellowship from the Fannie and John Hertz Foundation.
2001 .SH
2002 References
2003 .LP
2004 [Bell93]
2005 S.M. Bellovin and M. Merritt,
2006 ``Augmented Encrypted Key Exchange,''
2007 Proceedings of the 1st ACM Conference on Computer and Communications Security, 1993, pp. 244 - 250.
2008 .LP
2009 [Boyk00]
2010 Victor Boyko, Philip MacKenzie, and Sarvar Patel,
2011 ``Provably Secure Password-Authenticated Key Exchange using Diffie-Hellman,''
2012 Eurocrypt 2000, 156\-171.
2013 ... http://www.bell-labs.com/who/philmac/research/pak-final.ps.gz
2014 .LP
2015 [RFC2246]
2016 T . Dierks and C. Allen,
2017 ``The TLS Protocol, Version 1.0,''
2018 RFC 2246.
2019 .LP
2020 [Ford00]
2021 Warwick Ford and Burton S. Kaliski, Jr.,
2022 ``Server-Assisted Generation of a Strong Secret from a Password,''
2023 IEEE Fifth International Workshop on Enterprise Security,
2024 National Institute of Standards and Technology (NIST),
2025 Gaithersburg MD, June 14 - 16, 2000.
2026 .LP
2027 [Jabl]
2028 David P. Jablon,
2029 ``Strong Password-Only Authenticated Key Exchange,''
2030 \f(CWhttp://\%integritysciences.com/\%speke97.html\fP.
2031 .LP
2032 [Kami00]
2033 Michael Kaminsky.
2034 ``Flexible Key Management with SFS Agents,''
2035 Master's Thesis, MIT, May 2000.
2036 .LP
2037 [Mack]
2038 Philip MacKenzie,
2039 private communication.
2040 .LP
2041 [Mazi99]
2042 David Mazières, Michael Kaminsky, M. Frans Kaashoek and Emmett Witchel,
2043 ``Separating key management from file system security,''
2044 Symposium on Operating Systems Principles, 1999, pp. 124-139.
2045 .LP
2046 [Micr]
2047 Microsoft Passport,
2048 \f(CWhttp://\%www.passport.com/\fP.
2049 .LP
2050 [Perl99]
2051 Radia Perlman and Charlie Kaufman,
2052 ``Secure Password-Based Protocol for Downloading a Private Key,''
2053 Proc. 1999 Network and Distributed System Security Symposium,
2054 Internet Society, January 1999.
2055 .LP
2056 [Pike95]
2057 Rob Pike, Dave Presotto, Sean Dorward, Bob Flandrena, Ken Thompson, Howard Trickey, and Phil Winterbottom,
2058 ``Plan 9 from Bell Labs,''
2059 Computing Systems, \f3\&8\fP, 3, Summer 1995, pp. 221-254.
2060 .LP
2061 [Pike93]
2062 Rob Pike, Dave Presotto, Ken Thompson, Howard Trickey, Phil Winterbottom,
2063 ``The Use of Name Spaces in Plan 9,''
2064 Operating Systems Review, \f3\&27\fP, 2, April 1993, pp. 72-76
2065 (reprinted from Proceedings of the 5th ACM SIGOPS European Workshop,
2066 Mont Saint-Michel, 1992, Paper nº 34).
2067 .LP
2068 [Resc01]
2069 Eric Rescorla,
2070 ``SSL and TLS: Designing and Building Secure Systems,''
2071 Addison-Wesley, 2001. ISBN 0-201-61598-3, p. 387.
2072 .LP
2073 [RFC2138]
2074 C. Rigney, A. Rubens, W. Simpson, S. Willens,
2075 ``Remote Authentication Dial In User Service (RADIUS),''
2076 RFC2138, April 1997.
2077 .LP
2078 [RiLa]
2079 Ronald L. Rivest and Butler Lampson,
2080 ``SDSI\(emA Simple Distributed Security Infrastructure,''
2081 \f(CWhttp://\%theory.lcs.mit.edu/\%~rivest/\%sdsi10.ps\fP.
2082 .LP
2083 [Schn]
2084 Bruce Schneier, Password Safe,
2085 \f(CWhttp://\%www.counterpane.com/\%passsafe.html\fP.
2086 .LP
2087 [Sama96]
2088 Vipin Samar,
2089 ``Unified Login with Pluggable Authentication Modules (PAM),''
2090 Proceedings of the Third ACM Conference on Computer Communications and Security,
2091 March 1996, New Delhi, India.
2092 ... http://www1.acm.org/pubs/articles/proceedings/commsec/238168/p1-samar/p1-samar.pdf
2093 .LP
2094 [Stei88]
2095 Jennifer G. Steiner, Clifford Neumann, and Jeffrey I. Schiller,
2096 ``\fIKerberos\fR: An Authentication Service for Open Network Systems,''
2097 Proceedings of USENIX Winter Conference, Dallas, Texas, February 1988, pp. 191\-202.
2098 ... ftp://athena-dist.mit.edu/pub/kerberos/doc/usenix.PS
2099 .LP
2100 [Wu98]
2101 T. Wu,
2102 ``The Secure Remote Password Protocol,''
2103 Proceedings of
2104 the 1998 Internet Society Network and Distributed System Security
2105 Symposium, San Diego, CA, March 1998, pp. 97-111.
2106 .LP
2107 [Ylon96]
2108 Ylonen, T.,
2109 ``SSH\(emSecure Login Connections Over the Internet,''
2110 6th USENIX Security Symposium, pp. 37-42. San Jose, CA, July 1996.
2111 .SH
2112 Appendix: Summary of the PAK protocol
2113 .LP
2114 Let $q>2 sup 160# and $p>2 sup 1024# be primes
2115 such that $p=rq+1# with $r# not a multiple of $q#.
2116 Take $h ∈ Z sub p sup *# such that $g == h sup r# is not 1.
2117 These parameters may be chosen by the NIST algorithm for DSA,
2118 and are public, fixed values.
2119 The client $C# knows a secret $pi#
2120 and computes $H == (H sub 1 (C, ~ pi )) sup r# and $H sup -1#,
2121 where $H sub 1# is a hash function yielding a random element of $Z sub p sup *#,
2122 and $H sup -1# may be computed by gcd.
2123 (All arithmetic is modulo $p#.)
2124 The client gives $H sup -1# to the server $S# ahead of time by a private channel.
2125 To start a new connection, the client generates a random value $x#,
2126 computes $m == g sup x H#,
2127 then calls the server and sends $C# and $m#.
2128 The server checks $m != 0 mod p#,
2129 generates random $y#,
2130 computes $ mu == g sup y#,
2131 $ sigma == (m H sup -1 ) sup y#,
2132 and sends $S#, $mu#, $k == sha1 ( roman "\"server\"", C, S, m, mu , sigma , H sup -1 )#.
2133 Next the client computes $sigma =  mu sup x#,
2134 verifies $k#,
2135 and sends $k' == sha1 ( roman "\"client\"", C, S, m, mu , sigma , H sup -1 )#.
2136 The server then verifies $k'# and both sides begin
2137 using session key $K == sha1 ( roman "\"session\"", C, S, m, mu , sigma , H sup -1 )#.
2138 In the published version of PAK, the server name $S#
2139 is included in the initial
2140 hash $H#, but doing so is inconvenient in our application,
2141 as the server may be known by various equivalent names.
2142 .LP
2143 MacKenzie has shown
2144 [Mack]
2145 that the
2146 equivalence proof [Boyk00]
2147 can be adapted to cover our version.