Changeset 3034 for trunk/reader-videoguard12.c
- Timestamp:
- 09/10/10 19:57:18 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/reader-videoguard12.c
r3029 r3034 1 1 #include "globals.h" 2 2 #include "reader-common.h" 3 4 #include <termios.h> 5 #include <unistd.h> 6 #ifdef OS_LINUX 7 #include <linux/serial.h> 8 #endif 9 10 #define MAX_ATR_LEN 33 // max. ATR length 11 #define MAX_HIST 15 // max. number of historical characters 12 13 #define VG12_EMMTYPE_MASK 0xC0 14 #define VG12_EMMTYPE_G 0 15 #define VG12_EMMTYPE_U 1 16 #define VG12_EMMTYPE_S 2 17 18 #define write_cmd_vg(cmd, data) (card_write(reader, cmd, data, cta_res, &cta_lr) == 0) 3 #include "reader-videoguard-common.h" 19 4 20 5 ////// ==================================================================================== 21 22 int vg12_aes_active=0;23 AES_KEY vg12_dkey, vg12_ekey, vg12_Astro_Key;24 6 int VG12_BASEYEAR = 1997; 25 static void cAES_SetKey(const unsigned char *key)26 {27 AES_set_decrypt_key(key,128,&vg12_dkey);28 AES_set_encrypt_key(key,128,&vg12_ekey);29 vg12_aes_active=1;30 }31 32 static int cAES_Encrypt(const unsigned char *data, int len, unsigned char *crypt)33 {34 if(vg12_aes_active) {35 len=(len+15)&(~15); // pad up to a multiple of 1636 int i;37 for(i=0; i<len; i+=16) AES_encrypt(data+i,crypt+i,(const AES_KEY *)&vg12_ekey);38 return len;39 }40 return -1;41 }42 43 static int cw_is_valid(unsigned char *cw) //returns 1 if cw_is_valid, returns 0 if cw is all zeros44 {45 int i;46 for (i = 0; i < 8; i++)47 if (cw[i] != 0) {//test if cw = 0048 return OK;49 }50 return ERROR;51 }52 7 53 8 static const unsigned short NdTabB001[0x15][0x20]= { … … 100 55 static const unsigned char Hash4[] = {0x0B,0x04,0x07,0x08,0x05,0x09,0x0B,0x0A,0x07,0x02,0x0A,0x05,0x04,0x08,0x0D,0x0F}; 101 56 102 static void swap_lb (unsigned char *buff, int len) 103 { 104 105 #if __BYTE_ORDER != __BIG_ENDIAN 106 return; 107 108 #endif /* */ 109 int i; 110 unsigned short *tmp; 111 for (i = 0; i < len / 2; i++) { 112 tmp = (unsigned short *) buff + i; 113 *tmp = ((*tmp << 8) & 0xff00) | ((*tmp >> 8) & 0x00ff); 114 } 115 } 116 117 static inline void __xxor(unsigned char *data, int len, const unsigned char *v1, const unsigned char *v2) 118 { 119 switch(len) { // looks ugly, but the compiler can optimize it very well ;) 120 case 16: 121 *((unsigned int *)data+3) = *((unsigned int *)v1+3) ^ *((unsigned int *)v2+3); 122 *((unsigned int *)data+2) = *((unsigned int *)v1+2) ^ *((unsigned int *)v2+2); 123 case 8: 124 *((unsigned int *)data+1) = *((unsigned int *)v1+1) ^ *((unsigned int *)v2+1); 125 case 4: 126 *((unsigned int *)data+0) = *((unsigned int *)v1+0) ^ *((unsigned int *)v2+0); 127 break; 128 default: 129 while(len--) *data++ = *v1++ ^ *v2++; 130 break; 131 } 132 } 133 #define xor16(v1,v2,d) __xxor((d),16,(v1),(v2)) 134 #define val_by2on3(x) ((0xaaab*(x))>>16) //fixed point *2/3 135 136 unsigned short vg12_cardkeys[3][32]; 137 unsigned char vg12_stateD3A[16]; 138 139 static void cCamCryptVG12_LongMult(unsigned short *pData, unsigned short *pLen, unsigned int mult, unsigned int carry); 140 static void cCamCryptVG12_PartialMod(unsigned short val, unsigned int count, unsigned short *outkey, const unsigned short *inkey); 141 static void cCamCryptVG12_RotateRightAndHash(unsigned char *p); 142 static void cCamCryptVG12_Reorder16A(unsigned char *dest, const unsigned char *src); 143 static void cCamCryptVG12_ReorderAndEncrypt(unsigned char *p); 144 static void cCamCryptVG12_Process_D0(const unsigned char *ins, unsigned char *data); 145 static void cCamCryptVG12_Process_D1(const unsigned char *ins, unsigned char *data, const unsigned char *status); 146 static void cCamCryptVG12_Decrypt_D3(unsigned char *ins, unsigned char *data, const unsigned char *status); 147 static void cCamCryptVG12_PostProcess_Decrypt(unsigned char *buff, int len, unsigned char *cw1, unsigned char *cw2); 148 static void cCamCryptVG12_SetSeed(unsigned char *Key1, unsigned char *Key2); 149 static void cCamCryptVG12_GetCamKey(unsigned char *buff); 150 151 static void cCamCryptVG12_SetSeed(unsigned char *Key1, unsigned char *Key2) 152 { 153 swap_lb (Key1, 64); 154 swap_lb (Key2, 64); 155 memcpy(vg12_cardkeys[1],Key1,sizeof(vg12_cardkeys[1])); 156 memcpy(vg12_cardkeys[2],Key2,sizeof(vg12_cardkeys[2])); 157 swap_lb (Key1, 64); 158 swap_lb (Key2, 64); 159 } 160 161 static void cCamCryptVG12_GetCamKey(unsigned char *buff) 162 { 163 unsigned short *tb2=(unsigned short *)buff, c=1; 164 memset(tb2,0,64); 165 tb2[0]=1; 166 int i; 167 for(i=0; i<32; i++) cCamCryptVG12_LongMult(tb2,&c,vg12_cardkeys[1][i],0); 168 swap_lb (buff, 64); 169 } 170 171 static void cCamCryptVG12_PostProcess_Decrypt(unsigned char *buff, int len, unsigned char *cw1, unsigned char *cw2) 172 { 173 switch(buff[0]) { 174 case 0x48: 175 cCamCryptVG12_Process_D0(buff,buff+5); 176 break; 177 case 0x49: 178 cCamCryptVG12_Process_D1(buff,buff+5,buff+buff[4]+5); 179 break; 180 case 0x4B: 181 cCamCryptVG12_Decrypt_D3(buff,buff+5,buff+buff[4]+5); 182 if(buff[1]==0x54) { 183 memcpy(cw1,buff+5,8); 184 memset(cw2,0,8); //set to 0 so client will know it is not valid if not overwritten with valid cw 185 int ind; 186 for(ind=13; ind<len+13-8; ind++) { 187 if(buff[ind]==0x25) { 188 //memcpy(cw2,buff+5+ind+2,8); 189 memcpy(cw2,buff+ind+3,8); //tested on viasat 093E, sky uk 0963, sky it 919 //don't care whether cw is 0 or not 190 break; 191 } 192 /* if(buff[ind+1]==0) break; 193 ind+=buff[ind+1];*/ 194 } 195 } 196 break; 197 } 198 } 199 200 static void cCamCryptVG12_Process_D0(const unsigned char *ins, unsigned char *data) 201 { 202 switch(ins[1]) { 203 case 0xb4: 204 swap_lb (data, 64); 205 memcpy(vg12_cardkeys[0],data,sizeof(vg12_cardkeys[0])); 206 break; 207 case 0xbc: 208 { 209 swap_lb (data, 64); 210 unsigned short *idata=(unsigned short *)data; 211 const unsigned short *key1=(const unsigned short *)vg12_cardkeys[1]; 212 unsigned short key2[32]; 213 memcpy(key2,vg12_cardkeys[2],sizeof(key2)); 214 int count2; 215 for(count2=0; count2<32; count2++) { 216 unsigned int rem=0, div=key1[count2]; 217 int i; 218 for(i=31; i>=0; i--) { 219 unsigned int x=idata[i] | (rem<<16); 220 rem=(x%div)&0xffff; 221 } 222 unsigned int carry=1, t=val_by2on3(div) | 1; 223 while(t) { 224 if(t&1) carry=((carry*rem)%div)&0xffff; 225 rem=((rem*rem)%div)&0xffff; 226 t>>=1; 227 } 228 cCamCryptVG12_PartialMod(carry,count2,key2,key1); 229 } 230 unsigned short idatacount=0; 231 int i; 232 for(i=31; i>=0; i--) cCamCryptVG12_LongMult(idata,&idatacount,key1[i],key2[i]); 233 swap_lb (data, 64); 234 unsigned char stateD1[16]; 235 cCamCryptVG12_Reorder16A(stateD1,data); 236 cAES_SetKey(stateD1); 237 break; 238 } 239 } 240 } 241 242 static void cCamCryptVG12_Process_D1(const unsigned char *ins, unsigned char *data, const unsigned char *status) 243 { 244 unsigned char iter[16], tmp[16]; 245 memset(iter,0,sizeof(iter)); 246 memcpy(iter,ins,5); 247 xor16(iter,vg12_stateD3A,iter); 248 memcpy(vg12_stateD3A,iter,sizeof(iter)); 249 250 int datalen=status-data; 251 int datalen1=datalen; 252 if(datalen<0) datalen1+=15; 253 int blocklen=datalen1>>4; 254 int i; 255 int iblock; 256 for(i=0,iblock=0; i<blocklen+2; i++,iblock+=16) { 257 unsigned char in[16]; 258 int docalc=1; 259 if(blocklen==i && (docalc=datalen&0xf)) { 260 memset(in,0,sizeof(in)); 261 memcpy(in,&data[iblock],datalen-(datalen1&~0xf)); 262 } 263 else if(blocklen+1==i) { 264 memset(in,0,sizeof(in)); 265 memcpy(&in[5],status,2); 266 } 267 else 268 memcpy(in,&data[iblock],sizeof(in)); 269 270 if(docalc) { 271 xor16(iter,in,tmp); 272 cCamCryptVG12_ReorderAndEncrypt(tmp); 273 xor16(tmp,vg12_stateD3A,iter); 274 } 275 } 276 memcpy(vg12_stateD3A,tmp,16); 277 } 278 279 static void cCamCryptVG12_Decrypt_D3(unsigned char *ins, unsigned char *data, const unsigned char *status) 280 { 281 if(ins[4]>16) ins[4]-=16; 282 if(ins[1]==0xbe) memset(vg12_stateD3A,0,sizeof(vg12_stateD3A)); 283 284 unsigned char tmp[16]; 285 memset(tmp,0,sizeof(tmp)); 286 memcpy(tmp,ins,5); 287 xor16(tmp,vg12_stateD3A,vg12_stateD3A); 288 289 int len1=ins[4]; 290 int blocklen=len1>>4; 291 if(ins[1]!=0xbe) blocklen++; 292 293 unsigned char iter[16], states[16][16]; 294 memset(iter,0,sizeof(iter)); 295 int blockindex; 296 for(blockindex=0; blockindex<blocklen; blockindex++) { 297 iter[0]+=blockindex; 298 xor16(iter,vg12_stateD3A,iter); 299 cCamCryptVG12_ReorderAndEncrypt(iter); 300 xor16(iter,&data[blockindex*16],states[blockindex]); 301 if(blockindex==(len1>>4)) { 302 int c=len1-(blockindex*16); 303 if(c<16) memset(&states[blockindex][c],0,16-c); 304 } 305 xor16(states[blockindex],vg12_stateD3A,vg12_stateD3A); 306 cCamCryptVG12_RotateRightAndHash(vg12_stateD3A); 307 } 308 memset(tmp,0,sizeof(tmp)); 309 memcpy(tmp+5,status,2); 310 xor16(tmp,vg12_stateD3A,vg12_stateD3A); 311 cCamCryptVG12_ReorderAndEncrypt(vg12_stateD3A); 312 313 memcpy(vg12_stateD3A,status-16,sizeof(vg12_stateD3A)); 314 cCamCryptVG12_ReorderAndEncrypt(vg12_stateD3A); 315 316 memcpy(data,states[0],len1); 317 if(ins[1]==0xbe) { 318 cCamCryptVG12_Reorder16A(tmp,states[0]); 319 cAES_SetKey(tmp); 320 } 321 } 322 323 static void cCamCryptVG12_ReorderAndEncrypt(unsigned char *p) 324 { 325 unsigned char tmp[16]; 326 cCamCryptVG12_Reorder16A(tmp,p); 327 cAES_Encrypt(tmp,16,tmp); 328 cCamCryptVG12_Reorder16A(p,tmp); 329 } 330 331 // reorder AAAABBBBCCCCDDDD to ABCDABCDABCDABCD 332 333 static void cCamCryptVG12_Reorder16A(unsigned char *dest, const unsigned char *src) 334 { 335 int i; 336 int j; 337 int k; 338 for(i=0,k=0; i<4; i++) 339 for(j=i; j<16; j+=4,k++) 340 dest[k]=src[j]; 341 } 342 343 static void cCamCryptVG12_LongMult(unsigned short *pData, unsigned short *pLen, unsigned int mult, unsigned int carry) 344 { 345 int i; 346 for(i=0; i<*pLen; i++) { 347 carry+=pData[i]*mult; 348 pData[i]=(unsigned short)carry; 349 carry>>=16; 350 } 351 if(carry) pData[(*pLen)++]=carry; 352 } 353 354 static void cCamCryptVG12_PartialMod(unsigned short val, unsigned int count, unsigned short *outkey, const unsigned short *inkey) 355 { 356 if(count) { 357 unsigned int mod=inkey[count]; 358 unsigned short mult=(inkey[count]-outkey[count-1])&0xffff; 359 unsigned int i; 360 unsigned int ib1; 361 for(i=0,ib1=count-2; i<count-1; i++,ib1--) { 362 unsigned int t=(inkey[ib1]*mult)%mod; 363 mult=t-outkey[ib1]; 364 if(mult>t) mult+=mod; 365 } 366 mult+=val; 367 if((val>mult) || (mod<mult)) mult-=mod; 368 outkey[count]=(outkey[count]*mult)%mod; 369 } 370 else 371 outkey[0]=val; 372 } 373 374 static const unsigned char table1[256] = { 375 0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5, 0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76, 376 0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0, 0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0, 377 0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc, 0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15, 378 0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a, 0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75, 379 0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0, 0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84, 380 0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b, 0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf, 381 0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85, 0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8, 382 0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5, 0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2, 383 0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17, 0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73, 384 0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88, 0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb, 385 0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c, 0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79, 386 0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9, 0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08, 387 0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6, 0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a, 388 0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e, 0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e, 389 0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94, 0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf, 390 0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68, 0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16, 391 }; 392 393 static void cCamCryptVG12_RotateRightAndHash(unsigned char *p) 394 { 395 unsigned char t1=p[15]; 396 int i; 397 for(i=0; i<16; i++) { 398 unsigned char t2=t1; 399 t1=p[i]; p[i]=table1[(t1>>1)|((t2&1)<<7)]; 400 } 401 } 57 402 58 403 59 ////// ==================================================================================== 404 405 static unsigned char CW1[8], CW2[8];406 407 extern int io_serial_need_dummy_char;408 409 struct vg12_CmdTabEntry {410 unsigned char cla;411 unsigned char cmd;412 unsigned char len;413 unsigned char mode;414 };415 416 struct vg12_CmdTab {417 unsigned char index;418 unsigned char size;419 unsigned char Nentries;420 unsigned char dummy;421 struct vg12_CmdTabEntry e[1];422 };423 424 struct vg12_CmdTab *vg12_cmd_table=NULL;425 static void memorize_cmd_table (const unsigned char *mem, int size){426 vg12_cmd_table=(struct vg12_CmdTab *)malloc(sizeof(unsigned char) * size);427 memcpy(vg12_cmd_table,mem,size);428 }429 430 void Manage_Tag(unsigned char *Answer)431 {432 unsigned char Tag,Len,Len2;433 bool Valid_0x55=0;434 unsigned char *Body;435 unsigned char Buffer[0x10];436 int a=0x13;437 Len2=Answer[4];438 while(a<Len2)439 {440 Tag=Answer[a];441 Len=Answer[a+1];442 Body=Answer+a+2;443 switch(Tag)444 {445 case 0x55:{446 if(Body[0]==0x84) //Tag 0x56 has valid data...447 Valid_0x55=1;448 }break;449 case 0x56:{450 memcpy(Buffer+8,Body,8);451 }break;452 }453 a+=Len+2;454 455 }456 if(Valid_0x55)457 {458 memcpy(Buffer,Answer+5,8); //Copy original DW459 AES_decrypt(Buffer,Buffer,&vg12_Astro_Key); //vg12_Astro_Key declared and filled before...460 memcpy(CW1,Buffer,8); //Now copy calculated DW in right place461 }462 }463 464 static int cmd_table_get_info(const unsigned char *cmd, unsigned char *rlen, unsigned char *rmode)465 {466 struct vg12_CmdTabEntry *pcte=vg12_cmd_table->e;467 int i;468 for(i=0; i<vg12_cmd_table->Nentries; i++,pcte++)469 if(cmd[1]==pcte->cmd) {470 *rlen=pcte->len;471 *rmode=pcte->mode;472 return 1;473 }474 return 0;475 }476 477 static int status_ok(const unsigned char *status){478 //cs_log("[videoguard12-reader] check status %02x%02x", status[0],status[1]);479 return (status[0] == 0x90 || status[0] == 0x91)480 && (status[1] == 0x00 || status[1] == 0x01481 || status[1] == 0x20 || status[1] == 0x21482 || status[1] == 0x80 || status[1] == 0x81483 || status[1] == 0xa0 || status[1] == 0xa1);484 }485 486 static int read_cmd_len(struct s_reader * reader, const unsigned char *cmd)487 {488 def_resp;489 unsigned char cmd2[5];490 memcpy(cmd2,cmd,5);491 cmd2[3]=0x80;492 cmd2[4]=1;493 // some card reply with L 91 00 (L being the command length).494 495 if(!write_cmd_vg(cmd2,NULL) || !status_ok(cta_res+1)) {496 cs_debug("[videoguard12-reader] failed to read %02x%02x cmd length (%02x %02x)",cmd[1],cmd[2],cta_res[1],cta_res[2]);497 return -1;498 }499 return cta_res[0];500 }501 502 static int do_cmd(struct s_reader * reader, const unsigned char *ins, const unsigned char *txbuff, unsigned char *rxbuff, unsigned char * cta_res)503 {504 ushort cta_lr;505 unsigned char ins2[5];506 memcpy(ins2,ins,5);507 unsigned char len=0, mode=0;508 if(cmd_table_get_info(ins2,&len,&mode)) {509 if(len==0xFF && mode==2) {510 if(ins2[4]==0) ins2[4]=len=read_cmd_len(reader, ins2);511 }512 else if(mode!=0) ins2[4]=len;513 }514 if(ins2[0]==0x4b) ins2[4]=len+16;515 len=ins2[4];516 517 unsigned char tmp[264];518 if(!rxbuff) rxbuff=tmp;519 if(mode>1) {520 if(!write_cmd_vg(ins2,NULL) || !status_ok(cta_res+len)) return -1;521 memcpy(rxbuff,ins2,5);522 memcpy(rxbuff+5,cta_res,len);523 memcpy(rxbuff+5+len,cta_res+len,2);524 }525 else {526 if(!write_cmd_vg(ins2,(uchar *)txbuff) || !status_ok(cta_res)) return -2;527 memcpy(rxbuff,ins2,5);528 memcpy(rxbuff+5,txbuff,len);529 memcpy(rxbuff+5+len,cta_res,2);530 }531 532 cCamCryptVG12_PostProcess_Decrypt(rxbuff,len,CW1,CW2);533 534 // Start of suggested fix for 09ac cards535 // Log decrypted INS54536 ///if (rxbuff[1] == 0x54) {537 /// cs_dump (rxbuff, 5, "Decrypted INS54:");538 /// cs_dump (rxbuff + 5, rxbuff[4], "");539 ///}540 541 Manage_Tag(rxbuff);542 // End of suggested fix543 return len;544 }545 546 static void rev_date_calc(const unsigned char *Date, int *year, int *mon, int *day, int *hh, int *mm, int *ss)547 {548 *year=(Date[0]/12)+VG12_BASEYEAR;549 *mon=(Date[0]%12)+1;550 *day=Date[1] & 0x1f;551 *hh=Date[2]/8;552 *mm=(0x100*(Date[2]-*hh*8)+Date[3])/32;553 *ss=(Date[3]-*mm*32)*2;554 }555 60 556 61 static void read_tiers(struct s_reader * reader) … … 577 82 if(cta_res[2]==0 && cta_res[3]==0) break; 578 83 int y,m,d,H,M,S; 579 rev_date_calc(&cta_res[4],&y,&m,&d,&H,&M,&S );84 rev_date_calc(&cta_res[4],&y,&m,&d,&H,&M,&S,VG12_BASEYEAR); 580 85 unsigned short tier_id = (cta_res[2] << 8) | cta_res[3]; 581 86 char *tier_name = get_tiername(tier_id, reader->caid[0]); … … 589 94 /* known atrs */ 590 95 NDS_ATR_ENTRY nds12_atr_table[]={ // {atr}, atr len, base year, description 591 {{ 0x3F, 0x78, 0x13, 0x25, 0x03, 0x40, 0xB0, 0x20, 0xFF, 0xFF, 0x4A, 0x50, 0x00 }, 13, 1997, "VideoGuard DirecTV"},592 {{0},0,0, NULL},96 {{ 0x3F, 0x78, 0x13, 0x25, 0x03, 0x40, 0xB0, 0x20, 0xFF, 0xFF, 0x4A, 0x50, 0x00 }, 13, 1997, NDS12, "VideoGuard DirecTV"}, 97 {{0},0,0,0,NULL}, 593 98 }; 594 99 … … 774 279 for(a=0; a<4; a++) 775 280 Dimeno_Magic[a]=Dimeno_Magic[a]^boxID[a]; 776 //I supposed to declare a AES_KEY vg12_Astro_Key somewhere before...777 AES_set_decrypt_key(Dimeno_Magic,128,& vg12_Astro_Key);778 vg12_Astro_Key.rounds=10;281 //I supposed to declare a AES_KEY Astro_Key somewhere before... 282 AES_set_decrypt_key(Dimeno_Magic,128,&Astro_Key); 283 Astro_Key.rounds=10; 779 284 //Important for ecm decryption... 780 285 // End of suggested fix … … 815 320 0x0c, 0xcf, 0xb4, 0x2b, 0x3a, 0x2f, 0xd2, 0x09, 0x92, 0x15, 0x40, 0x47, 0x66, 0x5c, 0xda, 0xc9 816 321 }; 817 cCamCryptVG 12_SetSeed(seed1,seed2);322 cCamCryptVG_SetSeed(seed1,seed2); 818 323 819 324 unsigned char insB4[5] = { 0x48,0xB4,0x00,0x00,0x40 }; 820 325 unsigned char tbuff[64]; 821 cCamCryptVG 12_GetCamKey(tbuff);326 cCamCryptVG_GetCamKey(tbuff); 822 327 l=do_cmd(reader, insB4, tbuff, NULL,cta_res); 823 328 if(l<0 || !status_ok(cta_res)) { … … 1093 598 int serial_count = ((ep->emm[3] >> 4) & 3) + 1; 1094 599 int serial_len = (ep->emm[3] & 0x80) ? 3 : 4; 1095 uchar emmtype = (ep->emm[3] & VG 12_EMMTYPE_MASK) >> 6;600 uchar emmtype = (ep->emm[3] & VG_EMMTYPE_MASK) >> 6; 1096 601 1097 602 pos = 4 + (serial_len * serial_count) + 2; 1098 603 1099 604 switch(emmtype) { 1100 case VG 12_EMMTYPE_G:605 case VG_EMMTYPE_G: 1101 606 ep->type=GLOBAL; 1102 607 cs_debug_mask(D_EMM, "VIDEOGUARD12 EMM: GLOBAL"); 1103 608 return TRUE; 1104 609 1105 case VG 12_EMMTYPE_U:610 case VG_EMMTYPE_U: 1106 611 cs_debug_mask(D_EMM, "VIDEOGUARD12 EMM: UNIQUE"); 1107 612 ep->type=UNIQUE; … … 1119 624 return FALSE; // if UNIQUE but no serial match return FALSE 1120 625 1121 case VG 12_EMMTYPE_S:626 case VG_EMMTYPE_S: 1122 627 ep->type=SHARED; 1123 628 cs_debug_mask(D_EMM, "VIDEOGUARD12 EMM: SHARED");
Note:
See TracChangeset
for help on using the changeset viewer.