22 #if ((__GNUC__ >= 4) || defined(__IBM_GCC_ASM)) && !defined(__APPLE__) 23 # define GCC_DARN_ASM_AVAILABLE 1 27 #if CRYPTOPP_MSC_VERSION 28 # pragma warning(disable: 4702) 36 #if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) 40 #if (CRYPTOPP_BOOL_PPC32) 43 inline void DARN32(
void* output)
46 word32* ptr =
reinterpret_cast<word32*
>(output);
48 #if defined(GCC_DARN_ASM_AVAILABLE) 55 __asm__ __volatile__ (
56 #
if (CRYPTOPP_BIG_ENDIAN)
57 ".byte 0x7c, 0x60, 0x05, 0xe6 \n\t" 60 ".byte 0xe6, 0x05, 0x60, 0x7c \n\t" 63 :
"=r" (*ptr) : :
"r3" 65 }
while (*ptr == 0xFFFFFFFFu);
66 #elif defined(_ARCH_PWR9) 69 *ptr = __builtin_darn_32();
70 #elif defined(__APPLE__) 83 #if (CRYPTOPP_BOOL_PPC64) 86 inline void DARN64(
void* output)
89 word64* ptr =
reinterpret_cast<word64*
>(output);
91 #if defined(GCC_DARN_ASM_AVAILABLE) 97 __asm__ __volatile__ (
98 #
if (CRYPTOPP_BIG_ENDIAN)
99 ".byte 0x7c, 0x61, 0x05, 0xe6 \n\t" 102 ".byte 0xe6, 0x05, 0x61, 0x7c \n\t" 105 :
"=r" (*ptr) : :
"r3" 107 }
while (*ptr == 0xFFFFFFFFFFFFFFFFull);
108 #elif defined(_ARCH_PWR9) 111 *ptr = __builtin_darn();
112 #elif defined(__APPLE__) 137 if (size == 0)
return;
140 #if (CRYPTOPP_BOOL_PPC64) 143 i =
reinterpret_cast<uintptr_t
>(output) & 0x7;
147 std::memcpy(output, m_temp, i);
154 for (i = 0; i < size/8; i++)
163 std::memcpy(output, m_temp, size);
166 #elif (CRYPTOPP_BOOL_PPC32) 169 i =
reinterpret_cast<uintptr_t
>(output) & 0x3;
173 std::memcpy(output, m_temp, i);
179 for (i = 0; i < size/4; i++)
188 std::memcpy(output, m_temp, size);
193 CRYPTOPP_UNUSED(output);
194 throw NotImplemented(
"DARN: failed to find a suitable implementation");
214 #else // not PPC32 or PPC64 224 CRYPTOPP_UNUSED(output); CRYPTOPP_UNUSED(size);
233 #endif // PPC32 or PPC64 DARN()
Construct a DARN generator.
bool HasDARN()
Determine if a PowerPC processor has DARN available.
Exception thrown when a DARN generator encounters a generator related error.
size_type SizeInBytes() const
Provides the number of bytes in the SecBlock.
Abstract base classes that provide a uniform interface to this library.
Library configuration file.
void New(size_type newSize)
Change size without preserving contents.
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
Classes and functions for secure memory allocations.
virtual void DiscardBytes(size_t n)
Generate and discard n bytes.
bool IsAlignedOn(const void *ptr, unsigned int alignment)
Determines whether ptr is aligned to a minimum value.
A method was called which was not implemented.
Fixed size stack-based SecBlock.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
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.
byte * BytePtr()
Provides a byte pointer to the first element in the memory block.