diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-01-06 03:09:00 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-01-06 03:09:00 +0100 |
commit | 2dae1ed53a73d81bfb86778793a6bda265d5140d (patch) | |
tree | e037c4a663fc9d17906cc2045c488232ac223ece /sys/src/libauthsrv/convA2M.c | |
parent | e064752dd476b7a2f76567f8cc15f9c2645e5d3d (diff) |
auth: release dp9ik implementation and reentrant factotum
Diffstat (limited to 'sys/src/libauthsrv/convA2M.c')
-rw-r--r-- | sys/src/libauthsrv/convA2M.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/sys/src/libauthsrv/convA2M.c b/sys/src/libauthsrv/convA2M.c index d285ad770..4db2df39e 100644 --- a/sys/src/libauthsrv/convA2M.c +++ b/sys/src/libauthsrv/convA2M.c @@ -2,26 +2,35 @@ #include <libc.h> #include <authsrv.h> -#define CHAR(x) *p++ = f->x -#define SHORT(x) p[0] = f->x; p[1] = f->x>>8; p += 2 -#define VLONG(q) p[0] = (q); p[1] = (q)>>8; p[2] = (q)>>16; p[3] = (q)>>24; p += 4 -#define LONG(x) VLONG(f->x) -#define STRING(x,n) memmove(p, f->x, n); p += n +extern int form1B2M(char *ap, int n, uchar key[32]); int convA2M(Authenticator *f, char *ap, int n, Ticket *t) { uchar *p; - if(n < AUTHENTLEN) + if(n < 1+CHALLEN) return 0; p = (uchar*)ap; - CHAR(num); - STRING(chal, CHALLEN); - LONG(id); - n = p - (uchar*)ap; - if(t) + *p++ = f->num; + memmove(p, f->chal, CHALLEN), p += CHALLEN; + switch(t->form){ + case 0: + if(n < 1+CHALLEN+4) + return 0; + + memset(p, 0, 4), p += 4; /* unused id field */ + n = p - (uchar*)ap; encrypt(t->key, ap, n); - return n; + return n; + case 1: + if(n < 12+CHALLEN+NONCELEN+16) + return 0; + + memmove(p, f->rand, NONCELEN), p += NONCELEN; + return form1B2M(ap, (char*)p - ap, t->key); + } + + return 0; } |