]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libauthsrv/_asgetpakkey.c
libaml: fix gc bug, need to amltake()/amldrop() temporary buffer
[plan9front.git] / sys / src / libauthsrv / _asgetpakkey.c
1 #include <u.h>
2 #include <libc.h>
3 #include <authsrv.h>
4
5 int
6 _asgetpakkey(int fd, Ticketreq *tr, Authkey *a)
7 {
8         uchar y[PAKYLEN];
9         PAKpriv p;
10         int type;
11
12         type = tr->type;
13         tr->type = AuthPAK;
14         if(_asrequest(fd, tr) != 0){
15                 tr->type = type;
16                 return -1;
17         }
18         tr->type = type;
19         authpak_new(&p, a, y, 1);
20         if(write(fd, y, PAKYLEN) != PAKYLEN
21         || _asrdresp(fd, (char*)y, PAKYLEN) != PAKYLEN){
22                 memset(&p, 0, sizeof(p));
23                 return -1;
24         }
25         return authpak_finish(&p, a, y);
26 }