Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. void cCamCryptVG_SetSeed(struct s_reader *reader)
  2. {
  3. #if __BYTE_ORDER != __BIG_ENDIAN
  4. static const uint8_t key1[] =
  5. {
  6. 0xb9, 0xd5, 0xef, 0xd5, 0xf5, 0xd5, 0xfb, 0xd5, 0x31, 0xd6, 0x43, 0xd6, 0x55, 0xd6, 0x61, 0xd6,
  7. 0x85, 0xd6, 0x9d, 0xd6, 0xaf, 0xd6, 0xc7, 0xd6, 0xd9, 0xd6, 0x09, 0xd7, 0x15, 0xd7, 0x21, 0xd7,
  8. 0x27, 0xd7, 0x3f, 0xd7, 0x45, 0xd7, 0xb1, 0xd7, 0xbd, 0xd7, 0xdb, 0xd7, 0x11, 0xd8, 0x23, 0xd8,
  9. 0x29, 0xd8, 0x2f, 0xd8, 0x4d, 0xd8, 0x8f, 0xd8, 0xa1, 0xd8, 0xad, 0xd8, 0xbf, 0xd8, 0xd7, 0xd8
  10. };
  11.  
  12. void cCamCryptVG_GetCamKey(struct s_reader *reader, uint16_t *tb2)
  13. {
  14. struct videoguard_data *csystem_data = reader->csystem_data;
  15. uint16_t c = 1;
  16. memset(tb2, 0, 64);
  17. tb2[0] = 1;
  18. int32_t i;
  19.  
  20. for(i = 0; i < 32; i++)
  21. {
  22. cCamCryptVG_LongMult(tb2, &c, csystem_data->cardkeys[1][i], 0);
  23. }
  24. swap_lb((uint8_t *)tb2, 64);
  25. }
  26.  
  27. static void swap_lb(uint8_t *buff, int32_t len)
  28. {
  29. #if __BYTE_ORDER != __BIG_ENDIAN
  30. return;
  31. #endif
  32. int32_t i;
  33. uint8_t tmp;
  34.  
  35. for(i = 0; i < len / 2; i++)
  36. {
  37. tmp = buff[i * 2];
  38. buff[i * 2] = buff[(i * 2) + 1];
  39. buff[(i * 2) + 1] = tmp;
  40. }
  41. }
  42.  
  43. static void cCamCryptVG_LongMult(uint16_t *pData, uint16_t *pLen, uint32_t mult, uint32_t carry)
  44. {
  45. int32_t i;
  46. for(i = 0; i < *pLen; i++)
  47. {
  48. carry += pData[i] * mult;
  49. pData[i] = (uint16_t)carry;
  50. carry »= 16;
  51. }
  52.  
  53. if(carry) { pData[(*pLen)++] = carry; }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement