1 @c Copyright (C) 2002 Free Software Foundation, Inc.
2 @c This is part of the GnuPG manual.
3 @c For copying conditions, see the file gnupg.texi.
5 @node Invoking SCDAEMON
6 @chapter Invoking the SCDAEMON
7 @cindex SCDAEMON command options
8 @cindex command options
9 @cindex options, SCDAEMON command
14 \- Smartcard daemon for the GnuPG system
39 The @command{scdaemon} is a daemon to manage smartcards. It is usually
40 invoked by @command{gpg-agent} and in general not used directly.
43 @xref{Option Index}, for an index to @command{scdaemon}'s commands and
48 * Scdaemon Commands:: List of all commands.
49 * Scdaemon Options:: List of all options.
50 * Card applications:: Description of card applications.
51 * Scdaemon Configuration:: Configuration files.
52 * Scdaemon Examples:: Some usage examples.
53 * Scdaemon Protocol:: The protocol the daemon uses.
58 @node Scdaemon Commands
61 Commands are not distinguished from options except for the fact that
62 only one command is allowed.
67 Print the program version and licensing information. Not that you can
68 abbreviate this command.
72 Print a usage message summarizing the most usefule command-line options.
73 Not that you can abbreviate this command.
77 Print a list of all available options and commands. Not that you can
78 abbreviate this command.
82 Run in server mode and wait for commands on the @code{stdin}. This is
83 default mode is to create a socket and listen for commands there.
87 Run in server mode and wait for commands on the @code{stdin} as well as
88 on an additional Unix Domain socket. The server command @code{GETINFO}
89 may be used to get the name of that extra socket.
93 Run the program in the background. This option is required to prevent
94 it from being accidently running in the background.
101 @node Scdaemon Options
102 @section Option Summary
106 @item --options @var{file}
108 Reads configuration from @var{file} instead of from the default
109 per-user configuration file. The default configuration file is named
110 @file{scdaemon.conf} and expected in the @file{.gnupg} directory directly
111 below the home directory of the user.
113 @include opt-homedir.texi
120 Outputs additional information while running.
121 You can increase the verbosity by giving several
122 verbose commands to @command{gpgsm}, such as @samp{-vv}.
124 @item --debug-level @var{level}
126 Select the debug level for investigating problems. @var{level} may be
133 some basic debug messages
135 more verbose debug messages
137 even more detailed messages
139 all of the debug messages you can get
142 How these messages are mapped to the actual debugging flags is not
143 specified and may change with newer releases of this program. They are
144 however carefully selected to best aid in debugging.
147 All debugging options are subject to change and thus should not be used
148 by any application program. As the name says, they are only used as
149 helpers to debug problems.
153 @item --debug @var{flags}
155 This option is only useful for debugging and the behaviour may change at
156 any time without notice. FLAGS are bit encoded and may be given in
157 usual C-Syntax. The currently defined bits are:
163 values of big number integers
165 low level crypto operations
171 show memory statistics.
173 write hashed data to files named @code{dbgmd-000*}
175 trace Assuan protocol
177 trace APDU I/O to the card. This may reveal sensitive data.
182 Same as @code{--debug=0xffffffff}
184 @item --debug-wait @var{n}
186 When running in server mode, wait @var{n} seconds before entering the
187 actual processing loop and print the pid. This gives time to attach a
190 @item --debug-ccid-driver
192 Enable debug output from the included CCID driver for smartcards.
193 Using this option twice will also enable some tracing of the T=1
194 protocol. Note that this option may reveal sensitive data.
196 @item --debug-disable-ticker
197 @opindex debug-disable-ticker
198 This option disables all ticker functions like checking for card
201 @item --debug-allow-core-dump
202 @opindex debug-allow-core-dump
203 For security reasons we won't create a core dump when the process
204 aborts. For debugging purposes it is sometimes better to allow core
205 dump. This options enables it and also changes the working directory to
206 @file{/tmp} when running in @option{--server} mode.
211 Don't detach the process from the console. This is mainly useful for
214 @item --log-file @var{file}
216 Append all logging output to @var{file}. This is very helpful in
217 seeing what the agent actually does.
220 @item --pcsc-driver @var{library}
222 Use @var{library} to access the smartcard reader. The current default
223 is @file{libpcsclite.so}. Instead of using this option you might also
224 want to install a symbolic link to the default file name
225 (e.g. from @file{libpcsclite.so.1}).
227 @item --ctapi-driver @var{library}
228 @opindex ctapi-driver
229 Use @var{library} to access the smartcard reader. The current default
230 is @file{libtowitoko.so}. Note that the use of this interface is
231 deprecated; it may be removed in future releases.
234 @opindex disable-ccid
235 Disable the integrated support for CCID compliant readers. This
236 allows to fall back to one of the other drivers even if the internal
237 CCID driver can handle the reader. Note, that CCID support is only
238 available if libusb was available at build time.
240 @item --reader-port @var{number_or_string}
242 This option may be used to specify the port of the card terminal. A
243 value of 0 refers to the first serial device; add 32768 to access USB
244 devices. The default is 32768 (first USB device). PC/SC or CCID
245 readers might need a string here; run the program in verbose mode to get
246 a list of available readers. The default is then the first reader
249 To get a list of available CCID readers you may use this command:
251 echo scd getinfo reader_list | gpg-connect-agent --decode | awk '/^D/ @{print $2@}'
255 @item --card-timeout @var{n}
256 @opindex card-timeout
257 If @var{n} is not 0 and no client is actively using the card, the card
258 will be powered down after @var{n} seconds. Powering down the card
259 avoids a potential risk of damaging a card when used with certain
260 cheap readers. This also allows non Scdaemon aware applications to
261 access the card. The disadvantage of using a card timeout is that
262 accessing the card takes longer and that the user needs to enter the
263 PIN again after the next power up.
265 Note that with the current version of Scdaemon the card is powered
266 down immediatley at the next timer tick for any value of @var{n} other
270 @item --disable-keypad
271 @opindex disable-keypad
272 Even if a card reader features a keypad, do not try to use it.
279 This enables the use of Admin class commands for card applications
280 where this is supported. Currently we support it for the OpenPGP
281 card. Deny is the default. This commands is useful to inhibit
282 accidental access to admin class command which could ultimately lock
283 the card through wrong PIN numbers.
285 @item --disable-application @var{name}
286 @opindex disable-application
287 This option disables the use of the card application named
288 @var{name}. This is mainly useful for debugging or if a application
289 with lower priority should be used by default.
293 All the long options may also be given in the configuration file after
294 stripping off the two leading dashes.
297 @mansect card applications
298 @node Card applications
299 @section Description of card applications
301 @command{scdaemon} supports the card applications as described below.
304 * OpenPGP Card:: The OpenPGP card application
305 * NKS Card:: The Telesec NetKey card application
306 * DINSIG Card:: The DINSIG card application
307 * PKCS#15 Card:: The PKCS#15 card application
311 @subsection The OpenPGP card application ``openpgp''
313 This application is currently only used by @command{gpg} but may in
314 future also be useful with @command{gpgsm}.
316 The specification for such a card is available at
317 @uref{http://g10code.com/docs/openpgp-card-1.0.pdf}.
320 @subsection The Telesec NetKey card ``nks''
322 This is the main application of the Telesec cards as available in
323 Germany. It is a superset of the German DINSIG card. The card is
324 used by @command{gpgsm}.
327 @subsection The DINSIG card application ``dinsig''
329 This is an application as described in the German draft standard
330 @emph{DIN V 66291-1}. It is intended to be used by cards supporting
331 the German signature law and its bylaws (SigG and SigV).
334 @subsection The PKCS#15 card application ``p15''
336 This is common fraqmework for smart card applications. It is used by
340 @c *******************************************
341 @c *************** ****************
342 @c *************** FILES ****************
343 @c *************** ****************
344 @c *******************************************
346 @node Scdaemon Configuration
347 @section Configuration files
349 There are a few configuration files to control certain aspects of
350 @command{scdaemons}'s operation. Unless noted, they are expected in the
351 current home directory (@pxref{option --homedir}).
356 @cindex scdaemon.conf
357 This is the standard configuration file read by @command{scdaemon} on
358 startup. It may contain any valid long option; the leading two dashes
359 may not be entered and the option may not be abbreviated. This default
360 name may be changed on the command line (@pxref{option --options}).
364 If this file is present and executable, it will be called on veyer card
365 reader's status changed. An example of this script is provided with the
368 @item reader_@var{n}.status
369 This file is created by @command{sdaemon} to let other applications now
370 about reader status changes. Its use is now deprecated in favor of
380 @node Scdaemon Examples
383 @c man begin EXAMPLES
386 $ scdaemon --server -v
395 @node Scdaemon Protocol
396 @section Scdaemon's Assuan Protocol
398 The SC-Daemon should be started by the system to provide access to
399 external tokens. Using Smartcards on a multi-user system does not
400 make much sense expcet for system services, but in this case no
401 regular user accounts are hosted on the machine.
403 A client connects to the SC-Daemon by connecting to the socket named
404 @file{/var/run/scdaemon/socket}, configuration information is read from
405 @var{/etc/scdaemon.conf}
407 Each connection acts as one session, SC-Daemon takes care of
408 syncronizing access to a token between sessions.
411 * Scdaemon SERIALNO:: Return the serial number.
412 * Scdaemon LEARN:: Read all useful information from the card.
413 * Scdaemon READCERT:: Return a certificate.
414 * Scdaemon READKEY:: Return a public key.
415 * Scdaemon PKSIGN:: Signing data with a Smartcard.
416 * Scdaemon PKDECRYPT:: Decrypting data with a Smartcard.
417 * Scdaemon GETATTR:: Read an attribute's value.
418 * Scdaemon SETATTR:: Update an attribute's value.
419 * Scdaemon WRITEKEY:: Write a key to a card.
420 * Scdaemon GENKEY:: Generate a new key on-card.
421 * Scdaemon RANDOM:: Return random bytes generate on-card.
422 * Scdaemon PASSWD:: Change PINs.
423 * Scdaemon CHECKPIN:: Perform a VERIFY operation.
424 * Scdaemon RESTART:: Restart connection
425 * Scdaemon APDU:: Send a verbatim APDU to the card
428 @node Scdaemon SERIALNO
429 @subsection Return the serial number
431 This command should be used to check for the presence of a card. It is
432 special in that it can be used to reset the card. Most other commands
433 will return an error when a card change has been detected and the use of
434 this function is therefore required.
436 Background: We want to keep the client clear of handling card changes
437 between operations; i.e. the client can assume that all operations are
438 done on the same card unless he call this function.
444 Return the serial number of the card using a status reponse like:
447 S SERIALNO D27600000000000000000000 0
450 The trailing 0 should be ignored for now, it is reserved for a future
451 extension. The serial number is the hex encoded value identified by
452 the @code{0x5A} tag in the GDO file (FIX=0x2F02).
457 @subsection Read all useful information from the card
463 Learn all useful information of the currently inserted card. When
464 used without the force options, the command might do an INQUIRE
468 INQUIRE KNOWNCARDP <hexstring_with_serialNumber> <timestamp>
471 The client should just send an @code{END} if the processing should go on
472 or a @code{CANCEL} to force the function to terminate with a cancel
473 error message. The response of this command is a list of status lines
477 S KEYPAIRINFO @var{hexstring_with_keygrip} @var{hexstring_with_id}
480 If there is no certificate yet stored on the card a single "X" is
481 returned in @var{hexstring_with_keygrip}.
483 @node Scdaemon READCERT
484 @subsection Return a certificate
487 READCERT @var{hexified_certid}|@var{keyid}
490 This function is used to read a certificate identified by
491 @var{hexified_certid} from the card. With OpenPGP cards the keyid
492 @code{OpenPGP.3} may be used to rad the certticate of version 2 cards.
495 @node Scdaemon READKEY
496 @subsection Return a public key
499 READKEY @var{hexified_certid}
502 Return the public key for the given cert or key ID as an standard
507 @node Scdaemon PKSIGN
508 @subsection Signing data with a Smartcard
510 To sign some data the caller should use the command
513 SETDATA @var{hexstring}
516 to tell @command{scdaemon} about the data to be signed. The data must be given in
517 hex notation. The actual signing is done using the command
523 where @var{keyid} is the hexified ID of the key to be used. The key id
524 may have been retrieved using the command @code{LEARN}. If another
525 hash algorithm than SHA-1 is used, that algorithm may be given like:
528 PKSIGN --hash=@var{algoname} @var{keyid}
531 With @var{algoname} are one of @code{sha1}, @code{rmd160} or @code{md5}.
534 @node Scdaemon PKDECRYPT
535 @subsection Decrypting data with a Smartcard
537 To decrypt some data the caller should use the command
540 SETDATA @var{hexstring}
543 to tell @command{scdaemon} about the data to be decrypted. The data
544 must be given in hex notation. The actual decryption is then done
548 PKDECRYPT @var{keyid}
551 where @var{keyid} is the hexified ID of the key to be used.
554 @node Scdaemon GETATTR
555 @subsection Read an attribute's value.
559 @node Scdaemon SETATTR
560 @subsection Update an attribute's value.
564 @node Scdaemon WRITEKEY
565 @subsection Write a key to a card.
568 WRITEKEY [--force] @var{keyid}
571 This command is used to store a secret key on a a smartcard. The
572 allowed keyids depend on the currently selected smartcard
573 application. The actual keydata is requested using the inquiry
574 @code{KEYDATA} and need to be provided without any protection. With
575 @option{--force} set an existing key under this @var{keyid} will get
576 overwritten. The key data is expected to be the usual canonical encoded
579 A PIN will be requested in most saes. This however depends on the
580 actual card application.
583 @node Scdaemon GENKEY
584 @subsection Generate a new key on-card.
588 @node Scdaemon RANDOM
589 @subsection Return random bytes generate on-card.
594 @node Scdaemon PASSWD
595 @subsection Change PINs.
598 PASSWD [--reset] [--nullpin] @var{chvno}
601 Change the PIN or reset the retry counter of the card holder
602 verification vector number @var{chvno}. The option @option{--nullpin}
603 is used to initialize the PIN of TCOS cards (6 byte NullPIN only).
606 @node Scdaemon CHECKPIN
607 @subsection Perform a VERIFY operation.
613 Perform a VERIFY operation without doing anything else. This may be
614 used to initialize a the PIN cache earlier to long lasting
615 operations. Its use is highly application dependent:
620 Perform a simple verify operation for CHV1 and CHV2, so that further
621 operations won't ask for CHV2 and it is possible to do a cheap check on
622 the PIN: If there is something wrong with the PIN entry system, only the
623 regular CHV will get blocked and not the dangerous CHV3. @var{idstr} is
624 the usual card's serial number in hex notation; an optional fingerprint
625 part will get ignored.
627 There is however a special mode if @var{idstr} is suffixed with the
628 literal string @code{[CHV3]}: In this case the Admin PIN is checked if
629 and only if the retry counter is still at 3.
635 @node Scdaemon RESTART
636 @subsection Perform a RESTART operation.
642 Restart the current connection; this is a kind of warm reset. It
643 deletes the context used by this connection but does not actually
646 This is used by gpg-agent to reuse a primary pipe connection and
647 may be used by clients to backup from a conflict in the serial
648 command; i.e. to select another application.
654 @subsection Send a verbatim APDU to the card.
657 APDU [--atr] [--more] [@var{hexstring}]
661 Send an APDU to the current reader. This command bypasses the high
662 level functions and sends the data directly to the card.
663 @var{hexstring} is expected to be a proper APDU. If @var{hexstring} is
664 not given no commands are send to the card; However the command will
665 implicitly check whether the card is ready for use.
667 Using the option @code{--atr} returns the ATR of the card as a status
668 message before any data like this:
670 S CARD-ATR 3BFA1300FF813180450031C173C00100009000B1
673 Using the option @code{--more} handles the card status word MORE_DATA
674 (61xx) and concatenate all reponses to one block.
680 @command{gpg-agent}(1),
684 @include see-also-note.texi