1 | #include "globals.h"
|
---|
2 | #include "reader-common.h"
|
---|
3 | #include "reader-videoguard-common.h"
|
---|
4 |
|
---|
5 | static void read_tiers(struct s_reader * reader)
|
---|
6 | {
|
---|
7 | def_resp;
|
---|
8 | static const unsigned char ins2a[5] = { 0x48,0x2a,0x00,0x00,0x00 };
|
---|
9 | int l;
|
---|
10 | l=do_cmd(reader,ins2a,NULL,NULL,NULL,cta_res);
|
---|
11 | if(l<0 || !status_ok(cta_res+l)) return;
|
---|
12 | unsigned char ins76[5] = { 0x48,0x76,0x00,0x00,0x00 };
|
---|
13 | ins76[3]=0x7f; ins76[4]=2;
|
---|
14 | if(!write_cmd_vg(ins76,NULL) || !status_ok(cta_res+2)) return;
|
---|
15 | ins76[3]=0; ins76[4]=0;
|
---|
16 | int num=cta_res[1];
|
---|
17 | int i;
|
---|
18 |
|
---|
19 | for(i=0; i<num; i++) {
|
---|
20 | ins76[2]=i;
|
---|
21 | l=do_cmd(reader,ins76,NULL,NULL,NULL,cta_res);
|
---|
22 | if(l<0 || !status_ok(cta_res+l)) return;
|
---|
23 | if(cta_res[2]==0 && cta_res[3]==0) break;
|
---|
24 | int y,m,d,H,M,S;
|
---|
25 | rev_date_calc(&cta_res[4],&y,&m,&d,&H,&M,&S,reader->card_baseyear);
|
---|
26 | unsigned short tier_id = (cta_res[2] << 8) | cta_res[3];
|
---|
27 | char *tier_name = get_tiername(tier_id, reader->caid[0]);
|
---|
28 | cs_ri_log(reader, "[videoguard12-reader] tier: %04x, expiry date: %04d/%02d/%02d-%02d:%02d:%02d %s",tier_id,y,m,d,H,M,S,tier_name);
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | int videoguard12_card_init(struct s_reader * reader, ATR newatr)
|
---|
33 | {
|
---|
34 |
|
---|
35 | get_hist;
|
---|
36 | if ((hist_size < 7) || (hist[1] != 0xB0) || (hist[4] != 0xFF) || (hist[5] != 0x4A) || (hist[6] != 0x50)){
|
---|
37 | return ERROR;
|
---|
38 | }
|
---|
39 |
|
---|
40 | get_atr;
|
---|
41 | def_resp;
|
---|
42 |
|
---|
43 | /* set information on the card stored in reader-videoguard-common.c */
|
---|
44 | set_known_card_info(reader,atr,&atr_size);
|
---|
45 |
|
---|
46 | if((reader->ndsversion != NDS12) && ((reader->card_system_version != NDS12) || (reader->ndsversion != NDSAUTO))) {
|
---|
47 | /* known ATR and not NDS1+
|
---|
48 | or unknown ATR and not forced to NDS1+
|
---|
49 | or known NDS1+ ATR and forced to another NDS version
|
---|
50 | ... probably not NDS1+ */
|
---|
51 | return ERROR;
|
---|
52 | }
|
---|
53 |
|
---|
54 | cs_ri_log(reader, "[videoguard12-reader] type: %s, baseyear: %i", reader->card_desc, reader->card_baseyear);
|
---|
55 | if(reader->ndsversion == NDS12){
|
---|
56 | cs_log("[videoguard12-reader] forced to NDS1+");
|
---|
57 | }
|
---|
58 |
|
---|
59 | int l = 1;
|
---|
60 |
|
---|
61 | /* NDS1 and NDS1+ cards return XX 90 00 to this command NDS2 cards fail to respond to this*/
|
---|
62 | static const unsigned char ins3601[5] = { 0x48,0x36,0x01,0x00,0x01 };
|
---|
63 | if(!write_cmd_vg(ins3601,NULL) || !status_ok(cta_res+l)) {
|
---|
64 | return ERROR; // not a possible NDS1+ card
|
---|
65 | }
|
---|
66 |
|
---|
67 | static const unsigned char dummy_cmd_table[132] = {
|
---|
68 | 0x01, 0x82, 0x20, 0x01,
|
---|
69 | 0x48, 0x0E, 0xFF, 0x02,
|
---|
70 | 0x48, 0x18, 0x0C, 0x01,
|
---|
71 | 0x48, 0x1A, 0x08, 0x03,
|
---|
72 | 0x48, 0x1E, 0x09, 0x03,
|
---|
73 | 0x48, 0x2E, 0xFF, 0x00,
|
---|
74 | 0x48, 0x32, 0x01, 0x01,
|
---|
75 | 0x48, 0x36, 0xFF, 0x02,
|
---|
76 | 0x48, 0x38, 0x02, 0x03,
|
---|
77 | 0x48, 0x40, 0xFF, 0x00,
|
---|
78 | 0x48, 0x42, 0xFF, 0x00,
|
---|
79 | 0x48, 0x44, 0x35, 0x01,
|
---|
80 | 0x48, 0x46, 0xFF, 0x00,
|
---|
81 | 0x48, 0x4A, 0xFF, 0x00,
|
---|
82 | 0x48, 0x4C, 0x09, 0x01,
|
---|
83 | 0x48, 0x4E, 0x05, 0x03,
|
---|
84 | 0x48, 0x50, 0xFF, 0x02,
|
---|
85 | 0x48, 0x54, 0x2C, 0x03,
|
---|
86 | 0x48, 0x56, 0xFF, 0x02,
|
---|
87 | 0x48, 0x58, 0x4A, 0x03,
|
---|
88 | 0x48, 0x5A, 0xFF, 0x02,
|
---|
89 | 0x48, 0x5C, 0x04, 0x03,
|
---|
90 | 0x48, 0x5E, 0xFF, 0x02,
|
---|
91 | 0x48, 0x70, 0x25, 0x03,
|
---|
92 | 0x48, 0x72, 0x23, 0x03,
|
---|
93 | 0x48, 0x74, 0xFF, 0x02,
|
---|
94 | 0x48, 0x76, 0x0A, 0x03,
|
---|
95 | 0x48, 0x78, 0x18, 0x03,
|
---|
96 | 0x48, 0x7A, 0xFF, 0x00,
|
---|
97 | 0x48, 0x7C, 0xFF, 0x02,
|
---|
98 | 0x48, 0xB4, 0x40, 0x01,
|
---|
99 | 0x48, 0xBC, 0x50, 0x03,
|
---|
100 | 0x48, 0xBE, 0x10, 0x03 };
|
---|
101 |
|
---|
102 | memorize_cmd_table (reader,dummy_cmd_table,132);
|
---|
103 |
|
---|
104 | unsigned char buff[256];
|
---|
105 |
|
---|
106 | /* Read card serial number to initialise the card
|
---|
107 | unsigned char ins52[5] = { 0x48,0x52,0x00,0x00,0x14 };
|
---|
108 |
|
---|
109 | if(!write_cmd_vg(ins52,NULL) || !status_ok(cta_res+l)) {
|
---|
110 | cs_log ("[videoguard12-reader] failed to read serial");
|
---|
111 | return ERROR;
|
---|
112 | }
|
---|
113 | */
|
---|
114 |
|
---|
115 | static const unsigned char ins36[5] = { 0x48,0x36,0x00,0x00,0x00 };
|
---|
116 | unsigned char boxID [4];
|
---|
117 |
|
---|
118 | if (reader->boxid > 0) {
|
---|
119 | /* the boxid is specified in the config */
|
---|
120 | int i;
|
---|
121 | for (i=0; i < 4; i++) {
|
---|
122 | boxID[i] = (reader->boxid >> (8 * (3 - i))) % 0x100;
|
---|
123 | }
|
---|
124 | } else {
|
---|
125 | /* we can try to get the boxid from the card */
|
---|
126 | int boxidOK=0;
|
---|
127 | l=do_cmd(reader,ins36,NULL,buff,NULL,cta_res);
|
---|
128 | if(l<13)
|
---|
129 | cs_log("[videoguard12-reader] ins36: too short answer");
|
---|
130 | else if (buff[7] > 0x0F)
|
---|
131 | cs_log("[videoguard12-reader] ins36: encrypted - can't parse");
|
---|
132 | else {
|
---|
133 | /* skipping the initial fixed fields: cmdecho (4) + length (1) + encr/rev++ (4) */
|
---|
134 | int i=9;
|
---|
135 | int gotUA=0;
|
---|
136 | while (i<l) {
|
---|
137 | if (!gotUA && buff[i]<0xF0) { /* then we guess that the next 4 bytes is the UA */
|
---|
138 | gotUA=1;
|
---|
139 | i+=4;
|
---|
140 | } else switch (buff[i]) { /* object length vary depending on type */
|
---|
141 | case 0x00: /* padding */
|
---|
142 | i+=1;
|
---|
143 | break;
|
---|
144 | case 0xEF: /* card status */
|
---|
145 | i+=3;
|
---|
146 | break;
|
---|
147 | case 0xD1:
|
---|
148 | i+=4;
|
---|
149 | break;
|
---|
150 | case 0xDF: /* next server contact */
|
---|
151 | i+=5;
|
---|
152 | break;
|
---|
153 | case 0xF3: /* boxID */
|
---|
154 | memcpy(boxID,buff+i+1,sizeof(boxID));
|
---|
155 | boxidOK=1;
|
---|
156 | i+=5;
|
---|
157 | break;
|
---|
158 | case 0xF6:
|
---|
159 | i+=6;
|
---|
160 | break;
|
---|
161 | case 0x01: /* date & time */
|
---|
162 | i+=7;
|
---|
163 | break;
|
---|
164 | case 0xFA:
|
---|
165 | i+=9;
|
---|
166 | break;
|
---|
167 | case 0x5E:
|
---|
168 | case 0x67: /* signature */
|
---|
169 | case 0xDE:
|
---|
170 | case 0xE2:
|
---|
171 | case 0xE9: /* tier dates */
|
---|
172 | case 0xF8: /* Old PPV Event Record */
|
---|
173 | case 0xFD:
|
---|
174 | i+=buff[i+1]+2; /* skip length + 2 bytes (type and length) */
|
---|
175 | break;
|
---|
176 | default: /* default to assume a length byte */
|
---|
177 | cs_log("[videoguard12-reader] ins36 returned unknown type=0x%02X - parsing may fail", buff[i]);
|
---|
178 | i+=buff[i+1]+2;
|
---|
179 | }
|
---|
180 | }
|
---|
181 | }
|
---|
182 |
|
---|
183 | if(!boxidOK) {
|
---|
184 | cs_log ("[videoguard12-reader] no boxID available");
|
---|
185 | return ERROR;
|
---|
186 | }
|
---|
187 | }
|
---|
188 |
|
---|
189 | static const unsigned char ins4C[5] = { 0x48,0x4C,0x00,0x00,0x09 };
|
---|
190 | unsigned char payload4C[9] = { 0,0,0,0, 3,0,0,0,4 };
|
---|
191 | memcpy(payload4C,boxID,4);
|
---|
192 | if(!write_cmd_vg(ins4C,payload4C) || !status_ok(cta_res+l)) {
|
---|
193 | cs_log("[videoguard12-reader] sending boxid failed");
|
---|
194 | return ERROR;
|
---|
195 | }
|
---|
196 |
|
---|
197 | //short int SWIRDstatus = cta_res[1];
|
---|
198 | static const unsigned char ins58[5] = { 0x48,0x58,0x00,0x00,0x00 };
|
---|
199 | l=do_cmd(reader,ins58,NULL,buff,NULL,cta_res);
|
---|
200 | if(l<0) {
|
---|
201 | cs_log("[videoguard12-reader] cmd ins58 failed");
|
---|
202 | return ERROR;
|
---|
203 | }
|
---|
204 | memset(reader->hexserial, 0, 8);
|
---|
205 | memcpy(reader->hexserial+2, cta_res+3, 4);
|
---|
206 | memcpy(reader->sa, cta_res+3, 3);
|
---|
207 | reader->caid[0] = cta_res[24]*0x100+cta_res[25];
|
---|
208 |
|
---|
209 | /* we have one provider, 0x0000 */
|
---|
210 | reader->nprov = 1;
|
---|
211 | memset(reader->prid, 0x00, sizeof(reader->prid));
|
---|
212 |
|
---|
213 | /*
|
---|
214 | cs_log ("[videoguard12-reader] INS58 : Fuse byte=0x%02X, IRDStatus=0x%02X", cta_res[2],SWIRDstatus);
|
---|
215 | if (SWIRDstatus==4) {
|
---|
216 | // If swMarriage=4, not married then exchange for BC Key
|
---|
217 | cs_log ("[videoguard12-reader] Card not married, exchange for BC Keys");
|
---|
218 | */
|
---|
219 |
|
---|
220 | cCamCryptVG_SetSeed(reader);
|
---|
221 |
|
---|
222 | static const unsigned char insB4[5] = { 0x48,0xB4,0x00,0x00,0x40 };
|
---|
223 | unsigned char tbuff[64];
|
---|
224 | cCamCryptVG_GetCamKey(reader,tbuff);
|
---|
225 | l=do_cmd(reader,insB4,tbuff,NULL,NULL,cta_res);
|
---|
226 | if(l<0 || !status_ok(cta_res)) {
|
---|
227 | cs_log ("[videoguard12-reader] cmd D0B4 failed (%02X%02X)", cta_res[0], cta_res[1]);
|
---|
228 | return ERROR;
|
---|
229 | }
|
---|
230 |
|
---|
231 | static const unsigned char insBC[5] = { 0x48,0xBC,0x00,0x00,0x00 };
|
---|
232 | l=do_cmd(reader,insBC,NULL,NULL,NULL,cta_res);
|
---|
233 | if(l<0) {
|
---|
234 | cs_log("[videoguard12-reader] cmd D0BC failed");
|
---|
235 | return ERROR;
|
---|
236 | }
|
---|
237 |
|
---|
238 | static const unsigned char insBE[5] = { 0x48,0xBE,0x00,0x00,0x00 };
|
---|
239 | l=do_cmd(reader,insBE,NULL,NULL,NULL,cta_res);
|
---|
240 | if(l<0) {
|
---|
241 | cs_log("[videoguard12-reader] cmd D3BE failed");
|
---|
242 | return ERROR;
|
---|
243 | }
|
---|
244 |
|
---|
245 | static const unsigned char ins58a[5] = { 0x49,0x58,0x00,0x00,0x00 };
|
---|
246 | l=do_cmd(reader,ins58a,NULL,NULL,NULL,cta_res);
|
---|
247 | if(l<0) {
|
---|
248 | cs_log("[videoguard12-reader] cmd D158 failed");
|
---|
249 | return ERROR;
|
---|
250 | }
|
---|
251 |
|
---|
252 | static const unsigned char ins4Ca[5] = { 0x49,0x4C,0x00,0x00,0x00 };
|
---|
253 | l=do_cmd(reader,ins4Ca,payload4C,NULL,NULL,cta_res);
|
---|
254 | if(l<0 || !status_ok(cta_res)) {
|
---|
255 | cs_log("[videoguard12-reader] cmd D14Ca failed");
|
---|
256 | return ERROR;
|
---|
257 | }
|
---|
258 |
|
---|
259 | // fix for 09ac cards
|
---|
260 | unsigned char dimeno_magic[0x10]={0xF9,0xFB,0xCD,0x5A,0x76,0xB5,0xC4,0x5C,0xC8,0x2E,0x1D,0xE1,0xCC,0x5B,0x6B,0x02};
|
---|
261 | int a;
|
---|
262 | for(a=0; a<4; a++)
|
---|
263 | dimeno_magic[a]=dimeno_magic[a]^boxID[a];
|
---|
264 | AES_set_decrypt_key(dimeno_magic,128,&(reader->astrokey));
|
---|
265 |
|
---|
266 | cs_ri_log(reader, "[videoguard12-reader] type: VideoGuard, caid: %04X, serial: %02X%02X%02X%02X, BoxID: %02X%02X%02X%02X",
|
---|
267 | reader->caid[0],
|
---|
268 | reader->hexserial[2],reader->hexserial[3],reader->hexserial[4],reader->hexserial[5],
|
---|
269 | boxID[0],boxID[1],boxID[2],boxID[3]);
|
---|
270 |
|
---|
271 | cs_log("[videoguard12-reader] ready for requests");
|
---|
272 |
|
---|
273 | return OK;
|
---|
274 | }
|
---|
275 |
|
---|
276 | int videoguard12_do_ecm(struct s_reader * reader, ECM_REQUEST *er)
|
---|
277 | {
|
---|
278 | unsigned char cta_res[CTA_RES_LEN];
|
---|
279 | unsigned char ins40[5] = { 0x49,0x40,0x00,0x80,0xFF };
|
---|
280 | static const unsigned char ins54[5] = { 0x4B,0x54,0x00,0x00,0x00};
|
---|
281 | int posECMpart2=er->ecm[6]+7;
|
---|
282 | int lenECMpart2=er->ecm[posECMpart2]+1;
|
---|
283 | unsigned char tbuff[264];
|
---|
284 | tbuff[0]=0;
|
---|
285 | memcpy(tbuff+1,er->ecm+posECMpart2+1,lenECMpart2-1);
|
---|
286 | ins40[4]=lenECMpart2;
|
---|
287 | int l;
|
---|
288 | l = do_cmd(reader,ins40,tbuff,NULL,NULL,cta_res);
|
---|
289 | if(l>0 && status_ok(cta_res)) {
|
---|
290 | l = do_cmd(reader,ins54,NULL,NULL,er->cw,cta_res);
|
---|
291 | if(l>0 && status_ok(cta_res+l)) {
|
---|
292 | if (!cw_is_valid(er->cw+0,0)) //sky cards report 90 00 = ok but send cw = 00 when channel not subscribed
|
---|
293 | {
|
---|
294 | cs_log("[reader-videoguard12] ins54 returned status 90 00 but cw=00 -> channel not subscribed " );
|
---|
295 | return ERROR;
|
---|
296 | }
|
---|
297 |
|
---|
298 | if(er->ecm[0]&1) {
|
---|
299 | unsigned char tmpcw[8];
|
---|
300 | memcpy(tmpcw,er->cw+8,8);
|
---|
301 | memcpy(er->cw+8,er->cw+0,8);
|
---|
302 | memcpy(er->cw+0,tmpcw,8);
|
---|
303 | }
|
---|
304 |
|
---|
305 | //test for postprocessing marker
|
---|
306 | int posB0 = -1;
|
---|
307 | int i;
|
---|
308 | for (i = 6; i < posECMpart2; i++)
|
---|
309 | {
|
---|
310 | if (er->ecm[i-3] == 0x80 && er->ecm[i] == 0xB0 && ((er->ecm[i+1] == 0x01) ||(er->ecm[i+1] == 0x02)||(er->ecm[i+1] == 0x03) ) ) {
|
---|
311 | posB0 = i;
|
---|
312 | break;
|
---|
313 | }
|
---|
314 | }
|
---|
315 |
|
---|
316 | if (posB0 != -1) {
|
---|
317 | do_post_dw_hash( er->cw+0, &er->ecm[posB0-2]);
|
---|
318 | do_post_dw_hash( er->cw+8, &er->ecm[posB0-2]);
|
---|
319 | }
|
---|
320 |
|
---|
321 | return OK;
|
---|
322 | }
|
---|
323 | }
|
---|
324 | cs_log("[reader-videoguard12] ins54 (%d) status not ok %02x %02x",l, cta_res[0],cta_res[1] );
|
---|
325 | return ERROR;
|
---|
326 | }
|
---|
327 |
|
---|
328 | int videoguard12_get_emm_type(EMM_PACKET *ep, struct s_reader * rdr)
|
---|
329 | {
|
---|
330 |
|
---|
331 | /*
|
---|
332 | 82 30 ad 70 00 XX XX XX 00 XX XX XX 00 XX XX XX 00 XX XX XX 00 00
|
---|
333 | d3 02 00 22 90 20 44 02 4a 50 1d 88 ab 02 ac 79 16 6c df a1 b1 b7 77 00 ba eb 63 b5 c9 a9 30 2b 43 e9 16 a9 d5 14 00
|
---|
334 | d3 02 00 22 90 20 44 02 13 e3 40 bd 29 e4 90 97 c3 aa 93 db 8d f5 6b e4 92 dd 00 9b 51 03 c9 3d d0 e2 37 44 d3 bf 00
|
---|
335 | d3 02 00 22 90 20 44 02 97 79 5d 18 96 5f 3a 67 70 55 bb b9 d2 49 31 bd 18 17 2a e9 6f eb d8 76 ec c3 c9 cc 53 39 00
|
---|
336 | d2 02 00 21 90 1f 44 02 99 6d df 36 54 9c 7c 78 1b 21 54 d9 d4 9f c1 80 3c 46 10 76 aa 75 ef d6 82 27 2e 44 7b 00
|
---|
337 | */
|
---|
338 |
|
---|
339 | int i, pos;
|
---|
340 | int serial_count = ((ep->emm[3] >> 4) & 3) + 1;
|
---|
341 | int serial_len = (ep->emm[3] & 0x80) ? 3 : 4;
|
---|
342 | uchar emmtype = (ep->emm[3] & VG_EMMTYPE_MASK) >> 6;
|
---|
343 |
|
---|
344 | pos = 4 + (serial_len * serial_count) + 2;
|
---|
345 |
|
---|
346 | switch(emmtype) {
|
---|
347 | case VG_EMMTYPE_G:
|
---|
348 | ep->type=GLOBAL;
|
---|
349 | cs_debug_mask(D_EMM, "VIDEOGUARD12 EMM: GLOBAL");
|
---|
350 | return TRUE;
|
---|
351 |
|
---|
352 | case VG_EMMTYPE_U:
|
---|
353 | cs_debug_mask(D_EMM, "VIDEOGUARD12 EMM: UNIQUE");
|
---|
354 | ep->type=UNIQUE;
|
---|
355 | if (ep->emm[1] == 0) // detected UNIQUE EMM from cccam (there is no serial)
|
---|
356 | return TRUE;
|
---|
357 |
|
---|
358 | for (i = 1;i <= serial_count;i++) {
|
---|
359 | if (!memcmp (rdr->hexserial + 2, ep->emm + (serial_len * i), serial_len)) {
|
---|
360 | memcpy(ep->hexserial, ep->emm + (serial_len * i), serial_len);
|
---|
361 | return TRUE;
|
---|
362 | }
|
---|
363 |
|
---|
364 | pos = pos + ep->emm[pos+5] + 5;
|
---|
365 | }
|
---|
366 | return FALSE; // if UNIQUE but no serial match return FALSE
|
---|
367 |
|
---|
368 | case VG_EMMTYPE_S:
|
---|
369 | ep->type=SHARED;
|
---|
370 | cs_debug_mask(D_EMM, "VIDEOGUARD12 EMM: SHARED");
|
---|
371 | return TRUE; // FIXME: no check for SA
|
---|
372 |
|
---|
373 | default:
|
---|
374 | if (ep->emm[pos-2] != 0x00 && ep->emm[pos-1] != 0x00 && ep->emm[pos-1] != 0x01) {
|
---|
375 | //remote emm without serial
|
---|
376 | ep->type=UNKNOWN;
|
---|
377 | return TRUE;
|
---|
378 | }
|
---|
379 | return FALSE;
|
---|
380 | }
|
---|
381 | }
|
---|
382 |
|
---|
383 | void videoguard12_get_emm_filter(struct s_reader * rdr, uchar *filter)
|
---|
384 | {
|
---|
385 | filter[0]=0xFF;
|
---|
386 | filter[1]=3;
|
---|
387 |
|
---|
388 | //ToDo videoguard12_get_emm_filter basic construction
|
---|
389 |
|
---|
390 | filter[2]=UNIQUE;
|
---|
391 | filter[3]=0;
|
---|
392 |
|
---|
393 | filter[4+0] = 0x82;
|
---|
394 | filter[4+0+16] = 0xFF;
|
---|
395 |
|
---|
396 | memcpy(filter+4+2, rdr->hexserial+2, 4);
|
---|
397 | memset(filter+4+2+16, 0xFF, 4);
|
---|
398 |
|
---|
399 |
|
---|
400 | filter[36]=UNIQUE;
|
---|
401 | filter[37]=0;
|
---|
402 |
|
---|
403 | filter[38+0] = 0x82;
|
---|
404 | filter[38+0+16] = 0xFF;
|
---|
405 |
|
---|
406 | memcpy(filter+38+6, rdr->hexserial+2, 4);
|
---|
407 | memset(filter+38+6+16, 0xFF, 4);
|
---|
408 |
|
---|
409 |
|
---|
410 | filter[70]=UNIQUE;
|
---|
411 | filter[71]=0;
|
---|
412 |
|
---|
413 | filter[72+0] = 0x82;
|
---|
414 | filter[72+0+16] = 0xFF;
|
---|
415 |
|
---|
416 | memcpy(filter+72+10, rdr->hexserial+2, 4);
|
---|
417 | memset(filter+72+10+16, 0xFF, 4);
|
---|
418 |
|
---|
419 |
|
---|
420 | /* filter[104]=UNIQUE;
|
---|
421 | filter[105]=0;
|
---|
422 |
|
---|
423 | filter[106+0] = 0x82;
|
---|
424 | filter[106+0+16] = 0xFF;
|
---|
425 |
|
---|
426 | memcpy(filter+106+14, rdr->hexserial+2, 2);
|
---|
427 | memset(filter+106+14+16, 0xFF, 2); */
|
---|
428 |
|
---|
429 | return;
|
---|
430 | }
|
---|
431 |
|
---|
432 | int videoguard12_do_emm(struct s_reader * reader, EMM_PACKET *ep)
|
---|
433 | {
|
---|
434 | unsigned char cta_res[CTA_RES_LEN];
|
---|
435 | unsigned char ins42[5] = { 0x49,0x42,0x00,0x00,0xFF };
|
---|
436 | int rc=ERROR;
|
---|
437 |
|
---|
438 | const unsigned char *payload = payload_addr(ep->type, ep->emm, reader->hexserial);
|
---|
439 | while (payload) {
|
---|
440 | ins42[4]=*payload;
|
---|
441 | int l = do_cmd(reader,ins42,payload+1,NULL,NULL,cta_res);
|
---|
442 | if(l>0 && status_ok(cta_res)) {
|
---|
443 | rc=OK;
|
---|
444 | }
|
---|
445 |
|
---|
446 | cs_debug_mask(D_EMM, "[videoguard12-reader] EMM request return code : %02X%02X", cta_res[0], cta_res[1]);
|
---|
447 | //cs_dump(ep->emm, 64, "EMM:");
|
---|
448 | if (status_ok (cta_res) && (cta_res[1] & 0x01)) {
|
---|
449 | read_tiers(reader);
|
---|
450 | }
|
---|
451 |
|
---|
452 | if (num_addr(ep->emm) == 1 && (int)(&payload[1] - &ep->emm[0]) + *payload + 1 < ep->l) {
|
---|
453 | payload += *payload + 1;
|
---|
454 | if (*payload == 0x00) ++payload;
|
---|
455 | ++payload;
|
---|
456 | if (*payload != 0x02) break;
|
---|
457 | payload += 2 + payload[1];
|
---|
458 | }
|
---|
459 | else
|
---|
460 | payload = 0;
|
---|
461 |
|
---|
462 | }
|
---|
463 |
|
---|
464 | return(rc);
|
---|
465 | }
|
---|
466 |
|
---|
467 | int videoguard12_card_info(struct s_reader * reader)
|
---|
468 | {
|
---|
469 | /* info is displayed in init, or when processing info */
|
---|
470 | cs_log("[videoguard12-reader] card detected");
|
---|
471 | cs_log("[videoguard12-reader] type: %s", reader->card_desc);
|
---|
472 | read_tiers (reader);
|
---|
473 | return OK;
|
---|
474 | }
|
---|
475 |
|
---|
476 | void reader_videoguard12(struct s_cardsystem *ph)
|
---|
477 | {
|
---|
478 | ph->do_emm=videoguard12_do_emm;
|
---|
479 | ph->do_ecm=videoguard12_do_ecm;
|
---|
480 | ph->card_info=videoguard12_card_info;
|
---|
481 | ph->card_init=videoguard12_card_init;
|
---|
482 | ph->get_emm_type=videoguard12_get_emm_type;
|
---|
483 | ph->caids[0]=0x09;
|
---|
484 | }
|
---|