Changeset 11478 for trunk/reader-dgcrypt.c
- Timestamp:
- 01/18/19 23:36:20 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/reader-dgcrypt.c
r10582 r11478 7 7 static const uint8_t dgcrypt_atr[8] = { 0x3B, 0xE9, 0x00, 0x00, 0x81, 0x31, 0xC3, 0x45 }; 8 8 static const uint8_t cmd_CWKEY[5] = { 0x81, 0xD0, 0x00, 0x01, 0x08 }; 9 //static const uint8_t cmd_CAID[5] 9 //static const uint8_t cmd_CAID[5] = { 0x81, 0xC0, 0x00, 0x01, 0x0A }; 10 10 static const uint8_t cmd_SERIAL[5] = { 0x81, 0xD1, 0x00, 0x01, 0x10 }; 11 11 static const uint8_t cmd_LABEL[5] = { 0x81, 0xD2, 0x00, 0x01, 0x10 }; 12 //static const uint8_t cmd_SUBSYS[5] 12 //static const uint8_t cmd_SUBSYS[5] = { 0x81, 0xDD, 0x00, 0x10, 0x04 }; 13 13 static const uint8_t cmd_ECM[3] = { 0x80, 0xEA, 0x80 }; 14 14 15 15 struct dgcrypt_data 16 16 { 17 uint8_t 17 uint8_t session_key[16]; 18 18 }; 19 19 … … 21 21 { 22 22 rdr->ifsc = 195; 23 rdr->ns = 1; 23 rdr->ns = 1; 24 24 25 if(DEBUG) 25 26 { … … 28 29 } 29 30 int32_t ret = reader_cmd2icc(rdr, buf, buflen, response, response_length); 31 30 32 if(DEBUG) 31 33 { … … 34 36 } 35 37 // reader_cmd2icc retuns ERROR=1, OK=0 - the opposite of OK and ERROR defines in reader-common.h 38 36 39 if(ret) 37 40 { … … 39 42 return ERROR; 40 43 } 44 41 45 if(*response_length < 2 || *response_length < min_response_len) 42 46 { … … 44 48 return ERROR; // Response is two short 45 49 } 50 46 51 if(response[*response_length - 2] != 0x90 || response[*response_length - 1] != 0x00) 47 52 { … … 67 72 if(!cs_malloc(&rdr->csystem_data, sizeof(struct dgcrypt_data))) 68 73 { return ERROR; } 74 69 75 struct dgcrypt_data *csystem_data = rdr->csystem_data; 70 76 … … 76 82 77 83 rdr->nprov = 1; 78 rdr->caid 84 rdr->caid = 0x4ABF; 79 85 80 86 // Get session key 81 // 82 // 87 // Send: 81 D0 00 01 08 88 // Recv: 32 86 17 D5 2C 66 61 14 90 00 83 89 if(!dgcrypt_cmd(rdr, cmd_CWKEY, sizeof(cmd_CWKEY), cta_res, &cta_lr, 8)) 84 90 { return ERROR; } … … 87 93 88 94 // Get CAID 89 // 90 // 91 // 92 // 93 // 95 // Send: 81 C0 00 01 0A 96 // Recv: 4A BF 90 00 97 // if (!dgcrypt_cmd(rdr, cmd_CAID, sizeof(cmd_CAID), cta_res, &cta_lr, 2)) 98 // return ERROR; 99 // rdr->caid = (cta_res[0] << 8) | cta_res[1]; 94 100 95 101 // Get serial number 96 // 97 // 102 // Send: 81 D1 00 01 10 103 // Recv: 00 0D DB 08 71 0D D5 0C 30 30 30 30 30 30 30 30 90 00 98 104 if(!dgcrypt_cmd(rdr, cmd_SERIAL, sizeof(cmd_SERIAL), cta_res, &cta_lr, 8)) 99 105 { return ERROR; } … … 101 107 102 108 // Get LABEL 103 // 104 // 105 // 109 // Send: 81 D2 00 01 10 110 // Recv: 50 61 79 5F 54 56 5F 43 61 72 64 00 00 00 00 00 90 00 111 // Txt: P a y _ T V _ C a r d 106 112 if(!dgcrypt_cmd(rdr, cmd_LABEL, sizeof(cmd_LABEL), cta_res, &cta_lr, 16)) 107 113 { return ERROR; } … … 111 117 112 118 // Get subsystem - !FIXME! We are not using the answer of this command! 113 // 114 // 119 // Send: 81 DD 00 10 04 120 // Recv: 00 55 00 55 90 00 115 121 if(!dgcrypt_cmd(rdr, cmd_LABEL, sizeof(cmd_LABEL), cta_res, &cta_lr, 4)) 116 122 { return ERROR; } 117 123 118 124 rdr_log_sensitive(rdr, "CAID: 0x%04X, Serial: {%"PRIu64"} HexSerial: {%02X %02X %02X %02X %02X %02X %02X} Label: {%s}", 119 120 121 122 123 125 rdr->caid, 126 b2ll(7, rdr->hexserial), 127 rdr->hexserial[0], rdr->hexserial[1], rdr->hexserial[2], 128 rdr->hexserial[3], rdr->hexserial[4], rdr->hexserial[5], rdr->hexserial[6], 129 label); 124 130 125 131 return OK; … … 137 143 138 144 // Write ECM 139 // 140 // 145 // Send: 80 EA 80 00 55 00 00 3F 90 03 00 00 18 5D 82 4E 01 C4 2D 60 12 ED 34 37 ED 72 .. .. .. 146 // Recv: 72 25 8D A1 0D 0D D2 44 EE ED 51 2F 3B 5D 19 63 E6 90 00 141 147 if(!dgcrypt_cmd(rdr, cmd_buffer, er->ecm[2] + 3, cta_res, &cta_lr, 17)) 142 148 { return ERROR; } 143 if(cta_res[0] != 0x72) // CW response MUST start with 0x72 149 150 if(cta_res[0] != 0x72) // CW response MUST start with 0x72 144 151 { return ERROR; } 145 152
Note:
See TracChangeset
for help on using the changeset viewer.