changeset 20:3a57367afe34

Fixed bug which prevented Blowfish from resetting correctly.
author Thomas Dixon <reikon@reikon.us>
date Fri, 09 Jan 2009 01:24:45 -0500
parents 6e11990d031d
children ec23779ee794
files dcrypt/crypto/ciphers/Blowfish.d
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/dcrypt/crypto/ciphers/Blowfish.d	Wed Nov 19 19:48:31 2008 -0500
+++ b/dcrypt/crypto/ciphers/Blowfish.d	Fri Jan 09 01:24:45 2009 -0500
@@ -231,15 +231,11 @@
             throw new InvalidKeyError(
                     name()~": Invalid key length (requires 4-56 bytes)");
         
-        S0[] = S_INIT[0..256];
-        S1[] = S_INIT[256..512];
-        S2[] = S_INIT[512..768];
-        S3[] = S_INIT[768..1024];
-        P[] = P_INIT[];
+        workingKey = keyParams.key;
         
-        workingKey = keyParams.key;
         // Yes, this is ghetto. I know.
         _initialized = true;
+        
         setup(workingKey);
         
         if (!_encrypt)
@@ -288,6 +284,12 @@
     }
     
     private void setup(ubyte[] key) {
+        S0[] = S_INIT[0..256];
+        S1[] = S_INIT[256..512];
+        S2[] = S_INIT[512..768];
+        S3[] = S_INIT[768..1024];
+        P[] = P_INIT[];
+        
         uint index = 0;
 
         for (int i = 0; i < PBOX_SIZE; i++) {