mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-06 16:10:52 +02:00
1b26594345
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).