Page MenuHome GnuPG

Inform callers about memory alignment requirements of a cipher implementation
Closed, ResolvedPublic

Description

Currently, a caller is unable to determine the appropriate memory alignment that
is required for a given cipher. Thus, when using simple malloc, it may happen
that libgcrypt needs to add an additional copy step to re-align the input data.

If a caller would be able to determine the alignment on its own, the copy step
could be avoided and performance could be increased.

An example would be found in the Linux kernel crypto API where the
crypto_*_alignmask API calls allow the caller to know about alginment requirements.

Event Timeline

Currently, there is no need for alignmask API. Implementations that we have at
the moment can handle unaligned data and some have fast paths for word-aligned
in/out buffers (which malloc can provide).

We could add section in documentation about appropiate memory alignment for best
performance, and tell to align buffers to cacheline size.