Changeset 1812


Ignore:
Timestamp:
Mar 8, 2010, 6:07:16 PM (10 years ago)
Author:
merek
Message:

UMP r1857 - dingo35: optimize SECA EMM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/reader-seca.c

    r1766 r1812  
    195195  cs_ddump_mask (D_EMM, ep->emm, emm_length + 3, "EMM:");
    196196  switch (ep->type) {
    197     case SHARED:
    198       {
    199     //to test if SA matches
    200     //first find out prov id
    201     i=get_prov_index(&reader[ridx], (char *) ep->emm+3);
    202     if (i == -1)
    203         return ERROR;
    204     //prov id found, now test for SA (only first 3 bytes, custom byte does not count)
    205     if (memcmp (ep->emm + 5, reader[ridx].sa[i], 3)) {
    206         cs_log("[seca-reader] EMM: Shared update did not match; EMM SA:%02X%02X%02X, provider %i, Reader SA:%s.", ep->emm[5], ep->emm[6], ep->emm[7], i + 1, cs_hexdump (0, reader[ridx].sa[i], 3));
    207         return ERROR;
    208     }
    209     else {
    210         cs_log("[seca-reader] EMM: Shared update matched for EMM SA %02X%02X%02X, provider %i.", ep->emm[5], ep->emm[6], ep->emm[7], i + 1);
    211         ins40[3]=ep->emm[9];
    212         ins40[4]= emm_length - 0x07;
    213         ins40data_offset = 10;
    214     }
    215     break;
    216       }//end shared EMM
     197        case SHARED:
     198            ins40[3]=ep->emm[9];
     199            ins40[4]= emm_length - 0x07;
     200            ins40data_offset = 10;
     201            break;
    217202    case UNIQUE:   
    218       {
    219     //first test if UA matches
    220     if (memcmp (reader[ridx].hexserial, ep->emm + 3, 6)) {
    221         cs_log("[seca-reader] EMM: Unique update did not match; EMM Serial:%02X%02X%02X%02X%02X%02X, Reader Serial:%s.", ep->emm[3], ep->emm[4], ep->emm[5], ep->emm[6], ep->emm[7], ep->emm[8], cs_hexdump (0, reader[ridx].hexserial, 6));
    222         return ERROR;
    223     }
    224     else {
    225         //first find out prov id
    226         i=get_prov_index(&reader[ridx], (char *) ep->emm+9);
    227                 cs_log("[seca-reader] EMM: Unique update matched EMM Serial:%02X%02X%02X%02X%02X, provider %i.", ep->emm[3], ep->emm[4], ep->emm[5], ep->emm[6], ep->emm[7], ep->emm[8], i + 1);
    228 
    229         if (i==-1)
    230             return ERROR;
    231         ins40[3]=ep->emm[12];
    232         ins40[4]= emm_length - 0x0A;
    233         ins40data_offset = 13;
    234     }
    235     break;
    236       } //end unique EMM
     203            ins40[3]=ep->emm[12];
     204            ins40[4]= emm_length - 0x0A;
     205            ins40data_offset = 13;
     206            break;
    237207    case 0x83:  //new unknown EMM
    238208  /*
     
    242212    case 0x88:          //GA???
    243213    case 0x89:          //GA???
    244     default:
    245     cs_log("[seca-reader] EMM: Congratulations, you have discovered a new EMM on SECA. This has not been decoded yet, so send this output to authors:");
    246         cs_dump (ep->emm, emm_length + 3, "EMM:");
    247     return ERROR;   //unknown, no update
     214            default:
     215            cs_log("[seca-reader] EMM: Congratulations, you have discovered a new EMM on SECA. This has not been decoded yet, so send this output to authors:");
     216            cs_dump (ep->emm, emm_length + 3, "EMM:");
     217            return ERROR;   //unknown, no update
    248218  } //end of switch
    249219
     220  i=get_prov_index(&reader[ridx], (char *) ep->emm+9);
     221  if (i==-1)
     222    return ERROR;
    250223  ins40[2]=i;
    251224  write_cmd(ins40, ep->emm + ins40data_offset); //emm request
    252 //TODO  if ((cta_res[16] != 0x90) || (cta_res[17] != 0x00)) return (0);
    253 //  if ((cta_res[16] != 0x90) || (cta_res[17] != 0x19))
    254 //    seca_card_init(); //if return code = 90 19 then PPUA changed. //untested!!
    255 //  else
    256225  if (cta_res[0] == 0x97) {
    257226     cs_log("[seca-reader] EMM: Update not necessary.");
Note: See TracChangeset for help on using the changeset viewer.