1 .\" $NetBSD: skey.3,v 1.8 2003/06/06 13:42:50 wiz Exp $
3 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Gregory McGarry.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
41 .Nm skey_set_algorithm ,
42 .Nm skey_get_algorithm ,
47 .Nd one-time password (OTP) library
49 S/key One-Time Password Library (libskey, -lskey)
53 .Fn skeychallenge "struct skey *mp" "const char *name" "char *ss" \
56 .Fn skeylookup "struct skey *mp" "const char *name"
58 .Fn skeygetnext "struct skey *mp"
60 .Fn skeyverify "struct skey *mp" "char *response"
62 .Fn skeyzero "struct skey *mp" "char *response"
64 .Fn getskeyprompt "struct skey *mp" "char *name" "char *prompt"
66 .Fn skey_set_algorithm "const char *new"
68 .Fn skey_get_algorithm "void"
70 .Fn skey_haskey "const char *username"
72 .Fn skey_keyinfo "const char *username"
74 .Fn skey_passcheck "const char *username" "char *passwd"
76 .Fn skey_authenticate "const char *username"
80 .Fn keycrunch "char *result" "const char *seed" "const char *passwd"
84 .Fn readpass "char *buf " "int n"
86 .Fn readskey "char *buf" "int n"
88 .Fn atob8 "char *out" "const char *in"
90 .Fn btoa8 "char *out" "const char *in"
94 .Fn skipspace "const char *cp"
96 .Fn backspace "char *buf"
98 .Fn sevenbit "char *buf"
100 .Fn btoe "char *engout" "const char *c"
102 .Fn etob "char *out" "const char *e"
104 .Fn put8 "char *out" "const char *s"
108 library provides routines for accessing
110 one-time password (OTP) authentication system.
112 Most S/Key operations take a pointer to a
114 which should be considered as an opaque identifier.
116 The following high-level functions are available:
117 .Bl -tag -width compact
118 .It Fn skeychallenge "mp" "name" "ss" "sslen"
119 Return a S/Key challenge for user
121 If successful, the caller's skey structure
123 is filled and 0 is returned.
124 If unsuccessful (e.g. if name is unknown),
126 .It Fn skeylookup "mp" "name"
127 Find an entry for user
129 in the one-time password database.
130 Returns 0 if the entry is found and 1 if the entry is not found.
131 If an error occurs accessing the database, \-1 is returned.
132 .It Fn skeygetnext "mp"
133 Get the next entry in the one-time password database.
134 Returns 0 on success and the entry is stored in
136 and 1 if no more entries are available.
137 If an error occurs accessing the database, \-1 is returned.
138 .It Fn skeyverify "mp" "response"
141 to a S/Key challenge.
142 Returns 0 if the verification is successful and 1 if the verification failed.
143 If an error occurs accessing the database, \-1 is returned.
144 .It Fn skeyzero "mp" "response"
145 Comment out user's entry in the S/Key database.
146 Returns 0 on success and the database is updated,
147 otherwise \-1 is returned and the database remains unchanged.
148 .It Fn getskeyprompt "mp" "name" "prompt"
149 Issue a S/Key challenge for user
151 If successful, fill in the caller's skey structure
154 If unsuccessful (e.g. if name is unknown) \-1 is returned.
157 The following lower-level functions are available:
158 .Bl -tag -width compact
159 .It Fn skey_set_algorithm "new"
160 Set hash algorithm type.
163 are "md4", "md5" and "sha1".
164 .It Fn skey_get_algorithm "void"
165 Get current hash type.
166 .It Fn skey_haskey "username"
167 Returns 0 if the user
169 exists and 1 if the user doesn't exist.
170 Returns \-1 on file error.
171 .It Fn skey_keyinfo "username"
172 Returns the current sequence number and seed for user
174 .It Fn skey_passcheck "username" "passwd"
175 Checks to see if answer is the correct one to the current challenge.
176 .It Fn skey_authenticate "username"
177 Used when calling program will allow input of the user's response to
179 Returns zero on success or \-1 on failure.
182 The following miscellaneous functions are available:
183 .Bl -tag -width compact
185 One-way function to take 8 bytes pointed to by
187 and return 8 bytes in place.
188 .It Fn keycrunch "char *result" "const char *seed" "const char *passwd"
191 Strip trailing CR/LF characters from a line of text
193 .It Fn readpass "buf" "n"
194 Read in secret passwd (turns off echo).
195 .It Fn readskey "buf" "n"
196 Read in an s/key OTP (does not turn off echo).
197 .It Fn atob8 "out" "in"
198 Convert 8-byte hex-ascii string
202 Returns 0 on success, \-1 on error.
203 .It Fn btoa8 "out" "in"
204 Convert 8-byte binary array
208 Returns 0 on success, \-1 on error.
210 Convert hex digit to binary integer.
211 .It Fn skipspace "cp"
212 Skip leading spaces from the string
214 .It Fn backspace "buf"
215 Remove backspaced over characters from the string
217 .It Fn sevenbit "buf"
221 .It Fn btoe "engout" "c"
224 as a string of English words.
225 Returns a pointer to a static buffer in
227 .It Fn etob "out" "e"
228 Convert English to binary.
229 Returns 0 if the word is not in the database, 1 if all good words and
230 parity is valid, \-1 if badly formed input (i.e. \*[Gt] 4 char word)
231 and -2 if words are valid but parity is wrong.
232 .It Fn put8 "out" "s"
235 as a series of 16-bit hex digits.
238 .Bl -tag -width /usr/lib/libskey_p.a -compact
239 .It Pa /usr/lib/libskey.a
241 .It Pa /usr/lib/libskey.so
243 .It Pa /usr/lib/libskey_p.a
244 static skey library compiled for profiling
253 library functions are not re-entrant or thread-safe.
257 library defines many poorly named functions which pollute the name space.