summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2016-09-06 02:23:03 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2016-09-06 02:23:32 -0500
commit4114606c72147a3c2918bdca1a9cf5ef164bc06d (patch)
treeb01fb190501b157568073f7df92d74e3cdd5f391 /src
parent995e057abc6ad9458d64b648178d6efae244d877 (diff)
downloadsmartcardauth-4114606c72147a3c2918bdca1a9cf5ef164bc06d.tar.gz
smartcardauth-4114606c72147a3c2918bdca1a9cf5ef164bc06d.zip
Gracefully handle lack of random data in early system startup
Speed up PC/SC launch
Diffstat (limited to 'src')
-rw-r--r--src/cardpincheck.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/cardpincheck.c b/src/cardpincheck.c
index e6c1cc4..f1e730f 100644
--- a/src/cardpincheck.c
+++ b/src/cardpincheck.c
@@ -192,13 +192,13 @@ int main(int argc, char* argv[]) {
file_to_decrypt = argv[2];
}
- fprintf(stderr, "Initializing pkcs11-helper\n");
+ fprintf(stderr, "Initializing pkcs11-helper\n"); fflush(stderr);
if ((rv = pkcs11h_initialize()) != CKR_OK) {
fprintf(stderr, "pkcs11h_initialize failed: %s\n", pkcs11h_getMessage(rv));
return -1;
}
- fprintf(stderr, "Registering pkcs11-helper hooks\n");
+ fprintf(stderr, "Registering pkcs11-helper hooks\n"); fflush(stderr);
if ((rv = pkcs11h_setLogHook(pkcs_log_hook, NULL)) != CKR_OK) {
fprintf(stderr, "pkcs11h_setLogHook failed: %s\n", pkcs11h_getMessage(rv));
return -1;
@@ -223,7 +223,7 @@ int main(int argc, char* argv[]) {
return -1;
}
- fprintf(stderr, "Adding provider '%s'\n", opensc_provider_library);
+ fprintf(stderr, "Adding provider '%s'\n", opensc_provider_library); fflush(stderr);
if ((rv = pkcs11h_addProvider(opensc_provider_library, opensc_provider_library, FALSE, PKCS11H_PRIVATEMODE_MASK_AUTO, PKCS11H_SLOTEVENT_METHOD_AUTO, 0, FALSE)) != CKR_OK) {
fprintf(stderr, "pkcs11h_addProvider failed: %s\n", pkcs11h_getMessage(rv));
return -1;
@@ -284,7 +284,11 @@ int main(int argc, char* argv[]) {
// Check PIN
rv = pkcs11h_certificate_ensureKeyAccess(certificate);
if (rv != CKR_OK) {
- if (rv == CKR_CANCEL) {
+ if (rv == CKR_GENERAL_ERROR) {
+ ret = -4;
+ break;
+ }
+ else if (rv == CKR_CANCEL) {
ret = -3;
break;
}