summaryrefslogtreecommitdiff
path: root/sys/src/libauth/auth_userpasswd.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-08-19 21:06:17 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-08-19 21:06:17 +0200
commit02cfcfeab46f36aad95263ed40d19df7bd5eddef (patch)
tree30f67204be8d474b2c761e8944c20d042df1a08b /sys/src/libauth/auth_userpasswd.c
parentf785d4da07349c7bb250eb00a3f2bed3eb170828 (diff)
libauthsrv: generalize ticket service, not hardcoding ticket format and DES encryption
this is in preparation for replacing DES ticket encryption with something better. but first need to make the code stop making assumptions. the wire encoding of the Ticket might be variable length with TICKETLEN just giving an upper bound. the details will be handled by libauthsrv _asgetticket() and _asgetresp() funciotns. the Authenticator and Passwordreq structures are encrypted with the random ticket key. The encryption schmeme will depend on the Ticket format used, so we pass the Ticket* structure instead of the DES key. introduce Authkey structure that will hold all the required cryptographic keys instead of passing DES key.
Diffstat (limited to 'sys/src/libauth/auth_userpasswd.c')
-rw-r--r--sys/src/libauth/auth_userpasswd.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/src/libauth/auth_userpasswd.c b/sys/src/libauth/auth_userpasswd.c
index 292899281..e113d83a4 100644
--- a/sys/src/libauth/auth_userpasswd.c
+++ b/sys/src/libauth/auth_userpasswd.c
@@ -11,13 +11,13 @@
* this was copied from inet's guard.
*/
static void
-netresp(char *key, long chal, char *answer)
+netresp(Authkey *key, long chal, char *answer)
{
uchar buf[8];
memset(buf, 0, sizeof buf);
snprint((char *)buf, sizeof buf, "%lud", chal);
- if(encrypt(key, buf, 8) < 0)
+ if(encrypt(key->des, buf, 8) < 0)
abort();
sprint(answer, "%.8ux", buf[0]<<24 | buf[1]<<16 | buf[2]<<8 | buf[3]);
}
@@ -25,7 +25,8 @@ netresp(char *key, long chal, char *answer)
AuthInfo*
auth_userpasswd(char *user, char *passwd)
{
- char key[DESKEYLEN], resp[16];
+ char resp[16];
+ Authkey key;
AuthInfo *ai;
Chalstate *ch;
@@ -37,9 +38,9 @@ auth_userpasswd(char *user, char *passwd)
if((ch = auth_challenge("user=%q proto=p9cr role=server", user)) == nil)
return nil;
- passtokey(key, passwd);
- netresp(key, atol(ch->chal), resp);
- memset(key, 0, sizeof key);
+ passtokey(&key, passwd);
+ netresp(&key, atol(ch->chal), resp);
+ memset(&key, 0, sizeof(Authkey));
ch->resp = resp;
ch->nresp = strlen(resp);