diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-12-20 02:08:10 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-12-20 02:08:10 +0000 |
commit | 5155aff0efef105ec83e53007784e11c8634f114 (patch) | |
tree | 22c4b29ddf3821d9592a7bef417c6a0df47d40a2 | |
parent | 88299e2ef9350d7ba25ebffbe1d03ca9a347dca8 (diff) |
Commands for manipulating the token database (ActivCard, CRYPTOCard, or SNK-004)
from BSDi. Will be enabled when BSD authentication is turned on (login_token).
-rw-r--r-- | usr.sbin/tokenadm/Makefile | 27 | ||||
-rw-r--r-- | usr.sbin/tokenadm/tokenadm.8 | 123 | ||||
-rw-r--r-- | usr.sbin/tokenadm/tokenadm.c | 402 | ||||
-rw-r--r-- | usr.sbin/tokeninit/Makefile | 27 | ||||
-rw-r--r-- | usr.sbin/tokeninit/tokeninit.8 | 219 | ||||
-rw-r--r-- | usr.sbin/tokeninit/tokeninit.c | 238 |
6 files changed, 1036 insertions, 0 deletions
diff --git a/usr.sbin/tokenadm/Makefile b/usr.sbin/tokenadm/Makefile new file mode 100644 index 00000000000..013e3d0ecd3 --- /dev/null +++ b/usr.sbin/tokenadm/Makefile @@ -0,0 +1,27 @@ +# $OpenBSD: Makefile,v 1.1 2000/12/20 02:08:08 millert Exp $ + +PROG= tokenadm +SRCS= tokenadm.c init.c tokendb.c +MAN= tokenadm.8 +LDADD+= -ldes +DPADD= ${LIBDES} + +CFLAGS+=-I${.CURDIR}/../../libexec/login_token +.PATH: ${.CURDIR}/../../libexec/login_token + +TOKENS= activ crypto snk + +MLINKS= tokenadm.8 activadm.8 +MLINKS+=tokenadm.8 cryptoadm.8 +MLINKS+=tokenadm.8 snkadm.8 + +BINMODE=500 + +afterinstall: + for i in ${TOKENS} ; do \ + cd ${DESTDIR}/${BINDIR} && \ + rm -f $${i}adm && \ + ln ${PROG} $${i}adm ; \ + done + +.include <bsd.prog.mk> diff --git a/usr.sbin/tokenadm/tokenadm.8 b/usr.sbin/tokenadm/tokenadm.8 new file mode 100644 index 00000000000..7bfd36fcb73 --- /dev/null +++ b/usr.sbin/tokenadm/tokenadm.8 @@ -0,0 +1,123 @@ +.\" $OpenBSD: tokenadm.8,v 1.1 2000/12/20 02:08:08 millert Exp $ +.\" +.\" Copyright (c) 1996 Berkeley Software Design, Inc. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Berkeley Software Design, +.\" Inc. +.\" 4. The name of Berkeley Software Design, Inc. may not be used to endorse +.\" or promote products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" BSDI $From: tokenadm.8,v 1.3 1996/09/06 00:44:07 prb Exp $ +.\" +.Dd August 23, 1996 +.Dt TOKENADM 8 +.Os +.Sh NAME +.Nm activadm , cryptoadm , snkadm +.Nd manage the ActivCard, CRYPTOCard and SNK-004 token databases +.Sh SYNOPSIS +.Nm tokenadm +.Op Fl 1BDERT +.Op Fl d +.Op Fl e +.Op Fl m Ar [-]mode +.Op Fl r +.Op Ar user Op ... +.Sh DESCRIPTION +The +.Nm tokenadm +utility is display and edit user entries in the various token databases. +It may also be invoked as one the following: +.Nm activadm , cryptoadm , +or +.Nm snkadm . +The flags available are: +.Bl -tag -width indent +.It Fl 1 +Display users, one per line. +.It Fl B +Display users with no banner. +.It Fl D +Display disabled users. +.It Fl E +Display enabled users. +.It Fl R +Display users in reverse order. +.It Fl T +Display users in terse format (only the user names). +Unless +.Fl 1 +is also specified, four users will be displayed per line. +.It Fl d +Disable users without removing them from the database. +This prevents the users from authenticating, but does not loose their +shared secret. +The +.Fl m +flag may also be used with the +.Fl d +flag. +.It Fl e +Enable users. +This should be used to re-enable users who were disabled by the +.Fl m +flag may also be used with the +.Fl e +flag +option. +.It Fl m +Add +[or remove] +the specified mode of authentication for the user. Modes available are +decimal (dec), hexadecimal (hex) and phonebook (phone) and reduced-input (rim). +Not all modes are available for all types of cards. +The +.Fl m +flag may be used alone or in conjunction with either the +.Fl de +flags. +When ever reduced-input mode is set the reduced-input state is reset. +This should be done if a paper copy of challenge/responses had been +produced and then misplaced. +.It Fl r +Remove users from the database. +.El +.sp +Use of any of the +.Fl 1BDERT +flags precludes the use of any of the +.Fl demr +flags. +The +.Fl demr +flags all require at least one +.Ar user +argument. +.Sh SEE ALSO +.Xr x99token 1 , +.Xr login.conf 5 , +.Xr login_token 8 , +.Xr tokeninit 8 , diff --git a/usr.sbin/tokenadm/tokenadm.c b/usr.sbin/tokenadm/tokenadm.c new file mode 100644 index 00000000000..383b7b4c2bb --- /dev/null +++ b/usr.sbin/tokenadm/tokenadm.c @@ -0,0 +1,402 @@ +/* $OpenBSD: tokenadm.c,v 1.1 2000/12/20 02:08:09 millert Exp $ */ + +/*- + * Copyright (c) 1995 Migration Associates Corp. All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Berkeley Software Design, + * Inc. + * 4. The name of Berkeley Software Design, Inc. may not be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * BSDI $From: tokenadm.c,v 1.2 1996/10/17 00:54:28 prb Exp $ + */ + +#include <sys/param.h> +#include <sys/resource.h> +#include <sys/time.h> + +#include <err.h> +#include <errno.h> +#include <stdio.h> +#include <syslog.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +#include "token.h" +#include "tokendb.h" + + +typedef enum { LIST, ENABLE, DISABLE, REMOVE, MODECH } what_t; +typedef enum { + NOBANNER = 0x01, + TERSE = 0x02, + ENONLY = 0x04, + DISONLY = 0x08, + ONECOL = 0x10, + REVERSE = 0x20, + } how_t; + +static int force_unlock(char *); +static int process_record(char *, unsigned, unsigned); +static int process_modes(char *, unsigned, unsigned); +static void print_record(TOKENDB_Rec *, how_t); + +extern int +main(int argc, char **argv) +{ + int c, errors; + u_int emode, dmode, pmode; + struct rlimit cds; + what_t what; + how_t how; + TOKENDB_Rec tokenrec; + + what = LIST; + emode = dmode = 0; + pmode = 0; + errors = 0; + how = 0; + + (void)signal(SIGQUIT, SIG_IGN); + (void)signal(SIGINT, SIG_IGN); + (void)setpriority(PRIO_PROCESS, 0, 0); + + openlog(NULL, LOG_ODELAY, LOG_AUTH); + + if (token_init(argv[0]) < 0) { + syslog(LOG_ERR, "unknown token type"); + errx(1, "unknown token type"); + } + + /* + * Make sure we never dump core as we might have a + * valid user shared-secret in memory. + */ + + cds.rlim_cur = 0; + cds.rlim_max = 0; + if (setrlimit(RLIMIT_CORE, &cds) < 0) + syslog(LOG_ERR, "couldn't set core dump size to 0: %m"); + + while ((c = getopt(argc, argv, "BDERT1bdem:ru")) != EOF) + switch (c) { + case 'B': + if (what != LIST) + goto usage; + how |= NOBANNER; + break; + case 'T': + if (what != LIST) + goto usage; + how |= TERSE; + break; + case '1': + if (what != LIST) + goto usage; + how |= ONECOL; + break; + case 'D': + if (what != LIST) + goto usage; + how |= DISONLY; + break; + case 'E': + if (what != LIST) + goto usage; + how |= ENONLY; + break; + case 'R': + if (what != LIST) + goto usage; + how |= REVERSE; + break; + case 'd': + if (what != LIST || how) + goto usage; + what = DISABLE; + break; + case 'e': + if (what != LIST || how) + goto usage; + what = ENABLE; + break; + case 'r': + if (what != LIST || emode || dmode || how) + goto usage; + what = REMOVE; + break; + case 'm': + if (what == REMOVE || how) + goto usage; + if (*optarg == '-') { + if ((c = token_mode(optarg+1)) == NULL) + errx(1, "%s: unknown mode", optarg+1); + dmode |= c; + } else { + if ((c = token_mode(optarg)) == NULL) + errx(1, "%s: unknown mode", optarg); + emode |= c; + } + break; + default: + goto usage; + } + + if (what == LIST && (dmode || emode)) + what = MODECH; + + if (what == LIST) { + if ((how & (ENONLY|DISONLY)) == 0) + how |= ENONLY|DISONLY; + if (!(how & NOBANNER)) { + if ((how & (TERSE|ONECOL)) == (TERSE|ONECOL)) { + printf("User\n"); + printf("----------------\n"); + } else if (how & (TERSE)) { + printf("User "); + printf("User "); + printf("User "); + printf("User\n"); + printf("---------------- "); + printf("---------------- "); + printf("---------------- "); + printf("----------------\n"); + } else { + printf("User Status Modes\n"); + printf("---------------- -------- -----\n"); + } + } + + if (optind >= argc) { + if (tokendb_firstrec(how & REVERSE, &tokenrec)) + exit(0); + do + print_record(&tokenrec, how); + while (tokendb_nextrec(how & REVERSE, &tokenrec) == 0); + print_record(NULL, how); + exit(0); + } + } + + if (optind >= argc) { +usage: + fprintf(stderr, + "Usage: %sadm [-BDERT1 | -d | -e | -r] [-m mode] user [...]\n", + tt->name); + exit(1); + } + + + argv += optind - 1; + while (*++argv) + switch(what) { + case LIST: + if (tokendb_getrec(*argv, &tokenrec)) { + printf("%s: no such user\n", *argv); + break; + } + print_record(&tokenrec, how); + break; + case REMOVE: + if (tokendb_delrec(*argv)) { + warnx("%s: could not remove", *argv); + errors++; + } + break; + case DISABLE: + if (process_record(*argv, ~TOKEN_ENABLED, 0)) { + warnx("%s: could not disable", *argv); + ++errors; + } + if (emode || dmode) + goto modech; + break; + case ENABLE: + if (process_record(*argv, ~TOKEN_ENABLED, 0)) { + warnx("%s: could not enable", *argv); + ++errors; + } + if (emode || dmode) + goto modech; + break; + modech: + case MODECH: + if (process_modes(*argv, ~dmode, emode)) { + warnx("%s: could not change modes", *argv); + ++errors; + } + break; + } + + if (what == LIST) + print_record(NULL, how); + + exit(errors); +} + +/* + * Process a user record + */ + +static int +process_record(char *username, unsigned and_mask, unsigned or_mask) +{ + int count = 0; + TOKENDB_Rec tokenrec; + +retry: + switch (tokendb_lockrec(username, &tokenrec, TOKEN_LOCKED)) { + case 0: + tokenrec.flags &= and_mask; + tokenrec.flags |= or_mask; + tokenrec.flags &= ~TOKEN_LOCKED; + if (!tokendb_putrec(username, &tokenrec)) + return (0); + else + return (-1); + case 1: + sleep(1); + if (count++ < 60) + goto retry; + if (force_unlock(username)) + return (1); + goto retry; + + case ENOENT: + warnx("%s: nonexistent user", username); + return (1); + default: + return (-1); + } +} + +static int +process_modes(char *username, unsigned and_mask, unsigned or_mask) +{ + int count = 0; + TOKENDB_Rec tokenrec; + +retry: + switch (tokendb_lockrec(username, &tokenrec, TOKEN_LOCKED)) { + case 0: + tokenrec.mode &= and_mask; + tokenrec.mode |= or_mask; + /* + * When ever we set up for rim mode (even if we are + * already set up for it) reset the rim key + */ + if (or_mask & TOKEN_RIM) + memset(tokenrec.rim, 0, sizeof(tokenrec.rim)); + tokenrec.flags &= ~TOKEN_LOCKED; + if (!tokendb_putrec(username, &tokenrec)) + return (0); + else + return (-1); + case 1: + sleep(1); + if (count++ < 60) + goto retry; + if (force_unlock(username)) + return (1); + goto retry; + + case ENOENT: + warnx("%s: nonexistent user", username); + return (1); + default: + return (-1); + } +} + +/* + * Force remove a user record-level lock. + */ + +static int +force_unlock(char *username) +{ + TOKENDB_Rec tokenrec; + + if (tokendb_getrec(username, &tokenrec)) + return (-1); + + tokenrec.flags &= ~TOKEN_LOCKED; + tokenrec.flags &= ~TOKEN_LOGIN; + + if (tokendb_putrec(username, &tokenrec)) + return (1); + + return (0); +} + +/* + * Print a database record according to user a specified format + */ + +static void +print_record(TOKENDB_Rec *rec, how_t how) +{ + static int count = 0; + int i; + + if (rec == NULL) { + if ((count & 3) && (how & (TERSE|ONECOL)) == TERSE) + printf("\n"); + return; + } + + if (rec->flags & TOKEN_ENABLED) { + if ((how & ENONLY) == 0) + return; + } else { + if ((how & DISONLY) == 0) + return; + } + + switch (how & (TERSE|ONECOL)) { + case 0: + case ONECOL: + printf("%-16s %-8s", rec->uname, + rec->flags & TOKEN_ENABLED ? "enabled" : "disabled"); + + for (i = 1; i; i <<= 1) + if (rec->mode & i) + printf(" %s", token_getmode(i)); + printf("\n"); + break; + case TERSE: + if ((count & 3) == 3) + printf("%s\n", rec->uname); + else + printf("%-16s ", rec->uname); + break; + case TERSE|ONECOL: + printf("%s\n", rec->uname); + break; + } + ++count; +} diff --git a/usr.sbin/tokeninit/Makefile b/usr.sbin/tokeninit/Makefile new file mode 100644 index 00000000000..431e9a9bf52 --- /dev/null +++ b/usr.sbin/tokeninit/Makefile @@ -0,0 +1,27 @@ +# $OpenBSD: Makefile,v 1.1 2000/12/20 02:08:09 millert Exp $ + +PROG= tokeninit +SRCS= tokeninit.c init.c token.c tokendb.c +MAN= tokeninit.8 +LDADD+= -ldes +DPADD= ${LIBDES} + +CFLAGS+=-I${.CURDIR}/../../libexec/login_token +.PATH: ${.CURDIR}/../../libexec/login_token + +TOKENS= activ crypto snk + +MLINKS= tokeninit.8 activinit.8 +MLINKS+=tokeninit.8 cryptoinit.8 +MLINKS+=tokeninit.8 snkinit.8 + +BINMODE=500 + +afterinstall: + for i in ${TOKENS} ; do \ + cd ${DESTDIR}/${BINDIR} && \ + rm -f $${i}init && \ + ln ${PROG} $${i}init ; \ + done + +.include <bsd.prog.mk> diff --git a/usr.sbin/tokeninit/tokeninit.8 b/usr.sbin/tokeninit/tokeninit.8 new file mode 100644 index 00000000000..9d18dd0ee59 --- /dev/null +++ b/usr.sbin/tokeninit/tokeninit.8 @@ -0,0 +1,219 @@ +.\" $OpenBSD: tokeninit.8,v 1.1 2000/12/20 02:08:09 millert Exp $ +.\" +.\" Copyright (c) 1995 Migration Associates Corporation. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Berkeley Software Design, +.\" Inc. +.\" 4. The name of Berkeley Software Design, Inc. may not be used to endorse +.\" or promote products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" BSDI $From: tokeninit.8,v 1.3 1997/01/16 03:23:11 bostic Exp $ +.\" +.Dd September 26, 1995 +.Dt TOKENINIT 8 +.Os +.Sh NAME +.Nm activinit , cryptoinit , snkinit +.Nd Modify or add user in ActivCard, CRYPTOCard, or SNK-004 authentication system. +.Sh SYNOPSIS +.Nm tokeninit +.Op Fl f +.Op Fl h +.Op Fl m Ar mode +.Op Fl s +.Op Fl v +.Ar user_ID +.Op Ar user_ID ... +.Sh DESCRIPTION +.Pp +The +.Nm tokeninit +utility may also be invoked by one of the names: +.Nm activinit , cryptoinit , +or +.Nm snkinit . +Depending on the name it was invoked under, it will +initialize the system information to allow one to use the +ActivCard, CRYPTOCard or SNK-004 digital encryption token to login. +The +.Nm tokeninit +utility is intended for use by the system administrator. +.Pp +Token cards system provides strong user authentication by combining a user's +unique knowledge (a Personal Identification Number) and a physical object +(the token) which the user must have in their possession to login. +The system administrator programs the token with a secret encryption key +which is also stored in the database. The user programs the token with +a PIN. To discourage exhaustive attempts to guess the PIN, +configuration options permit the token to be programmed +to erase knowledge of the shared secret should the user enter +an excessive number of incorrect PIN entries. +.Pp +The user activates the token by entering their PIN into the token. +After activating the token, the user enters a random number challenge +presented by the host computer into the token. The challenge is encrypted by +the token and a response displayed. The user then enters the +response at the host computer's prompt, where it is compared with the +anticipated response. +.Pp +Token cards typically support multiple unique encryption keys. +This facility allows a single token to be used for multiple computer +systems, or multiple user instances on the same system. +.Sh OPTIONS +.Bl -hang +.It Fl f +Force reinitialization of an existing account. +The current shared secret stored in the database will be replaced a new +shared secret. +The new shared secret must be entered into the token, +replacing the current one. +.It Fl h +Read the shared secret as a 16 digit hexadecimal integer rather than +a sequence of 8 octets. +This is not supported when invoked as +.Nm snkinit . +.It Fl m +Specify the input modes allowed for this user. Possible modes are +decimal (dec), hexadecimal (hex), phonebook (phone) and reduced-input (rim). +Not all modes are available for all types of cards. Multiple +.Fl m +options may be specified to enable multiple modes. +By default only the hexadecimal mode is enabled, except for the SNK-004 +token, which by default only enables the decimal mode. +If an attempt is made to initialize a card with only reduced-input, the +default mode for the card is silently included. +.It Fl s +By default, +.Nm tokeninit +prompts for a shared secret to enter into the authentication database. +The +.Fl s +option generates a 64 bit cryptographically strong key for use in the token. +This shared secret will be saved +in the database for the user ID specified on the command line. +After entering the shared secret into the token, +determine that the checksum computed +by the token matches the one displayed by +.Nm tokeninit . +.It Fl v +Enable verbose mode. +.Nm tokeninit +will emit messages on the status of each user ID processed. +.El +.Sh REDUCED-INPUT MODE +Reduced-input mode allows the token to predict the next challenge, +given the current challenge. This may be used to eliminate the need +to enter the challenge to the token or may also be used with a paper list. +Using a program such as +.Xr x99token 1 +many challenges could be precomputed and printed. This list should be +kept secret. This list can then take the place of an actual token until +the system has issued all the challenges printed. +Challenges are predicted by the following algorithm: +.nf +.sp +* Encrypt the last challenge with the shared secret key + +* AND each byte of the response with 0x0f + +* Modulo each byte by 10 (0x0a) + +* ADD 0x30 (ASCII value of '0') to each byte +.fi +.sp +The resulting 8 bytes are all ASCII decimal digits and are the next challenge. +.Sh DIAGNOSTICS +Diagnostic messages are logged via syslog(3) with the LOG_AUTH facility. +.Sh FILES +.Bl -tag -width xetcxcrypto.db +.It Pa /etc/activ.db +data base of information for ActivCard system +.It Pa /etc/crypto.db +data base of information for CRYPTOCard system +.It Pa /etc/snk.db +data base of information for SNK-004 system +.El +.Sh COMMENTS +A supplier for +ActivCard tokens may be obtained by contacting: +.Pp +.Bl -inset -offset indent +.It ActivCard, Inc. +.br +303 Twin Dolphin Dr., Ste 420 +.br +Redwood City, CA 94065 +.br +Tel: (415) 654-1700 +.br +Fax: (415) 654-1701 +.El +.Pp +CRYPTOCard tokens may be obtained by contacting: +.Pp +.Bl -inset -offset indent +.It CRYPTOCard Incorporated +.br +Attn: Wade Clark +.br +1649 Barclay Blvd. +.br +Buffalo Grove, Illinois 60089 +.br +Tel: (800) 307-7042 / (708) 459-6500 +.br +Fax: (708) 459-6599 +.br +<token@cryptocard.com> +.El +.Pp +SNK-004 tokens may be obtained by contacting: +.Bl -inset -offset indent +.It Digital Pathways, Inc. +.br +Attn: Paul Kamian +.br +201 Ravendale Drive +.br +Mountain View, CA 94043-5216 +.br +Tel: (415) 964-0707 +.br +Fax: (415) 961-7487 +.br +<paul@digpath.com> +.El +.Sh BUGS +Not all modes of all cards are supported. +.Pp +.Sh SEE ALSO +.Xr x99token 1 , +.Xr syslog 3 , +.Xr tokenadm 8 , +.Xr tokenls 8 , +.Xr login_token 8 +.Sh AUTHOR +Jack Flory <jpf@mig.com> diff --git a/usr.sbin/tokeninit/tokeninit.c b/usr.sbin/tokeninit/tokeninit.c new file mode 100644 index 00000000000..69cd2f61488 --- /dev/null +++ b/usr.sbin/tokeninit/tokeninit.c @@ -0,0 +1,238 @@ +/* $OpenBSD: tokeninit.c,v 1.1 2000/12/20 02:08:09 millert Exp $ */ + +/*- + * Copyright (c) 1995 Migration Associates Corp. All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Berkeley Software Design, + * Inc. + * 4. The name of Berkeley Software Design, Inc. may not be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * BSDI $From: tokeninit.c,v 1.1 1996/08/26 20:27:28 prb Exp + */ + +#include <sys/param.h> +#include <sys/resource.h> +#include <sys/time.h> + +#include <err.h> +#include <stdio.h> +#include <syslog.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +#include "token.h" +#include "tokendb.h" + +static void strip_crlf(char *); +static void prompt_for_secret(int, char*); +static int parse_secret(int, char *, unsigned char *); + +int +main(int argc, char **argv) +{ + unsigned cmd = TOKEN_INITUSER; + int c; + int errors = 0; + int verbose = 0; + int hexformat = 0; + int modes = 0; + char seed[80]; + unsigned char secret[9]; + char *optstr; + + struct rlimit cds; + + (void)signal(SIGQUIT, SIG_IGN); + (void)signal(SIGINT, SIG_IGN); + (void)setpriority(PRIO_PROCESS, 0, 0); + + openlog(NULL, LOG_ODELAY, LOG_AUTH); + + cds.rlim_cur = 0; + cds.rlim_max = 0; + if (setrlimit(RLIMIT_CORE, &cds) < 0) + syslog(LOG_ERR, "couldn't set core dump size to 0: %m"); + + if (token_init(argv[0]) < 0) { + syslog(LOG_ERR, "unknown token type"); + errx(1, "unknown token type"); + } + + if (tt->options & TOKEN_HEXINIT) + optstr = "fhm:sv"; + else + optstr = "fm:sv"; + + while ((c = getopt(argc, argv, optstr)) != EOF) + switch (c) { + case 'f': /* force initialize existing user account */ + cmd |= TOKEN_FORCEINIT; + break; + + case 'h': + hexformat++; + break; + + case 'm': + if ((c = token_mode(optarg))) + modes |= c; + else + errx(1, "unknown mode"); + break; + + case 's': /* generate seed during initialization */ + cmd |= TOKEN_GENSECRET; + break; + + case 'v': /* verbose */ + verbose++; + break; + default: + fprintf(stderr, + "Usage: %sinit [-f%ssv] username [ username ... ]\n", + tt->name, (tt->options & TOKEN_HEXINIT) ? "h" : ""); + exit(1); + } + + if ((modes & ~TOKEN_RIM) == 0) + modes |= tt->defmode; + + argc -= optind; + argv = &argv[optind]; + + while (argc--) { + if (verbose) { + printf("Adding %s to %s database\n", *argv, tt->proper); + fflush(stdout); + } + if (!(cmd & TOKEN_GENSECRET)) { + prompt_for_secret(hexformat, *argv); + + if (fgets(seed, sizeof(seed), stdin) == NULL) { + fprintf(stderr, + "%sinit: No seed supplied for token.\n", + tt->name); + exit(1); + } + strip_crlf(seed); + if (strlen(seed) == 0) { + fprintf(stderr, + "%sinit: No seed supplied for token.\n", + tt->name); + exit(1); + } + memset(secret, 0, sizeof(secret)); + if (parse_secret(hexformat, seed, secret)) { + fprintf(stderr, + "%sinit: Invalid secret entered.\n", + tt->name); + exit(1); + } + } + switch (tokenuserinit(cmd, *argv, secret, modes)) { + case 0: + syslog(LOG_INFO, "User %s initialized in %s database", + *argv, tt->proper); + break; + case 1: + warnx("%s already exists in %s database!\n", + *argv, tt->proper); + syslog(LOG_INFO, "%s already exists in %s database", + *argv, tt->proper); + errors++; + break; + case -1: + warnx("Error initializing user %s in %s database.\n", + *argv, tt->proper); + syslog(LOG_INFO, + "Error initializing user %s in %s database: %m", + *argv, tt->proper); + errors++; + } + argv++; + } + exit(errors); +} + +/* + * Strip trailing cr/lf from a line of text + */ + +void +strip_crlf(char *buf) +{ + char *cp; + + if((cp = strchr(buf,'\r')) != NULL) + *cp = '\0'; + + if((cp = strchr(buf,'\n')) != NULL) + *cp = '\0'; +} + +/* + * Parse the 8 octal numbers or a 16 digit hex string into a token secret + */ + +static int +parse_secret(int hexformat, char *seed, unsigned char *secret) +{ + int i; + unsigned tmp[8]; + + if (hexformat) { + if ((i = sscanf(seed, "%02x %02x %02x %02x %02x %02x %02x %02x", + &tmp[0], &tmp[1], &tmp[2], &tmp[3], + &tmp[4], &tmp[5], &tmp[6], &tmp[7])) != 8) + return (-1); + } else { + if ((i = sscanf(seed, "%o %o %o %o %o %o %o %o", + &tmp[0], &tmp[1], &tmp[2], &tmp[3], + &tmp[4], &tmp[5], &tmp[6], &tmp[7])) != 8) + return (-1); + } + for (i=0; i < 8; i++) + secret[i] = tmp[i] & 0xff; + + return (0); +} + +/* + * Prompt user for seed for token + */ + +static void +prompt_for_secret(int hexformat, char* username) +{ + if (hexformat) + printf("Enter a 16 digit hexidecimal number " + "as a seed for %s\'s token:\n", username); + else + printf("Enter a series of 8 3-digit octal numbers " + "as a seed for %s\'s token:\n", username); +} |