summaryrefslogtreecommitdiff
path: root/sys/src/libauthsrv/_asgetresp.c
blob: da0e2bd204f5eb17471a9f8cd44c7c57913c3f2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <u.h>
#include <libc.h>
#include <authsrv.h>

int
_asgetresp(int fd, Ticket *t, Authenticator *a, Authkey *k)
{
	char tbuf[TICKETLEN+AUTHENTLEN];
	int n, m;

	m = TICKETLEN;
	memset(t, 0, sizeof(Ticket));
	if(a != nil){
		m += AUTHENTLEN;
		memset(a, 0, sizeof(Authenticator));
	}

	n = _asrdresp(fd, tbuf, m);
	if(n <= 0)
		return -1;

	m = convM2T(tbuf, n, t, k);
	if(m <= 0)
		return -1;

	if(a != nil){
		if(convM2A(tbuf+m, n-m, a, t) <= 0)
			return -1;
	}

	return 0;
}