Skip to content

Commit

Permalink
Fix poly1305 alignment mismatch.
Browse files Browse the repository at this point in the history
The C Poly1305 code is expecting the state buffer to be aligned to the
same alignment as `double`. However, the Rust code isn't necessarily
aligning it that much. The C code actually works fine without the
alignment hack as I had explicitly adjusted it to handle unaligned
inputs in a previous commit. However, I overlooked the effect that the
`union` of `double` hack.

This was apparently the cause of the segmentation faults that caused
tests to fail with SIGSEGV when building for ARM/Aarch64 with Stable
Rust. It seems that newer versions of Rust must align things more
granularly as the bug wasn't triggered in Rust Nightly.
  • Loading branch information
briansmith committed May 28, 2016
1 parent 7749647 commit 5d22c58
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions include/openssl/poly1305.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ extern "C" {
#endif


typedef union {
double align;
typedef struct {
uint8_t bytes[512];
} poly1305_state;

Expand Down

0 comments on commit 5d22c58

Please sign in to comment.