Ignore:
Timestamp:
2/12/2010 8:39:59 AM (5 years ago)
Author:
lowjoel
Message:

Removed CryptGenRandom? for a few reasons:

  • The only use was in the Entropy gathering code. We default to using RNGCryptoServiceProvider which is already a CSPRNG.
  • Since RNGCryptoServiceProvider doesn't accept seeds, we can't seed it with our entropy
  • CryptGenRandom? involved a lot of setting up -- certain computers do not have it and would result in a crash
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.Manager/EntropySource.cs

    r1802 r1832  
    271271            //Ticks since start up 
    272272            result.AddRange(StructToBuffer(Environment.TickCount)); 
    273  
    274             //CryptGenRandom 
    275             byte[] cryptGenRandom = new byte[160]; 
    276             if (Security.Randomise(cryptGenRandom)) 
    277                 result.AddRange(cryptGenRandom); 
    278  
    279273            return result.ToArray(); 
    280274        } 
     
    293287                result.AddRange(netApiStats); 
    294288 
    295 #if false 
    296             //Get disk I/O statistics for all the hard drives 
    297             try 
    298             { 
    299                 for (int drive = 0; ; ++drive) 
    300                 { 
    301                     //Try to open the drive. 
    302                     StreamInfo info = new StreamInfo(string.Format(CultureInfo.InvariantCulture, 
    303                         "\\\\.\\PhysicalDrive{0}", drive)); 
    304                     using (FileStream stream = info.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) 
    305                     { 
    306                         SafeFileHandle device = stream.SafeFileHandle; 
    307                         KernelApi.DiskPerformanceInfo diskPerformance = 
    308                             KernelApi.QueryDiskPerformanceInfo(device); 
    309                         if (diskPerformance != null) 
    310                         { 
    311                             result.AddRange(StructToBuffer(diskPerformance.BytesRead)); 
    312                             result.AddRange(StructToBuffer(diskPerformance.BytesWritten)); 
    313                             result.AddRange(StructToBuffer(diskPerformance.IdleTime)); 
    314                             result.AddRange(StructToBuffer(diskPerformance.QueryTime)); 
    315                             result.AddRange(StructToBuffer(diskPerformance.QueueDepth)); 
    316                             result.AddRange(StructToBuffer(diskPerformance.ReadCount)); 
    317                             result.AddRange(StructToBuffer(diskPerformance.ReadTime)); 
    318                             result.AddRange(StructToBuffer(diskPerformance.SplitCount)); 
    319                             result.AddRange(StructToBuffer(diskPerformance.StorageDeviceNumber)); 
    320                             result.AddRange(Encoding.UTF8.GetBytes(diskPerformance.StorageManagerName)); 
    321                             result.AddRange(StructToBuffer(diskPerformance.WriteCount)); 
    322                             result.AddRange(StructToBuffer(diskPerformance.WriteTime)); 
    323                         } 
    324                     } 
    325                 } 
    326             } 
    327             catch (FileNotFoundException) 
    328             { 
    329             } 
    330             catch (UnauthorizedAccessException) 
    331             { 
     289#false 
     290            foreach (VolumeInfo info in VolumeInfo.Volumes) 
     291            { 
     292                /*DiskPerformanceInfo performance = info.Performance; 
     293                result.AddRange(StructToBuffer(performance.BytesRead)); 
     294                result.AddRange(StructToBuffer(performance.BytesWritten)); 
     295                result.AddRange(StructToBuffer(performance.IdleTime)); 
     296                result.AddRange(StructToBuffer(performance.QueryTime)); 
     297                result.AddRange(StructToBuffer(performance.QueueDepth)); 
     298                result.AddRange(StructToBuffer(performance.ReadCount)); 
     299                result.AddRange(StructToBuffer(performance.ReadTime)); 
     300                result.AddRange(StructToBuffer(performance.SplitCount)); 
     301                result.AddRange(StructToBuffer(performance.WriteCount)); 
     302                result.AddRange(StructToBuffer(performance.WriteTime));*/ 
    332303            } 
    333304#endif 
    334             //Finally, our good friend CryptGenRandom() 
    335             byte[] cryptGenRandom = new byte[1536]; 
    336             if (Security.Randomise(cryptGenRandom)) 
    337                 result.AddRange(cryptGenRandom); 
    338305 
    339306            return result.ToArray(); 
Note: See TracChangeset for help on using the changeset viewer.