diff options
author | Vitaly Chikunov <vt@altlinux.org> | 2019-04-10 18:09:54 +0000 |
---|---|---|
committer | Vitaly Chikunov <vt@altlinux.org> | 2019-04-10 21:31:10 +0300 |
commit | e576f52929756beb785f29aa14b6393d7ac6c298 (patch) | |
tree | 16606cb8e7517ffa7316e4ad699464c737a4bf9b /gosthash2012.c | |
parent | 0232aa9efea28d3a3ecde4f8ce8ce9c96189af30 (diff) | |
download | gost-engine-e576f52929756beb785f29aa14b6393d7ac6c298.zip gost-engine-e576f52929756beb785f29aa14b6393d7ac6c298.tar.gz gost-engine-e576f52929756beb785f29aa14b6393d7ac6c298.tar.bz2 |
Fix Streebog alignment problem
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/
Diffstat (limited to 'gosthash2012.c')
-rw-r--r-- | gosthash2012.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gosthash2012.c b/gosthash2012.c index ee534c2..bbe7dcb 100644 --- a/gosthash2012.c +++ b/gosthash2012.c @@ -157,10 +157,13 @@ static void g(union uint512_u *h, const union uint512_u *N, 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->Sigma), (const union uint512_u *)data, &(CTX->Sigma)); + add512(&(CTX->Sigma), &m, &(CTX->Sigma)); } static INLINE void stage3(gost2012_hash_ctx * CTX) |