better error messages for verify pin
This commit is contained in:
+9
-4
@@ -1048,10 +1048,16 @@ static bool verify_pin(SCARDHANDLE *card, const char *pin, int verbose) {
|
|||||||
memset(apdu.st.data + len, 0xff, 8 - len);
|
memset(apdu.st.data + len, 0xff, 8 - len);
|
||||||
}
|
}
|
||||||
sw = send_data(card, &apdu, data, &recv_len, verbose);
|
sw = send_data(card, &apdu, data, &recv_len, verbose);
|
||||||
if(sw != 0x9000) {
|
if(sw == 0x9000) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
} else if((sw >> 8) == 0x63) {
|
||||||
|
fprintf(stderr, "Pin verification failed, %d tries left before pin is blocked.\n", sw & 0xff);
|
||||||
|
} else if(sw == 0x6983) {
|
||||||
|
fprintf(stderr, "Pin code blocked, use unblock-pin action to unblock.\n");
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Pin code verification failed with code %x.\n", sw);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this function is called for all three of change-pin, change-puk and unblock pin
|
/* this function is called for all three of change-pin, change-puk and unblock pin
|
||||||
@@ -1473,7 +1479,6 @@ int main(int argc, char *argv[]) {
|
|||||||
if(verify_pin(&card, args_info.pin_arg, verbosity)) {
|
if(verify_pin(&card, args_info.pin_arg, verbosity)) {
|
||||||
printf("Successfully verified PIN.\n");
|
printf("Successfully verified PIN.\n");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Failed to verify PIN.\n");
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user