Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AES-NI and other minor stuff #633

Merged
merged 9 commits into from
Oct 8, 2023
Merged

Fix AES-NI and other minor stuff #633

merged 9 commits into from
Oct 8, 2023

Conversation

sjaeckel
Copy link
Member

@sjaeckel sjaeckel commented Oct 5, 2023

Check commit messages for details.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Aligning a `struct` member via `attribute(align(<n>))` is not guaranteed
to work.
Change the approach to use an opaque buffer and always manually align
the start pointers of the keys.

c.f. DCIT/perl-CryptX#95

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
One can now define `LTC_NO_AES_NI` to disable AES-NI.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This is required
1. when cross-compiling
2. to enable/disable the specific compiler warnings

Tested on `bash`, `dash`, `zsh` and FreeBSD `sh`.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
In order to memory-align the used buffers for keys, IVs etc. we re-order
the struct members of ciphers, modes and encauth.

There's no guarantee that this works, but it improves the chances.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
```
src/encauth/ccm/ccm_memory.c: In function ‘ccm_memory’:
src/encauth/ccm/ccm_memory.c:164:17: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  164 |        PAD[x++] = (unsigned char)((len >> 24) & 255);
      |        ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/encauth/ccm/ccm_memory.c:43:19: note: at offset 16 into destination object ‘PAD’ of size 16
   43 |    unsigned char  PAD[16], ctr[16], CTRPAD[16], ptTag[16], b, *pt_real;
      |                   ^~~
```

Multiple reviews and tests determined that this can't happen, but most
likely computers are better in finding out such stuff (or it was a false
positive).

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Reported by @pineappleiceberg in [0]

[0] #577 (comment)

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Fixes e98e0a6

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
@sjaeckel sjaeckel added this to the next milestone Oct 5, 2023
@sjaeckel sjaeckel requested a review from karel-m October 5, 2023 09:17
Since make version 4.3 [0] the `#` sign inside a string is handled
differently. Fix that.

[0] https://lists.gnu.org/archive/html/info-gnu/2020-01/msg00004.html

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Copy link
Member

@karel-m karel-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, passes all tests with my perl module (on all platforms in the test suite)

@sjaeckel sjaeckel merged commit 91b7bbe into develop Oct 8, 2023
75 checks passed
@sjaeckel sjaeckel deleted the some-fixes branch October 8, 2023 21:04
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