xref: /netbsd-src/lib/libskey/skey.3 (revision d710132b4b8ce7f7cccaaf660cb16aa16b4077a0)
1.\"     $NetBSD: skey.3,v 1.8 2003/06/06 13:42:50 wiz Exp $
2.\"
3.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Gregory McGarry.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
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.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd November 10, 2001
38.Dt SKEY 3
39.Os
40.Sh NAME
41.Nm skey ,
42.Nm skeychallenge ,
43.Nm skeylookup ,
44.Nm skeygetnext ,
45.Nm skeyverify ,
46.Nm skeyzero ,
47.Nm getskeyprompt ,
48.Nm skey_set_algorithm ,
49.Nm skey_get_algorithm ,
50.Nm skey_haskey ,
51.Nm skey_keyinfo ,
52.Nm skey_passcheck ,
53.Nm skey_authenticate
54.Nd one-time password (OTP) library
55.Sh LIBRARY
56S/key One-Time Password Library (libskey, -lskey)
57.Sh SYNOPSIS
58.In skey.h
59.Ft int
60.Fn skeychallenge "struct skey *mp" "const char *name" "char *ss" \
61"size_t sslen"
62.Ft int
63.Fn skeylookup "struct skey *mp" "const char *name"
64.Ft int
65.Fn skeygetnext "struct skey *mp"
66.Ft int
67.Fn skeyverify "struct skey *mp" "char *response"
68.Ft int
69.Fn skeyzero "struct skey *mp" "char *response"
70.Ft int
71.Fn getskeyprompt "struct skey *mp" "char *name" "char *prompt"
72.Ft const char *
73.Fn skey_set_algorithm "const char *new"
74.Ft const char *
75.Fn skey_get_algorithm "void"
76.Ft int
77.Fn skey_haskey "const char *username"
78.Ft const char *
79.Fn skey_keyinfo "const char *username"
80.Ft int
81.Fn skey_passcheck "const char *username" "char *passwd"
82.Ft int
83.Fn skey_authenticate "const char *username"
84.Ft void
85.Fn f "char *x"
86.Ft int
87.Fn keycrunch "char *result" "const char *seed" "const char *passwd"
88.Ft void
89.Fn rip "char *buf"
90.Ft char *
91.Fn readpass "char *buf " "int n"
92.Ft char *
93.Fn readskey "char *buf" "int n"
94.Ft int
95.Fn atob8 "char *out" "const char *in"
96.Ft int
97.Fn btoa8 "char *out" "const char *in"
98.Ft int
99.Fn htoi "int c"
100.Ft const char *
101.Fn skipspace "const char *cp"
102.Ft void
103.Fn backspace "char *buf"
104.Ft void
105.Fn sevenbit "char *buf"
106.Ft char *
107.Fn btoe "char *engout" "const char *c"
108.Ft int
109.Fn etob "char *out" "const char *e"
110.Ft char *
111.Fn put8 "char *out" "const char *s"
112.Sh DESCRIPTION
113The
114.Nm
115library provides routines for accessing
116.Nx Ns 's
117one-time password (OTP) authentication system.
118.Pp
119Most S/Key operations take a pointer to a
120.Em struct skey ,
121which should be considered as an opaque identifier.
122.Sh FUNCTIONS
123The following high-level functions are available:
124.Bl -tag -width compact
125.It Fn skeychallenge "mp" "name" "ss" "sslen"
126Return a S/Key challenge for user
127.Fa name .
128If successful, the caller's skey structure
129.Fa mp
130is filled and 0 is returned.
131If unsuccessful (e.g. if name is unknown),
132\-1 is returned.
133.It Fn skeylookup "mp" "name"
134Find an entry for user
135.Fa name
136in the one-time password database.
137Returns 0 if the entry is found and 1 if the entry is not found.
138If an error occurs accessing the database, \-1 is returned.
139.It Fn skeygetnext "mp"
140Get the next entry in the one-time password database.
141Returns 0 on success and the entry is stored in
142.Ar mp
143and 1 if no more entries are available.
144If an error occurs accessing the database, \-1 is returned.
145.It Fn skeyverify "mp" "response"
146Verify response
147.Fa response
148to a S/Key challenge.
149Returns 0 if the verification is successful and 1 if the verification failed.
150If an error occurs accessing the database, \-1 is returned.
151.It Fn skeyzero "mp" "response"
152Comment out user's entry in the S/Key database.
153Returns 0 on success and the database is updated,
154otherwise \-1 is returned and the database remains unchanged.
155.It Fn getskeyprompt "mp" "name" "prompt"
156Issue a S/Key challenge for user
157.Ar name .
158If successful, fill in the caller's skey structure
159.Fa mp
160and return 0.
161If unsuccessful (e.g. if name is unknown) \-1 is returned.
162.El
163.Pp
164The following lower-level functions are available:
165.Bl -tag -width compact
166.It Fn skey_set_algorithm "new"
167Set hash algorithm type.
168Valid values for
169.Fa new
170are "md4", "md5" and "sha1".
171.It Fn skey_get_algorithm "void"
172Get current hash type.
173.It Fn skey_haskey "username"
174Returns 0 if the user
175.Fa username
176exists and 1 if the user doesn't exist.
177Returns \-1 on file error.
178.It Fn skey_keyinfo "username"
179Returns the current sequence number and seed for user
180.Ar username .
181.It Fn skey_passcheck "username" "passwd"
182Checks to see if answer is the correct one to the current challenge.
183.It Fn skey_authenticate "username"
184Used when calling program will allow input of the user's response to
185the challenge.
186Returns zero on success or \-1 on failure.
187.El
188.Pp
189The following miscellaneous functions are available:
190.Bl -tag -width compact
191.It Fn f "x"
192One-way function to take 8 bytes pointed to by
193.Fa x
194and return 8 bytes in place.
195.It Fn keycrunch "char *result" "const char *seed" "const char *passwd"
196Crunch a key.
197.It Fn rip "buf"
198Strip trailing CR/LF characters from a line of text
199.Fa buf .
200.It Fn readpass "buf" "n"
201Read in secret passwd (turns off echo).
202.It Fn readskey "buf" "n"
203Read in an s/key OTP (does not turn off echo).
204.It Fn atob8 "out" "in"
205Convert 8-byte hex-ascii string
206.Fa in
207to binary array
208.Fa out .
209Returns 0 on success, \-1 on error.
210.It Fn btoa8 "out" "in"
211Convert 8-byte binary array
212.Fa in
213to hex-ascii string
214.Fa out .
215Returns 0 on success, \-1 on error.
216.It Fn htoi "int c"
217Convert hex digit to binary integer.
218.It Fn skipspace "cp"
219Skip leading spaces from the string
220.Fa cp .
221.It Fn backspace "buf"
222Remove backspaced over characters from the string
223.Fa buf .
224.It Fn sevenbit "buf"
225Ensure line
226.Fa buf
227is all seven bits.
228.It Fn btoe "engout" "c"
229Encode 8 bytes in
230.Ar c
231as a string of English words.
232Returns a pointer to a static buffer in
233.Fa engout .
234.It Fn etob "out" "e"
235Convert English to binary.
236Returns 0 if the word is not in the database, 1 if all good words and
237parity is valid, \-1 if badly formed input (i.e. \*[Gt] 4 char word)
238and -2 if words are valid but parity is wrong.
239.It Fn put8 "out" "s"
240Display 8 bytes
241.Fa s
242as a series of 16-bit hex digits.
243.El
244.Sh FILES
245.Bl -tag -width /usr/lib/libskey_p.a -compact
246.It Pa /usr/lib/libskey.a
247static skey library
248.It Pa /usr/lib/libskey.so
249dynamic skey library
250.It Pa /usr/lib/libskey_p.a
251static skey library compiled for profiling
252.El
253.Sh SEE ALSO
254.Xr skey 1 ,
255.Xr skeyaudit 1 ,
256.Xr skeyinfo 1
257.Sh BUGS
258The
259.Nm
260library functions are not re-entrant or thread-safe.
261.Pp
262The
263.Nm
264library defines many poorly named functions which pollute the name space.
265