Skip to content

Commit

Permalink
Add PIN prompting support
Browse files Browse the repository at this point in the history
Signed-off-by: Simo Sorce <simo@redhat.com>
  • Loading branch information
simo5 committed Jul 26, 2022
1 parent ccb8447 commit 63d82a0
Showing 1 changed file with 18 additions and 0 deletions.
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

0 comments on commit 63d82a0

Please sign in to comment.