1 /* opiegen.c: Sample OTP generator based on the opiegenerator()
4 %%% portions-copyright-cmetz-96
5 Portions of this software are Copyright 1996-1999 by Craig Metz, All Rights
6 Reserved. The Inner Net License Version 2 applies to these portions of
8 You should have received a copy of the license with this software. If
9 you didn't get a copy, you may request one from <license@inner.net>.
13 Modified by cmetz for OPIE 2.3. OPIE_PASS_MAX changed to
14 OPIE_SECRET_MAX. Send debug info to syslog.
15 Modified by cmetz for OPIE 2.2. Use FUNCTION definition et al.
17 Created at NRL for OPIE 2.2.
26 int main
FUNCTION((argc
, argv
), int argc AND
char *argv
[])
28 char buffer
[OPIE_CHALLENGE_MAX
+1];
29 char secret
[OPIE_SECRET_MAX
+1];
30 char response
[OPIE_RESPONSE_MAX
+1];
34 fputs("Sorry, but you don't seem to be on a secure terminal.\n", stderr
);
41 fputs("Challenge: ", stderr
);
42 if (!opiereadpass(buffer
, sizeof(buffer
)-1, 1))
43 fprintf(stderr
, "Error reading challenge!");
48 ep
= buffer
+ sizeof(buffer
) - 1;
49 for (i
= 1, ap
= buffer
; (i
< argc
) && (ap
< ep
); i
++) {
51 while ((*(ap
++) = *(c
++)) && (ap
< ep
));
56 syslog(LOG_DEBUG
, "opiegen: challenge is +%s+\n", buffer
);
59 buffer
[sizeof(buffer
)-1] = 0;
61 fputs("Secret pass phrase: ", stderr
);
62 if (!opiereadpass(secret
, OPIE_SECRET_MAX
, 0)) {
63 fputs("Error reading secret pass phrase!\n", stderr
);
67 switch (result
= opiegenerator(buffer
, secret
, response
)) {
69 fputs("Not a valid OTP secret pass phrase.\n", stderr
);
72 fputs("Error processing challenge!\n", stderr
);
75 fputs("Not a valid OTP challenge.\n", stderr
);
78 fputs(response
, stdout
);
81 memset(secret
, 0, sizeof(secret
));
84 fprintf(stderr
, "Unknown error %d!\n", result
);
86 memset(secret
, 0, sizeof(secret
));