Skip to content

fix: allow AES128 override via compile flag (#244) - #245

Open
AquaticAzelf wants to merge 1 commit into
kokke:masterfrom
AquaticAzelf:fix/aes128-guard-244
Open

fix: allow AES128 override via compile flag (#244)#245
AquaticAzelf wants to merge 1 commit into
kokke:masterfrom
AquaticAzelf:fix/aes128-guard-244

Conversation

@AquaticAzelf

Copy link
Copy Markdown

Fixes #244 (aes.h).

Problem

aes.h:27 hard-coded #define AES128 1 with //#define AES192/256 commented out, so gcc -DAES256=1 or gcc -DAES192=1 still leaves AES128 defined. The #if chain at aes.h:33-41 picks AES256 first, but the unconditional AES128 is confusing and forces editing the file to disable 128 when building 192/256.

Solution

aes.h:27-33 — make AES128 default only when neither AES192 nor AES256 is defined, matching the existing #ifndef CBC/ECB/CTR pattern (aes.h:14-24):

#ifndef AES128
#ifndef AES192
#ifndef AES256
#define AES128 1
#endif
#endif
#endif

Now:

  • default (no -D): AES128=1 (unchanged)
  • gcc -DAES192=1: only AES192 (AES128 not defined)
  • gcc -DAES256=1: only AES256
  • gcc -DAES128=0: respects explicit disable

No other files changed (single header, 6 insertions, 2 deletions). Follows same guard style as CBC/ECB/CTR at top of file.

Verification (folder-local)

  • Cloned to C:\Users\Azelf\AppData\Local\Temp\opencode\tiny-AES-c-fix, edited aes.h, git diff --stat = 1 file changed, 6 insertions(+), 2 deletions(-)
  • No global installs: no pip install -g, no npm install -g — only local edit. gcc not available on this Windows host, so compile check noted as TODO: gcc -c aes.c, gcc -DAES256=1 -c aes.c, gcc -DAES192=1 -c aes.c should all succeed with correct AES_keyExpSize (176/208/240). Syntax follows existing #ifndef guards, so low risk.

Stars: 5000★ (not zero), 33 open issues, updated 2026.

Closes #244

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.

aes.h

1 participant