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.
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
+#if (__GNUC__ >= 11)
+# define OPT_FIX __attribute__ ((noipa))
+#else
+# define OPT_FIX
+#endif
+
#define W(x) w[(x) & 15]
#define step00_19(i,a,b,c,d,e) \
if (i>15) W(i) = rol32(W(i-3)^W(i-8)^W(i-14)^W(i-16), 1); \
- else W(i) = bswap(ww[i]); \
+ else W(i) = to_be32(ww[i]); \
e += rol32(a,5) + F1(b,c,d) + 0x5A827999 + W(i); \
b = rol32(b,30)
e += rol32(a,5) + F4(b,c,d) + 0xCA62C1D6 + W(i); \
b = rol32(b,30)
-void sha1_single_for_mh_sha1(const uint8_t * data, uint32_t digest[])
+static void OPT_FIX sha1_single_for_mh_sha1(const uint8_t * data, uint32_t digest[])
{
uint32_t a, b, c, d, e;
uint32_t w[16] = { 0 };
{
uint32_t i, j;
uint8_t buf[2 * SHA1_BLOCK_SIZE];
- union {
- uint64_t uint;
- uint8_t uchar[8];
- } convert;
- uint8_t *p;
digest[0] = MH_SHA1_H0;
digest[1] = MH_SHA1_H1;
else
i = SHA1_BLOCK_SIZE;
- convert.uint = 8 * len;
- p = buf + i - 8;
- p[0] = convert.uchar[7];
- p[1] = convert.uchar[6];
- p[2] = convert.uchar[5];
- p[3] = convert.uchar[4];
- p[4] = convert.uchar[3];
- p[5] = convert.uchar[2];
- p[6] = convert.uchar[1];
- p[7] = convert.uchar[0];
+ *(uint64_t *) (buf + i - 8) = to_be64((uint64_t) len * 8);
sha1_single_for_mh_sha1(buf, digest);
if (i == (2 * SHA1_BLOCK_SIZE))