-}
-
-
-void printarr(char * name, uint8_t* arr, int len)
-{
- int i ;
- printf("uint8_t %s[] = {", name);
- for(i =0 ; i< len ; i++)
- {
- printf("0x%02x,",*(arr+i));
- }
- printf("};\n");
-}
-
-int testMAC()
-{
-
- //From the "dismantling.IClass" paper:
- uint8_t cc_nr[] = {0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0,0,0,0};
- // But actually, that must be reversed, it's "on-the-wire" data
- reverse_arraybytes(cc_nr,sizeof(cc_nr));
-
- //From the paper
- uint8_t div_key[] = {0xE0,0x33,0xCA,0x41,0x9A,0xEE,0x43,0xF9};
- uint8_t correct_MAC[] = {0x1d,0x49,0xC9,0xDA};
-
- BitstreamIn bitstream = {cc_nr,sizeof(cc_nr) * 8,0};
- uint8_t dest []= {0,0,0,0,0,0,0,0};
- BitstreamOut out = { dest, sizeof(dest)*8, 0 };
- MAC(div_key,bitstream, out);
- //The output MAC must also be reversed
- reverse_arraybytes(dest, sizeof(dest));
-
- if(false && memcmp(dest, correct_MAC,4) == 0)
- {
- printf("MAC calculation OK!\n");
-
- }else
- {
- printf("MAC calculation failed\n");
- printarr("Calculated_MAC", dest, 4);
- printarr("Correct_MAC ", correct_MAC, 4);
- return 1;
- }
- return 0;
-}
-
-int calc_iclass_mac(uint8_t *cc_nr_p, int length, uint8_t *div_key_p, uint8_t *mac)