Check-in [5ba02cbd65]
Overview
Comment:Updated to strip library more on Linux, and work on Solaris

Updated to try to support more protocols

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:5ba02cbd65cce4f02c8ba92388bcbb43f81b1d1a
User & Date: rkeene on 2010-05-23 05:36:13
Other Links: manifest | tags
Context
2010-05-23
07:07
Added more debugging for failed realloc()s

Added ifdefs to support more versions of PCSC in debug mode check-in: 170e3dfda4 user: rkeene tags: trunk

05:36
Updated to strip library more on Linux, and work on Solaris

Updated to try to support more protocols check-in: 5ba02cbd65 user: rkeene tags: trunk

04:17
Updated return code documentation check-in: f337c480d8 user: rkeene tags: trunk
Changes

Modified Makefile.in from [d7442c4068] to [eb1d7f3b77].

    29     29   	$(CC) $(SHOBJFLAGS) $(CPPFLAGS) $(CFLAGS) -o asn1-x509.o -c asn1-x509.c
    30     30   
    31     31   asn1-x509_g.o: asn1-x509.c asn1-x509.h config.h
    32     32   	$(CC) $(SHOBJFLAGS) $(DEBUGCPPFLAGS) $(DEBUGCFLAGS) -o asn1-x509_g.o -c asn1-x509.c
    33     33   
    34     34   libcackey.@SHOBJEXT@: cackey.o asn1-x509.o
    35     35   	$(CC) $(SHOBJFLAGS) $(CPPFLAGS) $(CFLAGS) $(SHOBJLDFLAGS) $(LDFLAGS) -o libcackey.@SHOBJEXT@ cackey.o asn1-x509.o $(LIBS)
    36         -	-$(STRIP) -g "libcackey.@SHOBJEXT@"
           36  +	-$(STRIP) -x "libcackey.@SHOBJEXT@"
    37     37   
    38     38   libcackey_g.@SHOBJEXT@: cackey_g.o asn1-x509_g.o
    39     39   	$(CC) $(SHOBJFLAGS) $(DEBUGCPPFLAGS) $(DEBUGCFLAGS) $(SHOBJLDFLAGS) $(LDFLAGS) -o libcackey_g.@SHOBJEXT@ cackey_g.o asn1-x509_g.o $(LIBS)
    40     40   
    41     41   test: test.c libcackey_g.@SHOBJEXT@
    42     42   	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o test test.c -Wl,-R,. libcackey_g.@SHOBJEXT@
    43     43   

