[svn] / ecrypt / trunk / submissions / dragon / dragon.c  

svn: ecrypt/trunk/submissions/dragon/dragon.c

Diff for /ecrypt/trunk/submissions/dragon/dragon.c between version 1 and 6

version 1, Sun Jun 26 18:46:26 2005 UTC version 6, Sun Jun 26 20:15:09 2005 UTC
Line 80 
Line 80 
   
     assert(ctx && key);      assert(ctx && key);
   
     ctx->nlfsr_offset  = 0;  
     ctx->key_size      = keysize;      ctx->key_size      = keysize;
     ctx->full_rekeying = 1;  
     ctx->buffer_index  = 0;  
   
     /**      /**
       * Dragon supports the following combinations of key and IV sizes only:        * Dragon supports the following combinations of key and IV sizes only:
Line 158 
Line 155 
     assert(ctx && iv);      assert(ctx && iv);
   
     /**      /**
       * This is either a continuation of key initialization,        * Restore the state to the post-keysetup state.
       * or a fresh IV rekeying. In the latter case, restore the  
       * state to the post-keysetup state.  
       */        */
     if (ctx->full_rekeying == 0) {  
         for (idx = 0; idx < DRAGON_NLFSR_SIZE; idx++) {          for (idx = 0; idx < DRAGON_NLFSR_SIZE; idx++) {
             ctx->nlfsr_word[idx] = ctx->init_state[idx];              ctx->nlfsr_word[idx] = ctx->init_state[idx];
         }          }
     }  
   
     /* For a keysize of 128 bits, the Dragon NLFSR is initialized      /* For a keysize of 128 bits, the Dragon NLFSR is initialized
        using K and IV as follows (where k' and iv' represent         using K and IV as follows (where k' and iv' represent
Line 218 
Line 211 
         }          }
     }      }
   
       ctx->nlfsr_offset = 0;
   
     /** Iterate mixing process */      /** Iterate mixing process */
     for (idx = 0; idx < DRAGON_MIXING_STAGES; idx++) {      for (idx = 0; idx < DRAGON_MIXING_STAGES; idx++) {
         a = DRAGON_NLFSR_WORD(ctx, 0)  ^          a = DRAGON_NLFSR_WORD(ctx, 0)  ^
Line 247 
Line 242 
     }      }
     ctx->state_counter = ((u64)e << 32) | (u64)f;      ctx->state_counter = ((u64)e << 32) | (u64)f;
   
     /* Assume that the next keying operation will be IV only */      /* reset buffer index */
     ctx->full_rekeying = 0 ;      ctx->buffer_index = 0;
 }  }
   
 /**  /**
Line 348 
Line 343 
                 DRAGON_BUFFER_SIZE);                  DRAGON_BUFFER_SIZE);
         }          }
         *(keystream++) = ctx->keystream_buffer[ctx->buffer_index];          *(keystream++) = ctx->keystream_buffer[ctx->buffer_index];
         ctx->buffer_index = (ctx->buffer_index % DRAGON_BUFFER_SIZE);          ctx->buffer_index = ((ctx->buffer_index + 1) % DRAGON_BUFFER_BYTES);
     }      }
 }  }
   


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

eSTREAM Project

Powered by ViewCVS 1.0-dev
(Powered by Apache)

ViewCVS and CVS Help