]> git.lizzy.rs Git - plan9front.git/blob - sys/man/6/authsrv
authsrv(6): fix arrows
[plan9front.git] / sys / man / 6 / authsrv
1 .TH AUTHSRV 6
2 .SH NAME
3 authsrv, p9any, p9sk1, dp9ik \- authentication protocols
4 .SH DESCRIPTION
5 This manual page describes
6 the protocols used to authorize connections, confirm the identities
7 of users and machines, and maintain the associated databases.
8 The machine that provides these services is called the
9 .I authentication server
10 (AS).
11 The AS may be a stand-alone machine or a general-use machine such as a CPU server.
12 The network database
13 .IR ndb (6)
14 holds for each public machine, such as a CPU server or
15 file server, the name of the authentication server that machine uses.
16 .PP
17 Each machine contains four values important to authentication; a 56-bit DES
18 key, a 128-bit AES key, a 28-byte authentication ID, and a 48-byte authentication
19 domain name.
20 The ID is a user name and identifies who is currently responsible for the
21 kernel running on that machine.
22 The domain name identifies the machines across which the ID is valid.
23 Together, the ID and domain name identify the owner of a key.
24 .PP
25 When a terminal boots,
26 .IR factotum (4)
27 prompts for user name and password.
28 The user name becomes the terminal's authentication ID. 
29 The password is converted using
30 .I passtokey
31 (see
32 .IR authsrv (2))
33 into a 56-bit DES and 128-bit AES keys and saved in memory.
34 The authentication domain is set to the null string.
35 If possible,
36 .I factotum
37 validates the key with the AS
38 before saving it.
39 For Internet machines the correct AS to ask is found using
40 .IR dhcpd (8).
41 .PP
42 When a CPU or file server boots, 
43 .I factotum
44 reads the key, ID, and domain name from
45 non-volatile RAM.
46 This allows servers to reboot without operator intervention.
47 .PP
48 The details of any authentication are mixed with the semantics
49 of the particular service they are authenticating so we describe
50 them one case at a time. The following definitions will be used
51 in the descriptions:
52 .TF nullx
53 .TP
54 .I Ks
55 server's host ID's key
56 .TP
57 .I Kc
58 client's host ID's key
59 .TP
60 .I Kn
61 a nonce key created for a ticket
62 .RB ( key )
63 .TP
64 .I K{m}
65 message
66 .I m
67 encrypted with key
68 .I K
69 .TP
70 .I CHc
71 an 8-byte random challenge from a client
72 .RB ( chal )
73 .TP
74 .I CHs
75 an 8-byte random challenge from a server
76 .RB ( chal )
77 .TP
78 .I IDs
79 server's ID
80 .RB ( authid )
81 .TP
82 .I DN
83 server's authentication domain name
84 .RB ( authdom )
85 .TP
86 .I IDc
87 client's ID
88 .RB ( hostid ,
89 .BR cuid )
90 .TP
91 .I IDr
92 client's desired ID on server
93 .RB ( uid ,
94 .BR suid )
95 .TP
96 .I YAc
97 client → AS DH public key
98 .TP
99 .I YBc
100 AS → client DH public key
101 .TP
102 .I YAs
103 server → AS DH public key
104 .TP
105 .I YBs
106 AS → server DH public key
107 .TP
108 .I RNc
109 client's 32-byte random string
110 .TP
111 .I RNs
112 server's 32-byte random string
113 .PD
114 .PP
115 The parenthesized names are the ones used in the
116 .B Ticketreq
117 and
118 .B Ticket
119 structures in
120 .BR <authsrv.h> .
121 .PP
122 The message type constants
123 .IR AuthTreq ,
124 .IR AuthChal ,
125 .IR AuthPass ,
126 .IR AuthOK ,
127 .IR AuthErr ,
128 .IR AuthMod ,
129 .IR AuthApop ,
130 .IR AuthOKvar ,
131 .IR AuthChap ,
132 .IR AuthMSchap ,
133 .IR AuthCram ,
134 .IR AuthVNC ,
135 and
136 .IR AuthPAK
137 .RB ( type )
138 are defined in
139 .BR <authsrv.h> ,
140 as are the encrypted message types
141 .IR AuthTs ,
142 .IR AuthAs ,
143 .IR AuthAc ,
144 .IR AuthTp ,
145 and
146 .IR AuthHr
147 .RB ( num ).
148 .SS "Ticket Service
149 When a client and server wish to authenticate to each other,
150 they do so using
151 .I tickets
152 issued by the AS.
153 Obtaining tickets from the AS
154 is the client's responsibility.
155 .PP
156 The protocol to obtain a ticket pair is:
157 .TP
158 .I C→A:
159 .IR AuthTreq ,
160 .IR IDs ,
161 .IR DN ,
162 .IR CHs ,
163 .IR IDc ,
164 .IR IDr
165 .TP
166 .I A→C:
167 .IR AuthOK ,
168 .IR Kc { AuthTc ,
169 .IR CHs ,
170 .IR IDc ,
171 .IR IDr ,
172 .IR Kn },
173 .IR Ks { AuthTs ,
174 .IR CHs ,
175 .IR IDc ,
176 .IR IDr ,
177 .IR Kn }
178 .PP
179 The two tickets are identical except for their type fields
180 and the keys with which they are encrypted.
181 The client and server can each decrypt one of the tickets,
182 establishing a shared secret
183 .IR Kn .
184 .PP
185 The
186 tickets can be viewed as a statement by the
187 AS that
188 ``a client possessing the
189 .I Kn
190 key is allowed to authenticate as
191 .IR IDr .''
192 .PP
193 The presence of the server challenge
194 .I CHs
195 in the ticket allows the server to verify the freshness
196 of the ticket pair.
197 .PP
198 The AS sets the
199 .I IDr
200 in the tickets to the requested
201 .I IDr
202 only if
203 .I IDc
204 is allowed to
205 .I "speak for
206 .RI ( q.v. )
207 .IR IDr .
208 If not,
209 the AS sets
210 .I IDr
211 to the empty string.
212 .PP
213 If the users
214 .I IDc
215 or
216 .I IDs
217 do not exist,
218 the AS silently generates one-time
219 random keys to use in place of
220 .I Kc
221 or
222 .IR Ks ,
223 so that clients cannot probe the AS
224 to learn whether a user name is valid.
225 .SS "P9sk1
226 The Plan 9 shared key protocol
227 .I p9sk1
228 allows a client and server to authenticate each other.
229 The protocol is:
230 .TP
231 .I C→S:
232 .I CHc
233 .br
234 The client starts by sending a random challenge to the server.
235 .TP
236 .I S→C:
237 .IR AuthTreq ,
238 .IR IDs ,
239 .IR DN ,
240 .IR CHs ,
241 .IR \- ,
242 .IR \-
243 .br
244 The server replies with a ticket request giving its
245 id and authentication domain along with its own 
246 random challenge.
247 .TP
248 .I C→S:
249 .IR Ks { AuthTs ,
250 .IR CHs ,
251 .IR IDc ,
252 .IR IDr ,
253 .IR Kn },
254 .IR Kn { AuthAc ,
255 .IR CHs }
256 .br
257 The client adds 
258 .I IDc
259 and
260 .I IDr
261 to the ticket request and obtains a ticket pair
262 from the AS as described above.
263 The client relays the server's ticket along with
264 an 
265 .IR authenticator ,
266 the
267 .I AuthAc
268 message.
269 The authenticator proves to the server that the
270 client knows
271 .I Kn
272 and is therefore allowed to authenticate as
273 .IR IDr .
274 (The inclusion of
275 .IR CHs
276 in the authenticator avoids replay attacks.)
277 .TP
278 .I S→C:
279 .IR Kn { AuthAs ,
280 .IR CHc }
281 .br
282 The server replies with its own authenticator,
283 proving to the client that it also knows
284 .I Kn
285 and therefore 
286 .I Ks .
287 .SS "Password authenticated key exchange"
288 Initially, the server and client keys
289 .I Ks
290 and
291 .I Kc
292 where equivalent to the password derived 56-bit DES keys, which
293 made the encrypted tickets subject to offline dictionary attacks
294 and provided too small a key space against brute force attacks
295 on current hardware.
296 .PP
297 The
298 .I AuthPAK
299 protocol is used to establish new 256-bit random keys with the
300 AS for
301 .I Ks
302 and
303 .I Kc
304 before each ticket request on the connection.
305 .PP
306 The protocol is based on SPAKE2EE, where a hash of the user's secret
307 is used to encypt the public keys of a Elliptic-Curve Diffie-Hellman
308 key exchange. The user's
309 .I ID
310 and 128-bit AES key is hashed and mapped (using Elligator2)
311 into two curve points
312 .I PM
313 and
314 .IR PN ,
315 called the
316 .IR pakhash .
317 Both sides generate a random number
318 .IR xa / xb
319 and make the public keys
320 .IR YA / YB
321 as:
322 .IR YA = xa*G+PM ,
323 .IR YB = xb*G+PN .
324 After the public keys have been exchanged, each side calculates the
325 shared secret as:
326 .IR Z = xa*(YB-PN) = xb*(YA-PM) .
327 The shared secret
328 .I Z
329 is then hashed with the transmitted public keys
330 .IR YA | YB
331 producing the 256-bit
332 .IR pakkey .
333 .PP
334 The
335 .I pakkey
336 is then used in place of
337 .I Ks
338 and
339 .I Kc
340 to authenticate and encrypt tickets from the AS using
341 Chacha20/Poly1305 AEAD for the next following
342 request made on the connection.
343 .PP
344 The protocol (for
345 .IR AuthTreq )
346 to establish keys
347 .I Ks
348 and
349 .I Kc
350 with the AS for
351 .I IDs
352 and
353 .I IDc
354 is:
355 .TP
356 .I C→A:
357 .IR AuthPAK ,
358 .IR IDs ,
359 .IR DN ,
360 .IR CHs ,
361 .IR IDc ,
362 .IR IDr ,
363 .IR YAs ,
364 .I YAc
365 .TP
366 .I A→C:
367 .IR AuthOK ,
368 .IR YBs ,
369 .I YBc
370 .PP
371 The protocol (for
372 .IR AuthApop ,
373 .IR AuthChap ...)
374 to establish a single server key
375 .I Ks
376 for
377 .IR IDs :
378 .TP
379 .I C→A:
380 .IR AuthPAK ,
381 .IR \- ,
382 .IR DN ,
383 .IR CHs ,
384 .IR IDs ,
385 .IR IDc ,
386 .I YAs
387 .TP
388 .I A→C:
389 .IR AuthOK ,
390 .I YBs
391 .PP
392 The protocol (for
393 .IR AuthPass )
394 to establish a single client key
395 .I Kc
396 for
397 .IR IDc :
398 .TP
399 .I C→A:
400 .IR AuthPAK ,
401 .IR \- ,
402 .IR \- ,
403 .IR CHc ,
404 .IR \- ,
405 .IR IDc ,
406 .I YAc
407 .TP
408 .I A→C:
409 .IR AuthOK ,
410 .I YBc
411 .SS "Dp9ik"
412 The
413 .I dp9ik
414 protocol is an extended version of
415 .I p9sk1
416 that adds the random strings
417 .I RNc
418 and
419 .I RNs
420 in the
421 .I authenticator
422 messages for the session key derivation and uses the
423 password authenticated key exchange as described above
424 to derive the ticket encryption keys
425 .I Ks
426 and
427 .IR Kc :
428 .TP
429 .I C→S:
430 .I CHc
431 .br
432 The client starts by sending a random challenge to the server.
433 .TP
434 .I S→C:
435 .IR AuthPAK ,
436 .IR IDs ,
437 .IR DN ,
438 .IR CHs ,
439 .IR \- ,
440 .IR \- ,
441 .IR YAs
442 .br
443 The server generates a new public key
444 .I YAs
445 and replies with a
446 .I AuthPAK
447 request giving its
448 .I IDs
449 and authentication domain
450 .I DNs
451 along with its own random challenge
452 .I CHs
453 and its public key
454 .IR YAs .
455 .TP
456 .I C→S:
457 .IR YBs ,
458 .IR Ks { AuthTs ,
459 .IR CHs ,
460 .IR IDc ,
461 .IR IDr ,
462 .IR Kn },
463 .IR Kn { AuthAc ,
464 .IR CHs ,
465 .IR RNc }
466 .br
467 The client generates its own public key
468 .I YAc
469 and adds it along with 
470 .I IDc
471 and
472 .I IDr
473 to the
474 .I AuthPAK
475 request and obtains the public keys
476 .I YBs
477 and
478 .I YBc
479 from the AS response. At this point, client and AS
480 have completed ther authenticated key exchange and
481 derive
482 .I Kc
483 as described above.
484 Then the client requests a ticket pair using the same
485 message but with
486 .I AuthPAK
487 type changed to
488 .IR AuthTreq .
489 It decrypts his ticket with
490 .I Kc
491 extracting the shared secret
492 .IR Kn .
493 The client relays the server's
494 .I YBs
495 and ticket along with an
496 .IR authenticator ,
497 the
498 .I AuthAc
499 message.
500 The server finishes his authenticated key exchange
501 using
502 .I YBs
503 and derives
504 .I Ks
505 to decrypt his ticket to extract the shared secret
506 .IR Kn .
507 When the decryption of the clients authenticator using
508 .I Kn
509 is successfull then this proves to the server that the
510 client knows
511 .I Kn
512 and is therefore allowed to authenticate as
513 .IR IDr .
514 The random string
515 .I RNc
516 is used in the derivation of the session secret.
517 .TP
518 .I S→C:
519 .IR Kn { AuthAs ,
520 .IR CHc ,
521 .IR RNs }
522 .br
523 The server replies with its own authenticator,
524 proving to the client that it also knows
525 .I Kn
526 and contributes its random string
527 .IR RNs
528 for the session secret.
529 .PP
530 The 2048-bit session secret is derived with a PRF hashing the
531 concatenated random strings
532 .IR RNc | RNs
533 with the the shared secret key
534 .IR Kn .
535 .SS "P9any
536 .I P9any
537 is the standard Plan 9 authentication protocol.
538 It consists of a negotiation to determine a common
539 protocol, followed by the agreed-upon protocol.
540 .PP
541 The negotiation protocol is:
542 .TP
543 .I S→C:
544 .B v.2
545 .IB proto@authdom
546 .IB proto@authdom
547 .I ...
548 .TP
549 .I C→S:
550 .I proto
551 .I dom
552 .TP
553 .I S→C:
554 .B OK
555 .PP
556 Each message is a NUL-terminated UTF string.
557 The server begins by sending a list of
558 .IR proto ,
559 .I authdom
560 pairs it is willing to use.
561 The client
562 responds with its choice.
563 Requiring the client to wait for the final
564 .B OK
565 ensures that the client will not start
566 the chosen protocol until the server is ready.
567 .PP
568 The above is version 2 of the protocol.
569 Version 1,
570 no longer used,
571 omitted the first message's
572 .B v.2
573 prefix
574 and the 
575 .B OK
576 message.
577 .PP
578 The
579 .I p9any
580 protocol is the protocol used by all
581 Plan 9 services.
582 The file server runs it over special
583 authentication files
584 (see
585 .IR fauth (2)
586 and
587 .IR attach (5)).
588 Other services, such as
589 .IR cpu (1)
590 and
591 .IR exportfs (4),
592 run
593 .I p9any
594 over the network and then 
595 use
596 .I Kn
597 to derive an
598 .IR ssl (3)
599 key to encrypt the rest of their communications.
600 .SS "Password Change
601 Users connect directly to the AS
602 to change their passwords.
603 The protocol is:
604 .TP
605 .I C→A:
606 .IR AuthPass ,
607 .IR \- ,
608 .IR \- ,
609 .IR CHc ,
610 .IR \- ,
611 .IR IDc
612 .br
613 The client sends a password change ticket request.
614 .TP
615 .I A→C:
616 .IR Kc { AuthTp ,
617 .IR CHc ,
618 .IR IDc ,
619 .IR IDc ,
620 .IR Kn }
621 .br
622 The server responds with a ticket containing the key
623 .I Kn
624 encrypted with the client's key
625 .IR Kc
626 .TP
627 .I C→A:
628 .IR Kn { AuthPass ,
629 .IR old ,
630 .IR new ,
631 .IR changesecret ,
632 .IR secret }
633 .br
634 The client decrypts the ticket using the old password
635 and then sends back an encrypted password request
636 .RB ( Passwordreq
637 structure)
638 containing the old password and the new password.
639 If
640 .I changesecret
641 is set, the AS also changes
642 the user's 
643 .IR secret ,
644 the password used for non-Plan 9 authentications.
645 .TP
646 .I A→C:
647 .I AuthOK
648 or
649 .IR AuthErr ,
650 64-byte error message
651 .br
652 The AS responds with simply
653 .I AuthOK
654 or with
655 .I AuthErr
656 followed by a 64-byte error message.
657 .SS "Authentication Database
658 An
659 .IR ndb (2)
660 database file 
661 .B /lib/ndb/auth
662 exists for the AS.
663 This database maintains ``speaks for'' relationships, i.e.,
664 it lists which users may speak for other users when
665 authenticating.
666 The attribute types used by the AS are
667 .B hostid
668 and
669 .BR uid .
670 The value in the
671 .B hostid
672 is a client host's ID.
673 The values in the
674 .B uid
675 pairs in the same entry list which users that host ID
676 may speak for.
677 A uid value of
678 .B *
679 means the host ID may speak for all users.
680 A uid value of
681 .BI ! user
682 means the host ID may not speak for
683 .IR user .
684 For example:
685 .PP
686 .EX
687 hostid=bootes
688         uid=!sys uid=!adm uid=*
689 .EE
690 .PP
691 is interpreted as
692 .B bootes
693 may speak for any user except
694 .B sys
695 and
696 .BR adm .
697 This property is used heavily on CPU servers.
698 .SS "Foreign Protocols
699 The AS accepts ticket request
700 messages of types other than
701 .I AuthTreq
702 to allow users to
703 authenticate using non-Plan 9 protocols.
704 In these situations, the server communicates
705 directly with the AS.
706 Some protocols must begin without knowing the
707 client's name.  They ignore the client name in the
708 ticket request.
709 All the protocols end
710 with the AS sending
711 an
712 .I AuthOK
713 message containing a server ticket and authenticator.
714 .PP
715 .I AuthOK
716 messages
717 always have a fixed but context-dependent size.
718 The occasional variable-length OK message starts with a
719 .I AuthOKvar
720 byte and a five-byte space-padded decimal length of the
721 data that follows.
722 .PP
723 Anywhere an
724 .I AuthOK
725 message is expected, a
726 .I AuthErr
727 message may be substituted.
728 .de Ok
729 .TP
730 .I A→S:
731 .IR AuthOK ,
732 .IR Ks { AuthTs ,
733 .IR CHs ,
734 .IR IDc ,
735 .IR IDc ,
736 .IR Kn },
737 .IR Kn { AuthAc ,
738 .IR CHs }
739 ..
740 .PP
741 .TP
742 .I S→A:
743 .IR AuthChal ,
744 .IR \- ,
745 .IR DN ,
746 .IR CHs ,
747 .IR IDs ,
748 .IR IDc
749 .TP
750 .I A→S:
751 .IR AuthOK ,
752 .IR challenge
753 .TP
754 .I S→A:
755 .IR response
756 .Ok
757 .IP
758 This protocol allows the use of 
759 handheld authenticators such as SecureNet
760 keys and SecureID tokens
761 in programs such as
762 .IR ssh (1)
763 and
764 .I ftpd
765 (see
766 .IR ipserv (8)).
767 .IP
768 .I Challenge
769 and
770 .I response 
771 are text strings,
772 .SM NUL -padded
773 to 16 bytes
774 .RB ( NETCHLEN ).
775 The
776 .I challenge
777 is a random five-digit decimal number.
778 When using a SecureNet key or
779 .I netkey
780 (see
781 .IR passwd (1)),
782 the 
783 .I response
784 is an eight-digit decimal or hexadecimal number
785 that is an encryption of the challenge
786 using the user's DES key.
787 .IP
788 When using a SecureID token,
789 the challenge is ignored.
790 The response is the user's PIN followed by
791 the six-digit number currently displayed
792 on the token.
793 In this case, the AS
794 queries an external RADIUS server
795 to check the response.
796 Use of a RADIUS server requires an entry in
797 the authentication database.  For example:
798 .IP
799 .EX
800     radius=server-name secret=xyzzy
801         uid=howard rid=trickey
802         uid=sape   rid=smullender
803 .EE
804 .IP
805 In this example, the secret
806 .B xyzzy
807 is the hash key used in talking to the RADIUS server.
808 The
809 .BR uid / rid
810 lines map from Plan 9 user ids to RADIUS ids.
811 Users not listed are assumed to have the
812 same id in both places.
813 .TP
814 .I S→A:
815 .IR AuthApop ,
816 .IR \- ,
817 .IR DN ,
818 .IR CHs ,
819 .IR IDs ,
820 .IR \-
821 .TP
822 .I A→S:
823 .IR AuthOKvar ,
824 .IR challenge
825 .TP
826 .I S→A:
827 .IR AuthApop ,
828 .IR \- ,
829 .IR DN ,
830 .IR CHs ,
831 .IR IDs ,
832 .IR IDc ;
833 hexadecimal MD5 checksum
834 .Ok
835 .IP
836 This protocol implements APOP authentication
837 (see
838 .IR pop3 (8)).
839 After receiving a ticket request of type
840 .IR AuthApop ,
841 the AS generates a random challenge
842 of the form
843 .BI < random @ domain >\fR.
844 The client then replies with a new ticket request
845 giving the user name
846 followed by the MD5 checksum of
847 the challenge concatenated with the user's secret.
848 If the response is correct, the authentication
849 server sends back a ticket
850 and authenticator.
851 If the response is incorrect, the client may repeat the
852 ticket request/MD5 checksum message to try again.
853 .IP
854 The 
855 .I AuthCram
856 protocol runs identically to the
857 .I AuthApop
858 protocol, except that the expected MD5 checksum
859 is the keyed MD5 hash using the user's secret as the key
860 (see
861 .I hmac_md5
862 in
863 .IR sechash (2)).
864 .TP
865 .I S→A:
866 .IR AuthChap ,
867 .IR \- ,
868 .IR DN ,
869 .IR CHs ,
870 .IR IDs ,
871 .IR \-
872 .TP
873 .I A→S:
874 .I challenge
875 .TP
876 .I S→A:
877 .IR pktid ,
878 .IR IDc ,
879 .IR response
880 .Ok
881 .IP
882 This protocol implements CHAP authentication
883 (see
884 .IR ppp (8)).
885 The
886 .I challenge
887 is eight random bytes.
888 The response is a 16-byte MD5 checksum
889 over the packet id, user's secret, and challenge.
890 The reply packet is defined as 
891 .B OChapreply
892 in
893 .BR <authsrv.h> .
894 .TP
895 .I S→A:
896 .IR AuthMSchap ,
897 .IR \- ,
898 .IR DN ,
899 .IR CHs ,
900 .IR IDs ,
901 .IR \-
902 .TP
903 .I A→S:
904 .I challenge
905 .TP
906 .I S→A:
907 .IR IDc ,
908 .IR lm-response ,
909 .IR nt-response
910 .Ok
911 .IP
912 This protocol implements Microsoft's MS-CHAP
913 authentication
914 (see
915 .IR ppp (8)).
916 The
917 .I challenge
918 is eight random bytes.
919 The two responses are Microsoft's LM and NT hashes.
920 Only the NT hash may be used to authenticate,
921 as the LM hash is considered too weak.
922 The reply packet is defined as
923 .B OMSchapreply
924 in
925 .BR <authsrv.h> .
926 .TP
927 .I S→A:
928 .IR AuthVNC ,
929 .IR \- ,
930 .IR DN ,
931 .IR CHs ,
932 .IR IDs ,
933 .IR IDc
934 .TP
935 .I A→S:
936 .IR AuthOKvar ,
937 .I challenge
938 .TP
939 .I S→A:
940 .I response
941 .Ok
942 .IP
943 This protocol implements VNC authentication
944 (see
945 .I vncs
946 in
947 .IR vnc (1)).
948 The challenge is 16 random bytes, and the response
949 is a DES ECB encryption of the challenge.
950 The method by which VNC converts the user's
951 secret into a DES key is weak, 
952 considering only the first eight bytes of the secret.
953 .PD
954 .SH FILES
955 .TF /lib/ndb/auth.*xxx
956 .TP
957 .B /lib/ndb/auth
958 database file
959 .TP
960 .B /lib/ndb/auth.*
961 hash files for
962 .B /lib/ndb/auth
963 .SH SEE ALSO
964 .IR auth (2),
965 .IR fauth (2),
966 .IR cons (3),
967 .IR attach (5),
968 .IR auth (8)