- previous patch was bogus/incomplete
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1539 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
af0bd61682
commit
1eacefc83c
|
@ -594,53 +594,40 @@ int do_verify(int argc, char **argv)
|
||||||
{ "PRO", SC_AC_PRO },
|
{ "PRO", SC_AC_PRO },
|
||||||
{ NULL, -1 }
|
{ NULL, -1 }
|
||||||
};
|
};
|
||||||
int i, r, tries_left = -1;
|
int i, type = -1, ref, r, tries_left = -1;
|
||||||
u8 buf[30];
|
u8 buf[30];
|
||||||
const char *s;
|
const char *s;
|
||||||
size_t buflen = sizeof(buf);
|
size_t buflen = sizeof(buf);
|
||||||
struct sc_pin_cmd_data data;
|
|
||||||
|
|
||||||
if (argc < 1 || argc > 2)
|
if (argc < 1 || argc > 2)
|
||||||
goto usage;
|
goto usage;
|
||||||
|
|
||||||
memset(&data, 0, sizeof(data));
|
|
||||||
data.cmd = SC_PIN_CMD_VERIFY;
|
|
||||||
|
|
||||||
data.pin_type = -1;
|
|
||||||
for (i = 0; typeNames[i].name; i++) {
|
for (i = 0; typeNames[i].name; i++) {
|
||||||
if (strncasecmp(argv[0], typeNames[i].name, 3) == 0) {
|
if (strncasecmp(argv[0], typeNames[i].name, 3) == 0) {
|
||||||
data.pin_type = typeNames[i].type;
|
type = typeNames[i].type;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.pin_type == -1) {
|
if (type == -1) {
|
||||||
printf("Invalid type.\n");
|
printf("Invalid type.\n");
|
||||||
goto usage;
|
goto usage;
|
||||||
}
|
}
|
||||||
if (sscanf(argv[0] + 3, "%d", &data.pin_reference) != 1) {
|
if (sscanf(argv[0] + 3, "%d", &ref) != 1) {
|
||||||
printf("Invalid key reference.\n");
|
printf("Invalid key reference.\n");
|
||||||
goto usage;
|
goto usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
if (!(card->reader->slot[0].capabilities & SC_SLOT_CAP_PIN_PAD)) {
|
/* just return the retry counter */
|
||||||
printf("Card reader or driver doesn't support PIN PAD\n");
|
buflen = 0;
|
||||||
return -1;
|
}
|
||||||
}
|
if (argv[1][0] == '"') {
|
||||||
printf("Please enter PIN on the reader's pin pad.\n");
|
|
||||||
data.pin1.prompt = "Please enter PIN";
|
|
||||||
data.flags |= SC_PIN_CMD_USE_PINPAD;
|
|
||||||
} else if (argv[1][0] == '"') {
|
|
||||||
for (s=argv[1]+1, i=0; i < sizeof(buf) && *s && *s != '"';i++)
|
for (s=argv[1]+1, i=0; i < sizeof(buf) && *s && *s != '"';i++)
|
||||||
buf[i] = *s++;
|
buf[i] = *s++;
|
||||||
data.pin1.data = buf;
|
buflen = i;
|
||||||
data.pin1.len = i;
|
|
||||||
} else if (sc_hex_to_bin(argv[1], buf, &buflen) != 0) {
|
} else if (sc_hex_to_bin(argv[1], buf, &buflen) != 0) {
|
||||||
printf("Invalid key value.\n");
|
printf("Invalid key value.\n");
|
||||||
goto usage;
|
goto usage;
|
||||||
}
|
}
|
||||||
r = sc_pin_cmd(card, &data, &tries_left);
|
r = sc_verify(card, type, ref, buf, buflen, &tries_left);
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
if (r == SC_ERROR_PIN_CODE_INCORRECT) {
|
if (r == SC_ERROR_PIN_CODE_INCORRECT) {
|
||||||
if (tries_left >= 0)
|
if (tries_left >= 0)
|
||||||
|
@ -659,7 +646,6 @@ usage:
|
||||||
for (i = 0; typeNames[i].name; i++)
|
for (i = 0; typeNames[i].name; i++)
|
||||||
printf("\t%s\n", typeNames[i].name);
|
printf("\t%s\n", typeNames[i].name);
|
||||||
printf("Example: verify CHV2 31:32:33:34:00:00:00:00\n");
|
printf("Example: verify CHV2 31:32:33:34:00:00:00:00\n");
|
||||||
printf("If key is omitted, card reader's keypad will be used to collect PIN.\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue