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.

parallel_128_4int.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* FFdecsa -- fast decsa algorithm
  2. *
  3. * Copyright (C) 2003-2004 fatih89r
  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 as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19. struct group_t{
  20. unsigned int s1,s2,s3,s4;
  21. };
  22. typedef struct group_t group;
  23. #define GROUP_PARALLELISM 128
  24. group static inline FF0(){
  25. group res;
  26. res.s1=0x0;
  27. res.s2=0x0;
  28. res.s3=0x0;
  29. res.s4=0x0;
  30. return res;
  31. }
  32. group static inline FF1(){
  33. group res;
  34. res.s1=0xffffffff;
  35. res.s2=0xffffffff;
  36. res.s3=0xffffffff;
  37. res.s4=0xffffffff;
  38. return res;
  39. }
  40. group static inline FFAND(group a,group b){
  41. group res;
  42. res.s1=a.s1&b.s1;
  43. res.s2=a.s2&b.s2;
  44. res.s3=a.s3&b.s3;
  45. res.s4=a.s4&b.s4;
  46. return res;
  47. }
  48. group static inline FFOR(group a,group b){
  49. group res;
  50. res.s1=a.s1|b.s1;
  51. res.s2=a.s2|b.s2;
  52. res.s3=a.s3|b.s3;
  53. res.s4=a.s4|b.s4;
  54. return res;
  55. }
  56. group static inline FFXOR(group a,group b){
  57. group res;
  58. res.s1=a.s1^b.s1;
  59. res.s2=a.s2^b.s2;
  60. res.s3=a.s3^b.s3;
  61. res.s4=a.s4^b.s4;
  62. return res;
  63. }
  64. group static inline FFNOT(group a){
  65. group res;
  66. res.s1=~a.s1;
  67. res.s2=~a.s2;
  68. res.s3=~a.s3;
  69. res.s4=~a.s4;
  70. return res;
  71. }
  72. /* 64 rows of 128 bits */
  73. void static inline FFTABLEIN(unsigned char *tab, int g, unsigned char *data){
  74. *(((int *)tab)+2*g)=*((int *)data);
  75. *(((int *)tab)+2*g+1)=*(((int *)data)+1);
  76. }
  77. void static inline FFTABLEOUT(unsigned char *data, unsigned char *tab, int g){
  78. *((int *)data)=*(((int *)tab)+2*g);
  79. *(((int *)data)+1)=*(((int *)tab)+2*g+1);
  80. }
  81. void static inline FFTABLEOUTXORNBY(int n, unsigned char *data, unsigned char *tab, int g){
  82. int j;
  83. for(j=0;j<n;j++){
  84. *(data+j)^=*(tab+8*g+j);
  85. }
  86. }
  87. struct batch_t{
  88. unsigned int s1,s2,s3,s4;
  89. };
  90. typedef struct batch_t batch;
  91. #define BYTES_PER_BATCH 16
  92. batch static inline B_FFAND(batch a,batch b){
  93. batch res;
  94. res.s1=a.s1&b.s1;
  95. res.s2=a.s2&b.s2;
  96. res.s3=a.s3&b.s3;
  97. res.s4=a.s4&b.s4;
  98. return res;
  99. }
  100. batch static inline B_FFOR(batch a,batch b){
  101. batch res;
  102. res.s1=a.s1|b.s1;
  103. res.s2=a.s2|b.s2;
  104. res.s3=a.s3|b.s3;
  105. res.s4=a.s4|b.s4;
  106. return res;
  107. }
  108. batch static inline B_FFXOR(batch a,batch b){
  109. batch res;
  110. res.s1=a.s1^b.s1;
  111. res.s2=a.s2^b.s2;
  112. res.s3=a.s3^b.s3;
  113. res.s4=a.s4^b.s4;
  114. return res;
  115. }
  116. batch static inline B_FFN_ALL_29(){
  117. batch res;
  118. res.s1=0x29292929;
  119. res.s2=0x29292929;
  120. res.s3=0x29292929;
  121. res.s4=0x29292929;
  122. return res;
  123. }
  124. batch static inline B_FFN_ALL_02(){
  125. batch res;
  126. res.s1=0x02020202;
  127. res.s2=0x02020202;
  128. res.s3=0x02020202;
  129. res.s4=0x02020202;
  130. return res;
  131. }
  132. batch static inline B_FFN_ALL_04(){
  133. batch res;
  134. res.s1=0x04040404;
  135. res.s2=0x04040404;
  136. res.s3=0x04040404;
  137. res.s4=0x04040404;
  138. return res;
  139. }
  140. batch static inline B_FFN_ALL_10(){
  141. batch res;
  142. res.s1=0x10101010;
  143. res.s2=0x10101010;
  144. res.s3=0x10101010;
  145. res.s4=0x10101010;
  146. return res;
  147. }
  148. batch static inline B_FFN_ALL_40(){
  149. batch res;
  150. res.s1=0x40404040;
  151. res.s2=0x40404040;
  152. res.s3=0x40404040;
  153. res.s4=0x40404040;
  154. return res;
  155. }
  156. batch static inline B_FFN_ALL_80(){
  157. batch res;
  158. res.s1=0x80808080;
  159. res.s2=0x80808080;
  160. res.s3=0x80808080;
  161. res.s4=0x80808080;
  162. return res;
  163. }
  164. batch static inline B_FFSH8L(batch a,int n){
  165. batch res;
  166. res.s1=a.s1<<n;
  167. res.s2=a.s2<<n;
  168. res.s3=a.s3<<n;
  169. res.s4=a.s4<<n;
  170. return res;
  171. }
  172. batch static inline B_FFSH8R(batch a,int n){
  173. batch res;
  174. res.s1=a.s1>>n;
  175. res.s2=a.s2>>n;
  176. res.s3=a.s3>>n;
  177. res.s4=a.s4>>n;
  178. return res;
  179. }
  180. void static inline M_EMPTY(void){
  181. }