globalplatform
|
#include <stdio.h>
#include <winscard.h>
#include "types.h"
#include "library.h"
#include "security.h"
#include "error.h"
Go to the source code of this file.
Data Structures | |
struct | OPGP_CONNECTION_FUNCTIONS |
struct | OPGP_CARD_CONTEXT |
struct | OPGP_CARD_INFO |
Macros | |
#define | MAX_ATR_SIZE 33 |
Maximum ATR size. | |
#define | OPGP_TRACE_MODE_ENABLE 1 |
Switch trace mode on. | |
#define | OPGP_TRACE_MODE_DISABLE 0 |
Switch trace mode off. | |
#define | OPGP_CARD_PROTOCOL_T0 SCARD_PROTOCOL_T0 |
Transport protocol T=0. | |
#define | OPGP_CARD_PROTOCOL_T1 SCARD_PROTOCOL_T1 |
Transport protocol T=1. | |
Functions | |
OPGP_API void | OPGP_enable_trace_mode (DWORD enable, FILE *out) |
Enables the trace mode. More... | |
OPGP_API OPGP_ERROR_STATUS | OPGP_establish_context (OPGP_CARD_CONTEXT *cardContext) |
This function establishes a context to connection layer. More... | |
OPGP_API OPGP_ERROR_STATUS | OPGP_release_context (OPGP_CARD_CONTEXT *cardContext) |
This function releases the context to the connection layer established by OPGP_establish_context(). More... | |
OPGP_API OPGP_ERROR_STATUS | OPGP_list_readers (OPGP_CARD_CONTEXT cardContext, OPGP_STRING readerNames, PDWORD readerNamesLength) |
This function returns a list of currently available readers. More... | |
OPGP_API OPGP_ERROR_STATUS | OPGP_card_connect (OPGP_CARD_CONTEXT cardContext, OPGP_CSTRING readerName, OPGP_CARD_INFO *cardInfo, DWORD protocol) |
This function connects to a reader. More... | |
OPGP_API OPGP_ERROR_STATUS | OPGP_card_disconnect (OPGP_CARD_CONTEXT cardContext, OPGP_CARD_INFO *cardInfo) |
This function disconnects a reader. More... | |
OPGP_API 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) |
This function sends an APDU. More... | |
This file contains all connection related functions. The real functionality is implemented by plugins.
OPGP_API OPGP_ERROR_STATUS OPGP_card_connect | ( | OPGP_CARD_CONTEXT | cardContext, |
OPGP_CSTRING | readerName, | ||
OPGP_CARD_INFO * | cardInfo, | ||
DWORD | protocol | ||
) |
This function connects to a reader.
OPGP_card_disconnect MUST be called to release allocated resources. If something is not working, you may want to change the protocol type.
cardContext | [in] The valid OPGP_CARD_CONTEXT returned by establish_context() |
readerName | [in] The name of the reader to connect. |
*cardInfo | [out] The returned OPGP_CARD_INFO. |
protocol | [in] The transmit protocol type to use. Can be OPGP_CARD_PROTOCOL_T0 or OPGP_CARD_PROTOCOL_T1 or both ORed. |
OPGP_API OPGP_ERROR_STATUS OPGP_card_disconnect | ( | OPGP_CARD_CONTEXT | cardContext, |
OPGP_CARD_INFO * | cardInfo | ||
) |
This function disconnects a reader.
cardContext | [in] The valid OPGP_CARD_CONTEXT returned by establish_context() |
cardInfo | [in, out] The OPGP_CARD_INFO structure returned by card_connect(). |
<same here
OPGP_API void OPGP_enable_trace_mode | ( | DWORD | enable, |
FILE * | out | ||
) |
Enables the trace mode.
enable | [in] Enables or disables the trace mode. |
*out | [out] The pointer to to FILE to print result. |
OPGP_API OPGP_ERROR_STATUS OPGP_establish_context | ( | OPGP_CARD_CONTEXT * | cardContext | ) |
This function establishes a context to connection layer.
OPGP_release_context MUST be called to release allocated resources.
cardContext | [out] The returned OPGP_CARD_CONTEXT. |
OPGP_API OPGP_ERROR_STATUS OPGP_list_readers | ( | OPGP_CARD_CONTEXT | cardContext, |
OPGP_STRING | readerNames, | ||
PDWORD | readerNamesLength | ||
) |
This function returns a list of currently available readers.
cardContext | [in] The valid OPGP_CARD_CONTEXT returned by establish_context() |
readerNames | [out] The reader names will be a multi-string and separated by a NULL character and ended by a double NULL. (ReaderA\0ReaderB\0\0). If this value is NULL, list_readers ignores the buffer length supplied in readerNamesLength, writes the length of the multi-string that would have been returned if this parameter had not been NULL to readerNamesLength. |
readerNamesLength | [in, out] The length of the multi-string including all trailing null characters. |
OPGP_API OPGP_ERROR_STATUS OPGP_release_context | ( | OPGP_CARD_CONTEXT * | cardContext | ) |
This function releases the context to the connection layer established by OPGP_establish_context().
cardContext | [in, out] The valid OPGP_CARD_CONTEXT returned by establish_context() |
OPGP_API 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 | ||
) |
This function sends an APDU.
If the transmission is successful then the APDU status word is returned as errorCode in the OPGP_ERROR_STATUS structure.
cardContext | [in] The valid OPGP_CARD_CONTEXT returned by OPGP_establish_context() |
cardInfo | [in] The OPGP_CARD_INFO structure returned by OPGP_card_connect(). |
*secInfo | [in, out] The pointer to the GP211_SECURITY_INFO structure returned by GP211_mutual_authentication(). |
capdu | [in] The command APDU. |
capduLength | [in] The length of the command APDU. |
rapdu | [out] The response APDU. |
rapduLength | [in, out] The length of the the response APDU. |