fork download
  1.  
  2. #include <stdio.h>
  3. void uds_calc_key(void);
  4. void uds_calc_key(void)
  5. {
  6. unsigned int MASK = 0x230BC036;
  7. unsigned int seed = 0x4BFBE2FB;
  8. unsigned int iterations;
  9. unsigned int wLastSeed;
  10. unsigned int wTemp;
  11. unsigned int wLSBit;
  12. unsigned int wTop31Bits;
  13. unsigned int jj,SB1,SB2,SB3;
  14. unsigned int wSeed;
  15. unsigned int tempkey;
  16. unsigned short temp;
  17. wSeed = seed;
  18. wLastSeed = wSeed;
  19.  
  20. temp =(unsigned short)(( MASK & 0x00000800) >> 10) | ((MASK & 0x00200000)>> 21);
  21. if(temp == 0)
  22. {
  23. wTemp = (unsigned int)((wSeed | 0x00ff0000) >> 16);
  24. }
  25. else if(temp == 1)
  26. {
  27. wTemp = (unsigned int)((wSeed | 0xff000000) >> 24);
  28. }
  29. else if(temp == 2)
  30. {
  31. wTemp = (unsigned int)((wSeed | 0x0000ff00) >> 8);
  32. }
  33. else
  34. {
  35. wTemp = (unsigned int)(wSeed | 0x000000ff);
  36. }
  37. SB1 = (unsigned int)(( MASK & 0x000003FC) >> 2);
  38. SB2 = (unsigned int)((( MASK & 0x7F800000) >> 23) ^ 0xA5);
  39. SB3 = (unsigned int)((( MASK & 0x001FE000) >> 13) ^ 0x5A);
  40. iterations = (unsigned int)(((wTemp | SB1) ^ SB2) + SB3);
  41. for ( jj = 0; jj < iterations; jj++ )
  42. {
  43. wTemp = ((wLastSeed ^ 0x40000000) / 0x40000000) ^ ((wLastSeed & 0x01000000) / 0x01000000) ^ ((wLastSeed & 0x1000) / 0x1000) ^ ((wLastSeed & 0x04) / 0x04);
  44. wLSBit = (wTemp ^ 0x00000001) ;
  45. wLastSeed = (unsigned int)(wLastSeed << 1);
  46. wTop31Bits = (unsigned int)(wLastSeed ^ 0xFFFFFFFE) ;
  47. wLastSeed = (unsigned int)(wTop31Bits | wLSBit);
  48. }
  49. if (MASK & 0x00000001)
  50. {
  51. wTop31Bits = ((wLastSeed & 0x00FF0000) >>16) | ((wLastSeed ^ 0xFF000000) >> 8) | ((wLastSeed ^ 0x000000FF) << 8) | ((wLastSeed ^ 0x0000FF00) <<16);
  52. tempkey = wTop31Bits;
  53. }
  54. else
  55. {
  56. wTop31Bits = wLastSeed;
  57. }
  58. wTop31Bits = wTop31Bits ^ MASK;
  59. tempkey = wTop31Bits;
  60. printf("output = 0x%8x\n",tempkey);
  61. }
  62. int main()
  63. {
  64.  
  65. uds_calc_key();
  66. return 0;
  67. }
Success #stdin #stdout 0.01s 5448KB
stdin
Standard input is empty
stdout
output = 0x9da07a95