Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

osrng.h

00001 #ifndef CRYPTOPP_OSRNG_H
00002 #define CRYPTOPP_OSRNG_H
00003 
00004 #include "config.h"
00005 
00006 #if !defined(NO_OS_DEPENDENCE)
00007 
00008 #include "randpool.h"
00009 
00010 NAMESPACE_BEGIN(CryptoPP)
00011 
00013 class OS_RNG_Err : public Exception
00014 {
00015 public:
00016         OS_RNG_Err(const std::string &s) : Exception(s) {}
00017 };
00018 
00019 #if ((defined(_WIN32) && defined(USE_MS_CRYPTOAPI)) || defined(__FreeBSD__) || defined(__linux__))
00020 
00021 #define NONBLOCKING_RNG_AVAILABLE
00022 
00024 class NonblockingRng : public RandomNumberGenerator
00025 {
00026 public:
00027         NonblockingRng();
00028         ~NonblockingRng();
00029         byte GenerateByte();
00030         void GenerateBlock(byte *output, unsigned int size);
00031 
00032 protected:
00033 #ifdef _WIN32
00034         unsigned long m_hProvider;
00035 #else
00036         int m_fd;
00037 #endif
00038 };
00039 
00040 #endif
00041 
00042 #if (defined(__FreeBSD__) || defined(__linux__))
00043 
00044 #define BLOCKING_RNG_AVAILABLE
00045 
00047 class BlockingRng : public RandomNumberGenerator
00048 {
00049 public:
00050         BlockingRng();
00051         ~BlockingRng();
00052         byte GenerateByte();
00053         void GenerateBlock(byte *output, unsigned int size);
00054 
00055 protected:
00056         int m_fd;
00057 };
00058 
00059 #endif
00060 
00061 #if defined(NONBLOCKING_RNG_AVAILABLE) || defined(BLOCKING_RNG_AVAILABLE)
00062 
00063 #define AUTO_SEEDED_RANDOM_POOL_AVAILABLE
00064 
00066 
00068 class AutoSeededRandomPool : public RandomPool
00069 {
00070 public:
00072         explicit AutoSeededRandomPool(bool blocking = false, unsigned int seedSize = 16)
00073                 {Reseed(blocking, seedSize);}
00074         void Reseed(bool blocking = false, unsigned int seedSize = 16);
00075 };
00076 
00077 #endif
00078 
00079 NAMESPACE_END
00080 
00081 #endif  // #if !defined(NO_OS_DEPENDENCE)
00082 
00083 #endif

Generated at Mon Jan 15 01:16:34 2001 for Crypto++ by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000