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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include <u.h>
#include <libc.h>
#include <libsec.h>
#include <authsrv.h>
void
usage(void)
{
fprint(2, "usage: netkey\n");
exits("usage");
}
void
main(int argc, char *argv[])
{
char *chal, *pass, buf[32], key[DESKEYLEN];
char *s;
int n;
ARGBEGIN{
default:
usage();
}ARGEND
if(argc)
usage();
s = getenv("service");
if(s && strcmp(s, "cpu") == 0){
fprint(2, "netkey must not be run on the cpu server\n");
exits("boofhead");
}
pass = readcons("password", nil, 1);
if(pass == nil)
sysfatal("reading password: %r");
passtokey(key, pass);
for(;;){
chal = readcons("challenge", nil, 0);
if(chal == nil || *chal == 0)
exits(nil);
n = strtol(chal, 0, 10);
sprint(buf, "%d", n);
netcrypt(key, buf);
print("response: %s\n", buf);
}
}
|