changeset 33:b9f8aa42a547

More changes suggested by Glenn Haecker for D2 compatibility.
author Thomas Dixon <reikon@reikon.us>
date Thu, 14 May 2009 01:33:11 -0400
parents 2b4bccdc8387
children b1d9be1b3a34
files dcrypt/crypto/Hash.d dcrypt/crypto/MAC.d dcrypt/crypto/macs/HMAC.d dcrypt/crypto/params/SymmetricKey.d dcrypt/crypto/prngs/PBKDF2.d
diffstat 5 files changed, 32 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/dcrypt/crypto/Hash.d	Tue May 12 22:09:33 2009 -0400
+++ b/dcrypt/crypto/Hash.d	Thu May 14 01:33:11 2009 -0400
@@ -41,7 +41,7 @@
     {
         this (string input_)
         {
-            return this(cast(ubyte[])input_);
+            this(cast(ubyte[])input_);
         }
     }
     
@@ -162,7 +162,7 @@
      * 
      * Returns: Representation of the final hash value in hex.
      */
-    char[] hexDigest()
+    string hexDigest()
     {
         return ByteConverter.hexEncode(digest());
     }
--- a/dcrypt/crypto/MAC.d	Tue May 12 22:09:33 2009 -0400
+++ b/dcrypt/crypto/MAC.d	Thu May 14 01:33:11 2009 -0400
@@ -57,7 +57,7 @@
     ubyte[] digest();
     
     /** Returns: The computed MAC in hexadecimal. */
-    char[] hexDigest()
+    string hexDigest()
     {
         return ByteConverter.hexEncode(digest());
     }
--- a/dcrypt/crypto/macs/HMAC.d	Tue May 12 22:09:33 2009 -0400
+++ b/dcrypt/crypto/macs/HMAC.d	Thu May 14 01:33:11 2009 -0400
@@ -45,6 +45,15 @@
             init(new SymmetricKey(key)); // I'm lazy.
     }
     
+    /** Play nice with D2's idea of const. */
+    version (D_Version2)
+    {
+        this (Hash hash, string key)
+        {
+            this(hash, cast(ubyte[])key);
+        }
+    }
+    
     void init(CipherParameters params)
     {
         SymmetricKey keyParams = cast(SymmetricKey)params;
@@ -116,7 +125,7 @@
         return r;
     }
     
-    char[] hexDigest()
+    string hexDigest()
     {
         return ByteConverter.hexEncode(digest());
     }
--- a/dcrypt/crypto/params/SymmetricKey.d	Tue May 12 22:09:33 2009 -0400
+++ b/dcrypt/crypto/params/SymmetricKey.d	Thu May 14 01:33:11 2009 -0400
@@ -25,6 +25,15 @@
         _key = cast(ubyte[]) key;
     }
     
+    /** Play nice with D2's idea of const. */
+    version (D_Version2)
+    {
+        this (string key)
+        {
+            this(cast(ubyte[])key);
+        }
+    }
+    
     /** Returns: Key in ubytes held by this object. */
     ubyte[] key()
     {
--- a/dcrypt/crypto/prngs/PBKDF2.d	Tue May 12 22:09:33 2009 -0400
+++ b/dcrypt/crypto/prngs/PBKDF2.d	Thu May 14 01:33:11 2009 -0400
@@ -44,7 +44,7 @@
      *     iterations = The number of total iterations
      *     prf = The pseudo-random function
      */
-    this(string password, void[] salt_, uint iterations=1000, MAC prf=new HMAC(new SHA1))
+    this (string password, void[] salt_, uint iterations=1000, MAC prf=new HMAC(new SHA1))
     {
         
         salt = cast(ubyte[])salt_;
@@ -69,6 +69,15 @@
         _initialized = true;
     }
     
+    /** Play nice with D2's idea of const. */
+    version (D_Version2)
+    {
+        this (string password, string salt, uint iterations=1000, MAC prf=new HMAC(new SHA1))
+        {
+            this(password, cast(ubyte[])salt, iterations, prf);
+        }
+    }
+    
     void addEntropy(void[] input)
     {
         throw new NotSupportedError(name()~": addEntropy is not supported.");