Changeset 2567
- Timestamp:
- 3/21/2012 11:31:28 AM (14 months ago)
- Location:
- trunk/eraser/Eraser.Manager
- Files:
-
- 2 edited
-
EntropyPoller.cs (modified) (7 diffs)
-
ManagerLibrary.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser.Manager/EntropyPoller.cs
r2566 r2567 49 49 Pool = new byte[sizeof(uint) << 7]; 50 50 51 //Handle the Entropy Source Registered event. 52 Host.Instance.EntropySources.Registered += OnEntropySourceRegistered; 53 54 //Meanwhile, add all entropy sources already registered. 55 foreach (IEntropySource source in Host.Instance.EntropySources) 56 AddEntropySource(source); 57 51 58 //Then start the thread which maintains the pool. 52 59 Thread = new Thread(Main); … … 78 85 Thread.Sleep(2000 + (int)(DateTime.Now.Ticks % 2999)); 79 86 80 // Send entropy to the PRNGs for new seeds.87 //Send entropy to the PRNGs for new seeds. 81 88 DateTime now = DateTime.Now; 82 89 if (now - lastAddedEntropy > managerEntropySpan) … … 94 101 { 95 102 Thread.Abort(); 103 } 104 105 /// <summary> 106 /// Handles the OnEntropySourceRegistered event so we can register them with 107 /// ourselves. 108 /// </summary> 109 /// <param name="sender">The object which was registered.</param> 110 /// <param name="e">Event argument.</param> 111 private void OnEntropySourceRegistered(object sender, EventArgs e) 112 { 113 AddEntropySource((IEntropySource)sender); 96 114 } 97 115 … … 177 195 for (; i < Pool.Length - hashSize; i += hashSize) 178 196 Buffer.BlockCopy(hash.ComputeHash(Pool, i, 179 i + mixBlockSize >= Pool.Length ? Pool.Length - i : mixBlockSize),180 0, Pool, i, i + hashSize >= Pool.Length ? Pool.Length - i : hashSize);197 Math.Min(mixBlockSize, Pool.Length - i)), 0, Pool, i, 198 Math.Min(hashSize, Pool.Length - i)); 181 199 182 200 //Mix the remaining blocks which require copying from the front … … 184 202 for (; i < Pool.Length; i += hashSize) 185 203 { 186 Buffer.BlockCopy(Pool, i, combinedBuffer, 0, Pool.Length - i);187 188 Buffer.BlockCopy(Pool, 0, combinedBuffer, Pool.Length - i,189 mixBlockSize - (Pool.Length - i));204 int remainder = Pool.Length - i; 205 Buffer.BlockCopy(Pool, i, combinedBuffer, 0, remainder); 206 Buffer.BlockCopy(Pool, 0, combinedBuffer, remainder, 207 mixBlockSize - remainder); 190 208 191 209 Buffer.BlockCopy(hash.ComputeHash(combinedBuffer, 0, mixBlockSize), 0, 192 Pool, i, Pool.Length - i > hashSize ? hashSize : Pool.Length - i);210 Pool, i, Math.Min(hashSize, remainder)); 193 211 } 194 212 } … … 222 240 //Bring the pool position back to the front if we are at our end 223 241 if (PoolPosition >= Pool.Length) 242 { 224 243 PoolPosition = 0; 244 MixPool(); 245 } 225 246 226 247 int amountToMix = Math.Min(size, Pool.Length - PoolPosition); … … 228 249 mpEntropy = mpEntropy + amountToMix; 229 250 size -= amountToMix; 251 PoolPosition += amountToMix; 230 252 } 231 253 } -
trunk/eraser/Eraser.Manager/ManagerLibrary.cs
r2516 r2567 44 44 Instance = this; 45 45 Settings = new ManagerSettings(persistentStore); 46 entropyPoller = new EntropyPoller();47 46 Host.Initialise(persistentStore); 48 47 Host.Instance.PluginLoad += OnPluginLoad; 49 48 Host.Instance.Load(); 49 50 //Initialise the Entropy Poller last since it depends on the Host. 51 entropyPoller = new EntropyPoller(); 50 52 } 51 53
Note: See TracChangeset
for help on using the changeset viewer.
