- 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:
@@ -9,21 +9,24 @@ bindir = $(exec_prefix)/bin
|
|||||||
# Compiler
|
# Compiler
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -g
|
CFLAGS = -Wall -g
|
||||||
EXTRA_CFLAGS = -DNO_PACE
|
|
||||||
|
|
||||||
OPENSSL_CFLAGS = `pkg-config --cflags --libs libssl`
|
OPENSSL_CFLAGS = `pkg-config --cflags --libs libssl`
|
||||||
OPENSC_CFLAGS = `pkg-config --cflags --libs libopensc`
|
OPENSC_CFLAGS = `pkg-config --cflags --libs libopensc`
|
||||||
PTHREAD_CFLAGS = -pthread
|
PTHREAD_CFLAGS = -pthread
|
||||||
a_flags = $(CFLAGS) $(OPENSC_CFLAGS) $(OPENSSL_CFLAGS) \
|
a_flags = $(CFLAGS) $(OPENSC_CFLAGS) $(OPENSSL_CFLAGS) $(PTHREAD_CFLAGS)
|
||||||
$(PTHREAD_CFLAGS) $(EXTRA_CFLAGS)
|
|
||||||
|
|
||||||
INSTALL = install
|
INSTALL = install
|
||||||
INSTALL_PROGRAM = $(INSTALL)
|
INSTALL_PROGRAM = $(INSTALL)
|
||||||
|
|
||||||
|
|
||||||
TARGETS = ccid
|
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
|
# top-level rule
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
|
|||||||
11
ccid/ccid.c
11
ccid/ccid.c
@@ -27,7 +27,9 @@
|
|||||||
#include <opensc/log.h>
|
#include <opensc/log.h>
|
||||||
|
|
||||||
#include "ccid.h"
|
#include "ccid.h"
|
||||||
|
#ifndef NO_PACE
|
||||||
#include "pace.h"
|
#include "pace.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static sc_context_t *ctx = NULL;
|
static sc_context_t *ctx = NULL;
|
||||||
static sc_card_t *card_in_slot[SC_MAX_SLOTS];
|
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;
|
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 ccid_testpace(u8 pin_id, const char *pin, size_t pinlen)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1321,6 +1331,7 @@ int ccid_testpace(u8 pin_id, const char *pin, size_t pinlen)
|
|||||||
|
|
||||||
return SC_ERROR_SLOT_NOT_FOUND;
|
return SC_ERROR_SLOT_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int ccid_list_readers(sc_context_t *ctx)
|
static int ccid_list_readers(sc_context_t *ctx)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1296,6 +1296,11 @@ int pace_transmit_apdu(struct sm_ctx *ctx, sc_card_t *card,
|
|||||||
{
|
{
|
||||||
int r;
|
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) {
|
if (!ctx || !ctx->cipher_ctx) {
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_TYPE_DEBUG, SC_ERROR_INVALID_ARGUMENTS);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_TYPE_DEBUG, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,6 +273,12 @@ static int sm_encrypt(const struct sm_ctx *ctx, sc_card_t *card,
|
|||||||
goto err;
|
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);
|
sc_copy_asn1_entry(c_sm_capdu, sm_capdu);
|
||||||
|
|
||||||
sm_apdu->sensitive = 0;
|
sm_apdu->sensitive = 0;
|
||||||
|
|||||||
@@ -47,7 +47,6 @@
|
|||||||
|
|
||||||
#include "usbstring.h"
|
#include "usbstring.h"
|
||||||
#include "ccid.h"
|
#include "ccid.h"
|
||||||
#include "pace.h"
|
|
||||||
|
|
||||||
#define DRIVER_VENDOR_NUM 0x0D46 /* KOBIL Systems */
|
#define DRIVER_VENDOR_NUM 0x0D46 /* KOBIL Systems */
|
||||||
#define DRIVER_PRODUCT_NUM 0x3010 /* KOBIL Class 3 Reader */
|
#define DRIVER_PRODUCT_NUM 0x3010 /* KOBIL Class 3 Reader */
|
||||||
|
|||||||
Reference in New Issue
Block a user