pkcs11-tool: allow non-interactive change of User/SO PIN
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5543 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
438cf4b2d4
commit
a479c368a6
|
@ -1150,29 +1150,42 @@ static int change_pin(CK_SLOT_ID slot, CK_SESSION_HANDLE sess)
|
||||||
get_token_info(slot, &info);
|
get_token_info(slot, &info);
|
||||||
|
|
||||||
if (!(info.flags & CKF_PROTECTED_AUTHENTICATION_PATH)) {
|
if (!(info.flags & CKF_PROTECTED_AUTHENTICATION_PATH)) {
|
||||||
printf("Please enter the current PIN: ");
|
if (!opt_pin && !opt_so_pin) {
|
||||||
r = util_getpass(&old_pin, &len, stdin);
|
printf("Please enter the current PIN: ");
|
||||||
if (r < 0)
|
r = util_getpass(&old_pin, &len, stdin);
|
||||||
return 1;
|
if (r < 0)
|
||||||
if (!old_pin || !*old_pin || strlen(old_pin) > 20)
|
return 1;
|
||||||
return 1;
|
if (!old_pin || !*old_pin || strlen(old_pin) > 20)
|
||||||
strcpy(old_buf, old_pin);
|
return 1;
|
||||||
old_pin = old_buf;
|
strcpy(old_buf, old_pin);
|
||||||
|
old_pin = old_buf;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (opt_so_pin)
|
||||||
|
old_pin = opt_so_pin;
|
||||||
|
else
|
||||||
|
old_pin = opt_pin;
|
||||||
|
}
|
||||||
|
|
||||||
printf("Please enter the new PIN: ");
|
if (!opt_new_pin) {
|
||||||
r = util_getpass(&new_pin, &len, stdin);
|
printf("Please enter the new PIN: ");
|
||||||
if (r < 0)
|
r = util_getpass(&new_pin, &len, stdin);
|
||||||
return 1;
|
if (r < 0)
|
||||||
if (!new_pin || !*new_pin || strlen(new_pin) > 20)
|
return 1;
|
||||||
return 1;
|
if (!new_pin || !*new_pin || strlen(new_pin) > 20)
|
||||||
strcpy(new_buf, new_pin);
|
return 1;
|
||||||
|
strcpy(new_buf, new_pin);
|
||||||
printf("Please enter the new PIN again: ");
|
|
||||||
r = util_getpass(&new_pin, &len, stdin);
|
printf("Please enter the new PIN again: ");
|
||||||
if (r < 0)
|
r = util_getpass(&new_pin, &len, stdin);
|
||||||
return 1;
|
if (r < 0)
|
||||||
if (!new_pin || !*new_pin || strcmp(new_buf, new_pin) != 0)
|
return 1;
|
||||||
return 1;
|
if (!new_pin || !*new_pin || strcmp(new_buf, new_pin) != 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
new_pin = opt_new_pin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = p11->C_SetPIN(sess,
|
rv = p11->C_SetPIN(sess,
|
||||||
|
|
Loading…
Reference in New Issue