Mercurial > projects > dcrypt
diff dcrypt/crypto/prngs/PRNGFromHash.d @ 32:2b4bccdc8387
Added version() statements to play nice with D2's current feelings about const. Changed a few methods (addEntropy and read in the base PRNG class, and the constructor for ParametersWithIV) to accept void[] in place of ubyte[].
author | Thomas Dixon <reikon@reikon.us> |
---|---|
date | Tue, 12 May 2009 22:09:33 -0400 |
parents | ad687db713a4 |
children |
line wrap: on
line diff
--- a/dcrypt/crypto/prngs/PRNGFromHash.d Tue May 12 17:10:47 2009 -0400 +++ b/dcrypt/crypto/prngs/PRNGFromHash.d Tue May 12 22:09:33 2009 -0400 @@ -28,7 +28,7 @@ string name() { if (hash is null) - throw new NotInitializedError(name()~": PRNG not initialized"); + throw new NotInitializedError(name()~": PRNG not initialized."); return hash.name~"PRNG"; } @@ -49,7 +49,7 @@ index = this.hash.digestSize; // to force updating of the state } - void addEntropy(ubyte[] input) + void addEntropy(void[] input) { if (!_initialized) { @@ -57,13 +57,15 @@ seed = hash.digest(); _initialized = true; } else - throw new NotSupportedError(name()~": state is immutable once initialized"); + throw new NotSupportedError(name()~": state is immutable once initialized."); } - uint read(ubyte[] output) + uint read(void[] output_) { if (!_initialized) - throw new NotInitializedError(name()~": PRNG not initialized"); + throw new NotInitializedError(name()~": PRNG not initialized."); + + ubyte[] output = cast(ubyte[])output_; for (uint i = 0; i < output.length; i++) {