Skip to content

Add hooks for crypto callback mechanism - #34

Open
padelsbach wants to merge 4 commits into
wolfSSL:masterfrom
padelsbach:crypto-callback
Open

Add hooks for crypto callback mechanism#34
padelsbach wants to merge 4 commits into
wolfSSL:masterfrom
padelsbach:crypto-callback

Conversation

@padelsbach

Copy link
Copy Markdown
Contributor

NOTE: Merge wolfSSL/wolfssl#10857 prior to this PR

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #34

Scan targets checked: wolfsm-bugs, wolfsm-src
Findings: 5
4 finding(s) posted as inline comments (see file-level comments below)

Required changes (1)

wc_Sm3GetHash duplicates the device context by using raw sm3_copy()

File: sm3.c:1201
Function: wc_Sm3GetHash
Category: API contract violations

sm3_copy() byte-copies the struct, so sm3Copy shares devCtx with sm3; the following wc_Sm3Final() finalizes the shared device state and wc_Sm3Free(sm3Copy) releases it, so the caller's sm3 is left with a finalized/dangling device handle despite the documented "more data can be added" contract. Distinct from known #8803 (missing ForceZero).

Related known finding #8803 (similar but distinct): Both involve wc_Sm3GetHash disposing of a temporary SM3 copy, but this faults by shallow-copying devCtx and freeing/finalizing the caller's device state; #8803 faults by not zeroizing the temporary object. The causes and fixes (device-aware copy versus ForceZero) differ.

Recommendation: Call wc_Sm3Copy() here so the device-aware duplication path added in this PR is used.

Referenced code: sm3.c:1201-1203 (3 lines)


This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread sm4.c Outdated
Comment thread sm4.c
Comment thread sm2.c
Comment thread sm4.c Outdated
Comment thread sm4.c
Comment thread sm2.c
@padelsbach
padelsbach marked this pull request as ready for review September 4, 2026 22:26
@padelsbach padelsbach assigned wolfSSL-Bot and unassigned padelsbach Sep 4, 2026

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #34

Scan targets checked: wolfsm-bugs, wolfsm-src

Findings: 5
5 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread sm3.c
Comment thread sm3.c
Comment thread sm4.c
Comment thread sm3.c
Comment thread sm4.c

@philljj philljj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir found a few things, looks straightforward

Comment thread sm3.c
Comment thread sm3.c
Comment thread sm3.c
Comment thread sm4.c
Comment thread sm4.c
@philljj philljj assigned padelsbach and unassigned wolfSSL-Bot Sep 8, 2026
@padelsbach padelsbach assigned wolfSSL-Bot and unassigned padelsbach Sep 8, 2026
@philljj
philljj self-requested a review September 9, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants