# HG changeset patch # User Thomas Dixon # Date 1242279191 14400 # Node ID b9f8aa42a5479ebcf75d045907cf9fe1f3bc08c1 # Parent 2b4bccdc8387f5763d85e29b692ae9dc0346f4f9 More changes suggested by Glenn Haecker for D2 compatibility. diff -r 2b4bccdc8387 -r b9f8aa42a547 dcrypt/crypto/Hash.d --- 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()); } diff -r 2b4bccdc8387 -r b9f8aa42a547 dcrypt/crypto/MAC.d --- 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()); } diff -r 2b4bccdc8387 -r b9f8aa42a547 dcrypt/crypto/macs/HMAC.d --- 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()); } diff -r 2b4bccdc8387 -r b9f8aa42a547 dcrypt/crypto/params/SymmetricKey.d --- 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() { diff -r 2b4bccdc8387 -r b9f8aa42a547 dcrypt/crypto/prngs/PBKDF2.d --- 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.");