Ignore:
Timestamp:
1/25/2010 9:29:35 AM (5 years ago)
Author:
lowjoel
Message:

Bring the CodeReview? branch up to date with the current trunk at r1680

Location:
branches/eraser6/CodeReview
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/CodeReview

  • branches/eraser6/CodeReview/Eraser.Manager/EntropySource.cs

    r1568 r1681  
    11/*  
    22 * $Id$ 
    3  * Copyright 2008-2009 The Eraser Project 
     3 * Copyright 2008-2010 The Eraser Project 
    44 * Original Author: Joel Low <lowjoel@users.sourceforge.net> 
    55 * Modified By: Kasra Nassiri <cjax@users.sourceforge.net> 
     
    418418            } 
    419419#endif 
    420  
    421             //Query performance data. Because the Win32 version of this API (through 
    422             //the registry) may be buggy, use the NT Native API instead. 
    423             // 
    424             //Scan the first 64 possible information types (we don't bother with increasing 
    425             //the buffer size as we do with the Win32 version of the performance data 
    426             //read, we may miss a few classes but it's no big deal).  In addition the 
    427             //returned size value for some classes is wrong (eg 23 and 24 return a 
    428             //size of 0) so we miss a few more things, but again it's no big deal. This 
    429             //scan typically yields around 20 pieces of data, there's nothing in the 
    430             //range 65...128 so chances are there won't be anything above there either. 
    431             uint dataWritten = 0; 
    432             byte[] infoBuffer = new byte[65536]; 
    433             uint totalEntropy = 0; 
    434             for (uint infoType = 0; infoType < 64; ++infoType) 
    435             { 
    436                 uint sysInfo = NTApi.NtQuerySystemInformation(infoType, infoBuffer, 
    437                     (uint)infoBuffer.Length, out dataWritten); 
    438  
    439                 if (sysInfo == Win32ErrorCode.Success && dataWritten > 0) 
    440                 { 
    441                     byte[] entropy = new byte[dataWritten]; 
    442                     Buffer.BlockCopy(infoBuffer, 0, entropy, 0, (int)dataWritten); 
    443                     result.AddRange(entropy); 
    444                     totalEntropy += dataWritten; 
    445                 } 
    446             } 
    447  
    448             result.AddRange(StructToBuffer(totalEntropy)); 
    449  
    450420            //Finally, our good friend CryptGenRandom() 
    451421            byte[] cryptGenRandom = new byte[1536]; 
Note: See TracChangeset for help on using the changeset viewer.