Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of invalid object handles #495

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Introduce p11prov_obj_refresh_invalid
This is useful for refreshing invalid object handles

Signed-off-by: Jakub Zelenka <[email protected]>
bukka committed Dec 27, 2024
commit d9dc0866c693b242311b40d1d0ea1ba3c28053df
11 changes: 11 additions & 0 deletions src/objects.c
Original file line number Diff line number Diff line change
@@ -1315,6 +1315,17 @@ static void p11prov_obj_refresh(P11PROV_OBJ *obj)
p11prov_return_session(session);
}

CK_RV p11prov_obj_refresh_invalid(P11PROV_OBJ *obj)
{
obj->handle = CK_INVALID_HANDLE;
obj->cached = CK_INVALID_HANDLE;
p11prov_obj_refresh(obj);
if (obj->handle == CK_INVALID_HANDLE) {
return CKR_OBJECT_HANDLE_INVALID;
}
return CKR_OK;
}

#define SECRET_KEY_ATTRS 2
P11PROV_OBJ *p11prov_create_secret_key(P11PROV_CTX *provctx,
P11PROV_SESSION *session,
1 change: 1 addition & 0 deletions src/objects.h
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ CK_RV p11prov_obj_from_handle(P11PROV_CTX *ctx, P11PROV_SESSION *session,
CK_RV p11prov_obj_find(P11PROV_CTX *provctx, P11PROV_SESSION *session,
CK_SLOT_ID slotid, P11PROV_URI *uri,
store_obj_callback cb, void *cb_ctx);
CK_RV p11prov_obj_refresh_invalid(P11PROV_OBJ *obj);
P11PROV_OBJ *p11prov_create_secret_key(P11PROV_CTX *provctx,
P11PROV_SESSION *session,
bool session_key, unsigned char *secret,