summaryrefslogtreecommitdiff
path: root/lib/libskey
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-10-22 01:41:26 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-10-22 01:41:26 +0000
commit4ab93d1287e55e407a430cf2d79cae7e93978e07 (patch)
treed1855c1e863a86955a2cd0af8f9cf7446fbcddcd /lib/libskey
parent6e0922703dad7fe7ed57c2fe949ba98e03f2f79f (diff)
Fake an s/key challenge if user doesn't have an entry. Stops info
gathering attack.
Diffstat (limited to 'lib/libskey')
-rw-r--r--lib/libskey/skeylogin.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/libskey/skeylogin.c b/lib/libskey/skeylogin.c
index d7f05a9993a..666c5a9a532 100644
--- a/lib/libskey/skeylogin.c
+++ b/lib/libskey/skeylogin.c
@@ -8,7 +8,7 @@
*
* S/KEY verification check, lookups, and authentication.
*
- * $Id: skeylogin.c,v 1.9 1996/10/14 03:09:13 millert Exp $
+ * $Id: skeylogin.c,v 1.10 1996/10/22 01:41:25 millert Exp $
*/
#include <sys/param.h>
@@ -355,8 +355,34 @@ skey_authenticate(username)
/* Attempt an S/Key challenge */
i = skeychallenge(&skey, username, skeyprompt);
- if (i == -2)
- return 0;
+ /* Cons up a fake prompt if no entry in keys file */
+ if (i != 0) {
+ char *p, *u;
+
+ /* Base first 4 chars of seed on hostname */
+ if (gethostname(pbuf, sizeof(pbuf)) < 0)
+ strcpy(pbuf, "asjd");
+ p = &pbuf[4];
+ *p = '\0';
+
+ /* Base last 8 chars of seed on username */
+ u = username;
+ i = 8;
+ do {
+ if (*u == 0) {
+ /* Pad remainder with zeros */
+ while (--i >= 0)
+ *p++ = '0';
+ break;
+ }
+
+ *p++ = (*u++ % 10) + '0';
+ } while (--i != 0);
+ pbuf[12] = '\0';
+
+ (void)snprintf(skeyprompt, sizeof(skeyprompt), "otp-%s %d %s",
+ skey_get_algorithm(), 99, pbuf);
+ }
(void)fprintf(stderr, "%s\n", skeyprompt);
(void)fflush(stderr);