Changeset 747 for branches/smartreader
- Timestamp:
- 12/08/09 17:34:56 (14 years ago)
- Location:
- branches/smartreader
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/smartreader/csctapi/atr.c
r697 r747 32 32 */ 33 33 34 static unsigned long atr_fs_table[16] = { 3571200L, 5000000L, 6000000L, 8000000L, 12000000L, 16000000L, 20000000L , 0L, 0L, 5000000L, 7500000L, 10000000L, 15000000L, 20000000L , 0L, 0L};34 static unsigned long atr_fs_table[16] = {0, 5000000L, 6000000L, 8000000L, 12000000L, 16000000L, 20000000L, 0, 0, 5000000L, 7500000L, 10000000L, 15000000L, 20000000L, 0, 0}; 35 35 36 36 static unsigned atr_num_ib_table[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; … … 42 42 unsigned atr_f_table[16] = {0, 372, 558, 744, 1116, 1488, 1860, 0, 0, 512, 768, 1024, 1536, 2048, 0, 0}; 43 43 44 // double atr_d_table[16] = { 0, 1, 2, 4, 8, 16, 32, 0, 12, 20, 0.5, 0.25, 125, 0.0625, 0.03125, 0.015625};45 // the value bellow are wrong, use these above once the fix for baudrate after aTR is done46 double atr_d_table[16] = {0, 1, 2, 4, 8, 16, 0, 0, 0, 0, 0.5, 0.25, 125, 0.0625, 0.03125, 0.015625};44 double atr_d_table[16] = {0, 1, 2, 4, 8, 16, 32, 0, 12, 20, 0.5, 0.25, 125, 0.0625, 0.03125, 0.015625}; 45 //old table has 0 for RFU: 46 //double atr_d_table[16] = {0, 1, 2, 4, 8, 16, 0, 0, 0, 0, 0.5, 0.25, 125, 0.0625, 0.03125, 0.015625}; 47 47 48 48 unsigned atr_i_table[4] = {25, 50, 100, 0}; -
branches/smartreader/csctapi/icc_async.c
r737 r747 294 294 unsigned long ICC_Async_GetClockRate (ICC_Async * icc) 295 295 { 296 return IFD_Towitoko_GetClockRate(icc->ifd); 296 switch (icc->ifd->io->cardmhz) { 297 case 357: 298 case 358: 299 return (372L * 9600L); 300 case 368: 301 return (384L * 9600L); 302 default: 303 return icc->ifd->io->cardmhz * 10000L; 304 } 297 305 } 298 306 -
branches/smartreader/csctapi/ifd_towitoko.c
r737 r747 979 979 } 980 980 981 unsigned long982 IFD_Towitoko_GetClockRate (IFD * ifd)983 {984 return (372L * 9600L);985 /*986 if (ifd->io->cardmhz == 357 || ifd->io->cardmhz == 358)987 return (372L * 9600L);988 else989 return ifd->io->cardmhz * 10000L; */990 }991 981 992 982 unsigned long -
branches/smartreader/csctapi/ifd_towitoko.h
r8 r747 149 149 extern BYTE IFD_Towitoko_GetFirmware (IFD * ifd); 150 150 extern unsigned IFD_Towitoko_GetNumSlots (IFD * ifd); 151 extern unsigned long IFD_Towitoko_GetClockRate (IFD * ifd);152 151 extern unsigned long IFD_Towitoko_GetMaxBaudrate (IFD * ifd); 153 152 extern void IFD_Towitoko_GetDescription (IFD * ifd, BYTE * desc, unsigned length); -
branches/smartreader/csctapi/pps.c
r737 r747 134 134 if ((*length) <= 0 || !PPS_success) // If not by command, or PPS Exchange by command failed: Try PPS Exchange by ATR or Get parameters from ATR 135 135 { 136 cs_debug("ATR reports smartcard supports %i protocols:",atr->pn); 137 cs_debug("Protocol 1: T0"); 136 //atr->pn contains nr of TDi + 1 137 //so if TD1 exists: number of protocols = atr->pn -1 138 //if TD1 not exists: number of protocols = atr->pn 139 int numprot = atr->pn; 140 BYTE tx; 141 if (ATR_GetInterfaceByte (atr, 1, ATR_INTERFACE_BYTE_TD, &tx) == ATR_OK) 142 numprot--; 143 144 cs_debug("ATR reports smartcard supports %i protocols:",numprot); 138 145 int i,point; 139 146 char txt[50]; 140 for (i= 0; i< atr->pn-1; i++) {141 sprintf(txt,"Protocol %01i: ",i +2);147 for (i=1; i<= numprot; i++) { 148 sprintf(txt,"Protocol %01i: ",i); 142 149 point = 12; 143 if ( atr->ib[i][ATR_INTERFACE_BYTE_TA].present) {144 sprintf((char *)txt+point,"TA%i=%02X ",i, atr->ib[i][ATR_INTERFACE_BYTE_TA].value);150 if (ATR_GetInterfaceByte (atr, i, ATR_INTERFACE_BYTE_TA, &tx) == ATR_OK) { 151 sprintf((char *)txt+point,"TA%i=%02X ",i,tx); 145 152 point +=7; 146 153 } 147 if ( atr->ib[i][ATR_INTERFACE_BYTE_TB].present) {148 sprintf((char *)txt+point,"TB%i=%02X ",i, atr->ib[i][ATR_INTERFACE_BYTE_TB].value);154 if (ATR_GetInterfaceByte (atr, i, ATR_INTERFACE_BYTE_TB, &tx) == ATR_OK) { 155 sprintf((char *)txt+point,"TB%i=%02X ",i,tx); 149 156 point +=7; 150 157 } 151 if ( atr->ib[i][ATR_INTERFACE_BYTE_TC].present) {152 sprintf((char *)txt+point,"TC%i=%02X ",i, atr->ib[i][ATR_INTERFACE_BYTE_TC].value);158 if (ATR_GetInterfaceByte (atr, i, ATR_INTERFACE_BYTE_TC, &tx) == ATR_OK) { 159 sprintf((char *)txt+point,"TC%i=%02X ",i,tx); 153 160 point +=7; 154 161 } 155 if (atr->ib[i][ATR_INTERFACE_BYTE_TD].present) { 156 BYTE TD = atr->ib[i][ATR_INTERFACE_BYTE_TD].value; 157 sprintf((char *)txt+point,"TD%i=%02X ",i,TD); 162 if (ATR_GetInterfaceByte (atr, i, ATR_INTERFACE_BYTE_TD, &tx) == ATR_OK) { 163 sprintf((char *)txt+point,"TD%i=%02X ",i,tx); 158 164 point +=7; 159 sprintf((char *)txt+point,"(T%i)",TD&0x0F); 160 } 165 sprintf((char *)txt+point,"(T%i)",tx&0x0F); 166 } 167 else 168 sprintf((char *)txt+point,"no TD%i means T0",i); 161 169 cs_debug("%s",txt); 162 170 } … … 164 172 //If more than one protocol type and/or TA1 parameter values other than the default values and/or N equeal to 255 is/are indicated in the answer to reset, the card shall know unambiguously, after having sent the answer to reset, which protocol type or/and transmission parameter values (FI, D, N) will be used. Consequently a selection of the protocol type and/or the transmission parameters values shall be specified. 165 173 ATR_GetParameter (atr, ATR_PARAMETER_N, &(pps->parameters.n)); 166 if ( atr->pn> 1 || (atr->ib[0][ATR_INTERFACE_BYTE_TA].present == TRUE && atr->ib[0][ATR_INTERFACE_BYTE_TA].value != 0x11) || pps->parameters.n == 255) {174 if (numprot > 1 || (atr->ib[0][ATR_INTERFACE_BYTE_TA].present == TRUE && atr->ib[0][ATR_INTERFACE_BYTE_TA].value != 0x11) || pps->parameters.n == 255) { 167 175 // PTSS PTS0 PTS1 PTS2 PTS3 PCK 168 176 // PTSS PTS0 PTS1 PCK 169 177 BYTE req[] = { 0xFF, 0x10, 0x00, 0x00 }; //we currently do not support PTS2, standard guardtimes 170 178 171 179 int p; //protocol 1 = T0 , protocol 2 = TD1, 3=TD2 etc 172 for (p=2; p<atr->pn; p++) { 173 ATR_GetProtocolType(atr,p,&(pps->parameters.t)); //get protocol from TDi 174 req[1]=0x10 | pps->parameters.t; //PTS0 always flags PTS1 to be sent always 175 if (ATR_GetInterfaceByte (atr, p, ATR_INTERFACE_BYTE_TA, &req[2]) != ATR_OK) //PTS1 176 continue; 180 for (p=1; p<=numprot; p++) { 181 if (p == 1) 182 pps->parameters.t = 0; //default T0 protocol 183 else 184 ATR_GetProtocolType(atr,p+1,&(pps->parameters.t)); //get protocol from TDi //FIXME p+1 is needed for flaw in atr.c 185 if (pps->parameters.t == 14 && p < numprot) //if T14 and next protocol available 186 continue; //skip T14!!! 187 req[1]=0x10 | pps->parameters.t; //PTS0 always flags PTS1 to be sent always 188 if (ATR_GetInterfaceByte (atr, p, ATR_INTERFACE_BYTE_TA, &req[2]) != ATR_OK) //PTS1 189 req[2] = 0x11; //defaults FI and DI to 1 177 190 //req[3]=PPS_GetPCK(req,sizeof(req)-1); will be set by PPS_Exchange 178 int len = sizeof(req);191 unsigned int len = sizeof(req); 179 192 ret = PPS_Exchange (pps, req, &len); 180 193 if (ret == PPS_OK) { 181 pps->parameters.d = req[2] & 0x0F;182 194 BYTE FI = req[2] >> 4; 183 195 BYTE DI = req[2] & 0x0F; … … 193 205 } 194 206 207 //FIXME now what to do with T14? Currently, it tries PPS and if TA1 is there, it tries to obey it. If that PPS would fail, code below makes it 208 //fallback to default values. 209 //Only problem would arise when a card demands succesfull PPS on T14, and sends TA1 which should not be obeyed (!!) 210 //FIXME Currently InitICC sets baudrate to 9600 for all T14 cards, which is the old behaviour... 195 211 if (!PPS_success) {//last PPS not succesfull 196 // Get protocol offered by interface bytes T*2 if TD1 available, 197 if (atr->pn>1) { 198 ATR_GetProtocolType (atr, 2, &(pps->parameters.t)); 212 if (atr->ib[0][ATR_INTERFACE_BYTE_TA].present == TRUE && pps->parameters.t != 14) { //do not obey TA1 if T14 and no PTS 199 213 ATR_GetParameter (atr, ATR_PARAMETER_D, &(pps->parameters.d)); 200 214 ATR_GetParameter (atr, ATR_PARAMETER_F, &(pps->parameters.f)); 201 cs_debug("No PTS, selected protocol 2: T%i, F=%.0f, D=%.6f, N=%.0f\n", pps->parameters.t, pps->parameters.f, pps->parameters.d, pps->parameters.n); 202 } 203 else {//otherwise use default T0 204 pps->parameters.t = ATR_PROTOCOL_TYPE_T0; 215 } 216 else { 217 pps->parameters.f = ATR_DEFAULT_F; 205 218 pps->parameters.d = ATR_DEFAULT_D; 206 pps->parameters.f = ATR_DEFAULT_F; 207 cs_debug("No PTS, selected protocol 1: T%i, F=%.0f, D=%.6f, N=%.0f\n", pps->parameters.t, pps->parameters.f, pps->parameters.d, pps->parameters.n); 208 } 219 } 220 // Get protocol offered by interface bytes T*2 if TD1 available, 221 // FIXME or would it be wiser to not switch anything and stick to 9600? 222 ATR_GetProtocolType (atr, 2, &(pps->parameters.t)); 223 cs_debug("No PTS, selected protocol 1: T%i, F=%.0f, D=%.6f, N=%.0f\n", pps->parameters.t, pps->parameters.f, pps->parameters.d, pps->parameters.n); 209 224 } 210 225 }//end length<0 226 227 //make sure no zero values 228 if (!pps->parameters.f) { 229 pps->parameters.f = ATR_DEFAULT_F; 230 cs_log("Warning: F=0 is invalid, forcing F=%.0f",pps->parameters.f); 231 } 232 if (!pps->parameters.d) { 233 pps->parameters.d = ATR_DEFAULT_D; 234 cs_log("Warning: D=0 is invalid, forcing D=%.0f",pps->parameters.d); 235 } 211 236 212 237 #ifdef DEBUG_PROTOCOL … … 352 377 #endif 353 378 unsigned long baudrate; 354 355 baudrate = pps->parameters.d * ICC_Async_GetClockRate (pps->icc) / pps->parameters.f; 379 if (pps->parameters.t == 14) 380 baudrate = 9600; 381 else 382 baudrate = pps->parameters.d * ICC_Async_GetClockRate (pps->icc) / pps->parameters.f; 356 383 357 384 #ifdef DEBUG_PROTOCOL -
branches/smartreader/reader-nagra.c
r744 r747 222 222 unsigned char sign2[8]; 223 223 224 if (!has_dt08) memcpy(plainDT08RSA, reader[ridx].rsa_mod, 64); 224 if (!has_dt08) // if we have no valid dt08 calc then we use rsa from config and hexserial for calc of sessionkey 225 { 226 memcpy(plainDT08RSA, reader[ridx].rsa_mod, 64); 227 memcpy(signature,reader[ridx].hexserial, 4); 228 } 225 229 226 230 if(!do_cmd(0x2a,0x02,0xaa,0x42,NULL))
Note:
See TracChangeset
for help on using the changeset viewer.