/modules/softcam/cas/nagra.c

https://bitbucket.org/cesbo/astra · C · 94 lines · 55 code · 9 blank · 30 comment · 13 complexity · 955767a862c6f0bc3e25353ec23865a0 MD5 · raw file

  1. /*
  2. * Astra Module: SoftCAM
  3. * http://cesbo.com/astra
  4. *
  5. * Copyright (C) 2012-2013, Andrey Dyldin <and@cesbo.com>
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "../module_cam.h"
  21. struct module_data_t
  22. {
  23. MODULE_CAS_DATA();
  24. };
  25. static bool cas_check_em(module_data_t *mod, mpegts_psi_t *em)
  26. {
  27. const uint8_t em_type = em->buffer[0];
  28. switch(em_type)
  29. {
  30. // ECM
  31. case 0x80:
  32. case 0x81:
  33. {
  34. return true;
  35. }
  36. // EMM ( ret = MPEGTS_PACKET_EMM )
  37. case 0x83:
  38. {
  39. const uint8_t *ua = mod->__cas.decrypt->cam->ua;
  40. if(em->buffer[5] == ua[4]
  41. && em->buffer[4] == ua[5]
  42. && em->buffer[3] == ua[6])
  43. {
  44. if(em->buffer[7] == 0x10) // shared
  45. return true;
  46. else if(em->buffer[6] == ua[7]) // unique
  47. return true;
  48. }
  49. break;
  50. }
  51. case 0x82: // global
  52. {
  53. return true;
  54. }
  55. default:
  56. break;
  57. }
  58. return false;
  59. }
  60. static bool cas_check_keys(module_data_t *mod, const uint8_t *keys)
  61. {
  62. __uarg(mod);
  63. __uarg(keys);
  64. return true;
  65. }
  66. /*
  67. * CA descriptor (iso13818-1):
  68. * tag :8 (must be 0x09)
  69. * length :8
  70. * caid :16
  71. * reserved :3
  72. * pid :13
  73. * data :length-4
  74. */
  75. static bool cas_check_descriptor(module_data_t *mod, const uint8_t *desc)
  76. {
  77. __uarg(mod);
  78. __uarg(desc);
  79. return true;
  80. }
  81. static bool cas_check_caid(uint16_t caid)
  82. {
  83. return ((caid & 0xFF00) == 0x1800);
  84. }
  85. MODULE_CAS(nagra)