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)
19 sprint((char *)buf, "%lud", chal);
20 if(encrypt(key, buf, 8) < 0)
22 chal = (buf[0]<<24)+(buf[1]<<16)+(buf[2]<<8)+buf[3];
23 sprint(answer, "%.8lux", chal);
27 auth_userpasswd(char *user, char *passwd)
29 char key[DESKEYLEN], resp[16];
34 * Probably we should have a factotum protocol
35 * to check a raw password. For now, we use
36 * p9cr, which is simplest to speak.
38 if((ch = auth_challenge("user=%q proto=p9cr role=server", user)) == nil)
41 passtokey(key, passwd);
42 netresp(key, atol(ch->chal), resp);
43 memset(key, 0, sizeof key);
46 ch->nresp = strlen(resp);
47 ai = auth_response(ch);