1 /* opieserv.c: Sample OTP server based on the opiechallenge() and
2 opieverify() library routines.
5 This software is Copyright 1996-2001 by Craig Metz, All Rights Reserved.
6 The Inner Net License Version 3 applies to this software.
7 You should have received a copy of the license with this software. If
8 you didn't get a copy, you may request one from <license@inner.net>.
12 Modified by cmetz for OPIE 2.3. Send debug info to syslog.
13 Created by cmetz for OPIE 2.2.
22 int main
FUNCTION((argc
, argv
), int argc AND
char *argv
[])
27 char challenge
[OPIE_CHALLENGE_MAX
+1];
28 char response
[OPIE_RESPONSE_MAX
+1];
32 fputs("Principal: ", stderr
);
33 if (!opiereadpass(buffer
, sizeof(buffer
)-1, 1))
34 fprintf(stderr
, "Error reading principal!");
40 syslog(LOG_DEBUG
, "Principal is +%s+", principal
);
43 switch (result
= opiechallenge(&opie
, principal
, challenge
)) {
45 fputs("System error!\n", stderr
);
50 fputs("User not found!\n", stderr
);
53 fputs("System error!\n", stderr
);
56 fprintf(stderr
, "Unknown error %d!\n", result
);
60 fputs(challenge
, stdout
);
63 fputs("Response: ", stderr
);
64 if (!opiereadpass(response
, OPIE_RESPONSE_MAX
, 1)) {
65 fputs("Error reading response!\n", stderr
);
69 switch (result
= opieverify(&opie
, response
)) {
71 fputs("System error!\n", stderr
);
74 fputs("User verified.\n", stderr
);
77 fputs("Verify failed!\n", stderr
);
80 fprintf(stderr
, "Unknown error %d!\n", result
);