- Timestamp:
- 02/17/19 17:44:07 (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/atr.c
r11474 r11502 34 34 { 35 35 unsigned char TDi; 36 unsigned char buffer[ATR_MAX_SIZE] ;36 unsigned char buffer[ATR_MAX_SIZE] = "\x00"; 37 37 uint32_t pointer = 0, pn = 0; 38 38 static const uint32_t atr_num_ib_table[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; -
trunk/csctapi/icc_async.c
r11501 r11502 8 8 #include "ifd_phoenix.h" 9 9 #include "../oscam-time.h" 10 #include "../oscam-work.h"11 10 #ifdef READER_NAGRA_MERLIN 12 11 #include "../cscrypt/fast_aes.h" … … 15 14 #include "../cscrypt/idea.h" 16 15 #endif 17 18 int ishd04 = 0, ishd03 = 0;19 16 20 17 #define OK 0 … … 215 212 } 216 213 217 u nsigned charatrarr[ATR_MAX_SIZE];214 uint8_t atrarr[ATR_MAX_SIZE]; 218 215 uint32_t atr_size; 219 216 ATR_GetRaw(atr, atrarr, &atr_size); … … 223 220 reader->card_atr_length = atr_size; 224 221 225 // Get ICC reader->convention 226 if(ATR_GetConvention(atr, &(reader->convention)) != ATR_OK) 227 { 228 rdr_log(reader, "ERROR: Could not read reader->convention"); 229 reader->convention = 0; 230 reader->protocol_type = 0; 231 return ERROR; 232 } 233 reader->protocol_type = ATR_PROTOCOL_TYPE_T0; 234 if(crdr_ops->lock) 235 { 236 crdr_ops->lock(reader); 237 } 238 int32_t ret = Parse_ATR(reader, atr, deprecated); 239 if(crdr_ops->unlock) 240 { 241 crdr_ops->unlock(reader); 242 } 243 if(ret) 244 { 245 rdr_log(reader, "ERROR: Parse_ATR returned error"); 246 } 247 if(ret) 248 { 249 return ERROR; 250 } 222 // Get ICC reader->convention 223 if(ATR_GetConvention(atr, &(reader->convention)) != ATR_OK) 224 { 225 rdr_log(reader, "ERROR: Could not read reader->convention"); 226 reader->convention = 0; 227 reader->protocol_type = 0; 228 return ERROR; 229 } 230 reader->protocol_type = ATR_PROTOCOL_TYPE_T0; 231 232 // Parse_ATR and InitCard need to be included in lock because they change parity of serial port 233 if(crdr_ops->lock) 234 { 235 crdr_ops->lock(reader); 236 } 237 int32_t ret = Parse_ATR(reader, atr, deprecated); 238 if(crdr_ops->unlock) 239 { 240 crdr_ops->unlock(reader); 241 } 242 if(ret) 243 { 244 rdr_log(reader, "ERROR: Parse_ATR returned error"); 245 return ERROR; 246 } 251 247 252 248 #ifdef READER_NAGRA_MERLIN 253 if(ishd04 == 1) 254 { 255 rdr_log_dbg(reader, D_READER, "HD04 merlin handling"); 249 bool need_nagra_layer_switch = false; 250 bool is_cak7 = false; 251 252 static const uint8_t hd03atr [] = {0x3F,0xFF,0x95,0x00,0xFF,0x91,0x81,0x71,0xA0,0x47,0x00,0x44,0x4E,0x41,0x53,0x50,0x31,0x39,0x30,0x20,0x4D,0x65,0x72,0x51,0x32,0x35,0x4F}; //HD03, HD03A (CAK6.3 Mode) 253 static const uint8_t hd03atr2[] = {0x3F,0xFF,0x95,0x00,0xFF,0x91,0x81,0x71,0xFE,0x57,0x00,0x44,0x4E,0x41,0x53,0x50,0x34,0x31,0x30,0x20,0x52,0x65,0x76,0x51,0x32,0x35,0x17}; //HD03, HD03A (CAK7 Mode) 254 static const uint8_t hd04atr [] = {0x3F,0xFF,0x95,0x00,0xFF,0x91,0x81,0x71,0xFE,0x57,0x00,0x44,0x4E,0x41,0x53,0x50,0x34,0x32,0x30,0x20,0x52,0x65,0x76,0x53,0x36,0x30,0x17}; //HD04, HD04A (CAK7 only) 255 static const uint8_t hd04hatr[] = {0x3F,0xFF,0x95,0x00,0xFF,0x91,0x81,0x71,0xFE,0x57,0x00,0x44,0x4E,0x41,0x53,0x50,0x34,0x32,0x30,0x20,0x52,0x65,0x76,0x53,0x36,0x34,0x13}; //HD04H (CAK7 only) 256 257 ATR_GetRaw(atr, atrarr, &atr_size); 258 if(!memcmp(hd03atr, atrarr, atr_size)) need_nagra_layer_switch = true; 259 if(!memcmp(hd03atr2, atrarr, atr_size) || !memcmp(hd04atr, atrarr, atr_size) || !memcmp(hd04hatr, atrarr, atr_size)) is_cak7 = true; 260 261 if(is_cak7) 262 { 263 rdr_log(reader, "detected nagra merlin card in CAK7 mode"); 256 264 calculate_cak7_vars(reader, atr); 257 265 } 258 else if(ishd03 == 1) // Switch ROM 259 { 266 else if(need_nagra_layer_switch) 267 { 268 rdr_log(reader, "detected nagra merlin card in legacy mode -> try switch nagra layer to CAK7"); 260 269 uint8_t changerom_handshake[] = { 0x80, 0xCA, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 }; 261 270 … … 278 287 } 279 288 280 rdr_log(reader,"try to init nagra layer");281 282 289 if(!ICC_Async_CardWrite(reader, changerom_handshake, sizeof(changerom_handshake), cta_res, &cta_lr)) 283 290 { 284 291 if(cta_res[cta_lr-2] == cta_res1_ok && cta_res[cta_lr-1] == cta_res2_ok) 285 292 { 286 //rdr_log_dbg(reader, D_READER, "switch to nagra layer OK"); 287 rdr_log(reader, "switch to nagra layer OK"); 293 rdr_log(reader, "switch nagra layer OK"); 288 294 memset(atr, 0, 1); 289 295 call(crdr_ops->activate(reader, atr)); //try to read the atr of this layer 290 296 ATR_GetRaw(atr, atrarr, &atr_size); 291 //rdr_log_dbg(reader, D_READER, "Nagra layer ATR: %s", cs_hexdump(1, atrarr, atr_size, tmp, sizeof(tmp)));292 297 rdr_log(reader,"Nagra layer ATR: %s", cs_hexdump(1, atrarr, atr_size, tmp, sizeof(tmp))); 293 298 calculate_cak7_vars(reader, atr); … … 304 309 else 305 310 { 306 //rdr_log_dbg(reader, D_READER, "Switch to nagra layer failed!");307 311 rdr_log(reader,"Switch to nagra layer failed!"); 308 312 return ERROR; -
trunk/csctapi/io_serial.c
r11472 r11502 377 377 cs_ftimeus(&end); 378 378 gone = comp_timebus(&end, &start); 379 rdr_log (reader,"Flush readed byte Nr %d value %.2x time_us %"PRId64, n, b, gone);379 rdr_log_dbg(reader, D_DEVICE, "Flush readed byte Nr %d value %.2x time_us %"PRId64, n, b, gone); 380 380 cs_ftimeus(&start); // Reset timer 381 381 end = start; … … 383 383 cs_ftimeus(&endtotal); 384 384 gone = comp_timebus(&endtotal, &starttotal); 385 rdr_log (reader,"Buffers readed %d bytes total time_us %"PRId64, n, gone);385 rdr_log_dbg(reader, D_DEVICE, "Buffers readed %d bytes total time_us %"PRId64, n, gone); 386 386 } 387 387 -
trunk/oscam-string.c
r11493 r11502 49 49 if(cs_malloc(&newstr, strlen(str) + 1)) 50 50 { 51 strncpy(newstr, str, strlen(str));51 cs_strncpy(newstr, str, strlen(str) + 1); 52 52 return newstr; 53 53 }
Note:
See TracChangeset
for help on using the changeset viewer.