Changeset 3122 for trunk/reader-dre.c


Ignore:
Timestamp:
Sep 21, 2010, 12:12:42 PM (9 years ago)
Author:
dingo35
Message:

Making readers cryptoworks, dre threadsafe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/reader-dre.c

    r2853 r3122  
    55#define CMD_BYTE 0x59
    66
    7 static uchar xor (uchar * cmd, int cmdlen)
     7static uchar xor (const uchar * cmd, int cmdlen)
    88{
    99  int i;
     
    1414}
    1515
    16 static int dre_command (struct s_reader * reader, uchar * cmd, int cmdlen, unsigned char * cta_res, unsigned short * p_cta_lr)  //attention: inputcommand will be changed!!!! answer will be in cta_res, length cta_lr ; returning 1 = no error, return ERROR = err
    17 {
    18   static uchar startcmd[] = { 0x80, 0xFF, 0x10, 0x01, 0x05 };   //any command starts with this,
     16static int dre_command (struct s_reader * reader, const uchar * cmd, int cmdlen, unsigned char * cta_res, unsigned short * p_cta_lr)    //attention: inputcommand will be changed!!!! answer will be in cta_res, length cta_lr ; returning 1 = no error, return ERROR = err
     17{
     18  uchar startcmd[] = { 0x80, 0xFF, 0x10, 0x01, 0x05 };  //any command starts with this,
    1919  //last byte is nr of bytes of the command that will be sent
    2020  //after the startcmd
    2121//response on startcmd+cmd:     = { 0x61, 0x05 }  //0x61 = "OK", last byte is nr. of bytes card will send
    22   static uchar reqans[] = { 0x00, 0xC0, 0x00, 0x00, 0x08 }; //after command answer has to be requested,
     22  uchar reqans[] = { 0x00, 0xC0, 0x00, 0x00, 0x08 };    //after command answer has to be requested,
    2323  //last byte must be nr. of bytes that card has reported to send
    2424  uchar command[256];
     
    9292  def_resp;
    9393  int i;
    94   static uchar cmd59[] = { 0x59, 0x14 };    // subscriptions
    95   static uchar cmd5b[] = { 0x5b, 0x00, 0x14 };  //validity dates
     94  uchar cmd59[] = { 0x59, 0x14 };   // subscriptions
     95  uchar cmd5b[] = { 0x5b, 0x00, 0x14 }; //validity dates
    9696
    9797  cmd59[1] = reader->provider;
     
    136136    get_atr;
    137137  def_resp;
    138   static uchar ua[] = { 0x43, 0x15 };   // get serial number (UA)
    139   static uchar providers[] = { 0x49, 0x15 };    // get providers
     138  uchar ua[] = { 0x43, 0x15 };  // get serial number (UA)
     139  uchar providers[] = { 0x49, 0x15 };   // get providers
    140140  int i;
    141141    char *card;
     
    175175  memset (reader->prid, 0x00, 8);
    176176
    177   static uchar cmd30[] =
     177  static const uchar cmd30[] =
    178178    { 0x30, 0x81, 0x00, 0x81, 0x82, 0x03, 0x84, 0x05, 0x06, 0x87, 0x08, 0x09, 0x00, 0x81, 0x82, 0x03, 0x84, 0x05,
    179179    0x00
     
    185185FE 48 */
    186186
    187   static uchar cmd54[] = { 0x54, 0x14 };    // geocode
     187  uchar cmd54[] = { 0x54, 0x14 };   // geocode
    188188  cmd54[1] = reader->provider;
    189189  uchar geocode = 0;
     
    250250  def_resp;
    251251  if (reader->caid[0] == 0x4ae0) {
    252     static uchar ecmcmd41[] = { 0x41,
     252    uchar ecmcmd41[] = { 0x41,
    253253      0x58, 0x1f, 0x00,     //fixed part, dont change
    254254      0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,   //0x01 - 0x08: next key
     
    273273  else {
    274274
    275     static uchar ecmcmd51[] = { 0x51, 0x02, 0x56, 0x05, 0x00, 0x4A, 0xE3,   //fixed header?
     275    uchar ecmcmd51[] = { 0x51, 0x02, 0x56, 0x05, 0x00, 0x4A, 0xE3,  //fixed header?
    276276      0x9C, 0xDA,       //first three nibbles count up, fourth nibble counts down; all ECMs sent twice
    277277      0xC1, 0x71, 0x21, 0x06, 0xF0, 0x14, 0xA7, 0x0E,   //next key?
     
    363363    if(ep->type == UNIQUE && ep->emm[39] == 0x3d)
    364364    { /* For new package activation. */
    365         static uchar emmcmd58[26];
     365        uchar emmcmd58[26];
    366366        emmcmd58[0] = 0x58;
    367367        memcpy(&emmcmd58[1], &ep->emm[40], 24);
     
    373373    else
    374374    {
    375         static uchar emmcmd52[0x3a];
     375        uchar emmcmd52[0x3a];
    376376        emmcmd52[0] = 0x52;
    377377        int i;
     
    389389  }
    390390  else {
    391     static uchar emmcmd42[] =
     391    uchar emmcmd42[] =
    392392      { 0x42, 0x85, 0x58, 0x01, 0xC8, 0x00, 0x00, 0x00, 0x05, 0xB8, 0x0C, 0xBD, 0x7B, 0x07, 0x04, 0xC8,
    393393      0x77, 0x31, 0x95, 0xF2, 0x30, 0xB7, 0xE9, 0xEE, 0x0F, 0x81, 0x39, 0x1C, 0x1F, 0xA9, 0x11, 0x3E,
Note: See TracChangeset for help on using the changeset viewer.