tsdecrypt reads and decrypts CSA encrypted incoming mpeg transport stream over UDP/RTP using code words obtained from OSCAM or similar CAM server. tsdecrypt communicates with CAM server using cs378x (camd35 over tcp) protocol or newcamd protocol. https://georgi.unixsol.org/programs/tsdecrypt/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

csa.h 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * CSA functions
  3. * Copyright (C) 2012 Unix Solutions Ltd.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  17. */
  18. #ifndef CSA_H
  19. #define CSA_H
  20. // The following *MUST* be the same as struct dvbcsa_bs_batch_s from libdvbcsa
  21. struct csa_batch {
  22. uint8_t *data; // Pointer to payload
  23. unsigned int len; // Payload bytes lenght
  24. };
  25. #if USE_LIBDVBCSA
  26. #include <dvbcsa/dvbcsa.h>
  27. #define use_dvbcsa 1
  28. #else
  29. #define use_dvbcsa 0
  30. #define dvbcsa_key_t void
  31. #define dvbcsa_bs_key_t void
  32. #define dvbcsa_bs_batch_s csa_batch
  33. static inline dvbcsa_key_t * dvbcsa_key_alloc(void) { return NULL; }
  34. static inline void dvbcsa_key_free(dvbcsa_key_t *key) { (void)key; }
  35. static inline void dvbcsa_key_set(const uint8_t *cw, dvbcsa_key_t *key) { (void)cw; (void)key; }
  36. static inline void dvbcsa_decrypt(const uint8_t *key, uint8_t *data, unsigned int len) { (void)key; (void)data; (void)len; }
  37. static inline unsigned int dvbcsa_bs_batch_size(void) { return 0; }
  38. static inline dvbcsa_bs_key_t * dvbcsa_bs_key_alloc(void) { return NULL; }
  39. static inline void dvbcsa_bs_key_free(dvbcsa_bs_key_t *key) { (void)key; }
  40. static inline void dvbcsa_bs_key_set(uint8_t *cw, dvbcsa_bs_key_t *key) { (void)cw; (void)key; }
  41. static inline void dvbcsa_bs_decrypt(const dvbcsa_bs_key_t *key, const struct dvbcsa_bs_batch_s *pcks, unsigned int maxlen) { (void)key; (void)pcks; (void)maxlen; }
  42. #endif
  43. #include "data.h"
  44. struct csakey {
  45. dvbcsa_key_t *s_csakey[2];
  46. dvbcsa_bs_key_t *bs_csakey[2];
  47. };
  48. csakey_t * csa_key_alloc (void);
  49. void csa_key_free (csakey_t **pcsakey);
  50. unsigned int csa_get_batch_size (void);
  51. void csa_set_even_cw (csakey_t *csakey, uint8_t *even_cw);
  52. void csa_set_odd_cw (csakey_t *csakey, uint8_t *odd_cw);
  53. // key_idx 0 == even key
  54. // key_idx 1 == odd key
  55. void csa_decrypt_single_packet (csakey_t *csakey, uint8_t *payload, unsigned int payload_len, unsigned int key_idx);
  56. void csa_decrypt_multiple_even (csakey_t *csakey, struct csa_batch *batch);
  57. void csa_decrypt_multiple_odd (csakey_t *csakey, struct csa_batch *batch);
  58. void csa_benchmark(void);
  59. #endif