Commit 26b23cee authored by Nils Goroll's avatar Nils Goroll

make the shard sha256 extract endianness-agnostig

We should have interpreted it as big endian right from the start,
but now that we got the existing code developed on little endian,
we keep it so.

noticed after varnish core merge
parent 0f8c3f0f
......@@ -42,6 +42,17 @@
#include "parse_vcc_enums.h"
#include "shard_hash.h"
static __inline void
vle32enc(void *pp, uint32_t u)
{
uint8_t *p = (uint8_t *)pp;
p[0] = u & 0xff;
p[1] = (u >> 8) & 0xff;
p[2] = (u >> 16) & 0xff;
p[3] = (u >> 24) & 0xff;
}
static uint32_t __match_proto__(hash_func)
shard_hash_crc32(VCL_STRING s)
{
......@@ -61,6 +72,7 @@ shard_hash_sha256(VCL_STRING s)
unsigned char digest[32];
uint32_t uint32_digest[8];
} sha256_digest;
uint32_t r;
SHA256_Init(&sha256);
SHA256_Update(&sha256, s, strlen(s));
......@@ -70,7 +82,8 @@ shard_hash_sha256(VCL_STRING s)
* use low 32 bits only
* XXX: Are these the best bits to pick?
*/
return (sha256_digest.uint32_digest[7]);
vle32enc(&r, sha256_digest.uint32_digest[7]);
return (r);
}
static uint32_t __match_proto__(hash_func)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment