SASC-NG
DVBSoftCAM

parallel_064_8charA.h

Go to the documentation of this file.
00001 /* FFdecsa -- fast decsa algorithm
00002  *
00003  * Copyright (C) 2003-2004  fatih89r
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  */
00019 
00020 
00021 struct group_t{
00022   unsigned char s1[8];
00023 };
00024 typedef struct group_t group;
00025 
00026 #define GROUP_PARALLELISM 64
00027 
00028 group static inline FF0(){
00029   group res;
00030   int i;
00031   for(i=0;i<8;i++) res.s1[i]=0x0;
00032   return res;
00033 }
00034 
00035 group static inline FF1(){
00036   group res;
00037   int i;
00038   for(i=0;i<8;i++) res.s1[i]=0xff;
00039   return res;
00040 }
00041 
00042 group static inline FFAND(group a,group b){
00043   group res;
00044   int i;
00045   for(i=0;i<8;i++) res.s1[i]=a.s1[i]&b.s1[i];
00046   return res;
00047 }
00048 
00049 group static inline FFOR(group a,group b){
00050   group res;
00051   int i;
00052   for(i=0;i<8;i++) res.s1[i]=a.s1[i]|b.s1[i];
00053   return res;
00054 }
00055 
00056 group static inline FFXOR(group a,group b){
00057   group res;
00058   int i;
00059   for(i=0;i<8;i++) res.s1[i]=a.s1[i]^b.s1[i];
00060   return res;
00061 }
00062 
00063 group static inline FFNOT(group a){
00064   group res;
00065   int i;
00066   for(i=0;i<8;i++) res.s1[i]=~a.s1[i];
00067   return res;
00068 }
00069 
00070 
00071 /* 64 rows of 64 bits */
00072 
00073 void static inline FFTABLEIN(unsigned char *tab, int g, unsigned char *data){
00074   *(((int *)tab)+2*g)=*((int *)data);
00075   *(((int *)tab)+2*g+1)=*(((int *)data)+1);
00076 }
00077 
00078 void static inline FFTABLEOUT(unsigned char *data, unsigned char *tab, int g){
00079   *((int *)data)=*(((int *)tab)+2*g);
00080   *(((int *)data)+1)=*(((int *)tab)+2*g+1);
00081 }
00082 
00083 void static inline FFTABLEOUTXORNBY(int n, unsigned char *data, unsigned char *tab, int g){
00084   int j;
00085   for(j=0;j<n;j++){
00086     *(data+j)^=*(tab+8*g+j);
00087   }
00088 }
00089 
00090 struct batch_t{
00091   unsigned char s1[8];
00092 };
00093 typedef struct batch_t batch;
00094 
00095 #define BYTES_PER_BATCH 8
00096 
00097 batch static inline B_FFAND(batch a,batch b){
00098   batch res;
00099   int i;
00100   for(i=0;i<8;i++) res.s1[i]=a.s1[i]&b.s1[i];
00101   return res;
00102 }
00103 
00104 batch static inline B_FFOR(batch a,batch b){
00105   batch res;
00106   int i;
00107   for(i=0;i<8;i++) res.s1[i]=a.s1[i]|b.s1[i];
00108   return res;
00109 }
00110 
00111 batch static inline B_FFXOR(batch a,batch b){
00112   batch res;
00113   int i;
00114   for(i=0;i<8;i++) res.s1[i]=a.s1[i]^b.s1[i];
00115   return res;
00116 }
00117 
00118 
00119 batch static inline B_FFN_ALL_29(){
00120   batch res;
00121   int i;
00122   for(i=0;i<8;i++) res.s1[i]=0x29;
00123   return res;
00124 }
00125 batch static inline B_FFN_ALL_02(){
00126   batch res;
00127   int i;
00128   for(i=0;i<8;i++) res.s1[i]=0x02;
00129   return res;
00130 }
00131 batch static inline B_FFN_ALL_04(){
00132   batch res;
00133   int i;
00134   for(i=0;i<8;i++) res.s1[i]=0x04;
00135   return res;
00136 }
00137 batch static inline B_FFN_ALL_10(){
00138   batch res;
00139   int i;
00140   for(i=0;i<8;i++) res.s1[i]=0x10;
00141   return res;
00142 }
00143 batch static inline B_FFN_ALL_40(){
00144   batch res;
00145   int i;
00146   for(i=0;i<8;i++) res.s1[i]=0x40;
00147   return res;
00148 }
00149 batch static inline B_FFN_ALL_80(){
00150   batch res;
00151   int i;
00152   for(i=0;i<8;i++) res.s1[i]=0x80;
00153   return res;
00154 }
00155 
00156 batch static inline B_FFSH8L(batch a,int n){
00157   batch res;
00158   int i;
00159   for(i=0;i<8;i++) res.s1[i]=a.s1[i]<<n;
00160   return res;
00161 }
00162 
00163 batch static inline B_FFSH8R(batch a,int n){
00164   batch res;
00165   int i;
00166   for(i=0;i<8;i++) res.s1[i]=a.s1[i]>>n;
00167   return res;
00168 }
00169 
00170 void static inline M_EMPTY(void){
00171 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines