Skip to content

Commit

Permalink
feat(pkcs11-tool): set CKA_PRIVATE=CK_TRUE if the --private option is…
Browse files Browse the repository at this point in the history
… set
  • Loading branch information
AlexandreGonzalo committed Jun 11, 2024
1 parent d508726 commit 444f56b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/tools/pkcs11-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -3160,13 +3160,17 @@ static int gen_keypair(CK_SLOT_ID slot, CK_SESSION_HANDLE session,
if (opt_is_private != 0) {
FILL_ATTR(publicKeyTemplate[n_pubkey_attr], CKA_PRIVATE,
&_true, sizeof(_true));
n_pubkey_attr++;
FILL_ATTR(privateKeyTemplate[n_privkey_attr], CKA_PRIVATE,
&_true, sizeof(_true));
}
else {
FILL_ATTR(publicKeyTemplate[n_pubkey_attr], CKA_PRIVATE,
&_false, sizeof(_false));
n_pubkey_attr++;
FILL_ATTR(privateKeyTemplate[n_privkey_attr], CKA_PRIVATE,
&_false, sizeof(_false));
}
n_pubkey_attr++;
n_privkey_attr++;

if (opt_always_auth != 0) {
FILL_ATTR(privateKeyTemplate[n_privkey_attr], CKA_ALWAYS_AUTHENTICATE,
Expand Down Expand Up @@ -4191,7 +4195,11 @@ static CK_RV write_object(CK_SESSION_HANDLE session)
n_privkey_attr++;
FILL_ATTR(privkey_templ[n_privkey_attr], CKA_TOKEN, &_true, sizeof(_true));
n_privkey_attr++;
FILL_ATTR(privkey_templ[n_privkey_attr], CKA_PRIVATE, &_true, sizeof(_true));
if (opt_is_private != 0) {
FILL_ATTR(privkey_templ[n_privkey_attr], CKA_PRIVATE, &_true, sizeof(_true));
} else {
FILL_ATTR(privkey_templ[n_privkey_attr], CKA_PRIVATE, &_false, sizeof(_false));
}
n_privkey_attr++;
FILL_ATTR(privkey_templ[n_privkey_attr], CKA_SENSITIVE, &_true, sizeof(_true));
n_privkey_attr++;
Expand Down

0 comments on commit 444f56b

Please sign in to comment.