|
|
@ -192,13 +192,13 @@ int main(int argc, char* argv[]) {
|
|
|
|
file_to_decrypt = argv[2];
|
|
|
|
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) {
|
|
|
|
if ((rv = pkcs11h_initialize()) != CKR_OK) {
|
|
|
|
fprintf(stderr, "pkcs11h_initialize failed: %s\n", pkcs11h_getMessage(rv));
|
|
|
|
fprintf(stderr, "pkcs11h_initialize failed: %s\n", pkcs11h_getMessage(rv));
|
|
|
|
return -1;
|
|
|
|
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) {
|
|
|
|
if ((rv = pkcs11h_setLogHook(pkcs_log_hook, NULL)) != CKR_OK) {
|
|
|
|
fprintf(stderr, "pkcs11h_setLogHook failed: %s\n", pkcs11h_getMessage(rv));
|
|
|
|
fprintf(stderr, "pkcs11h_setLogHook failed: %s\n", pkcs11h_getMessage(rv));
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
@ -223,7 +223,7 @@ int main(int argc, char* argv[]) {
|
|
|
|
return -1;
|
|
|
|
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) {
|
|
|
|
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));
|
|
|
|
fprintf(stderr, "pkcs11h_addProvider failed: %s\n", pkcs11h_getMessage(rv));
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
@ -284,7 +284,11 @@ int main(int argc, char* argv[]) {
|
|
|
|
// Check PIN
|
|
|
|
// Check PIN
|
|
|
|
rv = pkcs11h_certificate_ensureKeyAccess(certificate);
|
|
|
|
rv = pkcs11h_certificate_ensureKeyAccess(certificate);
|
|
|
|
if (rv != CKR_OK) {
|
|
|
|
if (rv != CKR_OK) {
|
|
|
|
if (rv == CKR_CANCEL) {
|
|
|
|
if (rv == CKR_GENERAL_ERROR) {
|
|
|
|
|
|
|
|
ret = -4;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (rv == CKR_CANCEL) {
|
|
|
|
ret = -3;
|
|
|
|
ret = -3;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|