Use _rdrand32_step for X32. Whitespace

pull/211/head
root 2016-06-21 21:22:50 -04:00
parent 8576762836
commit d21248b995
2 changed files with 76 additions and 76 deletions

View File

@ -179,39 +179,39 @@ NAMESPACE_BEGIN(CryptoPP)
static int ALL_RRI_GenerateBlock(byte *output, size_t size, unsigned int safety)
{
assert((output && size) || !(output || size));
#if CRYPTOPP_BOOL_X64 || CRYTPOPP_BOOL_X32
word64 val;
#else
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
word32 val;
#else
word64 val;
#endif
while (size >= sizeof(val))
{
#if CRYPTOPP_BOOL_X64 || CRYTPOPP_BOOL_X32
if (_rdrand64_step((word64*)output))
#else
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
if (_rdrand32_step((word32*)output))
#else
if (_rdrand64_step((word64*)output))
#endif
{
{
output += sizeof(val);
size -= sizeof(val);
}
else
{
}
else
{
if (!safety--)
{
assert(0);
return 0;
}
}
}
}
if (size)
{
#if CRYPTOPP_BOOL_X64 || CRYTPOPP_BOOL_X32
if (_rdrand64_step(&val))
#else
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
if (_rdrand32_step(&val))
#else
if (_rdrand64_step(&val))
#endif
{
memcpy(output, &val, size);
@ -225,12 +225,12 @@ static int ALL_RRI_GenerateBlock(byte *output, size_t size, unsigned int safety)
return 0;
}
}
}
}
#if CRYPTOPP_BOOL_X64 || CRYTPOPP_BOOL_X32
*((volatile word64*)&val) = 0;
#else
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
*((volatile word32*)&val) = 0;
#else
*((volatile word64*)&val) = 0;
#endif
return int(size == 0);
@ -249,7 +249,7 @@ static int GCC_RRA_GenerateBlock(byte *output, size_t size, unsigned int safety)
char rc;
while (size)
{
__asm__ volatile(
__asm__ volatile(
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32
".byte 0x48, 0x0f, 0xc7, 0xf0;\n" // rdrand rax
#else
@ -259,10 +259,10 @@ static int GCC_RRA_GenerateBlock(byte *output, size_t size, unsigned int safety)
: "=a" (val), "=qm" (rc)
:
: "cc"
);
);
if (rc)
{
{
if (size >= sizeof(val))
{
#if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) && (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32)
@ -280,15 +280,15 @@ static int GCC_RRA_GenerateBlock(byte *output, size_t size, unsigned int safety)
memcpy(output, &val, size);
size = 0;
}
}
else
{
}
else
{
if (!safety--)
{
assert(0);
return 0;
}
}
}
}
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32
@ -360,39 +360,39 @@ void RDRAND::DiscardBytes(size_t n)
static int ALL_RSI_GenerateBlock(byte *output, size_t size, unsigned int safety)
{
assert((output && size) || !(output || size));
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32
word64 val;
#else
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
word32 val;
#else
word64 val;
#endif
while (size >= sizeof(val))
{
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32
if (_rdseed64_step((word64*)output))
#else
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
if (_rdseed32_step((word32*)output))
#else
if (_rdseed64_step((word64*)output))
#endif
{
{
output += sizeof(val);
size -= sizeof(val);
}
else
{
}
else
{
if (!safety--)
{
assert(0);
return 0;
}
}
}
}
if (size)
{
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32
if (_rdseed64_step(&val))
#else
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
if (_rdseed32_step(&val))
#else
if (_rdseed64_step(&val))
#endif
{
memcpy(output, &val, size);
@ -406,12 +406,12 @@ static int ALL_RSI_GenerateBlock(byte *output, size_t size, unsigned int safety)
return 0;
}
}
}
}
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32
*((volatile word64*)&val) = 0;
#else
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
*((volatile word32*)&val) = 0;
#else
*((volatile word64*)&val) = 0;
#endif
return int(size == 0);
@ -430,7 +430,7 @@ static int GCC_RSA_GenerateBlock(byte *output, size_t size, unsigned int safety)
char rc;
while (size)
{
__asm__ volatile(
__asm__ volatile(
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32
".byte 0x48, 0x0f, 0xc7, 0xf8;\n" // rdseed rax
#else
@ -440,10 +440,10 @@ static int GCC_RSA_GenerateBlock(byte *output, size_t size, unsigned int safety)
: "=a" (val), "=qm" (rc)
:
: "cc"
);
);
if (rc)
{
{
if (size >= sizeof(val))
{
#if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) && (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32)
@ -461,15 +461,15 @@ static int GCC_RSA_GenerateBlock(byte *output, size_t size, unsigned int safety)
memcpy(output, &val, size);
size = 0;
}
}
else
{
}
else
{
if (!safety--)
{
assert(0);
return 0;
}
}
}
}
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32