Some architectures in some circumstances do not allow unaligned
memory access (such as ARM, MIPS) triggering SIGBUS. This patch
very crudely fixes this issue.
The issue is found and original fix is proposed by Eric Biggers:
https://patchwork.kernel.org/patch/
10878865/
static INLINE void stage2(gost2012_hash_ctx * CTX, const unsigned char *data)
{
static INLINE void stage2(gost2012_hash_ctx * CTX, const unsigned char *data)
{
- g(&(CTX->h), &(CTX->N), data);
+ union uint512_u m;
+
+ memcpy(&m, data, sizeof(m));
+ g(&(CTX->h), &(CTX->N), (const unsigned char *)&m);
add512(&(CTX->N), &buffer512, &(CTX->N));
add512(&(CTX->N), &buffer512, &(CTX->N));
- add512(&(CTX->Sigma), (const union uint512_u *)data, &(CTX->Sigma));
+ add512(&(CTX->Sigma), &m, &(CTX->Sigma));
}
static INLINE void stage3(gost2012_hash_ctx * CTX)
}
static INLINE void stage3(gost2012_hash_ctx * CTX)