Commit 82c3883
committed
wolfcrypt/src/wc_pkcs11.c: cache PKCS#11 session across multi-call HMAC
The cryptocb dispatcher opened and closed a fresh PKCS#11 session around
each HMAC invocation. PKCS#11 sign operations are session-scoped, so a
multi-call HMAC (wc_HmacUpdate then wc_HmacFinal, which arrive as
separate cryptocb dispatches) had its C_SignFinal land on a session
that never saw a C_SignInit, returning CKR_OPERATION_NOT_INITIALIZED
and surfacing as WC_HW_E. This broke any code path that drives Update
and Final separately under PKCS#11 routing.
Cache the PKCS#11 session handle on Hmac.devCtx (cast through wc_ptr_t,
matching the existing pattern for cached PKCS#11 object handles) and
rebuild the Pkcs11Session on the stack. The session is opened on the
first dispatch when the operation enters
WC_HMAC_INNER_HASH_KEYED_DEV state and released when it leaves that
state (Final completed or hard error).1 parent 1c9555c commit 82c3883
1 file changed
Lines changed: 32 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6535 | 6535 | | |
6536 | 6536 | | |
6537 | 6537 | | |
6538 | | - | |
6539 | | - | |
| 6538 | + | |
| 6539 | + | |
| 6540 | + | |
| 6541 | + | |
| 6542 | + | |
| 6543 | + | |
| 6544 | + | |
| 6545 | + | |
| 6546 | + | |
| 6547 | + | |
| 6548 | + | |
6540 | 6549 | | |
6541 | | - | |
| 6550 | + | |
| 6551 | + | |
| 6552 | + | |
| 6553 | + | |
| 6554 | + | |
| 6555 | + | |
| 6556 | + | |
| 6557 | + | |
| 6558 | + | |
| 6559 | + | |
| 6560 | + | |
| 6561 | + | |
| 6562 | + | |
| 6563 | + | |
| 6564 | + | |
| 6565 | + | |
| 6566 | + | |
| 6567 | + | |
| 6568 | + | |
| 6569 | + | |
| 6570 | + | |
6542 | 6571 | | |
6543 | 6572 | | |
6544 | 6573 | | |
| |||
0 commit comments