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

Updates to align with name changes and corrections in wolfHSM PR52 #12

Merged
merged 10 commits into from
Aug 15, 2024

Conversation

billphipps
Copy link
Contributor

Aligning with wolfSSL/wolfHSM#52. Draft until that is merged.

Copy link
Contributor

@bigbrett bigbrett left a comment

Choose a reason for hiding this comment

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

Nice. I know it is still draft, but a few random notes

$(WOLFSSL_DIR)/wolfcrypt/src/sha256.c \
$(WOLFSSL_DIR)/wolfcrypt/src/aes.c \
$(WOLFSSL_DIR)/wolfcrypt/src/cmac.c
SRC_C += $(wildcard $(WOLFSSL_DIR)/wolfcrypt/src/*.c)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm I don't like wildcards in makefiles - can make for some hard to diagnose issues. Even though it takes up space, I think we should explicitly add all the source files we want to compile. Also serves customers better as they can see exactly which files are required to build, in case they are trying to replicate a minimal example in a different build environment. Just food for thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's make wildcard an option in the Makefile, not selected by default. Using the wildcard means we can swap out different user settings without touching the makefile. Also, wildcards makes sure that IDE's won't have an issue. Note that I only included the C files and not the wolfcrypt/port files. I'll tweak to make it optional.


#include "wolfcrypt/test/test.h"

#include "wh_demo_client_counter.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused include

Comment on lines +7 to +10
int wh_DemoClient_wcTest(whClientContext* clientContext)
{
return wolfcrypt_test(NULL);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably write something documenting that the caller is responsible for initializing wolfCrypt, RNG, etc before invoking this function, and tearing down after. On one hand, I want a demo function that includes doing everything it needs to demonstrate how a user would do it, but on the other hand the wolfCrypt init is global, so would screw things up for other demos if it deinits wolfCrypt. IDK. Maybe just write something indicating that wolfCrypt needs to be initialized along with the client context before invoking the functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add some comments. IMHO, wc_CryptoCbRegister/Deregister should handle the reference counting. Mayhaps I'll put together a mainline PR...

Comment on lines +31 to +32
/* Math library selection. */
#define USE_FAST_MATH
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably be using SP math for our official demos, since that is our preferred option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. I'll remove that to use the default. Was troubleshooting.

if (ret != 0) {
printf("Failed to wc_AesInit %d\n", ret);
goto exit;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say either scrub all the gotos in the file like you did in this function, or leave them as is, but probs don't want a mix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. more cleanups are a-coming!

@bigbrett bigbrett mentioned this pull request Aug 15, 2024
@billphipps billphipps merged commit ca72b19 into wolfSSL:main Aug 15, 2024
1 check passed
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