Modified cackey.c from [60d21a7b2f] to [5e1ae9e427].

   191    191   
   192    192   	if (retval != ptr) {
   193    193   		fprintf(stderr, "%s():%i: ", func, line);
   194    194   		fprintf(stderr, "REALLOC(%p) = %p", ptr, retval);
   195    195   		fprintf(stderr, "\n");
   196    196   		fflush(stderr);
   197    197   	}
          198  +
          199  +	if (retval == NULL) {
          200  +		CACKEY_DEBUG_PRINTF(" *** ERROR *** realloc returned NULL");
          201  +	}
   198    202   
   199    203   	return(retval);
   200    204   }
   201    205   
   202    206   static char *CACKEY_DEBUG_FUNC_STRDUP(const char *ptr, const char *func, int line) {
   203    207   	char *retval;
   204    208   
................................................................................
   559    563   typedef enum {
   560    564   	CACKEY_PCSC_S_TOKENPRESENT    = 1,
   561    565   	CACKEY_PCSC_S_OK              = 0,
   562    566   	CACKEY_PCSC_E_GENERIC         = -1,
   563    567   	CACKEY_PCSC_E_BADPIN          = -2,
   564    568   	CACKEY_PCSC_E_LOCKED          = -3,
   565    569   	CACKEY_PCSC_E_NEEDLOGIN       = -4,
   566         -	CACKEY_PCSC_E_TOKENABSENT     = -6,
          570  +	CACKEY_PCSC_E_TOKENABSENT     = -6
   567    571   } cackey_ret;
   568    572   
   569    573   struct cackey_tlv_cardurl {
   570    574   	unsigned char        rid[5];
   571    575   	cackey_tlv_apptype   apptype;
   572    576   	cackey_tlv_objectid  objectid;
   573    577   	cackey_tlv_objectid  appid;
................................................................................
   833    837   
   834    838   		return(CACKEY_PCSC_E_GENERIC);
   835    839   	}
   836    840   
   837    841   	/* Connect to reader, if needed */
   838    842   	if (!slot->pcsc_card_connected) {
   839    843   		CACKEY_DEBUG_PRINTF("SCardConnect(%s) called", slot->pcsc_reader);
   840         -		scard_conn_ret = SCardConnect(*cackey_pcsc_handle, slot->pcsc_reader, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &slot->pcsc_card, &protocol);
          844  +		scard_conn_ret = SCardConnect(*cackey_pcsc_handle, slot->pcsc_reader, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, &slot->pcsc_card, &protocol);
   841    845   
   842    846   		if (scard_conn_ret != SCARD_S_SUCCESS) {
   843    847   			CACKEY_DEBUG_PRINTF("Connection to card failed, returning in failure (SCardConnect() = %s/%li)", CACKEY_DEBUG_FUNC_SCARDERR_TO_STR(scard_conn_ret), (long) scard_conn_ret);
   844    848   
   845    849   			return(CACKEY_PCSC_E_GENERIC);
   846    850   		}
   847    851   
................................................................................
  1071   1075   	if (class == GSCIS_CLASS_ISO7816 && instruction == GSCIS_INSTR_VERIFY && p1 == 0x00 && p2 == 0x00) {
  1072   1076   		CACKEY_DEBUG_PRINTF("Sending APDU: <<censored>>");
  1073   1077   	} else {
  1074   1078   		CACKEY_DEBUG_PRINTBUF("Sending APDU:", xmit_buf, xmit_len);
  1075   1079   	}
  1076   1080   
  1077   1081   	recv_len = sizeof(recv_buf);
  1078         -	scard_xmit_ret = SCardTransmit(slot->pcsc_card, SCARD_PCI_T0, xmit_buf, xmit_len, SCARD_PCI_T1, recv_buf, &recv_len);
         1082  +	scard_xmit_ret = SCardTransmit(slot->pcsc_card, SCARD_PCI_T0, xmit_buf, xmit_len, NULL, recv_buf, &recv_len);
  1079   1083   	if (scard_xmit_ret != SCARD_S_SUCCESS) {
  1080   1084   		CACKEY_DEBUG_PRINTF("Failed to send APDU to card (SCardTransmit() = %s/%lx)", CACKEY_DEBUG_FUNC_SCARDERR_TO_STR(scard_xmit_ret), (unsigned long) scard_xmit_ret);
  1081   1085   		CACKEY_DEBUG_PRINTF("Marking slot as having been reset");
  1082   1086   
  1083   1087   		slot->transaction_depth = 0;
  1084   1088   		slot->slot_reset = 1;
  1085   1089   
  1086   1090   		if (scard_xmit_ret == SCARD_W_RESET_CARD) {
  1087   1091   			CACKEY_DEBUG_PRINTF("Reset required, please hold...");
  1088   1092   
  1089         -			scard_reconn_ret = SCardReconnect(slot->pcsc_card, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, SCARD_RESET_CARD, &protocol);
         1093  +			scard_reconn_ret = SCardReconnect(slot->pcsc_card, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, SCARD_RESET_CARD, &protocol);
  1090   1094   			if (scard_reconn_ret == SCARD_S_SUCCESS) {
  1091   1095   				/* Re-establish transaction, if it was present */
  1092   1096   				if (slot->transaction_depth > 0) {
  1093   1097   					slot->transaction_depth--;
  1094   1098   					cackey_begin_transaction(slot);
  1095   1099   				}
  1096   1100   
  1097   1101   				CACKEY_DEBUG_PRINTF("Reset successful, retransmitting");
  1098   1102   
  1099   1103   				recv_len = sizeof(recv_buf);
  1100         -				scard_xmit_ret = SCardTransmit(slot->pcsc_card, SCARD_PCI_T0, xmit_buf, xmit_len, SCARD_PCI_T0, recv_buf, &recv_len);
         1104  +				scard_xmit_ret = SCardTransmit(slot->pcsc_card, SCARD_PCI_T0, xmit_buf, xmit_len, NULL, recv_buf, &recv_len);
  1101   1105   
  1102   1106   				if (scard_xmit_ret != SCARD_S_SUCCESS) {
  1103   1107   					CACKEY_DEBUG_PRINTF("Retransmit failed, returning in failure after disconnecting the card (SCardTransmit = %s/%li)", CACKEY_DEBUG_FUNC_SCARDERR_TO_STR(scard_xmit_ret), (long) scard_xmit_ret);
  1104   1108   
  1105   1109   					SCardDisconnect(slot->pcsc_card, SCARD_RESET_CARD);
  1106   1110   					slot->pcsc_card_connected = 0;
  1107   1111