00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "ufc-crypt.h"
00028 #include "crypt.h"
00029 #include "crypt-private.h"
00030
00031 #ifdef _UFC_32_
00032
00033
00034
00035
00036
00037 #define SBA(sb, v) (*(long32*)((char*)(sb)+(v)))
00038
00039 void
00040 _ufc_doit_r(ufc_long itr, struct crypt_data *__data, ufc_long *res)
00041 {
00042 int i;
00043 long32 s, *k;
00044 long32 *sb01 = (long32*)__data->sb0;
00045 long32 *sb23 = (long32*)__data->sb2;
00046 long32 l1, l2, r1, r2;
00047
00048 l1 = (long32)res[0]; l2 = (long32)res[1];
00049 r1 = (long32)res[2]; r2 = (long32)res[3];
00050
00051 while(itr--) {
00052 k = (long32*)__data->keysched;
00053 for(i=8; i--; ) {
00054 s = *k++ ^ r1;
00055 l1 ^= SBA(sb01, s & 0xffff); l2 ^= SBA(sb01, (s & 0xffff)+4);
00056 l1 ^= SBA(sb01, s >>= 16 ); l2 ^= SBA(sb01, (s )+4);
00057 s = *k++ ^ r2;
00058 l1 ^= SBA(sb23, s & 0xffff); l2 ^= SBA(sb23, (s & 0xffff)+4);
00059 l1 ^= SBA(sb23, s >>= 16 ); l2 ^= SBA(sb23, (s )+4);
00060
00061 s = *k++ ^ l1;
00062 r1 ^= SBA(sb01, s & 0xffff); r2 ^= SBA(sb01, (s & 0xffff)+4);
00063 r1 ^= SBA(sb01, s >>= 16 ); r2 ^= SBA(sb01, (s )+4);
00064 s = *k++ ^ l2;
00065 r1 ^= SBA(sb23, s & 0xffff); r2 ^= SBA(sb23, (s & 0xffff)+4);
00066 r1 ^= SBA(sb23, s >>= 16 ); r2 ^= SBA(sb23, (s )+4);
00067 }
00068 s=l1; l1=r1; r1=s; s=l2; l2=r2; r2=s;
00069 }
00070 res[0] = l1; res[1] = l2; res[2] = r1; res[3] = r2;
00071 }
00072
00073 #endif
00074
00075 #ifdef _UFC_64_
00076
00077
00078
00079
00080
00081 #define SBA(sb, v) (*(long64*)((char*)(sb)+(v)))
00082
00083 void
00084 _ufc_doit_r(itr, __data, res)
00085 ufc_long itr, *res;
00086 struct crypt_data *__data;
00087 {
00088 int i;
00089 long64 l, r, s, *k;
00090 register long64 *sb01 = (long64*)__data->sb0;
00091 register long64 *sb23 = (long64*)__data->sb2;
00092
00093 l = (((long64)res[0]) << 32) | ((long64)res[1]);
00094 r = (((long64)res[2]) << 32) | ((long64)res[3]);
00095
00096 while(itr--) {
00097 k = (long64*)__data->keysched;
00098 for(i=8; i--; ) {
00099 s = *k++ ^ r;
00100 l ^= SBA(sb23, (s ) & 0xffff);
00101 l ^= SBA(sb23, (s >>= 16) & 0xffff);
00102 l ^= SBA(sb01, (s >>= 16) & 0xffff);
00103 l ^= SBA(sb01, (s >>= 16) );
00104
00105 s = *k++ ^ l;
00106 r ^= SBA(sb23, (s ) & 0xffff);
00107 r ^= SBA(sb23, (s >>= 16) & 0xffff);
00108 r ^= SBA(sb01, (s >>= 16) & 0xffff);
00109 r ^= SBA(sb01, (s >>= 16) );
00110 }
00111 s=l; l=r; r=s;
00112 }
00113
00114 res[0] = l >> 32; res[1] = l & 0xffffffff;
00115 res[2] = r >> 32; res[3] = r & 0xffffffff;
00116 }
00117
00118 #endif