14 #if CRYPTOPP_MSC_VERSION 15 # pragma warning(disable: 4702) 21 : m_divisor(DivisorHelper(divisor)), m_msr(0)
23 #if defined(CRYPTOPP_X86_ASM_AVAILABLE) 25 throw PadlockRNG_Err(
"PadlockRNG",
"PadlockRNG generator not available");
27 throw PadlockRNG_Err(
"PadlockRNG",
"PadlockRNG generator not available");
33 CRYPTOPP_UNUSED(output); CRYPTOPP_UNUSED(size);
34 #if defined(CRYPTOPP_X86_ASM_AVAILABLE) && defined(__GNUC__) 39 #
if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
47 ".byte 0x0f, 0xa7, 0xc0 ;\n" 50 :
"=g" (m_msr) :
"g" (m_buffer.
data()),
"g" (m_divisor)
51 #if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) 52 :
"eax",
"edx",
"rdi",
"cc" 54 :
"eax",
"edx",
"edi",
"cc" 58 const size_t ret = m_msr & 0x1f;
59 const size_t rem = STDMIN<size_t>(ret, STDMIN<size_t>(size, 16U ));
60 std::memcpy(output, m_buffer, rem);
61 size -= rem; output += rem;
63 #elif defined(CRYPTOPP_X86_ASM_AVAILABLE) && defined(_MSC_VER) && defined(_M_IX86) 66 word32 result, divisor = m_divisor;
67 byte *buffer = reinterpret_cast<byte*>(m_buffer.
data());
77 const size_t ret = (m_msr = result) & 0x1f;
78 const size_t rem = STDMIN<size_t>(ret, STDMIN<size_t>(size, 16U ));
79 std::memcpy(output, buffer, rem);
80 size -= rem; output += rem;
83 throw PadlockRNG_Err(
"GenerateBlock",
"PadlockRNG generator not available");
84 #endif // CRYPTOPP_X86_ASM_AVAILABLE virtual void DiscardBytes(size_t n)
Generate and discard n bytes.
size_type SizeInBytes() const
Provides the number of bytes in the SecBlock.
Classes for VIA Padlock RNG.
bool HasPadlockRNG()
Determines Padlock RNG availability.
Abstract base classes that provide a uniform interface to this library.
Library configuration file.
Hardware generated random numbers using VIA XSTORE.
Classes and functions for secure memory allocations.
A::pointer data()
Provides a pointer to the first element in the memory block.
Exception thrown when a PadlockRNG generator encounters a generator related error.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
Functions for CPU features and intrinsics.
T1 RoundUpToMultipleOf(const T1 &n, const T2 &m)
Rounds a value up to a multiple of a second value.
Crypto++ library namespace.
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
byte * BytePtr()
Provides a byte pointer to the first element in the memory block.