Changeset 2055 for trunk/eraser
- Timestamp:
- 05/04/10 06:51:04 (3 years ago)
- Location:
- trunk/eraser
- Files:
-
- 2 added
- 9 edited
-
Eraser.DefaultPlugins/EntropySources (added)
-
Eraser.DefaultPlugins/EntropySources/KernelEntropySource.cs (added)
-
Eraser.DefaultPlugins/Eraser.DefaultPlugins.csproj (modified) (2 diffs)
-
Eraser.DefaultPlugins/Plugin.cs (modified) (1 diff)
-
Eraser.DefaultPlugins/Strings.en.resx (modified) (1 diff)
-
Eraser.DefaultPlugins/Strings.it.resx (modified) (1 diff)
-
Eraser.DefaultPlugins/Strings.nl.resx (modified) (1 diff)
-
Eraser.DefaultPlugins/Strings.pl.resx (modified) (1 diff)
-
Eraser.DefaultPlugins/Strings.resx (modified) (1 diff)
-
Eraser.Manager/EntropySource.cs (modified) (4 diffs)
-
Eraser.Manager/Eraser.Manager.csproj (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser.DefaultPlugins/Eraser.DefaultPlugins.csproj
r2044 r2055 48 48 </PropertyGroup> 49 49 <ItemGroup> 50 <Reference Include="Microsoft.VisualBasic" /> 50 51 <Reference Include="System" /> 51 52 <Reference Include="System.Core"> … … 73 74 <DependentUpon>CustomMethodPassEditor.cs</DependentUpon> 74 75 </Compile> 76 <Compile Include="EntropySources\KernelEntropySource.cs" /> 75 77 <Compile Include="ErasureMethods\Custom.cs" /> 76 78 <Compile Include="ErasureMethods\DoD.cs" /> -
trunk/eraser/Eraser.DefaultPlugins/Plugin.cs
r2039 r2055 55 55 56 56 ManagerLibrary.Instance.PrngRegistrar.Add(new RngCrypto()); 57 58 ManagerLibrary.Instance.EntropySourceRegistrar.Add(new KernelEntropySource()); 57 59 58 60 ManagerLibrary.Instance.FileSystemRegistrar.Add(new Fat12FileSystem()); -
trunk/eraser/Eraser.DefaultPlugins/Strings.en.resx
r2052 r2055 316 316 <value>German VSITR</value> 317 317 </data> 318 <data name="Kernel Entropy Source" xml:space="preserve"> 319 <value>Kernel Entropy Source</value> 320 </data> 318 321 </root> -
trunk/eraser/Eraser.DefaultPlugins/Strings.it.resx
r2052 r2055 316 316 <value>German VSITR</value> 317 317 </data> 318 <data name="Kernel Entropy Source" xml:space="preserve"> 319 <value>(Untranslated)</value> 320 </data> 318 321 </root> -
trunk/eraser/Eraser.DefaultPlugins/Strings.nl.resx
r2052 r2055 316 316 <value>(Untranslated)</value> 317 317 </data> 318 <data name="Kernel Entropy Source" xml:space="preserve"> 319 <value>(Untranslated)</value> 320 </data> 318 321 </root> -
trunk/eraser/Eraser.DefaultPlugins/Strings.pl.resx
r2052 r2055 316 316 <value>German VSITR</value> 317 317 </data> 318 <data name="Kernel Entropy Source" xml:space="preserve"> 319 <value>(Untranslated)</value> 320 </data> 318 321 </root> -
trunk/eraser/Eraser.DefaultPlugins/Strings.resx
r2052 r2055 316 316 <value>German VSITR</value> 317 317 </data> 318 <data name="Kernel Entropy Source" xml:space="preserve"> 319 <value>Kernel Entropy Source</value> 320 </data> 318 321 </root> -
trunk/eraser/Eraser.Manager/EntropySource.cs
r1904 r2055 24 24 using System.Text; 25 25 26 using System.Globalization;27 26 using System.Threading; 28 27 using System.Security.Cryptography; … … 30 29 using System.Diagnostics; 31 30 using System.Reflection; 32 using System.IO;33 34 using System.Windows.Forms;35 using Microsoft.VisualBasic.Devices;36 using Microsoft.Win32.SafeHandles;37 using Eraser.Util;38 31 39 32 namespace Eraser.Manager … … 134 127 { 135 128 Poller = new EntropyPoller(); 136 Poller.AddEntropySource(new KernelEntropySource());137 129 } 138 130 … … 147 139 private Dictionary<Guid, EntropySource> sources = new Dictionary<Guid, EntropySource>(); 148 140 }; 149 150 /// <summary>151 /// Provides means of generating random entropy from the system or user space152 /// randomness.153 /// This class is hardcoded into the Manager Library as we need at least one154 /// instance of such behaviour within our system. The other classes could be155 /// implemented as plugins, managed by EntropySourceManager.156 /// </summary>157 public class KernelEntropySource : EntropySource158 {159 public override byte[] GetPrimer()160 {161 List<byte> result = new List<byte>();162 163 //Process information164 result.AddRange(StructToBuffer(Process.GetCurrentProcess().Id));165 result.AddRange(StructToBuffer(Process.GetCurrentProcess().StartTime.Ticks));166 167 result.AddRange(GetFastEntropy());168 result.AddRange(GetSlowEntropy());169 return result.ToArray();170 }171 172 public override Guid Guid173 {174 get175 {176 return new Guid("{11EDCECF-AD81-4e50-A73D-B9CF1F813093}");177 }178 }179 180 public override string Name181 {182 get183 {184 return "Kernel Entropy Source";185 }186 }187 188 public override byte[] GetEntropy()189 {190 List<byte> result = new List<byte>();191 result.AddRange(GetFastEntropy());192 result.AddRange(GetSlowEntropy());193 194 return result.ToArray();195 }196 197 /// <summary>198 /// Retrieves entropy from quick sources.199 /// </summary>200 public override byte[] GetFastEntropy()201 {202 List<byte> result = new List<byte>();203 204 //Add the free disk space to the pool205 result.AddRange(StructToBuffer(new DriveInfo(new DirectoryInfo(Environment.SystemDirectory).206 Root.FullName).TotalFreeSpace));207 208 //Miscellaneous window handles209 result.AddRange(StructToBuffer(UserApi.MessagePos));210 result.AddRange(StructToBuffer(UserApi.MessageTime));211 212 //The caret and cursor positions213 result.AddRange(StructToBuffer(UserApi.CaretPos));214 result.AddRange(StructToBuffer(Cursor.Position));215 216 //Currently running threads (dynamic, but not very)217 Process currProcess = Process.GetCurrentProcess();218 foreach (ProcessThread thread in currProcess.Threads)219 result.AddRange(StructToBuffer(thread.Id));220 221 //Various process statistics222 result.AddRange(StructToBuffer(currProcess.VirtualMemorySize64));223 result.AddRange(StructToBuffer(currProcess.MaxWorkingSet));224 result.AddRange(StructToBuffer(currProcess.MinWorkingSet));225 result.AddRange(StructToBuffer(currProcess.NonpagedSystemMemorySize64));226 result.AddRange(StructToBuffer(currProcess.PagedMemorySize64));227 result.AddRange(StructToBuffer(currProcess.PagedSystemMemorySize64));228 result.AddRange(StructToBuffer(currProcess.PeakPagedMemorySize64));229 result.AddRange(StructToBuffer(currProcess.PeakVirtualMemorySize64));230 result.AddRange(StructToBuffer(currProcess.PeakWorkingSet64));231 result.AddRange(StructToBuffer(currProcess.PrivateMemorySize64));232 result.AddRange(StructToBuffer(currProcess.WorkingSet64));233 result.AddRange(StructToBuffer(currProcess.HandleCount));234 235 //Amount of free memory236 ComputerInfo computerInfo = new ComputerInfo();237 result.AddRange(StructToBuffer(computerInfo.AvailablePhysicalMemory));238 result.AddRange(StructToBuffer(computerInfo.AvailableVirtualMemory));239 240 //Process execution times241 result.AddRange(StructToBuffer(currProcess.TotalProcessorTime));242 result.AddRange(StructToBuffer(currProcess.UserProcessorTime));243 result.AddRange(StructToBuffer(currProcess.PrivilegedProcessorTime));244 245 //Thread execution times246 foreach (ProcessThread thread in currProcess.Threads)247 {248 try249 {250 result.AddRange(StructToBuffer(thread.TotalProcessorTime));251 result.AddRange(StructToBuffer(thread.UserProcessorTime));252 result.AddRange(StructToBuffer(thread.PrivilegedProcessorTime));253 }254 catch (InvalidOperationException)255 {256 //Caught when the thread has exited in the middle of the foreach.257 }258 catch (System.ComponentModel.Win32Exception e)259 {260 if (e.NativeErrorCode != Win32ErrorCode.AccessDenied)261 throw;262 }263 }264 265 //Current system time266 result.AddRange(StructToBuffer(DateTime.Now.Ticks));267 268 //The high resolution performance counter269 result.AddRange(StructToBuffer(SystemInfo.PerformanceCounter));270 271 //Ticks since start up272 result.AddRange(StructToBuffer(Environment.TickCount));273 return result.ToArray();274 }275 276 /// <summary>277 /// Retrieves entropy from sources which are relatively slower than those from278 /// the FastAddEntropy function.279 /// </summary>280 public override byte[] GetSlowEntropy()281 {282 List<byte> result = new List<byte>();283 284 //NetAPI statistics285 byte[] netApiStats = NetApi.NetStatisticsGet(null, NetApiService.Workstation, 0, 0);286 if (netApiStats != null)287 result.AddRange(netApiStats);288 289 foreach (VolumeInfo info in VolumeInfo.Volumes)290 {291 DiskPerformanceInfo performance = info.Performance;292 if (performance == null)293 continue;294 295 result.AddRange(StructToBuffer(performance.BytesRead));296 result.AddRange(StructToBuffer(performance.BytesWritten));297 result.AddRange(StructToBuffer(performance.IdleTime));298 result.AddRange(StructToBuffer(performance.QueryTime));299 result.AddRange(StructToBuffer(performance.QueueDepth));300 result.AddRange(StructToBuffer(performance.ReadCount));301 result.AddRange(StructToBuffer(performance.ReadTime));302 result.AddRange(StructToBuffer(performance.SplitCount));303 result.AddRange(StructToBuffer(performance.WriteCount));304 result.AddRange(StructToBuffer(performance.WriteTime));305 }306 307 return result.ToArray();308 }309 }310 141 311 142 /// <summary> -
trunk/eraser/Eraser.Manager/Eraser.Manager.csproj
r2044 r2055 50 50 </PropertyGroup> 51 51 <ItemGroup> 52 <Reference Include="Microsoft.VisualBasic" />53 52 <Reference Include="System" /> 54 53 <Reference Include="System.Core">
Note: See TracChangeset
for help on using the changeset viewer.
