8 * compute the proper response. We encrypt the ascii of
9 * challenge number, with trailing binary zero fill.
10 * This process was derived empirically.
11 * this was copied from inet's guard.
14 netresp(char *key, long chal, char *answer)
18 memset(buf, 0, sizeof buf);
19 snprint((char *)buf, sizeof buf, "%lud", chal);
20 if(encrypt(key, buf, 8) < 0)
22 sprint(answer, "%.8ux", buf[0]<<24 | buf[1]<<16 | buf[2]<<8 | buf[3]);
26 auth_userpasswd(char *user, char *passwd)
28 char key[DESKEYLEN], resp[16];
33 * Probably we should have a factotum protocol
34 * to check a raw password. For now, we use
35 * p9cr, which is simplest to speak.
37 if((ch = auth_challenge("user=%q proto=p9cr role=server", user)) == nil)
40 passtokey(key, passwd);
41 netresp(key, atol(ch->chal), resp);
42 memset(key, 0, sizeof key);
45 ch->nresp = strlen(resp);
46 ai = auth_response(ch);