Mercurial > projects > dcrypt
diff dcrypt/crypto/prngs/PBKDF2.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 | 21847420b1ac |
line wrap: on
line diff
--- a/dcrypt/crypto/prngs/PBKDF2.d Sat May 09 23:29:20 2009 -0400 +++ b/dcrypt/crypto/prngs/PBKDF2.d Sun May 10 22:38:48 2009 -0400 @@ -28,7 +28,7 @@ ubyte[] salt, buffer; - char[] password; + string password; MAC prf; @@ -44,7 +44,7 @@ * iterations = The number of total iterations * prf = The pseudo-random function */ - this(char[] 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_; @@ -111,7 +111,7 @@ return output.length; } - char[] name() + string name() { return "PBKDF2-"~prf.name; } @@ -120,7 +120,7 @@ { unittest { - static char[][] test_passwords = [ + static string[] test_passwords = [ "password", "password", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"~ @@ -129,7 +129,7 @@ "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ]; - static char[][] test_salts = [ + static string[] test_salts = [ "ATHENA.MIT.EDUraeburn", "ATHENA.MIT.EDUraeburn", "pass phrase equals block size", @@ -140,7 +140,7 @@ 1, 1200, 1200, 1200 ]; - static const char[][] test_results = [ + static const string[] test_results = [ "cdedb5281bb2f801565a1122b2563515", "5c08eb61fdf71e4e4ec3cf6ba1f5512b"~ "a7e52ddbc5e5142f708a31e2e62b1e13", @@ -151,12 +151,12 @@ ]; PBKDF2 pbkdf2; - foreach (uint i, char[] p; test_passwords) + foreach (uint i, string p; test_passwords) { pbkdf2 = new PBKDF2(p, test_salts[i], test_iterations[i]); ubyte[] result = new ubyte[test_results[i].length >> 1]; pbkdf2.read(result); - char[] hexResult = ByteConverter.hexEncode(result); + string hexResult = ByteConverter.hexEncode(result); assert(hexResult == test_results[i], pbkdf2.name~": ("~hexResult~") != ("~test_results[i]~")"); }