comparison dcrypt/crypto/prngs/PBKDF2.d @ 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
comparison
equal deleted inserted replaced
32:2b4bccdc8387 33:b9f8aa42a547
42 * password = User supplied password 42 * password = User supplied password
43 * salt = (preferably random) salt 43 * salt = (preferably random) salt
44 * iterations = The number of total iterations 44 * iterations = The number of total iterations
45 * prf = The pseudo-random function 45 * prf = The pseudo-random function
46 */ 46 */
47 this(string password, void[] salt_, uint iterations=1000, MAC prf=new HMAC(new SHA1)) 47 this (string password, void[] salt_, uint iterations=1000, MAC prf=new HMAC(new SHA1))
48 { 48 {
49 49
50 salt = cast(ubyte[])salt_; 50 salt = cast(ubyte[])salt_;
51 if (salt == null) 51 if (salt == null)
52 throw new InvalidParameterError(name()~": No salt specified."); 52 throw new InvalidParameterError(name()~": No salt specified.");
65 blockCount = 0; 65 blockCount = 0;
66 buffer = new ubyte[this.prf.macSize]; 66 buffer = new ubyte[this.prf.macSize];
67 index = this.prf.macSize; 67 index = this.prf.macSize;
68 68
69 _initialized = true; 69 _initialized = true;
70 }
71
72 /** Play nice with D2's idea of const. */
73 version (D_Version2)
74 {
75 this (string password, string salt, uint iterations=1000, MAC prf=new HMAC(new SHA1))
76 {
77 this(password, cast(ubyte[])salt, iterations, prf);
78 }
70 } 79 }
71 80
72 void addEntropy(void[] input) 81 void addEntropy(void[] input)
73 { 82 {
74 throw new NotSupportedError(name()~": addEntropy is not supported."); 83 throw new NotSupportedError(name()~": addEntropy is not supported.");