hi. a small bux fixed for redhat 7.3 systems. david, please apply the diff to cvs. (what again is the current cvs pserver root?)
best regards, andreas
Index: COPYRIGHT
===================================================================
RCS file: /cvsroot/muscleframework/muscle/ETokenDriver/COPYRIGHT,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 COPYRIGHT
--- COPYRIGHT 17 Mar 2002 18:04:55 -0000 1.1.1.1
+++ COPYRIGHT 1 Jul 2002 12:08:31 -0000
@@ -1,4 +1,5 @@
(C) 2002 by Andreas Jellinghaus <[EMAIL PROTECTED]>
+(C) 2002 by Olaf Kirch <[EMAIL PROTECTED]>
the t1 implementation is based on scez - smartcard library
(C) 1999 - 2002 by Matthias Bruestle <[EMAIL PROTECTED]>
Index: README
===================================================================
RCS file: /cvsroot/muscleframework/muscle/ETokenDriver/README,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 README
--- README 17 Mar 2002 18:04:56 -0000 1.1.1.1
+++ README 1 Jul 2002 12:08:31 -0000
@@ -27,6 +27,18 @@
it works a bit.
+1.7.2002 version 0.3.2 released
+#include <string.h> in etoken.c added.
+
+25.6.2002 version 0.3.1 released
+added new product id 0x514 as reported by
+Roland Dirlewanger <[EMAIL PROTECTED]>. thanks Roland!
+
+13.6.2002 verson 0.3 released
+debugging now via syslog
+fix in t=1
+both done by olaf kirch, thanks!
+
8.2.2002 version 0.2 release
fixed very nasty bug in t1 protocol
Index: THANKS
===================================================================
RCS file: /cvsroot/muscleframework/muscle/ETokenDriver/THANKS,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 THANKS
--- THANKS 17 Mar 2002 18:04:56 -0000 1.1.1.1
+++ THANKS 1 Jul 2002 12:08:31 -0000
@@ -2,3 +2,8 @@
and lots of support.
Thanks to John P. Looney for testing and comments.
+
+Thanks to Roland Dirlewanger <[EMAIL PROTECTED]> for testing,
+and information on other product ids.
+
+laurent <[EMAIL PROTECTED]> reported a bug.
Index: etoken.c
===================================================================
RCS file: /cvsroot/muscleframework/muscle/ETokenDriver/etoken.c,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 etoken.c
--- etoken.c 17 Mar 2002 18:04:56 -0000 1.1.1.1
+++ etoken.c 1 Jul 2002 12:08:31 -0000
@@ -3,13 +3,12 @@
#include <ifdhandler.h>
#include <usb.h>
#include <stdio.h>
+#include <string.h>
#include <sys/types.h>
+#include <syslog.h>
#include "etoken.h"
-#define VENDOR_ID 0x0529
-#define PRODUCT_ID 0x50c
-
#define T1MAXBUF (254+4)
static u_int8_t eToken_ATR[] = { 0x3b, 0xe2, 0x00, 0xff, 0xc1, 0x10, 0x31,
@@ -25,20 +24,20 @@
/* auxiliary functions */
void hexdump(const u_int8_t * buffer, int length)
{
- int i;
+ char line[256];
+ int n, i;
for (i = 0; i < length; i++) {
if ((i & 0xf) == 0) {
- printf("%04x:", i);
- }
- printf(" %02hhx", buffer[i]);
- if ((i & 0xf) == 0xf) {
- printf("\n");
+ snprintf(line, sizeof(line), "%04x:", i);
}
+ n = strlen(line);
+ snprintf(line+n, sizeof(line)-n, " %02hhx", buffer[i]);
+ if ((i & 0xf) == 0xf)
+ syslog(LOG_DEBUG, "%s", line);
};
- if ((i & 0xf) != 0xf) {
- printf("\n");
- }
+ if ((i & 0xf) != 0xf)
+ syslog(LOG_DEBUG, "%s", line);
}
int
@@ -69,8 +68,9 @@
usb_find_devices();
for (mybus = usb_busses; mybus; mybus = mybus->next) {
for (mydev = mybus->devices; mydev; mydev = mydev->next) {
- if ((mydev->descriptor.idVendor == VENDOR_ID) &&
- (mydev->descriptor.idProduct == PRODUCT_ID)) {
+ if ((mydev->descriptor.idVendor == 0x529) &&
+ ((mydev->descriptor.idProduct == 0x50c) ||
+ (mydev->descriptor.idProduct == 0x514))) {
goto found;
}
}
Index: ifdhandler.c
===================================================================
RCS file: /cvsroot/muscleframework/muscle/ETokenDriver/ifdhandler.c,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 ifdhandler.c
--- ifdhandler.c 17 Mar 2002 18:04:54 -0000 1.1.1.1
+++ ifdhandler.c 1 Jul 2002 12:08:31 -0000
@@ -4,6 +4,7 @@
#include <usb.h>
#include <stdio.h>
#include <sys/types.h>
+#include <syslog.h>
#include "etoken.h"
@@ -24,7 +25,10 @@
{
struct eToken *eToken;
- printf("%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#ifdef DEBUG
+ syslog(LOG_DEBUG,
+ "%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#endif
eToken = get_token_by_lun(Lun);
if (! eToken) {
@@ -42,7 +46,10 @@
{
struct eToken *eToken;
- printf("%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#ifdef DEBUG
+ syslog(LOG_DEBUG,
+ "%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#endif
eToken = get_token_by_lun(Lun);
if (! eToken) {
@@ -62,8 +69,10 @@
{
struct eToken *eToken;
- printf("%s %d %s: Lun %ld, Tag %lx\n",
+#ifdef DEBUG
+ syslog(LOG_DEBUG, "%s %d %s: Lun %ld, Tag %lx\n",
__FILE__, __LINE__, __PRETTY_FUNCTION__, Lun, Tag);
+#endif
eToken = get_token_by_lun(Lun);
if (! eToken) {
@@ -79,9 +88,12 @@
{
struct eToken *eToken;
- printf("%s %d %s: Lun %ld, Tag %lx, Length %ld, hexdump follows\n",
+#if 0 && defined(DEBUG)
+ syslog(LOG_DEBUG,
+ "%s %d %s: Lun %ld, Tag %lx, Length %ld, hexdump follows\n",
__FILE__, __LINE__, __PRETTY_FUNCTION__, Lun, Tag, Length);
hexdump(Value, Length);
+#endif
eToken = get_token_by_lun(Lun);
if (! eToken) {
@@ -98,7 +110,10 @@
{
struct eToken *eToken;
- printf("%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#ifdef DEBUG
+ syslog(LOG_DEBUG,
+ "%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#endif
eToken = get_token_by_lun(Lun);
if (! eToken) {
@@ -125,8 +140,10 @@
int rc;
struct eToken *eToken;
- printf("%s %d %s: Lun %ld, Action %ld\n",
+#ifdef DEBUG
+ syslog(LOG_DEBUG, "%s %d %s: Lun %ld, Action %ld\n",
__FILE__, __LINE__, __PRETTY_FUNCTION__, Lun, Action);
+#endif
eToken = get_token_by_lun(Lun);
if (! eToken) {
@@ -141,8 +158,10 @@
*AtrLength = get_atr(Atr);
return IFD_SUCCESS;
}
- printf("%s %d %s: power up failed\n",
+#ifdef DEBUG
+ syslog(LOG_DEBUG, "%s %d %s: power up failed\n",
__FILE__, __LINE__, __PRETTY_FUNCTION__);
+#endif
return IFD_COMMUNICATION_ERROR;
case IFD_POWER_DOWN:
@@ -168,10 +187,13 @@
{
struct eToken *eToken;
- printf("%s %d %s: Lun %ld TxLength %ld RxLength %ld, hexdump follows\n",
+#ifdef DEBUG
+ syslog(LOG_DEBUG,
+ "%s %d %s: Lun %ld TxLength %ld RxLength %ld, hexdump follows\n",
__FILE__, __LINE__, __PRETTY_FUNCTION__,
Lun, TxLength, *RxLength);
hexdump(TxBuffer, TxLength);
+#endif
*RxLength = 0;
eToken = get_token_by_lun(Lun);
@@ -188,8 +210,11 @@
{
struct eToken *eToken;
- printf("%s %d %s: Lun %ld\n",
+#if 0 && defined(DEBUG)
+ syslog(LOG_DEBUG,
+ "%s %d %s: Lun %ld\n",
__FILE__, __LINE__, __PRETTY_FUNCTION__, Lun);
+#endif
eToken = get_token_by_lun(Lun);
if (! eToken) {
@@ -213,11 +238,13 @@
struct eToken *eToken;
int rc, len_in;
- printf
- ("%s %d %s: Lun %ld Protocol %ld TxLength %ld RxLength %ld, hexdump follows\n",
+#ifdef DEBUG
+ syslog(LOG_DEBUG(
+ "%s %d %s: Lun %ld Protocol %ld TxLength %ld RxLength %ld, hexdump follows\n",
__FILE__, __LINE__, __PRETTY_FUNCTION__, Lun,
SendPci.Protocol, TxLength, *RxLength);
hexdump(TxBuffer, TxLength);
+#endif
len_in = *RxLength;
*RxLength = 0; /* should be 0 on all errors */
@@ -246,10 +273,13 @@
rc = send_command(eToken, TxBuffer, RxBuffer, TxLength, &len_in);
*RxLength = len_in;
- printf ("%s %d %s: RxLength %ld, hexdump follows\n",
+#ifdef DEBUG
+ syslog(LOG_DEBUG,
+ "%s %d %s: Status %d, RxLength %ld, hexdump follows\n",
__FILE__, __LINE__, __PRETTY_FUNCTION__,
- *RxLength);
+ rc, *RxLength);
hexdump(RxBuffer, *RxLength);
+#endif
return rc;
}
Index: t1.c
===================================================================
RCS file: /cvsroot/muscleframework/muscle/ETokenDriver/t1.c,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 t1.c
--- t1.c 17 Mar 2002 18:04:55 -0000 1.1.1.1
+++ t1.c 1 Jul 2002 12:08:32 -0000
@@ -387,6 +387,12 @@
/* Check if data available. */
if (more == 0) {
+ /* last block was with pcb: bit6=0
+ * (no more following blocks)
+ * so there is no more data to send.
+ * if the card is waiting for
+ * additional data, then it is wrong.
+ * comm error! */
rc = IFD_COMMUNICATION_ERROR;
goto cleanup;
}
@@ -394,6 +400,9 @@
/* Change N(S) to new value. */
eToken->ns ^= 1;
/* Make next I-Block. */
+
+ /* Clear error counter */
+ rerrcntr = 0;
}
sendlen = min(apdu_cmdlen - sendptr, eToken->ifsc);
etoken-0.3.2.tar.gz
Description: GNU Zip compressed data
