diff --git a/src/objects.c b/src/objects.c index d18149e5..de29ca37 100644 --- a/src/objects.c +++ b/src/objects.c @@ -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, diff --git a/src/objects.h b/src/objects.h index c6ee04ff..aa30b9e7 100644 --- a/src/objects.h +++ b/src/objects.h @@ -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,