[svn] / ecrypt / trunk / submissions / py / tpy6 / tpy6.c  

svn: ecrypt/trunk/submissions/py/tpy6/tpy6.c

Diff for /ecrypt/trunk/submissions/py/tpy6/tpy6.c between version 21 and 204

version 21, Mon Jun 27 05:47:37 2005 UTC version 204, Mon Jan 29 14:29:46 2007 UTC
Line 93 
Line 93 
   u32 s;    u32 s;
   
   int keysize=ctx->keysize;    int keysize=ctx->keysize;
     int keysizeb=(keysize+7)>>3;
   int ivsize=ctx->ivsize;    int ivsize=ctx->ivsize;
   int ivsizeb=(ivsize+7)>>3;    int ivsizeb=(ivsize+7)>>3;
   
 #define P(x) (((u8*)&(ctx->KPY[x][1]))[0])  #define P(x) (((u8*)&(ctx->KPY[x][1]))[0])
 #define KY(x) (ctx->KPY[(x)-(YMININD)][0])  #define KY(x) (ctx->KPY[(x)-(YMININD)][0])
 #define EIV(x) (((u8*)&(ctx->KPY[x+64-ivsizeb][1]))[2])  #define EIV(x) (((u8*)&(ctx->KPY[x+64-2*ivsizeb][1]))[2])
   
   /* Create an initial permutation */    /* Create an initial permutation */
   u8 v= iv[0] ^ ((KY(0)>>16)&0xFF);    u8 v= iv[0] ^ ((KY(0)>>16)&0xFF);
Line 134 
Line 135 
       s = s + iv[i] + KY(YMININD+i);        s = s + iv[i] + KY(YMININD+i);
       u8 s0 = P(s&0x3F);        u8 s0 = P(s&0x3F);
       EIV(i) = s0;        EIV(i) = s0;
       s = ROTL32(s, 6) ^ (u32)s0;        u8 s1 = P((s>>2)&0x3F);
         EIV(i+ivsizeb) = s1;
         s = ROTL32(s, 12) ^ (u32)s0 ^ (((u32)s1)<<6);
     }      }
   /* Again, but with the last words of KY, and update EIV */    /* Again, but with the last words of KY, and update EIV */
   for(i=0; i<ivsizeb; i++)    for(i=0; i<ivsizeb*2; i++)
     {      {
       s = s + iv[i] + KY(YMAXIND-i);        s = s + EIV((i+ivsizeb*2-1)%(ivsizeb*2)) + KY(YMAXIND-i);
       u8 s0 = P(s&0x3F);        u8 s0 = P(s&0x3F);
       EIV(i) += s0;        EIV(i) += s0;
       EIV(i) &= 0x3F;        EIV(i) &= 0x3F;
Line 152 
Line 155 
 #define P(i8,j) (((u8*)ctx->KPY)[(i8)+8*(j)+4])  #define P(i8,j) (((u8*)ctx->KPY)[(i8)+8*(j)+4])
   /* access P[i+j] where i8=8*i. */    /* access P[i+j] where i8=8*i. */
   /* P is byte 4 of the 8-byte record */    /* P is byte 4 of the 8-byte record */
 #define EIV(i8,j) (((u8*)ctx->KPY)[(i8)+8*(j+64-ivsizeb)+6])  #define EIV(i8,j) (((u8*)ctx->KPY)[(i8)+8*(j+64-2*ivsizeb)+6])
   /* access P[i+j] where i8=8*i. */    /* access P[i+j] where i8=8*i. */
   /* EIV is byte 6 of the 8-byte record */    /* EIV is byte 6 of the 8-byte record */
 #define Y(i8,j) (((u32*)&(((u8*)ctx->KPY)[(i8)+8*((j)-(YMININD))]))[0])  #define Y(i8,j) (((u32*)&(((u8*)ctx->KPY)[(i8)+8*((j)-(YMININD))]))[0])
Line 164 
Line 167 
       u32 x0 = EIV(i,ivsizeb) = EIV(i,0)^(s&0x3F);        u32 x0 = EIV(i,ivsizeb) = EIV(i,0)^(s&0x3F);
       P(i,64)=P(i,x0);        P(i,64)=P(i,x0);
       P(i,x0)=P(i,0);        P(i,x0)=P(i,0);
       Y(i,YMAXIND+1)=s=(s^Y(i,YMININD))+Y(i,x0);        s=ROTL32(s,8)+Y(i,YMAXIND);
         Y(i,YMAXIND+1) = Y(i,YMININD) + (s^Y(i,x0));
     }      }
   
   s=s+Y(i,8)+Y(i,21)+Y(i,48);    s=s+Y(i,8)+Y(i,21)+Y(i,48);
Line 215 
Line 219 
      /* loose a few bytes                                    */       /* loose a few bytes                                    */
 {  {
   int i;    int i;
     int bl;
   
   u32 s=ctx->s;    u32 s=ctx->s;
   
Line 309 
Line 314 
      /* last call for this stream, or either you will loose a few bytes */       /* last call for this stream, or either you will loose a few bytes */
 {  {
   int i;    int i;
     int bl;
   
   u32 s=ctx->s;    u32 s=ctx->s;
   
Line 353 
Line 359 
           Y(i,YMAXIND+1)=(s^Y(i,YMININD))+Y(i,P(i,1+48));            Y(i,YMAXIND+1)=(s^Y(i,YMININD))+Y(i,P(i,1+48));
           s=ROTL32(s,11);            s=ROTL32(s,11);
           u32 output1=(s^Y(i,64))+Y(i,P(i,1+8));            u32 output1=(s^Y(i,64))+Y(i,P(i,1+8));
             u8 output1b[4];
           U32TO8_LITTLE(keystream+i, output1);            U32TO8_LITTLE(keystream+i, output1);
           s=ROTL32(s,7);            s=ROTL32(s,7);
           u32 output2=(s^Y(i,-1))+Y(i,P(i,1+21));            u32 output2=(s^Y(i,-1))+Y(i,P(i,1+21));
Line 393 
Line 400 
 {  {
   int i;    int i;
   u8 j=0;    u8 j=0;
   static u8 str[] =    static char str[] =
     "This is the seed for generating the fixed internal permutation for Py. "      "This is the seed for generating the fixed internal permutation for Py. "
     "The permutation is used in the key setup and IV setup as a source of nonlinearity. "      "The permutation is used in the key setup and IV setup as a source of nonlinearity. "
     "The shifted special keys on a keyboard are ~!@#$%^&*()_+{}:|<>?";      "The shifted special keys on a keyboard are ~!@#$%^&*()_+{}:|<>?";
   u8 *p=str;    u8 *p=(u8*)str;
   
   for(i=0; i<256; i++)    for(i=0; i<256; i++)
     internal_permutation[i] = i;      internal_permutation[i] = i;
Line 410 
Line 417 
       internal_permutation[j&0xFF] = tmp;        internal_permutation[j&0xFF] = tmp;
       p++;        p++;
       if(p[0] == 0)        if(p[0] == 0)
         p=str;          p=(u8*)str;
     }      }
 }  }


Generate output suitable for use with a patch program
Legend:
Removed from v.21  
changed lines
  Added in v.204

eSTREAM Project

Powered by ViewCVS 1.0-dev
(Powered by Apache)

ViewCVS and CVS Help