view dcrypt/crypto/PRNG.d @ 28:ad687db713a4

Further reworked the code for hash padding. Replaced all instances of 'char[]' with 'string' and removed a few 'const' modifiers as per Glenn Haecker's patch for D2 compatibility. Updated CONTRIBUTORS file.
author Thomas Dixon <reikon@reikon.us>
date Sun, 10 May 2009 22:38:48 -0400
parents 8b5eaf3c2979
children 2b4bccdc8387
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(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);
    
    /** Returns: The name of the PRNG algorithm */
    string name();
}