1 #pragma src "/sys/src/libauthsrv"
2 #pragma lib "libauthsrv.a"
5 * Interface for talking to authentication server.
7 typedef struct Ticket Ticket;
8 typedef struct Ticketreq Ticketreq;
9 typedef struct Authenticator Authenticator;
10 typedef struct Nvrsafe Nvrsafe;
11 typedef struct Passwordreq Passwordreq;
12 typedef struct OChapreply OChapreply;
13 typedef struct OMSchapreply OMSchapreply;
15 typedef struct Authkey Authkey;
19 ANAMELEN= 28, /* name max size in previous proto */
20 AERRLEN= 64, /* errstr max size in previous proto */
21 DOMLEN= 48, /* authentication domain name length */
22 DESKEYLEN= 7, /* encrypt/decrypt des key length */
23 AESKEYLEN= 16, /* encrypt/decrypt aes key length */
25 CHALLEN= 8, /* plan9 sk1 challenge length */
26 NETCHLEN= 16, /* max network challenge length (used in AS protocol) */
28 SECRETLEN= 32, /* secret max size */
32 KEYDBOFF= 8, /* bytes of random data at key file's start */
33 OKEYDBLEN= ANAMELEN+DESKEYLEN+4+2, /* old key file entry length */
34 KEYDBLEN= OKEYDBLEN+SECRETLEN, /* key file entry length */
37 /* AuthPAK constants */
39 PAKSLEN= (448+7)/8, /* ed448 scalar */
40 PAKPLEN= 4*PAKSLEN, /* point in extended format X,Y,Z,T */
41 PAKHASHLEN= 2*PAKPLEN, /* hashed points PM,PN */
42 PAKXLEN= PAKSLEN, /* random scalar secret key */
43 PAKYLEN= PAKSLEN, /* decaf encoded public key */
46 /* encryption numberings (anti-replay) */
49 AuthTreq=1, /* ticket request */
50 AuthChal=2, /* challenge box request */
51 AuthPass=3, /* change password */
52 AuthOK=4, /* fixed length reply follows */
53 AuthErr=5, /* error follows */
54 AuthMod=6, /* modify user */
55 AuthApop=7, /* apop authentication for pop3 */
56 AuthOKvar=9, /* variable length reply follows */
57 AuthChap=10, /* chap authentication for ppp */
58 AuthMSchap=11, /* MS chap authentication for ppp */
59 AuthCram=12, /* CRAM verification for IMAP (RFC2195 & rfc2104) */
60 AuthHttp=13, /* http domain login */
61 AuthVNC=14, /* VNC server login (deprecated) */
62 AuthPAK=19, /* authenticated diffie hellman key agreement */
63 AuthTs=64, /* ticket encrypted with server's key */
64 AuthTc, /* ticket encrypted with client's key */
65 AuthAs, /* server generated authenticator */
66 AuthAc, /* client generated authenticator */
67 AuthTp, /* ticket encrypted with client's key for password change */
68 AuthHr, /* http reply */
74 char authid[ANAMELEN]; /* server's encryption id */
75 char authdom[DOMLEN]; /* server's authentication domain */
76 char chal[CHALLEN]; /* challenge from server */
77 char hostid[ANAMELEN]; /* host's encryption id */
78 char uid[ANAMELEN]; /* uid of requesting user on host */
80 #define TICKREQLEN (3*ANAMELEN+CHALLEN+DOMLEN+1)
84 char num; /* replay protection */
85 char chal[CHALLEN]; /* server challenge */
86 char cuid[ANAMELEN]; /* uid on client */
87 char suid[ANAMELEN]; /* uid on server */
88 uchar key[NONCELEN]; /* nonce key */
90 char form; /* (not transmitted) format (0 = des, 1 = ccpoly) */
92 #define MAXTICKETLEN (12+CHALLEN+2*ANAMELEN+NONCELEN+16)
96 char num; /* replay protection */
97 char chal[CHALLEN]; /* server/client challenge */
98 uchar rand[NONCELEN]; /* server/client nonce */
100 #define MAXAUTHENTLEN (12+CHALLEN+NONCELEN+16)
108 char secret[SECRETLEN]; /* new secret */
110 #define MAXPASSREQLEN (12+2*ANAMELEN+1+SECRETLEN+16)
118 #define OCHAPREPLYLEN (1+ANAMELEN+OMD5LEN)
123 char LMresp[24]; /* Lan Manager response */
124 char NTresp[24]; /* NT response */
126 #define OMSCHAPREPLYLEN (ANAMELEN+24+24)
130 char des[DESKEYLEN]; /* DES key from password */
131 uchar aes[AESKEYLEN]; /* AES key from password */
132 uchar pakkey[PAKKEYLEN]; /* shared key from AuthPAK exchange (see authpak_finish()) */
133 uchar pakhash[PAKHASHLEN]; /* secret hash from AES key and user name (see authpak_hash()) */
137 * convert to/from wire format
139 extern int convT2M(Ticket*, char*, int, Authkey*);
140 extern int convM2T(char*, int, Ticket*, Authkey*);
141 extern int convA2M(Authenticator*, char*, int, Ticket*);
142 extern int convM2A(char*, int, Authenticator*, Ticket*);
143 extern int convTR2M(Ticketreq*, char*, int);
144 extern int convM2TR(char*, int, Ticketreq*);
145 extern int convPR2M(Passwordreq*, char*, int, Ticket*);
146 extern int convM2PR(char*, int, Passwordreq*, Ticket*);
149 * convert ascii password to auth key
151 extern void passtokey(Authkey*, char*);
153 extern void passtodeskey(char key[DESKEYLEN], char *p);
154 extern void passtoaeskey(uchar key[AESKEYLEN], char *p);
160 NVread = 0, /* just read */
161 NVwrite = 1<<0, /* always prompt and rewrite nvram */
162 NVwriteonerr = 1<<1, /* prompt and rewrite nvram when corrupt */
163 NVwritemem = 1<<2, /* don't prompt, write nvram from argument */
169 char machkey[DESKEYLEN]; /* file server's authid's des key */
171 char authkey[DESKEYLEN]; /* authid's des key from password */
174 * file server config string of device holding full configuration;
175 * secstore key on non-file-servers.
177 char config[CONFIGLEN];
179 char authid[ANAMELEN]; /* auth userid, e.g., bootes */
181 char authdom[DOMLEN]; /* auth domain, e.g., cs.bell-labs.com */
184 uchar aesmachkey[AESKEYLEN];
188 extern uchar nvcsum(void*, int);
189 extern int readnvram(Nvrsafe*, int);
192 * call up auth server
194 extern int authdial(char *netroot, char *authdom);
197 * exchange messages with auth server
199 extern int _asgetpakkey(int, Ticketreq*, Authkey*);
200 extern int _asgetticket(int, Ticketreq*, char*, int);
201 extern int _asrequest(int, Ticketreq*);
202 extern int _asgetresp(int, Ticket*, Authenticator*, Authkey *);
203 extern int _asrdresp(int, char*, int);
208 typedef struct PAKpriv PAKpriv;
216 extern void authpak_hash(Authkey *k, char *u);
217 extern void authpak_new(PAKpriv *p, Authkey *k, uchar y[PAKYLEN], int isclient);
218 extern int authpak_finish(PAKpriv *p, Authkey *k, uchar y[PAKYLEN]);