| 1 |
/*
|
| 2 |
protocol_t1.h
|
| 3 |
ISO 7816 T=1 Transport Protocol definitions
|
| 4 |
|
| 5 |
This file is part of the Unix driver for Towitoko smartcard readers
|
| 6 |
Copyright (C) 2000 Carlos Prados <cprados@yahoo.com>
|
| 7 |
|
| 8 |
This library is free software; you can redistribute it and/or
|
| 9 |
modify it under the terms of the GNU Lesser General Public
|
| 10 |
License as published by the Free Software Foundation; either
|
| 11 |
version 2 of the License, or (at your option) any later version.
|
| 12 |
|
| 13 |
This library is distributed in the hope that it will be useful,
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 16 |
Lesser General Public License for more details.
|
| 17 |
|
| 18 |
You should have received a copy of the GNU Lesser General Public
|
| 19 |
License along with this library; if not, write to the Free Software
|
| 20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
| 21 |
*/
|
| 22 |
|
| 23 |
#ifndef _PROTOCOL_T1_
|
| 24 |
#define _PROTOCOL_T1_
|
| 25 |
|
| 26 |
#include "defines.h"
|
| 27 |
#include "apdu.h"
|
| 28 |
|
| 29 |
/*
|
| 30 |
* Exported constants definition
|
| 31 |
*/
|
| 32 |
|
| 33 |
/* Return codes */
|
| 34 |
#define PROTOCOL_T1_OK 0 /* Command OK */
|
| 35 |
#define PROTOCOL_T1_ICC_ERROR 2 /* ICC comunication error */
|
| 36 |
#define PROTOCOL_T1_ERROR 4 /* T=1 Protocol Error */
|
| 37 |
#define PROTOCOL_T1_NOT_IMPLEMENTED 7 /* Feture not implemented */
|
| 38 |
|
| 39 |
/*
|
| 40 |
* Exported datatypes definition
|
| 41 |
*/
|
| 42 |
|
| 43 |
/* T=1 Protocol context */
|
| 44 |
typedef struct
|
| 45 |
{
|
| 46 |
int lun; /* Asynchronous integrated cirtuit card */
|
| 47 |
unsigned short ifsc; /* Information field size for the ICC */
|
| 48 |
unsigned short ifsd; /* Information field size for the IFD */
|
| 49 |
int edc; /* Type of error detection code */
|
| 50 |
BYTE ns; /* Send sequence number */
|
| 51 |
}
|
| 52 |
Protocol_T1;
|
| 53 |
|
| 54 |
/*
|
| 55 |
* Exported functions declaration
|
| 56 |
*/
|
| 57 |
|
| 58 |
/* negociate IFSD */
|
| 59 |
int
|
| 60 |
Protocol_T1_Negociate_IFSD(Protocol_T1 * t1, int ifsd);
|
| 61 |
|
| 62 |
/* Create a new protocol handler */
|
| 63 |
extern Protocol_T1 *
|
| 64 |
Protocol_T1_New (void);
|
| 65 |
|
| 66 |
/* Delete a protocol handler */
|
| 67 |
extern void
|
| 68 |
Protocol_T1_Delete (Protocol_T1 * t1);
|
| 69 |
|
| 70 |
/* Initialise a protocol handler */
|
| 71 |
extern int
|
| 72 |
Protocol_T1_Init (Protocol_T1 * t1, int icc);
|
| 73 |
|
| 74 |
/* Send a command and return a response */
|
| 75 |
extern int
|
| 76 |
Protocol_T1_Command (Protocol_T1 * t1, APDU_Cmd * cmd, APDU_Rsp * rsp);
|
| 77 |
|
| 78 |
/* Close a protocol handler */
|
| 79 |
extern int
|
| 80 |
Protocol_T1_Close (Protocol_T1 * t1);
|
| 81 |
|
| 82 |
#endif /* _PROTOCOL_T1_ */
|