[pkg-opensc-commit] [libp11] 203/239: examples: auth: authenticate prior to any listing
Eric Dorland
eric at moszumanska.debian.org
Sat Oct 17 06:21:34 UTC 2015
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository libp11.
commit 987e183ec3a6fea1201d862cb94b6a9f7b6e99b9
Author: Nikos Mavrogiannopoulos <nmav at redhat.com>
Date: Thu Jul 2 12:30:21 2015 +0200
examples: auth: authenticate prior to any listing
That makes the example work with cards that have their
objects marked as private.
---
examples/auth.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/examples/auth.c b/examples/auth.c
index f433aba..035a507 100644
--- a/examples/auth.c
+++ b/examples/auth.c
@@ -74,20 +74,6 @@ int main(int argc, char *argv[])
printf("Slot token model.......: %s\n", slot->token->model);
printf("Slot token serialnr....: %s\n", slot->token->serialnr);
- /* get all certs */
- rc = PKCS11_enumerate_certs(slot->token, &certs, &ncerts);
- if (rc) {
- fprintf(stderr, "PKCS11_enumerate_certs failed\n");
- goto failed;
- }
- if (ncerts <= 0) {
- fprintf(stderr, "no certificates found\n");
- goto failed;
- }
-
- /* use the first cert */
- authcert=&certs[0];
-
if (!slot->token->loginRequired)
goto loggedin;
@@ -120,6 +106,7 @@ int main(int argc, char *argv[])
password[rc-1]=0;
}
+ loggedin:
/* perform pkcs #11 login */
rc = PKCS11_login(slot, 0, password);
memset(password, 0, strlen(password));
@@ -128,7 +115,20 @@ int main(int argc, char *argv[])
goto failed;
}
- loggedin:
+ /* get all certs */
+ rc = PKCS11_enumerate_certs(slot->token, &certs, &ncerts);
+ if (rc) {
+ fprintf(stderr, "PKCS11_enumerate_certs failed\n");
+ goto failed;
+ }
+ if (ncerts <= 0) {
+ fprintf(stderr, "no certificates found\n");
+ goto failed;
+ }
+
+ /* use the first cert */
+ authcert=&certs[0];
+
/* get random bytes */
random = malloc(RANDOM_SIZE);
if (!random)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/libp11.git
More information about the pkg-opensc-commit
mailing list