Enhance Side Channel resistance of TPM2 RSA Decryption Wrapper #4429
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The TPM2 Wrapper of RSA decryption had a bug with incompatible types while setting
valid_mask
.During the fix up we noticed that the rest of the function did not run in constant time and may present an oracle on padding failures. Thanks to @phwork for finding this.
This PR enhances the wrapper's side channel resistance in that regard.
Unfortunately, the ESAPI call already introduces some side channel leaks by allocating the result buffer only if the decryption succeeds. This is by specification (Section 14.3.1), as the call to the underlying RSA decryption function returns an error code if unpadding fails.
@randombit opinions are welcome, we are not sure how big of an issue this is and if our enhancement makes much sense.