- given ASN.1 decoding routines a facelift
- implemented certificate enumeration git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@13 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
3088f6547b
commit
202c8e5227
@ -64,7 +64,7 @@ static CK_ATTRIBUTE certificate[] = {
|
|||||||
int slot_connect(int id)
|
int slot_connect(int id)
|
||||||
{
|
{
|
||||||
struct sc_card *card;
|
struct sc_card *card;
|
||||||
struct sc_pkcs15_pin_object pin;
|
struct sc_pkcs15_pin_info pin;
|
||||||
int r, c = 0;
|
int r, c = 0;
|
||||||
|
|
||||||
r = sc_connect_card(ctx, id, &card);
|
r = sc_connect_card(ctx, id, &card);
|
||||||
@ -81,7 +81,7 @@ int slot_connect(int id)
|
|||||||
return CKR_TOKEN_NOT_RECOGNIZED;
|
return CKR_TOKEN_NOT_RECOGNIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (sc_pkcs15_read_pin_object(slot[id].p15card, ++c, &pin) == 0);
|
while (sc_pkcs15_read_pin_info(slot[id].p15card, ++c, &pin) == 0);
|
||||||
LOG("Found total of %d PIN codes.\n", c);
|
LOG("Found total of %d PIN codes.\n", c);
|
||||||
slot[id].flags = SLOT_CONNECTED;
|
slot[id].flags = SLOT_CONNECTED;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ int main(int argc, char **argv) {
|
|||||||
struct sc_context *ctx = NULL;
|
struct sc_context *ctx = NULL;
|
||||||
struct sc_card *card = NULL;
|
struct sc_card *card = NULL;
|
||||||
struct sc_pkcs15_card *p15_card = NULL;
|
struct sc_pkcs15_card *p15_card = NULL;
|
||||||
struct sc_pkcs15_pin_object pin;
|
struct sc_pkcs15_pin_info pin;
|
||||||
char buf[16], buf2[16];
|
char buf[16], buf2[16];
|
||||||
|
|
||||||
int i,c ;
|
int i,c ;
|
||||||
@ -51,20 +51,22 @@ int main(int argc, char **argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
sc_pkcs15_print_card(p15_card);
|
sc_pkcs15_print_card(p15_card);
|
||||||
return 0;
|
i = sc_pkcs15_enum_certificates(p15_card);
|
||||||
i = sc_pkcs15_read_certificate(p15_card, 0);
|
if (i < 0) {
|
||||||
if (i) {
|
fprintf(stderr, "Certificate enumeration failed with %s\n", sc_strerror(i));
|
||||||
fprintf(stderr, "Certificate read failed with %d\n", i);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
printf("%d certificates found.\n", i);
|
||||||
|
for (i = 0; i < p15_card->cert_count; i++)
|
||||||
|
sc_pkcs15_print_cert_info(&p15_card->cert_info[i]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
printf("Searching for PIN codes...\n");
|
printf("Searching for PIN codes...\n");
|
||||||
|
|
||||||
c = 0;
|
c = 0;
|
||||||
while (sc_pkcs15_read_pin_object(p15_card, ++c, &pin) == 0) {
|
while (sc_pkcs15_read_pin_info(p15_card, ++c, &pin) == 0) {
|
||||||
sc_pkcs15_print_pin_object(&pin);
|
sc_pkcs15_print_pin_info(&pin);
|
||||||
}
|
}
|
||||||
c--;
|
c--;
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user