1.\"	$OpenBSD: sectok.1,v 1.8 2001/08/15 19:48:39 rees Exp $
2.\"
3.\" Copyright (C) 2001, Jakob Schlyter. All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. Neither the name of the project nor the names of its contributors
14.\"    may be used to endorse or promote products derived from this software
15.\"    without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE.
28.\"
29.Dd July 17, 2001
30.Dt SECTOK 1
31.Os
32.\"
33.Sh NAME
34.Nm sectok
35.Nd communicate with smartcards using iso7816
36.\"
37.Sh SYNOPSIS
38.Nm sectok
39.Op Fl 0123
40.Op Fl f Ar scriptfile
41.Op Fl s Ar sleeptime
42.\"
43.Sh DESCRIPTION
44.Nm
45is a command-line-like interface for communicating with smartcards.
46APDUs can be sent to the card, and results are displayed. Some
47commands are card-specific, and focus on the Schlumberger Cyberflex
48Access Javacards.
49.Pp
50The options are as follows:
51.Bl -tag -width Ds
52.It Fl 0123
53Select port.
54.Pp
55.It Fl f Ar scriptfile
56Run commands from scriptfile.
57.Pp
58.It Fl s Ar sleeptime
59Set sleep (in milliseconds) between commands in the script.
60.El
61.Sh COMMANDS
62.Ss Non-card commands
63.Pp
64.Bl -tag -width Ds
65.It Xo
66.Cm help
67.Xc
68List all commands.
69.It Xo
70.Cm help
71.Op command
72.Xc
73Show help for
74.Ar command .
75.It Xo
76.Cm ?
77.Op command
78.Xc
79Show help for
80.Ar command .
81.It Xo
82.Cm reset
83.Op Fl 0123ivf
84.Xc
85Reset smartcard.
86.Bl -tag -width Ds
87.It Fl 0123
88select port
89.It Fl i
90don't wait for card insertion
91.It Fl v
92verbose
93.It Fl f
94open connection even if atr is bad
95.El
96.It Xo
97.Cm open
98.Op Fl 0123ivf
99.Xc
100Synonym for reset.
101.It Xo
102.Cm close
103.Xc
104Close smartcard connection.
105.It Xo
106.Cm quit
107.Xc
108Quit
109.Nm Li .
110.El
111.Ss ISO 7816-4 commands
112.Pp
113.Bl -tag -width Ds
114.It Xo
115.Cm apdu
116.Op Fl c Ar class
117.Ar "ins p1 p2 p3 data ..."
118.Xc
119Send APDU to smartcard.
120.It Xo
121.Cm fid
122.Op Fl v
123.Ar fid/aid
124.Xc
125Select file or aid identified by
126.Ar fid/aid .
127.Ar fid/aid
128can be a numeric fid such as 3f00, a two character name, or an aid in hex or ascii.
129.It Xo
130.Cm isearch
131.Xc
132Try all 256 possible instructions and print results.
133.It Xo
134.Cm class
135.Op Ar class
136.Xc
137Inquire or set default application
138.Ar class .
139.It Xo
140.Cm read
141.Op Fl x
142.Ar filesize
143.Xc
144Read selected fid and write to stdout.
145.It Xo
146.Cm write
147.Ar input-filename
148.Xc
149Read from
150.Ar input-filename
151and write to selected fid.
152.It Xo
153.Cm challenge
154.Op Ar length
155.Xc
156Get a random challenge from the card.
157.It Xo
158.Cm pin
159.Op Fl k Ar keyno
160.Op Ar PIN
161.Xc
162Verify CHV (PIN).
163.It Xo
164.Cm chpin
165.Op Fl k Ar keyno
166.Xc
167Change CHV (PIN).
168.El
169.Ss Cyberflex commands
170.Pp
171.Bl -tag -width Ds
172.It Xo
173.Cm ls
174.Op Fl l
175.Xc
176List all files in current DF.
177.It Xo
178.Cm acl
179.Ar fid
180.Op Ar principal: "r1 r2 ..."
181.Xc
182.Bl -tag -width Ds
183.It principals
184world, CHV1, CHV2, AUT0, AUT1, AUT2, AUT3, AUT4
185.It f_rights
186r, w, x/a, inval, rehab, dec, inc
187.It d_rights
188l, d, a, i, manage
189.El
190.It Xo
191.Cm create
192.Ar fid
193.Ar size
194.Xc
195.It Xo
196.Cm delete
197.Ar fid
198.Xc
199.It Xo
200.Cm jdefault
201.Op Fl d
202.Xc
203Set default applet.
204.Bl -tag -width Ds
205.It Fl d
206set default applet to default loader
207.El
208.It Xo
209.Cm jatr
210.Xc
211Set java atr.
212.It Xo
213.Cm jdata
214.Xc
215Print useful info about the card
216.It Xo
217.Cm login
218.Op Fl d
219.Op Fl k Ar keyno
220.Op Fl v
221.Op Fl x Ar hex-aut0
222.Xc
223"login" (verify AUT0 key)
224.Bl -tag -width Ds
225.It Fl d
226use manufacturer's default AUT0 key
227.El
228.It Xo
229.Cm jload
230.Op Fl p Ar progID
231.Op Fl c Ar contID
232.Op Fl s Ar cont_size
233.Op Fl i Ar inst_size
234.Op Fl v
235.Op Fl a Ar aid
236.Ar filename
237.Xc
238Load an applet to the card.
239If the first byte of the
240.Ar aid
241is '#' it will be converted to 0xfc.
242.It Xo
243.Cm junload
244.Op Fl p Ar progID
245.Op Fl c Ar contID
246.Xc
247.It Xo
248.Cm jselect
249.Op Fl a Ar aid
250.Op Fl d
251.Xc
252Select applet.
253.Bl -tag -width Ds
254.It Fl d
255select default loader
256.El
257.It Xo
258.Cm setpass
259.Op Fl d
260.Op Fl x Ar hex-aut0
261.Xc
262.Bl -tag -width Ds
263.It Fl d
264use manufacturer's default AUT0 key
265.El
266.El
267.\"
268.Sh AUTHORS
269.Nm
270was written by Jim Rees and others at University of Michigan
271Center for Information Technology Integration (CITI).
272.\"
273.Sh HISTORY
274.Nm
275first appeared in
276.Ox 3.0 .
277