"Fossies" - the Fresh Open Source Software Archive

Member "src/Core/RandomNumberGenerator.h" (10 Oct 2018, 2073 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "RandomNumberGenerator.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  Derived from source code of TrueCrypt 7.1a, which is
    3  Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
    4  by the TrueCrypt License 3.0.
    5 
    6  Modifications and additions to the original source code (contained in this file)
    7  and all other portions of this file are Copyright (c) 2013-2017 IDRIX
    8  and are governed by the Apache License 2.0 the full text of which is
    9  contained in the file License.txt included in VeraCrypt binary and source
   10  code distribution packages.
   11 */
   12 
   13 #ifndef TC_HEADER_Core_RandomNumberGenerator
   14 #define TC_HEADER_Core_RandomNumberGenerator
   15 
   16 #include "Platform/Platform.h"
   17 #include "Volume/Hash.h"
   18 #include "Common/Random.h"
   19 
   20 namespace VeraCrypt
   21 {
   22     class RandomNumberGenerator
   23     {
   24     public:
   25         static void AddToPool (const ConstBufferPtr &buffer);
   26         static void GetData (const BufferPtr &buffer, bool allowAnyLength = false) { GetData (buffer, false, allowAnyLength); }
   27         static void GetDataFast (const BufferPtr &buffer, bool allowAnyLength = false) { GetData (buffer, true, allowAnyLength); }
   28         static shared_ptr <Hash> GetHash ();
   29         static bool IsEnrichedByUser () { return EnrichedByUser; }
   30         static bool IsRunning () { return Running; }
   31         static ConstBufferPtr PeekPool () { return Pool; }
   32         static void SetEnrichedByUserStatus (bool enriched) { EnrichedByUser = enriched; }
   33         static void SetHash (shared_ptr <Hash> hash);
   34         static void Start ();
   35         static void Stop ();
   36 
   37         static const size_t PoolSize = RNG_POOL_SIZE;
   38 
   39     protected:
   40         static void AddSystemDataToPool (bool fast);
   41         static void GetData (const BufferPtr &buffer, bool fast, bool allowAnyLength);
   42         static void HashMixPool ();
   43         static void Test ();
   44         RandomNumberGenerator ();
   45 
   46         static const size_t MaxBytesAddedBeforePoolHashMix = RANDMIX_BYTE_INTERVAL;
   47 
   48         static Mutex AccessMutex;
   49         static size_t BytesAddedSincePoolHashMix;
   50         static bool EnrichedByUser;
   51         static SecureBuffer Pool;
   52         static shared_ptr <Hash> PoolHash;
   53         static size_t ReadOffset;
   54         static bool Running;
   55         static size_t WriteOffset;
   56     };
   57 }
   58 
   59 #endif // TC_HEADER_Core_RandomNumberGenerator