-
Notifications
You must be signed in to change notification settings - Fork 16
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
Update curve25519 and posixshm transport #73
Conversation
billphipps
commented
Sep 11, 2024
- Update curve25519 to match ecc code structure.
- Update posix shm transport to work on MacOS and add optional DMA mappings
- Clean up tests
- Correct other typos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review: Haven't yet looked at the crypto or TCP portions yet. But wanted some clarifications of how things are supposed to work re: client initialization
|
||
/* Unmap the header and remap the full area */ | ||
(void)munmap((void*)header, sizeof(*header)); | ||
ret = posixTransportShm_Map(fd, size, map); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the rationale behind mapping just the header first, then unmapping and remapping the entire area? Vs just mapping the whole thing in one go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client doesn't know the sizes of the buffers, so it maps the header first to find out, then remaps once the sizes are understood.
return wh_TransportMem_SendRequest(ctx->transportMemCtx, len, data); | ||
/* Check connected status */ | ||
switch(ctx->state) { | ||
case PTSHM_STATE_NONE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit confused about this logic (as well as the client initialization. Since the client init is what initially zeros the context and calls posixTransportShm_{Use/Handle}Map()
on it, and we don't ever want a user to be sending requests without first initializing the client context, should we even be handling the NONE
state here? I'd have figured that this logic should have been in the INITIALIZED
state, since that is what the client init handler sets the state to once it successfully initializes. Is this some sort of deferred initialization that is allowed if the original client init fails? If so perhaps we just call client init again here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The server creates and zeroes the object. The client only has to map it. NONE is used when the client was not able to open the object OR the object was not completely setup by the server. This forces the client to attempt to reopen, map the header, and then remap the entire object. Once the client is able to successfully map the entire segment, it sets the intiitalzed member in the header and leaves the mapping intact. Recall, the client init only tries once to open and map the object, so the entire sequence is tried again here as well. Sorry for the misleading comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks good
Verified crypto tests pass on tc3xx |
Co-authored-by: Brett Nicholas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just need to guard unistd.h
include with WOLFHSM_CFG_TEST_POSIX
and I can merge
test/wh_test_crypto.c
Outdated
@@ -26,6 +26,7 @@ | |||
#include <stdint.h> | |||
#include <stdio.h> /* For printf */ | |||
#include <string.h> /* For memset, memcpy */ | |||
#include <unistd.h> /* For sleep */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to be protected by WOLFHSM_CFG_TEST_POSIX
(block already present later in this file)
Update curve25519 and posixshm transport