diff --git a/ccid/src/cats-test.c b/ccid/src/cats-test.c
index e252ab1..5c52895 100644
--- a/ccid/src/cats-test.c
+++ b/ccid/src/cats-test.c
@@ -1,20 +1,20 @@
/*
* Copyright (C) 2010 Frank Morgner
*
- * This file is part of ifdnfc.
+ * This file is part of ccid.
*
- * ifdnfc is free software: you can redistribute it and/or modify it under the
+ * ccid is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
- * ifdnfc is distributed in the hope that it will be useful, but WITHOUT ANY
+ * ccid is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
- * ifdnfc. If not, see .
+ * ccid. If not, see .
*/
#include
#include
diff --git a/ccid/src/ccid.c b/ccid/src/ccid.c
index dc91fef..468dd77 100644
--- a/ccid/src/ccid.c
+++ b/ccid/src/ccid.c
@@ -1407,7 +1407,7 @@ perform_unknown(const __u8 *in, size_t inlen, __u8 **out, size_t *outlen)
return SC_SUCCESS;
}
-int ccid_parse_bulkin(const __u8* inbuf, size_t inlen, __u8** outbuf)
+int ccid_parse_bulkout(const __u8* inbuf, size_t inlen, __u8** outbuf)
{
int sc_result;
size_t outlen;
diff --git a/ccid/src/ccid.h b/ccid/src/ccid.h
index 5283498..164786b 100644
--- a/ccid/src/ccid.h
+++ b/ccid/src/ccid.h
@@ -268,11 +268,58 @@ struct hid_class_descriptor {
__u8 bNumDescriptors;
} __attribute__ ((packed));
+/**
+ * @brief Initializes reader for relaying
+ *
+ * @param[in] reader_id Index to the reader to be used (optional). Set to -1 to use a reader with a inserted card.
+ * @param[in] cdriver Card driver to be used (optional)
+ * @param[in] verbose Verbosity level passed to \c sc_context_t
+ *
+ * @return \c SC_SUCCESS or error code if an error occurred
+ */
int ccid_initialize(int reader_id, const char *cdriver, int verbose);
+
+/**
+ * @brief Disconnects from card, reader and releases allocated memory
+ */
void ccid_shutdown();
-int ccid_parse_bulkin(const __u8* inbuf, size_t inlen, __u8** outbuf);
+
+/**
+ * @brief Parses input from PC and generates the appropriate RDR response
+ *
+ * Parses command pipe bulk-OUT messages and generates resoponse pipe bulk-IN
+ * messages according to CCID Rev 1.1 section 6.1, 6.2
+ *
+ * @param[in] inbuf input buffer (command pipe bulk-OUT message)
+ * @param[in] inlen length of \a inbuf
+ * @param[in,out] outbuf where to save the output buffer (resoponse pipe bulk-IN message), memory is reused via realloc()
+ *
+ * @return length of \a outbuf or -1 if an error occurred
+ */
+int ccid_parse_bulkout(const __u8* inbuf, size_t inlen, __u8** outbuf);
+
+/**
+ * @brief Parses input from control pipe and generates the appropriate response
+ *
+ * Parses CCID class-specific requests according to CCID Rev 1.1 section 5.3
+ *
+ * @param[in] setup input from control pipe
+ * @param[in,out] outbuf where to save the output buffer, memory is reused via realloc()
+ *
+ * @return length of \a outbuf or -1 if an error occurred
+ */
int ccid_parse_control(struct usb_ctrlrequest *setup, __u8 **outbuf);
+
+/**
+ * @brief Generates event messages
+ *
+ * @param[in,out] slotchange where to save the output
+ * @param[in] timeout currently not used
+ * @note ccid_state_changed() must be called periodically. Because the OpenSC implementation of sc_wait_for_event() blocks all other operations with the reader, it can't be used for slot state detection.
+ *
+ * @return 1 if a card is present and/or the state is changed or 0
+ */
int ccid_state_changed(RDR_to_PC_NotifySlotChange_t **slotchange, int timeout);
#ifdef __cplusplus
diff --git a/ccid/src/pace.c b/ccid/src/pace.c
index eae525b..c247484 100644
--- a/ccid/src/pace.c
+++ b/ccid/src/pace.c
@@ -162,6 +162,10 @@ static int pace_sm_pre_transmit(sc_card_t *card, const struct sm_ctx *ctx,
static int pace_sm_post_transmit(sc_card_t *card, const struct sm_ctx *ctx,
sc_apdu_t *sm_apdu);
+static int increment_ssc(struct pace_sm_ctx *psmctx);
+static int decrement_ssc(struct pace_sm_ctx *psmctx);
+static int reset_ssc(struct pace_sm_ctx *psmctx);
+
int GetReadersPACECapabilities(u8 *bitmap)
{
diff --git a/ccid/src/pace/pace.h b/ccid/src/pace/pace.h
index b9cedc7..3485ac0 100644
--- a/ccid/src/pace/pace.h
+++ b/ccid/src/pace/pace.h
@@ -64,10 +64,6 @@ extern "C" {
#define MIN_PIN_LEN 6
#define MAX_MRZ_LEN 128
-int increment_ssc(struct pace_sm_ctx *psmctx);
-int decrement_ssc(struct pace_sm_ctx *psmctx);
-int reset_ssc(struct pace_sm_ctx *psmctx);
-
const char *pace_secret_name(enum s_type pin_id);
diff --git a/ccid/src/pace/sm.h b/ccid/src/pace/sm.h
index 5d043e8..98db359 100644
--- a/ccid/src/pace/sm.h
+++ b/ccid/src/pace/sm.h
@@ -25,13 +25,19 @@
extern "C" {
#endif
+/** Padding indicator: use ISO/IEC 9797-1 padding method 2 */
#define SM_ISO_PADDING 0x01
+/** Padding indicator: use no padding */
#define SM_NO_PADDING 0x02
+/** Secure messaging context */
struct sm_ctx {
+ /** 1 if secure messaging is activated, 0 otherwise */
unsigned char active;
+ /** Padding-content indicator byte (ISO 7816-4 Table 30) */
u8 padding_indicator;
+ /** Pad to this block length */
size_t block_length;
void *authentication_ctx;
diff --git a/ccid/src/usb.c b/ccid/src/usb.c
index 8d25b3c..89e888d 100644
--- a/ccid/src/usb.c
+++ b/ccid/src/usb.c
@@ -72,16 +72,16 @@ static const char *cdriver = NULL;
static const struct option options[] = {
/*{ "hid", no_argument, &dohid, 1 },*/
- { "help", no_argument, NULL, OPT_HELP },
- { "reader", required_argument, NULL, OPT_READER },
+ { "help", no_argument, NULL, OPT_HELP },
+ { "reader", required_argument, NULL, OPT_READER },
{ "card-driver", required_argument, NULL, OPT_CARD },
- { "serial", required_argument, NULL, OPT_SERIAL },
- { "product", required_argument, NULL, OPT_PRODUCT },
- { "vendor", required_argument, NULL, OPT_VENDOR },
- { "interrupt", no_argument, NULL, OPT_INTERRUPT },
- { "verbose", no_argument, NULL, OPT_VERBOSE },
- { "info", no_argument, NULL, OPT_INFO },
- { NULL, 0, NULL, 0 }
+ { "serial", required_argument, NULL, OPT_SERIAL },
+ { "product", required_argument, NULL, OPT_PRODUCT },
+ { "vendor", required_argument, NULL, OPT_VENDOR },
+ { "interrupt", no_argument, NULL, OPT_INTERRUPT },
+ { "verbose", no_argument, NULL, OPT_VERBOSE },
+ { "info", no_argument, NULL, OPT_INFO },
+ { NULL, 0, NULL, 0 }
};
static const char *option_help[] = {
/*"Emulate HID device",*/
@@ -286,17 +286,17 @@ static const struct usb_endpoint_descriptor *hs_eps [] = {
static char serial [57];
static struct usb_string stringtab [] = {
- { STRINGID_MFGR, "morgner@informatik.hu-berlin.de", },
- { STRINGID_PRODUCT, "CCID to PCSC Gadget", },
- { STRINGID_SERIAL, serial, },
- { STRINGID_CONFIG, "The Configuration", },
- { STRINGID_INTERFACE, "CCID to PCSC", },
- { STRINGID_HID_INTERFACE, "Human Device Interface Gadget", },
+ { STRINGID_MFGR, "morgner@informatik.hu-berlin.de", },
+ { STRINGID_PRODUCT, "CCID Emulator", },
+ { STRINGID_SERIAL, serial, },
+ { STRINGID_CONFIG, "", },
+ { STRINGID_INTERFACE, "", },
+ { STRINGID_HID_INTERFACE, "Human Device Interface Gadget", },
};
static struct usb_gadget_strings strings = {
- .language = 0x0409, /* "en-us" */
- .strings = stringtab,
+ .language = 0x0409, /* "en-us" */
+ .strings = stringtab,
};
/*-------------------------------------------------------------------------*/
@@ -1030,7 +1030,7 @@ static void *ccid (void *param)
fprintf(stderr, "bulk loop: got %d, done.\n", result);
if (!result) break;
- result = ccid_parse_bulkin(inbuf, result, &outbuf);
+ result = ccid_parse_bulkout(inbuf, result, &outbuf);
if (result < 0) break;
if (verbose > 1)