Mercurial > projects > dcrypt
view dcrypt/crypto/PRNG.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 source
/** * This file is part of the dcrypt project. * * Copyright: Copyright (C) dcrypt contributors 2008. All rights reserved. * License: MIT * Authors: Thomas Dixon */ module dcrypt.crypto.PRNG; public import dcrypt.crypto.errors.ShortBufferError; public import dcrypt.crypto.errors.NotInitializedError; public import dcrypt.crypto.errors.InvalidParameterError; public import dcrypt.crypto.errors.NotSupportedError; /** Relatively simple interface for PRNGs. */ abstract class PRNG { protected bool _initialized; /** Returns: Whether or not the PRNG has been initialized. */ bool initialized() { return _initialized; } /** * Introduce entropy into the PRNG. An initial call to this is * usually required for seeding. * * Params: * input = Bytes to introduce into the PRNG as entropy */ void addEntropy(void[] input); /** Play nice with D2's idea of const. */ version (D_Version2) { void addEntropy(string input) { addEntropy(cast(ubyte[])input); } } /** * Read bytes from the keystream of the PRNG into output. * * Params: * output = Array to fill with the next bytes of the keystream */ uint read(void[] output_); /** Returns: The name of the PRNG algorithm */ string name(); }