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__) 42 #
if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
50 ".byte 0x0f, 0xa7, 0xc0 ;\n" 53 :
"=g" (m_msr) :
"g" (m_buffer.
data()),
"g" (m_divisor)
54 #if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) 55 :
"rax",
"rdx",
"rdi",
"cc" 57 :
"eax",
"edx",
"edi",
"cc" 61 const size_t ret = m_msr & 0x1f;
62 const size_t rem = STDMIN<size_t>(ret, STDMIN<size_t>(size, 16U ));
63 std::memcpy(output, m_buffer, rem);
64 size -= rem; output += rem;
66 #elif defined(CRYPTOPP_X86_ASM_AVAILABLE) && defined(_MSC_VER) && defined(_M_IX86) 69 word32 result, divisor = m_divisor;
70 byte *buffer =
reinterpret_cast<byte*
>(m_buffer.
data());
80 const size_t ret = (m_msr = result) & 0x1f;
81 const size_t rem = STDMIN<size_t>(ret, STDMIN<size_t>(size, 16U ));
82 std::memcpy(output, buffer, rem);
83 size -= rem; output += rem;
86 throw PadlockRNG_Err(
"GenerateBlock",
"PadlockRNG generator not available");
87 #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.
PadlockRNG(word32 divisor=1)
Construct a PadlockRNG generator.
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.