diff dcrypt/crypto/ciphers/Salsa20.d @ 28:ad687db713a4

Further reworked the code for hash padding. Replaced all instances of 'char[]' with 'string' and removed a few 'const' modifiers as per Glenn Haecker's patch for D2 compatibility. Updated CONTRIBUTORS file.
author Thomas Dixon <reikon@reikon.us>
date Sun, 10 May 2009 22:38:48 -0400
parents 8b5eaf3c2979
children
line wrap: on
line diff
--- a/dcrypt/crypto/ciphers/Salsa20.d	Sat May 09 23:29:20 2009 -0400
+++ b/dcrypt/crypto/ciphers/Salsa20.d	Sun May 10 22:38:48 2009 -0400
@@ -19,8 +19,8 @@
     protected
     {
         // Constants
-        const ubyte[] sigma = cast(ubyte[])"expand 32-byte k",
-                      tau = cast(ubyte[])"expand 16-byte k";
+        static ubyte[] sigma = cast(ubyte[])"expand 32-byte k",
+                       tau = cast(ubyte[])"expand 16-byte k";
         
         // Counter indexes (added for ChaCha)            
         uint i0, i1;
@@ -85,7 +85,7 @@
         _encrypt = _initialized = true;
     }
     
-    char[] name()
+    string name()
     {
         return "Salsa20";
     }
@@ -235,7 +235,7 @@
     {
         unittest
         {
-            static const char[][] test_keys = [
+            static string[] test_keys = [
                 "80000000000000000000000000000000", 
                 "0053a6f94c9ff24598eb3e91e4378add",
                 "00002000000000000000000000000000"~
@@ -245,14 +245,14 @@
                 
             ];
             
-            static const char[][] test_ivs = [
+            static string[] test_ivs = [
                 "0000000000000000",            
                 "0d74db42a91077de",
                 "0000000000000000",
                 "288ff65dc42b92f9"
             ];
                  
-            static const char[][] test_plaintexts = [
+            static string[] test_plaintexts = [
                 "00000000000000000000000000000000"~
                 "00000000000000000000000000000000"~
                 "00000000000000000000000000000000"~
@@ -276,7 +276,7 @@
                 
             ];
                  
-            static const char[][] test_ciphertexts = [
+            static string[] test_ciphertexts = [
                 "4dfa5e481da23ea09a31022050859936"~ // Expected output
                 "da52fcee218005164f267cb65f5cfd7f"~
                 "2b4f97e0ff16924a52df269515110a07"~
@@ -300,7 +300,7 @@
 
             Salsa20 s20 = new Salsa20();
             ubyte[] buffer = new ubyte[64];
-            char[] result;
+            string result;
             for (int i = 0; i < test_keys.length; i++)
             {
                 SymmetricKey key = new SymmetricKey(ByteConverter.hexDecode(test_keys[i]));