SASC-NG
DVBSoftCAM

parallel_128_16charA.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[16];
00023 };
00024 typedef struct group_t group;
00025 
00026 #define GROUP_PARALLELISM 128
00027 
00028 group static inline FF0(){
00029   group res;
00030   int i;
00031   for(i=0;i<16;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<16;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<16;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<16;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<16;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<16;i++) res.s1[i]=~a.s1[i];
00067   return res;
00068 }
00069 
00070 
00071 /* 64 rows of 128 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 
00091 struct batch_t{
00092   unsigned char s1[16];
00093 };
00094 typedef struct batch_t batch;
00095 
00096 #define BYTES_PER_BATCH 16
00097 
00098 batch static inline B_FFAND(batch a,batch b){
00099   batch res;
00100   int i;
00101   for(i=0;i<16;i++) res.s1[i]=a.s1[i]&b.s1[i];
00102   return res;
00103 }
00104 
00105 batch static inline B_FFOR(batch a,batch b){
00106   batch res;
00107   int i;
00108   for(i=0;i<16;i++) res.s1[i]=a.s1[i]|b.s1[i];
00109   return res;
00110 }
00111 
00112 batch static inline B_FFXOR(batch a,batch b){
00113   batch res;
00114   int i;
00115   for(i=0;i<16;i++) res.s1[i]=a.s1[i]^b.s1[i];
00116   return res;
00117 }
00118 
00119 
00120 batch static inline B_FFN_ALL_29(){
00121   batch res;
00122   int i;
00123   for(i=0;i<16;i++) res.s1[i]=0x29;
00124   return res;
00125 }
00126 batch static inline B_FFN_ALL_02(){
00127   batch res;
00128   int i;
00129   for(i=0;i<16;i++) res.s1[i]=0x02;
00130   return res;
00131 }
00132 batch static inline B_FFN_ALL_04(){
00133   batch res;
00134   int i;
00135   for(i=0;i<16;i++) res.s1[i]=0x04;
00136   return res;
00137 }
00138 batch static inline B_FFN_ALL_10(){
00139   batch res;
00140   int i;
00141   for(i=0;i<16;i++) res.s1[i]=0x10;
00142   return res;
00143 }
00144 batch static inline B_FFN_ALL_40(){
00145   batch res;
00146   int i;
00147   for(i=0;i<16;i++) res.s1[i]=0x40;
00148   return res;
00149 }
00150 batch static inline B_FFN_ALL_80(){
00151   batch res;
00152   int i;
00153   for(i=0;i<16;i++) res.s1[i]=0x80;
00154   return res;
00155 }
00156 
00157 batch static inline B_FFSH8L(batch a,int n){
00158   batch res;
00159   int i;
00160   for(i=0;i<16;i++) res.s1[i]=a.s1[i]<<n;
00161   return res;
00162 }
00163 
00164 batch static inline B_FFSH8R(batch a,int n){
00165   batch res;
00166   int i;
00167   for(i=0;i<16;i++) res.s1[i]=a.s1[i]>>n;
00168   return res;
00169 }
00170 
00171 void static inline M_EMPTY(void){
00172 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines