globalplatform/connection.h

Go to the documentation of this file.
00001 /*  Copyright (c) 2009, Karsten Ohme
00002  *  This file is part of GlobalPlatform.
00003  *
00004  *  GlobalPlatform is free software: you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published by
00006  *  the Free Software Foundation, either version 3 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  GlobalPlatform is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Lesser General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with GlobalPlatform.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00023 #ifndef OPGP_CONNECTION_H
00024 #define OPGP_CONNECTION_H
00025 
00026 #ifdef __cplusplus
00027 extern "C"
00028 {
00029 #endif
00030 
00031 #include <stdio.h>
00032 #ifdef WIN32
00033 #include <WinSCard.h>
00034 #else
00035 #include <PCSC/winscard.h>
00036 #endif
00037 #include "types.h"
00038 #include "library.h"
00039 #include "security.h"
00040 #include "error.h"
00041 
00042 #if !defined __winscard_h__
00043 #define MAX_ATR_SIZE 32 //!< Maximum ATR size
00044 #endif
00045 
00046 #define OPGP_TRACE_MODE_ENABLE 1 //!< Switch trace mode on
00047 #define OPGP_TRACE_MODE_DISABLE 0 //!< Switch trace mode off
00048 
00049 #define OPGP_CARD_PROTOCOL_T0 SCARD_PROTOCOL_T0 //!< Transport protocol T=0
00050 #define OPGP_CARD_PROTOCOL_T1 SCARD_PROTOCOL_T1 //!< Transport protocol T=1
00051 
00055 typedef struct
00056 {
00057         PVOID establishContext; 
00058         PVOID releaseContext; 
00059         PVOID cardConnect; 
00060         PVOID cardDisconnect; 
00061         PVOID listReaders; 
00062         PVOID sendAPDU; 
00063 
00064 } OPGP_CONNECTION_FUNCTIONS;
00065 
00069 typedef struct {
00070         PVOID librarySpecific; 
00071         TCHAR libraryName[64]; 
00072         TCHAR libraryVersion[32]; 
00073         PVOID libraryHandle; 
00074         OPGP_CONNECTION_FUNCTIONS connectionFunctions; 
00075 } OPGP_CARD_CONTEXT;
00076 
00080 typedef struct {
00081         BYTE ATR[MAX_ATR_SIZE]; 
00082         DWORD ATRLength; 
00083         BYTE logicalChannel; 
00084         BYTE specVersion; 
00085         PVOID librarySpecific; 
00086 } OPGP_CARD_INFO;
00087 
00088 // functions
00089 
00091 OPGP_API
00092 void OPGP_enable_trace_mode(DWORD enable, FILE *out);
00093 
00095 OPGP_API
00096 OPGP_ERROR_STATUS OPGP_establish_context(OPGP_CARD_CONTEXT *cardContext);
00097 
00099 OPGP_API
00100 OPGP_ERROR_STATUS OPGP_release_context(OPGP_CARD_CONTEXT *cardContext);
00101 
00103 OPGP_API
00104 OPGP_ERROR_STATUS OPGP_list_readers(OPGP_CARD_CONTEXT cardContext, OPGP_STRING readerNames, PDWORD readerNamesLength);
00105 
00107 OPGP_API
00108 OPGP_ERROR_STATUS OPGP_card_connect(OPGP_CARD_CONTEXT cardContext, OPGP_CSTRING readerName, OPGP_CARD_INFO *cardInfo, DWORD protocol);
00109 
00111 OPGP_API
00112 OPGP_ERROR_STATUS OPGP_card_disconnect(OPGP_CARD_CONTEXT cardContext, OPGP_CARD_INFO *cardInfo);
00113 
00115 OPGP_API
00116 OPGP_ERROR_STATUS OPGP_send_APDU(OPGP_CARD_CONTEXT cardContext, OPGP_CARD_INFO cardInfo, GP211_SECURITY_INFO *secInfo, PBYTE capdu, DWORD capduLength, PBYTE rapdu, PDWORD rapduLength);
00117 
00118 #ifdef __cplusplus
00119 }
00120 #endif
00121 #endif
Generated on Wed Aug 11 00:24:28 2010 for GlobalPlatformLibrary by  doxygen 1.6.3