Mercurial > projects > dcrypt
view dcrypt/crypto/PRNG.d @ 14:5ce3012f1def
Removed some redundancy in code. Added NotSupportedError, a base PRNG class and a class which creates a PRNG from a hash function. Changed the MAC class' finalization methods to digest and hexDigest instead of finish and hexFinish respectively. Also added a base Checksum class, crc32 and adler32 in dcrypt.misc as per request.
author | Thomas Dixon <reikon@reikon.us> |
---|---|
date | Tue, 18 Nov 2008 18:03:40 -0500 |
parents | |
children | 0de48552be35 |
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: The name of the PRNG. */ char[] name(); /** 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(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(ubyte[] output); }