-
Notifications
You must be signed in to change notification settings - Fork 824
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
Add CryptoCb features #6636
Add CryptoCb features #6636
Conversation
I still owe a build option 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.
Really nice. Just a few minor suggestions.
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.
Looks great, just a couple small portability and coding standard cleanups. Then happy to merge it.
wolfcrypt/src/cryptocb.c
Outdated
@@ -223,11 +252,28 @@ static WC_INLINE int wc_CryptoCb_TranslateErrorCode(int ret) | |||
return ret; | |||
} | |||
|
|||
/* Helper function to reset a device entry to invalid */ | |||
static inline void wc_CryptoCb_ClearDev(CryptoCb *dev) |
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.
Consider WC_INLINE
vs inline
. Portability.
wolfcrypt/src/cryptocb.c
Outdated
@@ -255,6 +301,8 @@ void wc_CryptoCb_SetDeviceFindCb(CryptoDevCallbackFind cb) | |||
|
|||
int wc_CryptoCb_RegisterDevice(int devId, CryptoDevCallbackFunc cb, void* ctx) | |||
{ | |||
int rc=0; |
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.
Please use spaces around =
. There are several places.
wolfcrypt/src/cryptocb.c
Outdated
#ifdef WOLF_CRYPTO_CB_CMD | ||
if (dev->cb != NULL) { | ||
/* Invoke callback with unregister command.*/ | ||
wc_CryptoInfo info= {0}; |
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.
Prefer an XMEMSET for portability. The = {0}
is not perfectly portable.
wolfcrypt/src/cryptocb.c
Outdated
#ifdef WOLF_CRYPTO_CB_CMD | ||
if (cb != NULL) { | ||
/* Invoke callback with register command */ | ||
wc_CryptoInfo info= {0}; |
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.
Prefer an XMEMSET for portability. The = {0}
is not perfectly portable.
else if ((rc == CRYPTOCB_UNAVAILABLE) || | ||
(rc == NOT_COMPILED_IN)) { | ||
/* Not implemented. Return success*/ | ||
rc = 0; |
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.
Thank you for this. It enables backwards compatibility when WOLF_CRYPTO_CB_CMD
is defined. I tested this with and without using wolfTPM's TLS crypto callback examples and all works!
Description
Added additional cryptocb features:
Testing
This was tested using the out-of-tree VaultIC 420 porting library. The current cryptocb test passed within test and the cleanup is being called automatically.
Checklist