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/convPR2M.c | |
parent | e064752dd476b7a2f76567f8cc15f9c2645e5d3d (diff) |
auth: release dp9ik implementation and reentrant factotum
Diffstat (limited to 'sys/src/libauthsrv/convPR2M.c')
-rw-r--r-- | sys/src/libauthsrv/convPR2M.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/sys/src/libauthsrv/convPR2M.c b/sys/src/libauthsrv/convPR2M.c index d5c0ee7ac..0f3463ef2 100644 --- a/sys/src/libauthsrv/convPR2M.c +++ b/sys/src/libauthsrv/convPR2M.c @@ -2,29 +2,33 @@ #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 convPR2M(Passwordreq *f, char *ap, int n, Ticket *t) { uchar *p; - if(n < PASSREQLEN) + if(n < 1+2*ANAMELEN+1+SECRETLEN) return 0; p = (uchar*)ap; - CHAR(num); - STRING(old, ANAMELEN); - STRING(new, ANAMELEN); - CHAR(changesecret); - STRING(secret, SECRETLEN); - n = p - (uchar*)ap; - if(t) + *p++ = f->num; + memmove(p, f->old, ANAMELEN), p += ANAMELEN; + memmove(p, f->new, ANAMELEN), p += ANAMELEN; + *p++ = f->changesecret; + memmove(p, f->secret, SECRETLEN), p += SECRETLEN; + switch(t->form){ + case 0: + n = p - (uchar*)ap; encrypt(t->key, ap, n); - return n; + return n; + case 1: + if(n < 12+2*ANAMELEN+1+SECRETLEN+16) + return 0; + return form1B2M(ap, p - (uchar*)ap, t->key); + } + + return 0; } |