added workaround for current buergerclient to read efcardaccess
git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@251 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -96,6 +96,7 @@ AC_SUBST(OPENSSL_LIBS)
|
|||||||
|
|
||||||
AM_CONDITIONAL(WITH_PACE, test "${enable_pace}" != "no")
|
AM_CONDITIONAL(WITH_PACE, test "${enable_pace}" != "no")
|
||||||
AM_COND_IF(WITH_PACE, [AC_DEFINE(WITH_PACE, 1, [enable PACE support])])
|
AM_COND_IF(WITH_PACE, [AC_DEFINE(WITH_PACE, 1, [enable PACE support])])
|
||||||
|
AM_COND_IF(WITH_PACE, [AC_DEFINE(BUERGERCLIENT_WORKAROUND, 1, [Always get EF.CardAccess, when connecting to a smart card. This is a workaround for the recent Buergerclient])])
|
||||||
|
|
||||||
|
|
||||||
# --enable-ccid-test
|
# --enable-ccid-test
|
||||||
|
|||||||
@@ -35,13 +35,21 @@
|
|||||||
#include <pace/scutil.h>
|
#include <pace/scutil.h>
|
||||||
|
|
||||||
static struct sm_ctx sctx;
|
static struct sm_ctx sctx;
|
||||||
|
#ifdef BUERGERCLIENT_WORKAROUND
|
||||||
|
static char *ef_cardaccess = NULL;
|
||||||
|
static size_t ef_cardaccess_length = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include "pace/scutil.h"
|
#include "pace/scutil.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static sc_context_t *ctx = NULL;
|
static sc_context_t *ctx = NULL;
|
||||||
|
#ifdef BUERGERCLIENT_WORKAROUND
|
||||||
|
static sc_card_t *card_in_slot[1];
|
||||||
|
#else
|
||||||
static sc_card_t *card_in_slot[SC_MAX_SLOTS];
|
static sc_card_t *card_in_slot[SC_MAX_SLOTS];
|
||||||
|
#endif
|
||||||
static sc_reader_t *reader;
|
static sc_reader_t *reader;
|
||||||
|
|
||||||
struct ccid_class_descriptor
|
struct ccid_class_descriptor
|
||||||
@@ -141,6 +149,11 @@ int ccid_initialize(int reader_id, const char *cdriver, int verbose)
|
|||||||
|
|
||||||
#ifdef WITH_PACE
|
#ifdef WITH_PACE
|
||||||
memset(&sctx, 0, sizeof(sctx));
|
memset(&sctx, 0, sizeof(sctx));
|
||||||
|
#ifdef BUERGERCLIENT_WORKAROUND
|
||||||
|
free(ef_cardaccess);
|
||||||
|
ef_cardaccess = NULL;
|
||||||
|
ef_cardaccess_length = 0;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return SC_SUCCESS;
|
return SC_SUCCESS;
|
||||||
@@ -160,6 +173,11 @@ void ccid_shutdown()
|
|||||||
#ifdef WITH_PACE
|
#ifdef WITH_PACE
|
||||||
pace_sm_ctx_clear_free(sctx.cipher_ctx);
|
pace_sm_ctx_clear_free(sctx.cipher_ctx);
|
||||||
memset(&sctx, 0, sizeof(sctx));
|
memset(&sctx, 0, sizeof(sctx));
|
||||||
|
#ifdef BUERGERCLIENT_WORKAROUND
|
||||||
|
free(ef_cardaccess);
|
||||||
|
ef_cardaccess = NULL;
|
||||||
|
ef_cardaccess_length = 0;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,6 +423,12 @@ perform_PC_to_RDR_IccPowerOn(const __u8 *in, size_t inlen, __u8 **out, size_t *o
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sc_result >= 0) {
|
if (sc_result >= 0) {
|
||||||
|
#ifdef BUERGERCLIENT_WORKAROUND
|
||||||
|
if (get_ef_card_access(card_in_slot[request->bSlot],
|
||||||
|
(u8 **) &ef_cardaccess, &ef_cardaccess_length) < 0) {
|
||||||
|
sc_error(ctx, "Could not get EF.CardAccess.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return get_RDR_to_PC_SlotStatus(request->bSlot, request->bSeq,
|
return get_RDR_to_PC_SlotStatus(request->bSlot, request->bSeq,
|
||||||
sc_result, out, outlen, card_in_slot[request->bSlot]->atr,
|
sc_result, out, outlen, card_in_slot[request->bSlot]->atr,
|
||||||
card_in_slot[request->bSlot]->atr_len);
|
card_in_slot[request->bSlot]->atr_len);
|
||||||
@@ -826,6 +850,10 @@ perform_PC_to_RDR_Secure_EstablishPACEChannel(sc_card_t *card,
|
|||||||
|
|
||||||
/*if (sc_reset(card) < 0)*/
|
/*if (sc_reset(card) < 0)*/
|
||||||
/*sc_error(ctx, "Could not reset card, will continue anyway");*/
|
/*sc_error(ctx, "Could not reset card, will continue anyway");*/
|
||||||
|
#ifdef BUERGERCLIENT_WORKAROUND
|
||||||
|
pace_output.ef_cardaccess_length = ef_cardaccess_length;
|
||||||
|
pace_output.ef_cardaccess = ef_cardaccess;
|
||||||
|
#endif
|
||||||
|
|
||||||
sc_result = EstablishPACEChannel(NULL, card, pace_input, &pace_output,
|
sc_result = EstablishPACEChannel(NULL, card, pace_input, &pace_output,
|
||||||
&sctx);
|
&sctx);
|
||||||
|
|||||||
@@ -159,6 +159,21 @@ IMPLEMENT_ASN1_FUNCTIONS(PACE_GEN_AUTH_R)
|
|||||||
|
|
||||||
const size_t maxresp = SC_MAX_APDU_BUFFER_SIZE - 2;
|
const size_t maxresp = SC_MAX_APDU_BUFFER_SIZE - 2;
|
||||||
|
|
||||||
|
static int pace_sm_encrypt(sc_card_t *card, const struct sm_ctx *ctx,
|
||||||
|
const u8 *data, size_t datalen, u8 **enc);
|
||||||
|
static int pace_sm_decrypt(sc_card_t *card, const struct sm_ctx *ctx,
|
||||||
|
const u8 *enc, size_t enclen, u8 **data);
|
||||||
|
static int pace_sm_authenticate(sc_card_t *card, const struct sm_ctx *ctx,
|
||||||
|
const u8 *data, size_t datalen, u8 **outdata);
|
||||||
|
static int pace_sm_verify_authentication(sc_card_t *card, const struct sm_ctx *ctx,
|
||||||
|
const u8 *mac, size_t maclen,
|
||||||
|
const u8 *macdata, size_t macdatalen);
|
||||||
|
static int pace_sm_pre_transmit(sc_card_t *card, const struct sm_ctx *ctx,
|
||||||
|
sc_apdu_t *apdu);
|
||||||
|
static int pace_sm_post_transmit(sc_card_t *card, const struct sm_ctx *ctx,
|
||||||
|
sc_apdu_t *sm_apdu);
|
||||||
|
|
||||||
|
|
||||||
int GetReadersPACECapabilities(u8 *bitmap)
|
int GetReadersPACECapabilities(u8 *bitmap)
|
||||||
{
|
{
|
||||||
if (!bitmap)
|
if (!bitmap)
|
||||||
@@ -171,7 +186,7 @@ int GetReadersPACECapabilities(u8 *bitmap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** select and read EF.CardAccess */
|
/** select and read EF.CardAccess */
|
||||||
static int get_ef_card_access(sc_card_t *card,
|
int get_ef_card_access(sc_card_t *card,
|
||||||
u8 **ef_cardaccess, size_t *length_ef_cardaccess)
|
u8 **ef_cardaccess, size_t *length_ef_cardaccess)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|||||||
@@ -51,20 +51,6 @@ int reset_ssc(struct pace_sm_ctx *psmctx);
|
|||||||
|
|
||||||
const char *pace_secret_name(enum s_type pin_id);
|
const char *pace_secret_name(enum s_type pin_id);
|
||||||
|
|
||||||
int pace_sm_encrypt(sc_card_t *card, const struct sm_ctx *ctx,
|
|
||||||
const u8 *data, size_t datalen, u8 **enc);
|
|
||||||
int pace_sm_decrypt(sc_card_t *card, const struct sm_ctx *ctx,
|
|
||||||
const u8 *enc, size_t enclen, u8 **data);
|
|
||||||
int pace_sm_authenticate(sc_card_t *card, const struct sm_ctx *ctx,
|
|
||||||
const u8 *data, size_t datalen, u8 **outdata);
|
|
||||||
int pace_sm_verify_authentication(sc_card_t *card, const struct sm_ctx *ctx,
|
|
||||||
const u8 *mac, size_t maclen,
|
|
||||||
const u8 *macdata, size_t macdatalen);
|
|
||||||
int pace_sm_pre_transmit(sc_card_t *card, const struct sm_ctx *ctx,
|
|
||||||
sc_apdu_t *apdu);
|
|
||||||
int pace_sm_post_transmit(sc_card_t *card, const struct sm_ctx *ctx,
|
|
||||||
sc_apdu_t *sm_apdu);
|
|
||||||
|
|
||||||
|
|
||||||
struct establish_pace_channel_input {
|
struct establish_pace_channel_input {
|
||||||
unsigned char pin_id;
|
unsigned char pin_id;
|
||||||
@@ -96,6 +82,11 @@ struct establish_pace_channel_output {
|
|||||||
unsigned char *id_icc;
|
unsigned char *id_icc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef BUERGERCLIENT_WORKAROUND
|
||||||
|
int get_ef_card_access(sc_card_t *card,
|
||||||
|
u8 **ef_cardaccess, size_t *length_ef_cardaccess);
|
||||||
|
#endif
|
||||||
|
|
||||||
int GetReadersPACECapabilities(u8 *bitmap);
|
int GetReadersPACECapabilities(u8 *bitmap);
|
||||||
|
|
||||||
int EstablishPACEChannel(const struct sm_ctx *oldpacectx, sc_card_t *card,
|
int EstablishPACEChannel(const struct sm_ctx *oldpacectx, sc_card_t *card,
|
||||||
|
|||||||
Reference in New Issue
Block a user