Skip to content

Separate gost89, gosthash, gosthash2012 modules and fix incorrect alignment in gosthash2012 causing potential SEGFAULT #514

Merged
chipitsine merged 2 commits intogost-engine:masterfrom
Mironenko:split-gost-core-1-upstream
Feb 24, 2026
Merged

Separate gost89, gosthash, gosthash2012 modules and fix incorrect alignment in gosthash2012 causing potential SEGFAULT #514
chipitsine merged 2 commits intogost-engine:masterfrom
Mironenko:split-gost-core-1-upstream

Conversation

@Mironenko
Copy link
Contributor

This PR separates modules that do not depend on OpenSSL or the complex gost-core,
as part of addressing #496.

It also adds tests for the gosthash and gosthash2012 modules.

Additionally, it fixes incorrect alignment in gosthash2012 that could lead to SEGFAULTs.

Add tests for gosthash and gosthash2012
Before this commit, the declaration of `union uint512_u` applied 16-byte alignment
only to the typedef name, resulting in different alignments:
* `union uint512_u` — 8 bytes
* `uint512_u` — 16 bytes

The implementation in gosthash2012.c assumes 16-byte alignment for the union.
When the tag type (`union uint512_u`) was used (e.g., in structures or on the stack),
this mismatch could lead to misaligned accesses and SEGFAULT.

After this change, 16-byte alignment is applied to the union type itself, so both:
* `union uint512_u`
* `uint512_u`

are consistently 16-byte aligned.
@chipitsine chipitsine merged commit c8372ff into gost-engine:master Feb 24, 2026
12 checks passed
@Mironenko Mironenko deleted the split-gost-core-1-upstream branch February 24, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants