Am 24.10.2015 um 03:16 schrieb Jeffrey Walton: > > > On Sunday, October 18, 2015 at 8:23:32 PM UTC-4, Jeffrey Walton wrote: > > > The only thing left to do with it is > a) verify that I actually did the opcode right [1] > > > By the way, I think RDSEED detection code should look similar to > the following. Also see the discussion of Highest Function level > at > https://en.wikipedia.org/wiki/CPUID#EAX.3D0:_Highest_Function_Parameter > <https://en.wikipedia.org/wiki/CPUID#EAX.3D0:_Highest_Function_Parameter> > ... > > > Here's what the RDSEED detection code ended up being. AMD does not > offer RDSEED, so we need to filter the call for Intel processors. I think the run-time detection code should be in cpu.h and cpu.cpp and not in rdrand.h and rdrand.cpp. There is already AMD / Intel and feature detection code and our code would fit perfectly there. The outside (of cpu.XXX) could access via HasRdRand() and HasRdSeed().
BR JPM > > static bool IsIntel(const word32 output[4]) > { > // This is the "GenuineIntel" string > return (output[1] /*EBX*/ == 0x756e6547) && > (output[2] /*ECX*/ == 0x6c65746e) && > (output[3] /*EDX*/ == 0x49656e69); > } > > static bool IsAMD(const word32 output[4]) > { > // This is the "AuthenticAMD" string > return (output[1] /*EBX*/ == 0x68747541) && > (output[2] /*ECX*/ == 0x69746E65) && > (output[3] /*EDX*/ == 0x444D4163); > } > > static bool RDSEED_Runtime_Helper() > { > #if defined(CRYPTOPP_CPUID_AVAILABLE) > bool rdseed = false; word32 output[4]; > if (CpuId(0, output)) > { > // Only Intel supports RDSEED at the moment. > if (IsIntel(output)) > { > if (output[0] /*EAX*/ >= 7 && CpuId(7, output)) > { > static const unsigned int RDSEED_FLAG = (1 << 18); > rdseed = !!(output[1] /*EBX*/ & RDSEED_FLAG); > } > } > } > return rdseed; > #else > return false; > #endif > } > > > And the updated RDRAND helper routine: > > static bool RDRAND_Runtime_Helper() > { > #if defined(CRYPTOPP_CPUID_AVAILABLE) > bool rdrand = false; word32 output[4]; > if (CpuId(0, output)) > { > if (IsIntel(output) || IsAMD(output)) > { > if (output[0] /*EAX*/ >= 1 && CpuId(1, output)) > { > static const unsigned int RDRAND_FLAG = (1 << 30); > rdrand = !!(output[2] /*ECX*/ & RDRAND_FLAG); > } > } > } > return rdrand; > #else > return false; > #endif > } > > Jeff > -- > -- > You received this message because you are subscribed to the "Crypto++ > Users" Google Group. > To unsubscribe, send an email to > cryptopp-users-unsubscr...@googlegroups.com. > More information about Crypto++ and this group is available at > http://www.cryptopp.com. > --- > You received this message because you are subscribed to the Google > Groups "Crypto++ Users" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to cryptopp-users+unsubscr...@googlegroups.com > <mailto:cryptopp-users+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout. -- -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com. More information about Crypto++ and this group is available at http://www.cryptopp.com. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.