| 1 | /* |
|---|
| 2 | * $Id$ |
|---|
| 3 | * Copyright 2008-2011 The Eraser Project |
|---|
| 4 | * Original Author: Joel Low <lowjoel@users.sourceforge.net> |
|---|
| 5 | * Modified By: |
|---|
| 6 | * |
|---|
| 7 | * This file is part of Eraser. |
|---|
| 8 | * |
|---|
| 9 | * Eraser is free software: you can redistribute it and/or modify it under the |
|---|
| 10 | * terms of the GNU General Public License as published by the Free Software |
|---|
| 11 | * Foundation, either version 3 of the License, or (at your option) any later |
|---|
| 12 | * version. |
|---|
| 13 | * |
|---|
| 14 | * Eraser is distributed in the hope that it will be useful, but WITHOUT ANY |
|---|
| 15 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
|---|
| 16 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|---|
| 17 | * |
|---|
| 18 | * A copy of the GNU General Public License can be found at |
|---|
| 19 | * <http://www.gnu.org/licenses/>. |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | using System; |
|---|
| 23 | using System.Collections.Generic; |
|---|
| 24 | using System.Linq; |
|---|
| 25 | using System.Text; |
|---|
| 26 | |
|---|
| 27 | using Eraser.Plugins.ExtensionPoints; |
|---|
| 28 | |
|---|
| 29 | namespace Eraser.Plugins.Registrars |
|---|
| 30 | { |
|---|
| 31 | /// <summary> |
|---|
| 32 | /// Class managing all the PRNG algorithms. |
|---|
| 33 | /// </summary> |
|---|
| 34 | public class PrngRegistrar : Registrar<IPrng> |
|---|
| 35 | { |
|---|
| 36 | /// <summary> |
|---|
| 37 | /// Constructor. |
|---|
| 38 | /// </summary> |
|---|
| 39 | internal PrngRegistrar() |
|---|
| 40 | { |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | /// <summary> |
|---|
| 44 | /// Gets the PRNG that is active. |
|---|
| 45 | /// </summary> |
|---|
| 46 | /// <remarks>Client code should set the <see cref="ActivePrngGuid"/> |
|---|
| 47 | /// member.</remarks> |
|---|
| 48 | public IPrng ActivePrng |
|---|
| 49 | { |
|---|
| 50 | get |
|---|
| 51 | { |
|---|
| 52 | return this[ActivePrngGuid]; |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | /// <summary> |
|---|
| 57 | /// Sets the GUID of the active PRNG. |
|---|
| 58 | /// </summary> |
|---|
| 59 | public Guid ActivePrngGuid |
|---|
| 60 | { |
|---|
| 61 | private get; |
|---|
| 62 | set; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | /// <summary> |
|---|
| 66 | /// Allows the EntropyThread to get entropy to the PRNG functions as seeds. |
|---|
| 67 | /// </summary> |
|---|
| 68 | /// <param name="entropy">An array of bytes, being entropy for the PRNG.</param> |
|---|
| 69 | public void AddEntropy(byte[] entropy) |
|---|
| 70 | { |
|---|
| 71 | lock (this) |
|---|
| 72 | foreach (IPrng prng in Host.Instance.Prngs) |
|---|
| 73 | prng.Reseed(entropy); |
|---|
| 74 | } |
|---|
| 75 | } |
|---|
| 76 | } |
|---|