- sm will yield error when the class byte indicates a sm apdu and pace will

simply transmit the apdu without encrypting/authenticating it.
- fixed building process when compiling without pace


git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@81 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
frankmorgner
2010-04-27 20:00:42 +00:00
parent 6e81cb30cd
commit fdc400b911
5 changed files with 29 additions and 5 deletions

View File

@@ -9,21 +9,24 @@ bindir = $(exec_prefix)/bin
# Compiler
CC = gcc
CFLAGS = -Wall -g
EXTRA_CFLAGS = -DNO_PACE
OPENSSL_CFLAGS = `pkg-config --cflags --libs libssl`
OPENSC_CFLAGS = `pkg-config --cflags --libs libopensc`
PTHREAD_CFLAGS = -pthread
a_flags = $(CFLAGS) $(OPENSC_CFLAGS) $(OPENSSL_CFLAGS) \
$(PTHREAD_CFLAGS) $(EXTRA_CFLAGS)
a_flags = $(CFLAGS) $(OPENSC_CFLAGS) $(OPENSSL_CFLAGS) $(PTHREAD_CFLAGS)
INSTALL = install
INSTALL_PROGRAM = $(INSTALL)
TARGETS = ccid
CCID_OBJ = ccid.o sm.o usbstring.o usb.o
CCID_OBJ = ccid.o sm.o pace.o pace_lib.o usbstring.o usb.o
ifdef PACE
CCID_OBJ += pace.o pace_lib.o
else
a_flags += -DNO_PACE
endif
# top-level rule
all: $(TARGETS)

View File

@@ -27,7 +27,9 @@
#include <opensc/log.h>
#include "ccid.h"
#ifndef NO_PACE
#include "pace.h"
#endif
static sc_context_t *ctx = NULL;
static sc_card_t *card_in_slot[SC_MAX_SLOTS];
@@ -1305,6 +1307,14 @@ int ccid_state_changed(RDR_to_PC_NotifySlotChange_t **slotchange, int timeout)
return 0;
}
#ifdef NO_PACE
int ccid_testpace(u8 pin_id, const char *pin, size_t pinlen)
{
sc_error(ctx, "ccid not compiled with support for PACE.");
return SC_ERROR_NOT_SUPPORTED;
}
#else
int ccid_testpace(u8 pin_id, const char *pin, size_t pinlen)
{
int i;
@@ -1321,6 +1331,7 @@ int ccid_testpace(u8 pin_id, const char *pin, size_t pinlen)
return SC_ERROR_SLOT_NOT_FOUND;
}
#endif
static int ccid_list_readers(sc_context_t *ctx)
{

View File

@@ -1296,6 +1296,11 @@ int pace_transmit_apdu(struct sm_ctx *ctx, sc_card_t *card,
{
int r;
if ((apdu->cla & 0x0C) == 0x0C) {
sc_debug(card->ctx, "Given APDU is already protected with some secure messaging.");
SC_FUNC_RETURN(card->ctx, SC_LOG_TYPE_DEBUG, sc_transmit_apdu(card, apdu));
}
if (!ctx || !ctx->cipher_ctx) {
SC_FUNC_RETURN(card->ctx, SC_LOG_TYPE_DEBUG, SC_ERROR_INVALID_ARGUMENTS);
}

View File

@@ -273,6 +273,12 @@ static int sm_encrypt(const struct sm_ctx *ctx, sc_card_t *card,
goto err;
}
if ((apdu->cla & 0x0C) == 0x0C) {
r = SC_ERROR_INVALID_ARGUMENTS;
sc_error(card->ctx, "Given APDU is already protected with some secure messaging.");
goto err;
}
sc_copy_asn1_entry(c_sm_capdu, sm_capdu);
sm_apdu->sensitive = 0;

View File

@@ -47,7 +47,6 @@
#include "usbstring.h"
#include "ccid.h"
#include "pace.h"
#define DRIVER_VENDOR_NUM 0x0D46 /* KOBIL Systems */
#define DRIVER_PRODUCT_NUM 0x3010 /* KOBIL Class 3 Reader */