14#if CRYPTOPP_MSC_VERSION
15# pragma warning(disable: 4702)
26 : m_divisor(DivisorHelper(divisor)), m_msr(0)
28#if defined(CRYPTOPP_X86_ASM_AVAILABLE)
31 throw PadlockRNG_Err(
"PadlockRNG",
"PadlockRNG generator not available");
36 CRYPTOPP_UNUSED(output); CRYPTOPP_UNUSED(size);
37#if defined(CRYPTOPP_X86_ASM_AVAILABLE) && defined(__GNUC__)
51 ".byte 0x0f, 0xa7, 0xc0 ;\n"
54 :
"=g" (m_msr) :
"g" (m_buffer.
data()),
"g" (m_divisor)
56 :
"rax",
"rdx",
"rdi",
"cc"
58 :
"eax",
"edx",
"edi",
"cc"
62 const size_t ret = m_msr & 0x1f;
63 const size_t rem = STDMIN<size_t>(ret, STDMIN<size_t>(size, 16U ));
64 std::memcpy(output, m_buffer, rem);
65 size -= rem; output += rem;
67#elif defined(CRYPTOPP_X86_ASM_AVAILABLE) && defined(_MSC_VER) && defined(_M_IX86)
70 word32 result, divisor = m_divisor;
71 byte *buffer =
reinterpret_cast<byte*
>(m_buffer.
data());
81 const size_t ret = (m_msr = result) & 0x1f;
82 const size_t rem = STDMIN<size_t>(ret, STDMIN<size_t>(size, 16U ));
83 std::memcpy(output, buffer, rem);
84 size -= rem; output += rem;
87 throw PadlockRNG_Err(
"GenerateBlock",
"PadlockRNG generator not available");
Exception thrown when a PadlockRNG generator encounters a generator related error.
Hardware generated random numbers using VIA XSTORE.
PadlockRNG(word32 divisor=1)
Construct a PadlockRNG generator.
virtual void DiscardBytes(size_t n)
Generate and discard n bytes.
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
A::pointer data()
Provides a pointer to the first element in the memory block.
size_type SizeInBytes() const
Provides the number of bytes in the SecBlock.
byte * BytePtr()
Provides a byte pointer to the first element in the memory block.
Library configuration file.
#define CRYPTOPP_BOOL_X32
32-bit x32 platform
#define CRYPTOPP_BOOL_X64
32-bit x86 platform
unsigned int word32
32-bit unsigned datatype
Functions for CPU features and intrinsics.
Abstract base classes that provide a uniform interface to this library.
T1 RoundUpToMultipleOf(const T1 &n, const T2 &m)
Rounds a value up to a multiple of a second value.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
Crypto++ library namespace.
Classes for VIA Padlock RNG.
Classes and functions for secure memory allocations.