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

Add PIN prompting support #36

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Changes from all commits
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
18 changes: 18 additions & 0 deletions src/store.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ static int p11prov_store_load(void *ctx, OSSL_CALLBACK *object_cb,
{
P11PROV_OBJECT *obj = (P11PROV_OBJECT *)ctx;
struct p11prov_slot *slots = NULL;
char cb_pin[MAX_PIN_LENGTH + 1] = { 0 };
/* 0 is CKO_DATA ibut we do not use it */
CK_OBJECT_CLASS class = 0;
int nslots = 0;
Expand Down Expand Up @@ -535,6 +536,23 @@ static int p11prov_store_load(void *ctx, OSSL_CALLBACK *object_cb,
}
if (pin) {
pinlen = strlen((const char *)pin);
} else {
const char *info = "PKCS#11 Token";
OSSL_PARAM params[2] = {
OSSL_PARAM_DEFN(OSSL_PASSPHRASE_PARAM_INFO,
OSSL_PARAM_UTF8_STRING, (void *)info,
sizeof(info)),
OSSL_PARAM_END,
};
size_t cb_pin_len = 0;
ret = pw_cb(cb_pin, sizeof(cb_pin), &cb_pin_len, params,
pw_cbarg);
if (ret != RET_OSSL_OK) {
continue;
}

pin = (CK_UTF8CHAR_PTR)cb_pin;
pinlen = cb_pin_len;
}

if (obj->login_session == CK_INVALID_HANDLE) {
Expand Down