Skip to content

Commit

Permalink
Refresh signature key object on invalid handle
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Zelenka <[email protected]>
  • Loading branch information
bukka committed Dec 27, 2024
1 parent d9dc086 commit c925ead
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/signature.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ static CK_RV p11prov_sig_operate_init(P11PROV_SIG_CTX *sigctx, bool digest_op,
}

done:
if (ret != CKR_OK) {
if (ret != CKR_OK && ret != CKR_OBJECT_HANDLE_INVALID) {
p11prov_return_session(session);
} else {
*_session = session;
Expand Down Expand Up @@ -935,10 +935,22 @@ static CK_RV p11prov_sig_operate(P11PROV_SIG_CTX *sigctx, unsigned char *sig,
tbslen += mech->der_digestinfo_len;
}

p11prov_set_error_mark(sigctx->provctx);
ret = p11prov_sig_operate_init(sigctx, false, &session);
if (ret != CKR_OK) {
return ret;
if (ret == CKR_OBJECT_HANDLE_INVALID && p11prov_obj_refresh_invalid(sigctx->key) == CKR_OK) {
ret = p11prov_sig_operate_init(sigctx, false, &session);
}
if (ret != CKR_OK) {
p11prov_clear_last_error_mark(sigctx->provctx);
return ret;
} else {
p11prov_pop_error_to_mark(sigctx->provctx);
}
} else {
p11prov_clear_last_error_mark(sigctx->provctx);
}

sess = p11prov_session_handle(session);

if (sigctx->operation == CKF_SIGN) {
Expand Down

0 comments on commit c925ead

Please sign in to comment.