Copyright(c) 2011-2016 Intel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
+ modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************/
+#if defined(__clang__)
+# pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function)
+#elif defined(__ICC)
+# pragma intel optimization_parameter target_arch=AVX2
+#elif defined(__ICL)
+# pragma [intel] optimization_parameter target_arch=AVX2
+#elif (__GNUC__ >= 5)
+# pragma GCC target("avx2")
+#endif
+
#include "sha512_mb.h"
#include "memcpy_inline.h"
+#include "endian_helper.h"
#ifdef _MSC_VER
# include <intrin.h>
#ifdef HAVE_AS_KNOWS_AVX512
static inline void hash_init_digest(SHA512_WORD_T * digest);
-static inline uint32_t hash_pad(uint8_t padblock[SHA512_BLOCK_SIZE * 2], uint32_t total_len);
+static inline uint32_t hash_pad(uint8_t padblock[SHA512_BLOCK_SIZE * 2], uint64_t total_len);
static SHA512_HASH_CTX *sha512_ctx_mgr_resubmit(SHA512_HASH_CTX_MGR * mgr,
SHA512_HASH_CTX * ctx);
memcpy_fixedlen(digest, hash_initial_digest, sizeof(hash_initial_digest));
}
-static inline uint32_t hash_pad(uint8_t padblock[SHA512_BLOCK_SIZE * 2], uint32_t total_len)
+static inline uint32_t hash_pad(uint8_t padblock[SHA512_BLOCK_SIZE * 2], uint64_t total_len)
{
- uint32_t i = total_len & (SHA512_BLOCK_SIZE - 1);
+ uint32_t i = (uint32_t) (total_len & (SHA512_BLOCK_SIZE - 1));
memclr_fixedlen(&padblock[i], SHA512_BLOCK_SIZE);
padblock[i] = 0x80;
*((uint64_t *) & padblock[i - 16]) = 0;
#endif
- *((uint64_t *) & padblock[i - 8]) = _byteswap_uint64((uint64_t) total_len << 3);
+ *((uint64_t *) & padblock[i - 8]) = to_be64((uint64_t) total_len << 3);
return i >> SHA512_LOG2_BLOCK_SIZE; // Number of extra blocks to hash
}
struct slver sha512_ctx_mgr_flush_avx512_slver = { 0x016c, 0x00, 0x06 };
#endif // HAVE_AS_KNOWS_AVX512
+
+#if defined(__clang__)
+# pragma clang attribute pop
+#endif