Skip to content

Move AesEax definition to aes.h#6885

Merged
JacobBarthelmeh merged 1 commit intowolfSSL:masterfrom
bigbrett:aes-eax
Oct 19, 2023
Merged

Move AesEax definition to aes.h#6885
JacobBarthelmeh merged 1 commit intowolfSSL:masterfrom
bigbrett:aes-eax

Conversation

@bigbrett
Copy link
Copy Markdown
Contributor

Description

Makes AesEax struct available for public use.

New PR taking over for #6864
Fixes #6862

Testing

Tested using provided reproducer. Confirmed fixed.

@bigbrett bigbrett added the For This Release Release version 5.9.1 label Oct 18, 2023
Comment thread wolfssl/wolfcrypt/aes.h

/* Because of the circular dependency between AES and CMAC, we need to prevent
* inclusion of AES EAX from CMAC to avoid a recursive inclusion */
#ifndef WOLF_CRYPT_CMAC_H
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This works, but why not use the WC_CMAC_TYPE_DEFINED macro guard and just have "typedef struct Cmac Cmac" if not yet defined? Then include cmac.h in the source file if building with EAX enabled. We've ran into similar problems with includes and typedef's (grep for TYPE_DEFINED macros).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

wasn't aware of that strategy, let me look into it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@JacobBarthelmeh I'm not able to get that strategy to work, given that the AesEax structure needs to hold a Cmac struct (and not a Cmac*, which would work). The compiler needs to know the size and definition of that structure when it processes the header for a given translation unit using aes.h, and so we can't get around this with a forward declaration (AFAICT). I don't believe there is anywhere in our code where we use the TYPE_DEFINED-proteced forward declaration in the manner of this specific circular dependency scenario (only for resolving pointer types, for which a fwd declaration will work). I'm made a small C program to test this out and I can't get the strategy to work with simpler structs either. If you think I'm wrong about this, please let me know how you think I can get around it, but I think the only solution (that doesn't involve me creating a new file for aes eax) is including cmac.h from aes.h like I proposed above.

@bigbrett bigbrett assigned wolfSSL-Bot and unassigned bigbrett Oct 19, 2023
@JacobBarthelmeh JacobBarthelmeh merged commit 22be42a into wolfSSL:master Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For This Release Release version 5.9.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Streaming AES EAX API cannot be used because AesEax is private

3 participants