Changeset 2055 for trunk/eraser


Ignore:
Timestamp:
5/4/2010 6:51:04 AM (5 years ago)
Author:
lowjoel
Message:

Move the entropy source implementations to the DefaultPlugin?.

Location:
trunk/eraser
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser/Eraser.DefaultPlugins/Eraser.DefaultPlugins.csproj

    r2044 r2055  
    4848  </PropertyGroup> 
    4949  <ItemGroup> 
     50    <Reference Include="Microsoft.VisualBasic" /> 
    5051    <Reference Include="System" /> 
    5152    <Reference Include="System.Core"> 
     
    7374      <DependentUpon>CustomMethodPassEditor.cs</DependentUpon> 
    7475    </Compile> 
     76    <Compile Include="EntropySources\KernelEntropySource.cs" /> 
    7577    <Compile Include="ErasureMethods\Custom.cs" /> 
    7678    <Compile Include="ErasureMethods\DoD.cs" /> 
  • trunk/eraser/Eraser.DefaultPlugins/Plugin.cs

    r2039 r2055  
    5555 
    5656            ManagerLibrary.Instance.PrngRegistrar.Add(new RngCrypto()); 
     57 
     58            ManagerLibrary.Instance.EntropySourceRegistrar.Add(new KernelEntropySource()); 
    5759 
    5860            ManagerLibrary.Instance.FileSystemRegistrar.Add(new Fat12FileSystem()); 
  • trunk/eraser/Eraser.DefaultPlugins/Strings.en.resx

    r2052 r2055  
    316316    <value>German VSITR</value> 
    317317  </data> 
     318  <data name="Kernel Entropy Source" xml:space="preserve"> 
     319    <value>Kernel Entropy Source</value> 
     320  </data> 
    318321</root> 
  • trunk/eraser/Eraser.DefaultPlugins/Strings.it.resx

    r2052 r2055  
    316316    <value>German VSITR</value> 
    317317  </data> 
     318  <data name="Kernel Entropy Source" xml:space="preserve"> 
     319    <value>(Untranslated)</value> 
     320  </data> 
    318321</root> 
  • trunk/eraser/Eraser.DefaultPlugins/Strings.nl.resx

    r2052 r2055  
    316316    <value>(Untranslated)</value> 
    317317  </data> 
     318  <data name="Kernel Entropy Source" xml:space="preserve"> 
     319    <value>(Untranslated)</value> 
     320  </data> 
    318321</root> 
  • trunk/eraser/Eraser.DefaultPlugins/Strings.pl.resx

    r2052 r2055  
    316316    <value>German VSITR</value> 
    317317  </data> 
     318  <data name="Kernel Entropy Source" xml:space="preserve"> 
     319    <value>(Untranslated)</value> 
     320  </data> 
    318321</root> 
  • trunk/eraser/Eraser.DefaultPlugins/Strings.resx

    r2052 r2055  
    316316    <value>German VSITR</value> 
    317317  </data> 
     318  <data name="Kernel Entropy Source" xml:space="preserve"> 
     319    <value>Kernel Entropy Source</value> 
     320  </data> 
    318321</root> 
  • trunk/eraser/Eraser.Manager/EntropySource.cs

    r1904 r2055  
    2424using System.Text; 
    2525 
    26 using System.Globalization; 
    2726using System.Threading; 
    2827using System.Security.Cryptography; 
     
    3029using System.Diagnostics; 
    3130using 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; 
    3831 
    3932namespace Eraser.Manager 
     
    134127        { 
    135128            Poller = new EntropyPoller(); 
    136             Poller.AddEntropySource(new KernelEntropySource()); 
    137129        } 
    138130 
     
    147139        private Dictionary<Guid, EntropySource> sources = new Dictionary<Guid, EntropySource>(); 
    148140    }; 
    149          
    150     /// <summary> 
    151     /// Provides means of generating random entropy from the system or user space 
    152     /// randomness. 
    153     /// This class is hardcoded into the Manager Library as we need at least one 
    154     /// instance of such behaviour within our system. The other classes could be 
    155     /// implemented as plugins, managed by EntropySourceManager. 
    156     /// </summary> 
    157     public class KernelEntropySource : EntropySource 
    158     { 
    159         public override byte[] GetPrimer() 
    160         { 
    161             List<byte> result = new List<byte>(); 
    162  
    163             //Process information 
    164             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 Guid 
    173         { 
    174             get 
    175             { 
    176                 return new Guid("{11EDCECF-AD81-4e50-A73D-B9CF1F813093}"); 
    177             } 
    178         } 
    179  
    180         public override string Name 
    181         { 
    182             get 
    183             { 
    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 pool 
    205             result.AddRange(StructToBuffer(new DriveInfo(new DirectoryInfo(Environment.SystemDirectory). 
    206                 Root.FullName).TotalFreeSpace)); 
    207  
    208             //Miscellaneous window handles 
    209             result.AddRange(StructToBuffer(UserApi.MessagePos)); 
    210             result.AddRange(StructToBuffer(UserApi.MessageTime)); 
    211  
    212             //The caret and cursor positions 
    213             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 statistics 
    222             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 memory 
    236             ComputerInfo computerInfo = new ComputerInfo(); 
    237             result.AddRange(StructToBuffer(computerInfo.AvailablePhysicalMemory)); 
    238             result.AddRange(StructToBuffer(computerInfo.AvailableVirtualMemory)); 
    239  
    240             //Process execution times 
    241             result.AddRange(StructToBuffer(currProcess.TotalProcessorTime)); 
    242             result.AddRange(StructToBuffer(currProcess.UserProcessorTime)); 
    243             result.AddRange(StructToBuffer(currProcess.PrivilegedProcessorTime)); 
    244  
    245             //Thread execution times 
    246             foreach (ProcessThread thread in currProcess.Threads) 
    247             { 
    248                 try 
    249                 { 
    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 time 
    266             result.AddRange(StructToBuffer(DateTime.Now.Ticks)); 
    267  
    268             //The high resolution performance counter 
    269             result.AddRange(StructToBuffer(SystemInfo.PerformanceCounter)); 
    270  
    271             //Ticks since start up 
    272             result.AddRange(StructToBuffer(Environment.TickCount)); 
    273             return result.ToArray(); 
    274         } 
    275  
    276         /// <summary> 
    277         /// Retrieves entropy from sources which are relatively slower than those from 
    278         /// the FastAddEntropy function. 
    279         /// </summary> 
    280         public override byte[] GetSlowEntropy() 
    281         { 
    282             List<byte> result = new List<byte>(); 
    283  
    284             //NetAPI statistics 
    285             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     } 
    310141 
    311142    /// <summary> 
  • trunk/eraser/Eraser.Manager/Eraser.Manager.csproj

    r2044 r2055  
    5050  </PropertyGroup> 
    5151  <ItemGroup> 
    52     <Reference Include="Microsoft.VisualBasic" /> 
    5352    <Reference Include="System" /> 
    5453    <Reference Include="System.Core"> 
Note: See TracChangeset for help on using the changeset viewer.