comparison 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
comparison
equal deleted inserted replaced
13:7ea528b61802 14:5ce3012f1def
1 /**
2 * This file is part of the dcrypt project.
3 *
4 * Copyright: Copyright (C) dcrypt contributors 2008. All rights reserved.
5 * License: MIT
6 * Authors: Thomas Dixon
7 */
8
9 module dcrypt.crypto.PRNG;
10
11 public import dcrypt.crypto.errors.ShortBufferError;
12 public import dcrypt.crypto.errors.NotInitializedError;
13 public import dcrypt.crypto.errors.InvalidParameterError;
14 public import dcrypt.crypto.errors.NotSupportedError;
15
16 /** Relatively simple interface for PRNGs. */
17 abstract class PRNG {
18
19 protected bool _initialized;
20
21 /** Returns: The name of the PRNG. */
22 char[] name();
23
24 /** Returns: Whether or not the PRNG has been initialized. */
25 bool initialized() {
26 return _initialized;
27 }
28
29 /**
30 * Introduce entropy into the PRNG. An initial call to this is
31 * usually required for seeding.
32 *
33 * Params:
34 * input = Bytes to introduce into the PRNG as entropy
35 */
36 void addEntropy(ubyte[] input);
37
38 /**
39 * Read bytes from the keystream of the PRNG into output.
40 *
41 * Params:
42 * output = Array to fill with the next bytes of the keystream
43 */
44 uint read(ubyte[] output);
45 }