1 #include <u.h> 2 #include <libc.h> 3 #include <authsrv.h> 4 #include "authcmdlib.h" 5 6 7 void 8 usage(void) 9 { 10 fprint(2, "usage: netkey\n"); 11 exits("usage"); 12 } 13 14 void 15 main(int argc, char *argv[]) 16 { 17 char buf[32], pass[32], key[DESKEYLEN]; 18 char *s; 19 int n; 20 21 ARGBEGIN{ 22 default: 23 usage(); 24 }ARGEND 25 if(argc) 26 usage(); 27 28 s = getenv("service"); 29 if(s && strcmp(s, "cpu") == 0){ 30 fprint(2, "netkey must not be run on the cpu server\n"); 31 exits("boofhead"); 32 } 33 34 readln("Password: ", pass, sizeof pass, 1); 35 passtokey(key, pass); 36 37 for(;;){ 38 print("challenge: "); 39 n = read(0, buf, sizeof buf - 1); 40 if(n <= 0) 41 exits(0); 42 buf[n] = '\0'; 43 n = strtol(buf, 0, 10); 44 sprint(buf, "%d", n); 45 netcrypt(key, buf); 46 print("response: %s\n", buf); 47 } 48 } 49