Fix error in CT compare, add negative tests for TLS pad checks#385
Open
ColtonWilley wants to merge 1 commit intowolfSSL:masterfrom
Open
Fix error in CT compare, add negative tests for TLS pad checks#385ColtonWilley wants to merge 1 commit intowolfSSL:masterfrom
ColtonWilley wants to merge 1 commit intowolfSSL:masterfrom
Conversation
padelsbach
reviewed
Apr 5, 2026
| byte wp_ct_byte_mask_ne(byte a, byte b) | ||
| { | ||
| return (((int32_t)b - a) >> 31) & (((int32_t)a - b) >> 31); | ||
| return (((int32_t)b - a) >> 31) | (((int32_t)a - b) >> 31); |
Contributor
There was a problem hiding this comment.
This is potentially a more robust fix, with less bit math:
return ~wp_ct_byte_mask_eq(a, b);
| /** | ||
| * Constant time, set mask when first value is not equal to second. | ||
| * | ||
| * @param [in] a First valuue. |
Contributor
There was a problem hiding this comment.
Semi-related nit: typo here in "valuue". Also on line 1155.
| * Encrypt block-aligned plaintext (produces a full padding block), corrupt a | ||
| * ciphertext byte so the padding block is garbled, verify DecryptFinal rejects. | ||
| */ | ||
| int test_des3_cbc_bad_pad(void *data) |
Contributor
There was a problem hiding this comment.
I see that DES3 CBC is the only path for testing wp_ct_byte_mask_ne, currently. So this is a good add, but...
Can we add some test vectors for wp_ct_* functions? There seem to be no direct tests of these today. Just to ensure coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.