Changeset 1193
- Timestamp:
- 01/12/10 17:00:36 (14 years ago)
- Location:
- trunk/csctapi
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/atr.c
r1137 r1193 153 153 atr->ib[pn][ATR_INTERFACE_BYTE_TD].present = TRUE; 154 154 (atr->TCK).present = ((TDi & 0x0F) != ATR_PROTOCOL_TYPE_T0); 155 if ((TDi & 0xF0) == 0) //last TDi byte156 break;157 155 if (pn >= ATR_MAX_PROTOCOLS) 158 156 return (ATR_MALFORMED); … … 284 282 atr->ib[pn][ATR_INTERFACE_BYTE_TD].present = TRUE; 285 283 (atr->TCK).present = ((TDi & 0x0F) != ATR_PROTOCOL_TYPE_T0); 286 if ((TDi & 0xF0) == 0) //last TDi byte287 break;288 284 if (pn >= ATR_MAX_PROTOCOLS) 289 285 return (ATR_MALFORMED); -
trunk/csctapi/ifd_towitoko.c
r1182 r1193 620 620 if(n==0) 621 621 return IFD_TOWITOKO_IO_ERROR; 622 #endif 622 623 if ((buf[0] !=0x3B) && (buf[0] != 0x3F)) //irdeto S02 reports FD as first byte ?!? 624 buf[0] = 0x3B; 623 625 624 #ifdef SCI_DEV625 626 (*atr) = ATR_New (); 626 627 if(ATR_InitFromArray ((*atr), buf, n) == ATR_OK) … … 630 631 req_ts.tv_nsec = 50000000; 631 632 nanosleep (&req_ts, NULL); 632 #ifdef SCI_DEV633 633 if (ioctl(ifd->io->fd, IOCTL_SET_ATR_READY)<0) 634 634 return IFD_TOWITOKO_IO_ERROR; 635 #endif636 635 return IFD_TOWITOKO_OK; 637 636 } -
trunk/csctapi/pps.c
r1183 r1193 138 138 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 139 139 { 140 int numprot = atr->pn ;//number of protocol lines in ATR140 int numprot = atr->pn-1;//number of protocol lines in ATR 141 141 BYTE tx; 142 cs_debug("ATR reports smartcard supports %i protocols:",numprot);142 cs_debug("ATR reports %i protocol lines:",numprot); 143 143 int i,point; 144 144 char txt[50]; … … 147 147 OffersT[i] = FALSE; 148 148 for (i=1; i<= numprot; i++) { 149 sprintf(txt,"Protocol %01i: ",i); 150 point = 12; 149 point = 0; 151 150 if (ATR_GetInterfaceByte (atr, i, ATR_INTERFACE_BYTE_TA, &tx) == ATR_OK) { 152 151 sprintf((char *)txt+point,"TA%i=%02X ",i,tx); … … 211 210 else { //negotiable mode 212 211 213 bool NeedsPTS = ((pps->parameters.t != 14) && (numprottype > 1 || (atr->ib[0][ATR_INTERFACE_BYTE_TA].present == TRUE && atr->ib[0][ATR_INTERFACE_BYTE_TA].value != 0x11) || pps->parameters.n == 255)); //needs PTS according to ISO 7816 , SCI gets stuck on our PTS 214 if (NeedsPTS) { 215 // PTSS PTS0 PTS1 PTS2 PTS3 PCK 216 // PTSS PTS0 PTS1 PCK 217 BYTE req[] = { 0xFF, 0x10, 0x00, 0x00 }; //we currently do not support PTS2, standard guardtimes 218 219 int p; 220 for (p=1; p<=numprot; p++) { 221 ATR_GetProtocolType(atr,p,&(pps->parameters.t)); 212 bool NeedsPTS = ((pps->parameters.t != 14) && (numprottype > 1 || (atr->ib[0][ATR_INTERFACE_BYTE_TA].present == TRUE && atr->ib[0][ATR_INTERFACE_BYTE_TA].value != 0x11) || pps->parameters.n == 255)); //needs PTS according to ISO 7816 , SCI gets stuck on our PTS 213 if (NeedsPTS) { 214 // PTSS PTS0 PTS1 PTS2 PTS3 PCK 215 // PTSS PTS0 PTS1 PCK 216 BYTE req[] = { 0xFF, 0x10, 0x00, 0x00 }; //we currently do not support PTS2, standard guardtimes 222 217 req[1]=0x10 | pps->parameters.t; //PTS0 always flags PTS1 to be sent always 223 if (ATR_GetInterfaceByte (atr, p, ATR_INTERFACE_BYTE_TA, &req[2]) != ATR_OK) //PTS1218 if (ATR_GetInterfaceByte (atr, 1, ATR_INTERFACE_BYTE_TA, &req[2]) != ATR_OK) //PTS1 224 219 req[2] = 0x11; //defaults FI and DI to 1 225 220 //req[3]=PPS_GetPCK(req,sizeof(req)-1); will be set by PPS_Exchange … … 231 226 pps->parameters.d = (double) (atr_d_table[DI]); 232 227 PPS_success = TRUE; 233 protocol_selected = p; 234 cs_debug("PTS Succesfull, selected protocol %i: T%i, F=%.0f, D=%.6f, N=%.0f\n", protocol_selected, pps->parameters.t, (double) atr_f_table[pps->parameters.FI], pps->parameters.d, pps->parameters.n); 235 break; 228 cs_debug("PTS Succesfull, selected protocol: T%i, F=%.0f, D=%.6f, N=%.0f\n", pps->parameters.t, (double) atr_f_table[pps->parameters.FI], pps->parameters.d, pps->parameters.n); 236 229 } 237 230 else 238 cs_ddump(req,4,"PTS Failure for protocol %i, response:",p); 239 } 240 } 241 242 //FIXME Currently InitICC sets baudrate to 9600 for all T14 cards (=no switching); 243 //When for SCI, T14 protocol, TA1 is obeyed, this goes OK for mosts devices, but somehow on DM7025 Sky S02 card goes wrong when setting ETU (ok on DM800/DM8000) 244 if (!PPS_success) {//last PPS not succesfull 245 BYTE TA1; 246 if (ATR_GetInterfaceByte (atr, 1 , ATR_INTERFACE_BYTE_TA, &TA1) == ATR_OK) { 247 pps->parameters.FI = TA1 >> 4; 248 ATR_GetParameter (atr, ATR_PARAMETER_D, &(pps->parameters.d)); 249 } 250 else { //do not obey TA1 251 pps->parameters.FI = ATR_DEFAULT_FI; 252 pps->parameters.d = ATR_DEFAULT_D; 253 } 254 ATR_GetProtocolType (atr, 1, &(pps->parameters.t)); 255 protocol_selected = 1; 256 257 if (NeedsPTS) { 258 if ((pps->parameters.d == 32) || (pps->parameters.d == 12) || (pps->parameters.d == 20)) 259 pps->parameters.d = 0; //behave conform "old" atr_d_table; viaccess cards that fail PTS need this 260 } 261 /////Here all non-ISO behaviour 262 /////End all non-ISO behaviour 263 264 cs_debug("No PTS %s, selected protocol 1: T%i, F=%.0f, D=%.6f, N=%.0f\n", NeedsPTS?"happened":"needed", pps->parameters.t, (double) atr_f_table[pps->parameters.FI], pps->parameters.d, pps->parameters.n); 265 } 231 cs_ddump(req,4,"PTS Failure, response:"); 232 } 233 234 //FIXME Currently InitICC sets baudrate to 9600 for all T14 cards (=no switching); 235 //When for SCI, T14 protocol, TA1 is obeyed, this goes OK for mosts devices, but somehow on DM7025 Sky S02 card goes wrong when setting ETU (ok on DM800/DM8000) 236 if (!PPS_success) {//last PPS not succesfull 237 BYTE TA1; 238 if (ATR_GetInterfaceByte (atr, 1 , ATR_INTERFACE_BYTE_TA, &TA1) == ATR_OK) { 239 pps->parameters.FI = TA1 >> 4; 240 ATR_GetParameter (atr, ATR_PARAMETER_D, &(pps->parameters.d)); 241 } 242 else { //do not obey TA1 243 pps->parameters.FI = ATR_DEFAULT_FI; 244 pps->parameters.d = ATR_DEFAULT_D; 245 } 246 ATR_GetProtocolType (atr, 1, &(pps->parameters.t)); 247 protocol_selected = 1; 248 249 if (NeedsPTS) { 250 if ((pps->parameters.d == 32) || (pps->parameters.d == 12) || (pps->parameters.d == 20)) 251 pps->parameters.d = 0; //behave conform "old" atr_d_table; viaccess cards that fail PTS need this 252 } 253 /////Here all non-ISO behaviour 254 /////End all non-ISO behaviour 255 256 cs_debug("No PTS %s, selected protocol T%i, F=%.0f, D=%.6f, N=%.0f\n", NeedsPTS?"happened":"needed", pps->parameters.t, (double) atr_f_table[pps->parameters.FI], pps->parameters.d, pps->parameters.n); 257 } 266 258 }//end negotiable mode 267 259 }//end length<0 … … 468 460 469 461 } 470 else471 462 #elif COOL 472 463 if(pps->icc->ifd->io->com==RTYP_SCI) { … … 479 470 return PPS_OK; 480 471 } 481 else482 472 #endif 483 473 {
Note:
See TracChangeset
for help on using the changeset viewer.