|
|
@ -3,13 +3,19 @@ |
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
|
|
|
|
#include "crypto/sha256.h" |
|
|
|
#include "crypto/sha256.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "crypto/common.h" |
|
|
|
#include "crypto/common.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <string.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
|
|
#include <atomic> |
|
|
|
#include <atomic> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(__x86_64__) || defined(__amd64__) |
|
|
|
|
|
|
|
#include <cpuid.h> |
|
|
|
|
|
|
|
namespace sha256_sse4 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
void Transform(uint32_t* s, const unsigned char* chunk, size_t blocks); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// Internal implementation code.
|
|
|
|
// Internal implementation code.
|
|
|
|
namespace |
|
|
|
namespace |
|
|
|
{ |
|
|
|
{ |
|
|
@ -140,6 +146,14 @@ void (*Transform)(uint32_t*, const unsigned char*, size_t) = sha256::Transform; |
|
|
|
|
|
|
|
|
|
|
|
std::string SHA256AutoDetect() |
|
|
|
std::string SHA256AutoDetect() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#if defined(__x86_64__) || defined(__amd64__) |
|
|
|
|
|
|
|
uint32_t eax, ebx, ecx, edx; |
|
|
|
|
|
|
|
if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (ecx >> 19) & 1) { |
|
|
|
|
|
|
|
Transform = sha256_sse4::Transform; |
|
|
|
|
|
|
|
return "sse4"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
return "standard"; |
|
|
|
return "standard"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|