Repository navigation
harden KTRI operation with PKCS7 - #12147
JacobBarthelmeh wants to merge 6 commits into
Conversation
|
3405e7b to
11f65c8
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12147
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
|
tests good with multi-test with |
| @@ -13033,6 +12442,7 @@ static int wc_PKCS7_DecryptKtri(wc_PKCS7* pkcs7, byte* in, word32 inSz, | |||
| DYNAMIC_TYPE_WOLF_BIGINT); | |||
| if (encryptedKey == NULL) | |||
| return MEMORY_E; | |||
| XMEMSET(encryptedKey, 0, (word32)encryptedKeySz); | |||
There was a problem hiding this comment.
Claude:
I don't think this is needed. When *recipFound == 1, the next line XMEMCPYs all encryptedKeySz bytes over the buffer, and when it's 0 the buffer is freed straight away, so the zeros are never read. If the aim is to make sure every byte the new scan reads is initialized, the buffer that needs it is the OAEP outKey. I'd suggest removing this line, or moving the memset there.
| * branching on padding validity. */ | ||
| startOff = (word32)((wc_ptr_t)outKey - | ||
| (wc_ptr_t)encryptedKey); | ||
| startOff &= (word32)0 - (word32)(haveSrc & 1); |
There was a problem hiding this comment.
Use ctMaskSelWord32 to make sure that the best known CT code is used.
startOff = ctMaskSelWord32(haveSrc,
(word32)((wc_ptr_t)outKey - (wc_ptr_t)encryptedKey), 0);
There was a problem hiding this comment.
Great feedback! Thanks fixed now.
There was a problem hiding this comment.
XMEMSET the buffer to 0 after allocation to prevent reading uninitialized memory and ANDing it.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12147
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
There was a problem hiding this comment.
🟡 Changes recommended
The PKCS#7 signature change breaks compilation of both white-box test translation units, whose callers still pass four arguments instead of two. Separately, the fallback extension changes caller-visible behavior for malformed wrapped keys in NO_HMAC/NO_SHA256 builds and needs a next-release changelog entry documenting that behavior and any supported compatibility alternative.
2 open issues
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12147
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-bugs
Not reviewed (no scan target covers them): .wolfssl_known_macro_extras, tests/api/test_pkcs7.h
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite


ZD 22791
Thanks to Basavesh Ammanaghatta Shivakumar @basavesh and Swarn Priya @swarnpriya (Washington State University) for the hardening report.