MirOS Manual: sectok(3), sectok_apdu(3), sectok_cardpresent(3), sectok_close(3), sectok_dump_reply(3), sectok_fdump_reply(3), sectok_fmt_fid(3), sectok_friendly_open(3), sectok_get_input(3), sectok_get_ins(3), sectok_get_sw(3), sectok_open(3), sectok_parse_atr(3), sectok_parse_fname(3), sectok_parse_input(3), sectok_print_sw(3), sectok_reset(3), sectok_selectfile(3), sectok_swOK(3), sectok_xopen(3)

SECTOK(3)                  BSD Programmer's Manual                   SECTOK(3)

NAME

     sectok - library for communicating with ISO 7816 smartcards

SYNOPSIS

     #include <sectok.h>

     int
     sectok_open(int rn, int flags, int *swp);

     int
     sectok_friendly_open(const char *rn, int flags, int *swp);

     int
     sectok_xopen(int rn, int flags, char *config_path, char *driver_path,
             int *swp);

     int
     sectok_reset(int fd, int flags, unsigned char *atr, int *swp);

     int
     sectok_apdu(int fd, int cla, int ins, int p1, int p2, int ilen,
             unsigned char *ibuf, int olen, unsigned char *obuf, int *swp);

     int
     sectok_cardpresent(int fd);

     int
     sectok_close(int fd);

     int
     sectok_selectfile(int fd, int cla, unsigned char *fid, int *swp);

     void
     sectok_fmt_fid(char *fname, size_t fnamelen, unsigned char *fid);

     int
     sectok_parse_atr(int fd, int flags, unsigned char *atr, int len,
             struct scparam *param);

     void
     sectok_parse_fname(char *buf, unsigned char *fid);

     int
     sectok_parse_input(char *ibuf, unsigned char *obuf, int olen);

     int
     sectok_get_input(FILE *f, unsigned char *obuf, int omin, int olen);

     int
     sectok_fdump_reply(FILE *f, unsigned char *p, int n, int sw);

     int
     sectok_dump_reply(unsigned char *p, int n, int sw);

     void
     sectok_print_sw(int sw);

     char *
     sectok_get_sw(int sw);

     char *
     sectok_get_ins(int ins);

     int
     sectok_swOK(int sw);

DESCRIPTION

     sectok provides initialization, input, output, and other basic routines
     for ISO 7816 smart cards. Many of the routines return a status word. This
     will either be an error code as given in the include file, or an SW1/SW2
     pair as specified in ISO 7816.

     sectok_open() opens a connection to a smart card via serial port number
     rn. Ports are numbered from 0, which corresponds to /dev/tty00 on UNIX.
     If there is no card in the reader, sectok_open() will either wait for
     card insertion, or if flag STONOWAIT is given, it will return immediately
     with error STENOCARD. swp points to a status word that will be set on re-
     turn.

     sectok_friendly_open() opens a connection to a smart card via a reader
     device name rn. Mapping from reader name to serial port number is the
     same as used in sectok_open(). For other arguments and return values, see
     sectok_open().

     sectok_reset() resets the card and returns the ATR in the buffer pointed
     to by atr if it is not NULL. If the STRFORCE flag is given, a connection
     to the card will be established using default protocol parameters even if
     the card ATR is illegal.

     sectok_apdu() sends an APDU to the card with optional IN and OUT data.

     cla     application class

     ins     instruction code

     p1, p2  per ISO 7816-3 or application dependent

     ilen    length of IN data

     ibuf    pointer to IN data

     olen    length of OUT data

     obuf    pointer to OUT data

     swp     pointer to return status word

     sectok_cardpresent() returns whether a card is present in the reader.

     sectok_close() closes a connection to a smart card.

     sectok_selectfile() selects a file given its FID by sending a "select"
     apdu to the card.

     sectok_fmt_fid() returns a printable name for a FID.

     sectok_parse_atr() parses a card ATR and returns the protocol parameters.
     If the STRV flag is given it will print the parameters to standard out.

     sectok_parse_fname() translates a printable name to a FID.

     sectok_print_sw() looks up the error message string affiliated with a
     status word and writes it to standard out.

     sectok_swOK() returns 1 if sw indicates success, or 0 if it indicates
     failure.

SEE ALSO

     sectok(1)

HISTORY

     sectok first appeared in OpenBSD 3.0.

AUTHORS

     Jim Rees and others at University of Michigan Center for Information
     Technology Integration (CITI).

MirOS BSD #10-current           August 3, 2001                               2

Generated on 2014-04-02 20:57:59 by $MirOS: src/scripts/roff2htm,v 1.79 2014/02/10 00:36:11 tg Exp $

These manual pages and other documentation are copyrighted by their respective writers; their source is available at our CVSweb, AnonCVS, and other mirrors. The rest is Copyright © 2002‒2014 The MirOS Project, Germany.
This product includes material provided by Thorsten Glaser.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report – diffs preferred.