Topic: Crypto callback device context
I'm looking at using crypto callback and have questions about the use of the devCtx member placed in the structures (wc_Sha etc) where WOLF_CRYPTO_CB is used. This is not about the ctx member included in the CryptoCb structure.
Where the method consists of initialisation(), update(), finalise() such as sha, hmac I would like to use this member to point to a myContext loaded when crypto callback is first used with this structure and then freed when the structure use is completed. I assume this is one reason why the member is there? This does rely on the finalise() always being called which I believe is the case with hash and hmac.
The devCtx is initialised to NULL in wc_InitSha256_ex() but not in wc_InitSha_ex(), I assume this is an omission and devCtx meant to be initialised to NULL. Also it would be useful for all crypto callback using structures that can be used more than once to have a devCtx member which is initialised to NULL, this is done for AES but not for RSA which doesn't have devCtx - not sure if RSA is ever called more than once for the same key structure, if not then clearly not needed.
I'm not sure what the wc_Sha256Copy() function called from wc_Sha256GetHash() does. My concern is that it may create a duplicate copy that exists at the same time as the first and I will end up with 2 sructues pointing to the same myContext, this would only be a problem if the original was in the middle of an active hash which probably isn't ever the case but I just want to be sure.
Can you add the devCtx=NULL initialise to wc_InitSha_Ex() and anywhere else it is not done for the next issue?