Changeset View
Changeset View
Standalone View
Standalone View
src/crypto/sha256.cpp
Show All 21 Lines | |||||
void Transform_4way(uint8_t *out, const uint8_t *in); | void Transform_4way(uint8_t *out, const uint8_t *in); | ||||
} | } | ||||
namespace sha256d64_avx2 { | namespace sha256d64_avx2 { | ||||
void Transform_8way(uint8_t *out, const uint8_t *in); | void Transform_8way(uint8_t *out, const uint8_t *in); | ||||
} | } | ||||
namespace sha256d64_shani { | namespace sha256d64_shani { | ||||
void Transform_2way(unsigned char *out, const unsigned char *in); | void Transform_2way(uint8_t *out, const uint8_t *in); | ||||
} | } | ||||
namespace sha256_shani { | namespace sha256_shani { | ||||
void Transform(uint32_t *s, const unsigned char *chunk, size_t blocks); | void Transform(uint32_t *s, const uint8_t *chunk, size_t blocks); | ||||
} | } | ||||
// Internal implementation code. | // Internal implementation code. | ||||
namespace { | namespace { | ||||
/// Internal SHA-256 implementation. | /// Internal SHA-256 implementation. | ||||
namespace sha256 { | namespace sha256 { | ||||
inline uint32_t Ch(uint32_t x, uint32_t y, uint32_t z) { | inline uint32_t Ch(uint32_t x, uint32_t y, uint32_t z) { | ||||
return z ^ (x & (y ^ z)); | return z ^ (x & (y ^ z)); | ||||
▲ Show 20 Lines • Show All 652 Lines • ▼ Show 20 Lines | bool SelfTest() { | ||||
{ | { | ||||
uint8_t out[32]; | uint8_t out[32]; | ||||
TransformD64(out, data + 1); | TransformD64(out, data + 1); | ||||
if (!std::equal(out, out + 32, result_d64)) return false; | if (!std::equal(out, out + 32, result_d64)) return false; | ||||
} | } | ||||
// Test TransformD64_2way, if available. | // Test TransformD64_2way, if available. | ||||
if (TransformD64_2way) { | if (TransformD64_2way) { | ||||
unsigned char out[64]; | uint8_t out[64]; | ||||
TransformD64_2way(out, data + 1); | TransformD64_2way(out, data + 1); | ||||
if (!std::equal(out, out + 64, result_d64)) return false; | if (!std::equal(out, out + 64, result_d64)) return false; | ||||
} | } | ||||
// Test TransformD64_4way, if available. | // Test TransformD64_4way, if available. | ||||
if (TransformD64_4way) { | if (TransformD64_4way) { | ||||
uint8_t out[128]; | uint8_t out[128]; | ||||
TransformD64_4way(out, data + 1); | TransformD64_4way(out, data + 1); | ||||
▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines |