cleanup debug/quiet/verbose handling.
now all tools accept "-v" for verbose operation, and you can specify -v several times to get more verbose i.e. debugging output. git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1792 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
4aa731e415
commit
9b7cdbffad
|
@ -22,14 +22,9 @@ The default is to auto-detect the correct card driver.
|
|||
.BR \-\-wait ", " \-w
|
||||
Causes \*(nm to wait for the token to be inserted into \fIreader\fP.
|
||||
.TP
|
||||
.BR \-\-quiet ", " \-q
|
||||
Causes \*(nm to be less verbose about what is going on behind the scenes.
|
||||
.TP
|
||||
.BR \-\-debug ", " \-d
|
||||
Causes \*(nm to print debugging information during operation. This option
|
||||
may be specified more than once to incrementaly increase the amount
|
||||
of debugging information output.
|
||||
either \-\-login or \-\-pin.
|
||||
.BR \-\-verbose ", " \-v
|
||||
Causes \*(nm to be more verbose. Specify this flag several times
|
||||
to enable debug output in the opensc library.
|
||||
.SH SEE ALSO
|
||||
.BR opensc (7).
|
||||
.SH AUTHORS
|
||||
|
|
|
@ -14,7 +14,7 @@ stored on the smart card. User PIN authentication is
|
|||
performed for those operations that require it.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR \-\-verify\-pin ", " \-v
|
||||
.BR \-\-verify\-pin ", " \-V
|
||||
Verifies CHV1 before issuing commands
|
||||
.TP
|
||||
.BR \-\-list\-keys ", " \-l
|
||||
|
@ -57,13 +57,9 @@ value is 1024.
|
|||
Forces \*(nm to use reader number \fInum\fP for operations. The default
|
||||
is to use reader number 0, the first reader in the system.
|
||||
.TP
|
||||
.BR \-\-quiet ", " \-q
|
||||
Perform operations quietly. This causes \*(nm to be less 'chatty'
|
||||
about the status of the operation.
|
||||
.TP
|
||||
.BR \-\-debug ", " \-d
|
||||
Print debug output. This option may be supplied many times each
|
||||
increasing the verbosity of debug messages.
|
||||
.BR \-\-verbose ", " \-v
|
||||
Causes \*(nm to be more verbose. Specify this flag several times
|
||||
to enable debug output in the opensc library.
|
||||
.SH SEE ALSO
|
||||
.BR opensc (7),
|
||||
.BR pkcs15-tool (1)
|
||||
|
|
|
@ -23,9 +23,9 @@ in the system.
|
|||
.BR "\-\-card\-driver " \fIdriver\fP ", \-D " \fIdriver\fP
|
||||
Use the given card driver. The default is auto-detected.
|
||||
.TP
|
||||
.BR \-\-debug ", " \-d
|
||||
Print debug output. This option may be supplied many times each
|
||||
increasing the verbosity of debug messages.
|
||||
.BR \-\-verbose ", " \-v
|
||||
Causes \*(nm to be more verbose. Specify this flag several times
|
||||
to enable debug output in the opensc library.
|
||||
.SH COMMANDS
|
||||
The following commands are suported at the \*(nm interactive prompt.
|
||||
.PP
|
||||
|
|
|
@ -38,12 +38,9 @@ in the system.
|
|||
.BR "\-\-card\-driver " \fIdriver\fP ", \-c " \fIdriver\fP
|
||||
Use the given card driver. The default is auto-detected.
|
||||
.TP
|
||||
.BR \-\-quiet ", " \-q
|
||||
Quiet operation
|
||||
.TP
|
||||
.BR \-\-debug ", " \-d
|
||||
Print debug output. This option may be supplied many times each
|
||||
increasing the verbosity of debug messages.
|
||||
.BR \-\-verbose ", " \-v
|
||||
Causes \*(nm to be more verbose. Specify this flag several times
|
||||
to enable debug output in the opensc library.
|
||||
.SH SEE ALSO
|
||||
.BR opensc (7),
|
||||
.BR opensc-explorer (1)
|
||||
|
|
|
@ -26,9 +26,6 @@ read the command line from the system or if it is embedded in a script.
|
|||
.BR \-\-change\-pin ", " \-c
|
||||
Change the user PIN on the token
|
||||
.TP
|
||||
.BR \-\-quiet ", " \-q
|
||||
Causes \*(nm to be less verbose about what is going on behind the scenes.
|
||||
.TP
|
||||
.BR \-\-test ", " \-t
|
||||
Performs some tests on the token. This option is most useful when used with
|
||||
either \-\-login or \-\-pin.
|
||||
|
@ -92,6 +89,10 @@ Specify a module to load.
|
|||
.BR "\-\-moz\-cert " \fIpath\fP ", \-z " \fIpath\fP
|
||||
Tests a Mozilla-like keypair generation and certificate request.
|
||||
Specify the \fIpath\fP to the certificate file.
|
||||
.TP
|
||||
.BR \-\-verbose ", " \-v
|
||||
Causes \*(nm to be more verbose. Specify this flag several times
|
||||
to enable debug output in the opensc library.
|
||||
.SH SEE ALSO
|
||||
.BR opensc (7).
|
||||
.SH AUTHORS
|
||||
|
|
|
@ -77,12 +77,9 @@ a process can be displayed by any user using the
|
|||
command. It is therefore a security risk to specify
|
||||
secret information such as PINs on the command line.
|
||||
.TP
|
||||
.BR \-\-quiet ", " \-q
|
||||
Operate quietly.
|
||||
.TP
|
||||
.BR \-\-debug ", " \-d
|
||||
Print debugging information. By specifying this option
|
||||
several times, you can increase the verbosity level.
|
||||
.BR \-\-verbose ", " \-v
|
||||
Causes \*(nm to be more verbose. Specify this flag several times
|
||||
to enable debug output in the opensc library.
|
||||
.SH AUTHORS
|
||||
\*(nm was written by Juha Yrjölä <juha.yrjola@iki.fi>.
|
||||
This manpage was contributed by Olaf Kirch <okir@lst.de>.
|
||||
|
|
|
@ -269,9 +269,9 @@ You can specify
|
|||
.B \-\-options-file
|
||||
several times.
|
||||
.TP
|
||||
.BR \-\-debug ", " \-d
|
||||
Turns on debugging output. Specifying this option more than once
|
||||
increases the verbosity of the output.
|
||||
.BR \-\-verbose ", " \-v
|
||||
Causes \*(nm to be more verbose. Specify this flag several times
|
||||
to enable debug output in the opensc library.
|
||||
.SH SEE ALSO
|
||||
.BR pkcs15-profile (5) .
|
||||
.SH BUGS
|
||||
|
|
|
@ -63,13 +63,9 @@ is useful with the \-\-change\-pin operation.
|
|||
Forces \*(nm to use reader number \fInum\fP for operations. The default
|
||||
is to use reader number 0, the first reader in the system.
|
||||
.TP
|
||||
.BR \-\-quiet ", " \-q
|
||||
Perform operations quietly. This causes \*(nm to be less 'chatty'
|
||||
about the status of the operation.
|
||||
.TP
|
||||
.BR \-\-debug ", " \-d
|
||||
Print debug output. This option may be supplied many times each
|
||||
increasing the verbosity of debug messages.
|
||||
.BR \-\-verbose ", " \-v
|
||||
Causes \*(nm to be more verbose. Specify this flag several times
|
||||
to enable debug output in the opensc library.
|
||||
.SH SEE ALSO
|
||||
.BR opensc (7),
|
||||
.BR pkcs15-init (1),
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "engine_opensc.h"
|
||||
|
||||
/* static state info one card/reader at a time */
|
||||
static int quiet = 1;
|
||||
static int verbose = 0;
|
||||
static int sc_reader_id = 0;
|
||||
static sc_context_t *ctx = NULL;
|
||||
static sc_card_t *card = NULL;
|
||||
|
@ -64,7 +64,7 @@ int opensc_init(void)
|
|||
{
|
||||
int r = 0;
|
||||
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
fprintf(stderr, "initializing engine");
|
||||
|
||||
r = sc_establish_context(&ctx, "openssl");
|
||||
|
@ -191,7 +191,7 @@ EVP_PKEY *opensc_load_public_key(ENGINE * e, const char *s_key_id,
|
|||
sc_pkcs15_cert_t *cert = NULL;
|
||||
EVP_PKEY *key_out = NULL;
|
||||
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
fprintf(stderr, "Loading public key!\n");
|
||||
id = (struct sc_pkcs15_id *) malloc(sizeof(struct sc_pkcs15_id));
|
||||
id->len = SC_PKCS15_MAX_ID_SIZE;
|
||||
|
@ -199,14 +199,14 @@ EVP_PKEY *opensc_load_public_key(ENGINE * e, const char *s_key_id,
|
|||
|
||||
r = sc_pkcs15_find_pubkey_by_id(p15card, id, &obj);
|
||||
if (r >= 0) {
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Reading public key with ID '%s'\n", s_key_id);
|
||||
r = sc_pkcs15_read_pubkey(p15card, obj, &pubkey);
|
||||
} else if (r == SC_ERROR_OBJECT_NOT_FOUND) {
|
||||
/* No pubkey - try if there's a certificate */
|
||||
r = sc_pkcs15_find_cert_by_id(p15card, id, &obj);
|
||||
if (r >= 0) {
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Reading certificate with ID '%s'\n",
|
||||
s_key_id);
|
||||
r = sc_pkcs15_read_certificate(p15card,
|
||||
|
@ -272,7 +272,7 @@ EVP_PKEY *opensc_load_private_key(ENGINE * e, const char *s_key_id,
|
|||
{
|
||||
EVP_PKEY *key_out;
|
||||
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
fprintf(stderr, "Loading private key!");
|
||||
if (sc_pin) {
|
||||
free(sc_pin);
|
||||
|
@ -319,7 +319,7 @@ sc_sign(int type, const u_char * m, unsigned int m_len,
|
|||
int r;
|
||||
unsigned long flags = 0;
|
||||
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
fprintf(stderr, "signing with type %d\n", type);
|
||||
r = sc_prkey_op_init(rsa, &key_obj, SC_USAGE_SIGN);
|
||||
if (r)
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
PKCS11_CTX *ctx;
|
||||
char *pin = NULL;
|
||||
int quiet = 1;
|
||||
int verbose = 0;
|
||||
|
||||
char *module = PKCS11_DEFAULT_MODULE_NAME;
|
||||
int default_module = 1;
|
||||
|
@ -54,9 +54,9 @@ int set_pin(const char *_pin)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int set_quiet(int i)
|
||||
int inc_verbose()
|
||||
{
|
||||
quiet = i;
|
||||
verbose++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ int pkcs11_finish(ENGINE * engine)
|
|||
|
||||
int pkcs11_init(ENGINE * engine)
|
||||
{
|
||||
if (!quiet) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "initializing engine\n");
|
||||
}
|
||||
ctx = PKCS11_CTX_new();
|
||||
|
@ -234,7 +234,7 @@ EVP_PKEY *pkcs11_load_key(ENGINE * e, const char *s_slot_key_id,
|
|||
if (PKCS11_enumerate_slots(ctx, &slot_list, &count) < 0)
|
||||
fail("failed to enumerate slots\n");
|
||||
|
||||
if(!quiet) {
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Found %u slot%s\n", count, (count <= 1) ? "" : "s");
|
||||
}
|
||||
for (n = 0; n < count; n++) {
|
||||
|
@ -256,7 +256,7 @@ EVP_PKEY *pkcs11_load_key(ENGINE * e, const char *s_slot_key_id,
|
|||
flags[m - 2] = '\0';
|
||||
}
|
||||
|
||||
if(!quiet) {
|
||||
if(verbose) {
|
||||
fprintf(stderr,"[%u] %-25.25s %-16s", n, slot->description, flags);
|
||||
if (slot->token) {
|
||||
fprintf(stderr," (%s)",
|
||||
|
@ -292,7 +292,7 @@ EVP_PKEY *pkcs11_load_key(ENGINE * e, const char *s_slot_key_id,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if(!quiet) {
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Found slot: %s\n", slot->description);
|
||||
fprintf(stderr,"Found token: %s\n", slot->token->label);
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ EVP_PKEY *pkcs11_load_key(ENGINE * e, const char *s_slot_key_id,
|
|||
if (PKCS11_enumerate_certs(tok, &certs, &count))
|
||||
fail("unable to enumerate certificates\n");
|
||||
|
||||
if(!quiet) {
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Found %u certificate%s:\n", count, (count <= 1) ? "" : "s");
|
||||
for (n = 0; n < count; n++) {
|
||||
PKCS11_CERT *c = certs + n;
|
||||
|
@ -338,19 +338,19 @@ EVP_PKEY *pkcs11_load_key(ENGINE * e, const char *s_slot_key_id,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if(!quiet) {
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Found %u key%s:\n", count, (count <= 1) ? "" : "s");
|
||||
}
|
||||
for (n = 0; n < count; n++) {
|
||||
PKCS11_KEY *k = keys + n;
|
||||
|
||||
if(!quiet) {
|
||||
if(verbose) {
|
||||
fprintf(stderr," %2u %c%c %s\n", n + 1,
|
||||
k->isPrivate ? 'P' : ' ', k->needLogin ? 'L' : ' ', k->label);
|
||||
}
|
||||
if (key_id_len != 0 && k->id_len == key_id_len &&
|
||||
memcmp(k->id, key_id, key_id_len) == 0) {
|
||||
if(!quiet) {
|
||||
if(verbose) {
|
||||
fprintf(stderr," ID = %s\n", s_key_id);
|
||||
}
|
||||
selected_key = k;
|
||||
|
|
|
@ -37,7 +37,7 @@ int set_module(const char *modulename);
|
|||
|
||||
int set_pin(const char *pin);
|
||||
|
||||
int set_quiet(int i);
|
||||
int inc_verbose();
|
||||
|
||||
int pkcs11_finish(ENGINE * engine);
|
||||
|
||||
|
|
|
@ -125,9 +125,7 @@ static int pkcs11_engine_ctrl(ENGINE * e, int cmd, long i, void *p, void (*f) ()
|
|||
case CMD_PIN:
|
||||
return set_pin((const char *) p);
|
||||
case CMD_VERBOSE:
|
||||
return set_quiet(0);
|
||||
case CMD_QUIET:
|
||||
return set_quiet(1);
|
||||
return inc_verbose();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ if [ -z "$__p15init__" ]; then
|
|||
--split-key|\
|
||||
--no-prompt|\
|
||||
--soft|\
|
||||
-d*)
|
||||
-v*)
|
||||
p15init="$p15init $1";;
|
||||
--reader)
|
||||
P15_READER=$2
|
||||
|
@ -179,7 +179,7 @@ function run_check_output {
|
|||
|
||||
function skip_if_card {
|
||||
|
||||
name=`$osctool -q --name`
|
||||
name=`$osctool --name`
|
||||
for __pat in "$@"; do
|
||||
if expr "$name" : "${__pat}.*" >/dev/null; then
|
||||
msg "Detected $name; skipping test"
|
||||
|
@ -190,7 +190,7 @@ function skip_if_card {
|
|||
|
||||
function skip_unless_card {
|
||||
|
||||
name=`$osctool -q --name`
|
||||
name=`$osctool --name`
|
||||
for __pat in "$@"; do
|
||||
if expr "$name" : "${__pat}.*" >/dev/null; then
|
||||
return
|
||||
|
@ -217,7 +217,7 @@ function p15_init {
|
|||
:::
|
||||
EOF
|
||||
|
||||
$p15init --assert-pristine -q ||
|
||||
$p15init --assert-pristine ||
|
||||
fail "This test requires a clean card, please erase existing pkcs15 structure"
|
||||
|
||||
msg "Initializing card ($*)"
|
||||
|
|
|
@ -37,23 +37,21 @@
|
|||
const char *app_name = "cardos-info";
|
||||
|
||||
int opt_reader = -1, opt_debug = 0, opt_wait = 0;
|
||||
int quiet = 0;
|
||||
int verbose = 0;
|
||||
|
||||
const struct option options[] = {
|
||||
{"reader", 1, 0, 'r'},
|
||||
{"card-driver", 1, 0, 'c'},
|
||||
{"quiet", 0, 0, 'q'},
|
||||
{"wait", 0, 0, 'w'},
|
||||
{"debug", 0, 0, 'd'},
|
||||
{"verbose", 0, 0, 'v'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
const char *option_help[] = {
|
||||
"Uses reader number <arg> [0]",
|
||||
"Forces the use of driver <arg> [auto-detect]",
|
||||
"Quiet operation",
|
||||
"Wait for a card to be inserted",
|
||||
"Debug output -- may be supplied several times",
|
||||
"Verbose operation. Use several times to enable debug output.",
|
||||
};
|
||||
|
||||
struct sc_context *ctx = NULL;
|
||||
|
@ -349,8 +347,8 @@ int main(int argc, char *const argv[])
|
|||
case 'r':
|
||||
opt_reader = atoi(optarg);
|
||||
break;
|
||||
case 'q':
|
||||
quiet++;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'd':
|
||||
opt_debug++;
|
||||
|
@ -381,7 +379,7 @@ int main(int argc, char *const argv[])
|
|||
}
|
||||
}
|
||||
|
||||
err = connect_card(ctx, &card, opt_reader, 0, opt_wait, quiet);
|
||||
err = connect_card(ctx, &card, opt_reader, 0, opt_wait, verbose);
|
||||
if (err)
|
||||
goto end;
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
|
||||
const char *app_name = "cryptoflex-tool";
|
||||
|
||||
int opt_reader = 0, opt_debug = 0;
|
||||
int opt_reader = 0;
|
||||
int opt_key_num = 1, opt_pin_num = -1;
|
||||
int quiet = 0;
|
||||
int verbose = 0;
|
||||
int opt_exponent = 3;
|
||||
int opt_mod_length = 1024;
|
||||
int opt_key_count = 1;
|
||||
|
@ -49,7 +49,7 @@ const struct option options[] = {
|
|||
{ "create-pin-file", 1, 0, 'P' },
|
||||
{ "generate-key", 0, 0, 'g' },
|
||||
{ "read-key", 0, 0, 'R' },
|
||||
{ "verify-pin", 0, 0, 'v' },
|
||||
{ "verify-pin", 0, 0, 'V' },
|
||||
{ "key-num", 1, 0, 'k' },
|
||||
{ "app-df", 1, 0, 'a' },
|
||||
{ "prkey-file", 1, 0, 'p' },
|
||||
|
@ -57,8 +57,7 @@ const struct option options[] = {
|
|||
{ "exponent", 1, 0, 'e' },
|
||||
{ "modulus-length", 1, 0, 'm' },
|
||||
{ "reader", 1, 0, 'r' },
|
||||
{ "quiet", 0, 0, 'q' },
|
||||
{ "debug", 0, 0, 'd' },
|
||||
{ "verbose", 0, 0, 'v' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -76,8 +75,7 @@ const char *option_help[] = {
|
|||
"The RSA exponent to use in key generation [3]",
|
||||
"Modulus length to use in key generation [1024]",
|
||||
"Uses reader number <arg> [0]",
|
||||
"Quiet operation",
|
||||
"Debug output -- may be supplied several times",
|
||||
"Verbose operation. Use several times to enable debug output.",
|
||||
};
|
||||
|
||||
struct sc_context *ctx = NULL;
|
||||
|
@ -549,7 +547,7 @@ int generate_key(void)
|
|||
r = select_app_df();
|
||||
if (r)
|
||||
return 1;
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Generating key...\n");
|
||||
r = sc_transmit_apdu(card, &apdu);
|
||||
if (r) {
|
||||
|
@ -588,7 +586,7 @@ int create_key_files(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Creating key files for %d keys.\n", opt_key_count);
|
||||
|
||||
file = sc_file_new();
|
||||
|
@ -630,7 +628,7 @@ int create_key_files(void)
|
|||
fprintf(stderr, "Unable to create public key file: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Key files generated successfully.\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -853,7 +851,7 @@ int store_key(void)
|
|||
r = encode_public_key(rsa, pub, &pubsize);
|
||||
if (r)
|
||||
return r;
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Storing private key...\n");
|
||||
r = select_app_df();
|
||||
if (r)
|
||||
|
@ -861,7 +859,7 @@ int store_key(void)
|
|||
r = update_private_key(prv, prvsize);
|
||||
if (r)
|
||||
return r;
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Storing public key...\n");
|
||||
r = select_app_df();
|
||||
if (r)
|
||||
|
@ -1113,7 +1111,7 @@ int main(int argc, char * const argv[])
|
|||
exit(2);
|
||||
}
|
||||
break;
|
||||
case 'v':
|
||||
case 'V':
|
||||
opt_pin_num = 1;
|
||||
break;
|
||||
case 'e':
|
||||
|
@ -1131,11 +1129,8 @@ int main(int argc, char * const argv[])
|
|||
case 'r':
|
||||
opt_reader = atoi(optarg);
|
||||
break;
|
||||
case 'q':
|
||||
quiet++;
|
||||
break;
|
||||
case 'd':
|
||||
opt_debug++;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'a':
|
||||
opt_appdf = optarg;
|
||||
|
@ -1149,8 +1144,8 @@ int main(int argc, char * const argv[])
|
|||
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
if (opt_debug)
|
||||
ctx->debug = opt_debug;
|
||||
if (verbose > 1)
|
||||
ctx->debug = verbose-1;
|
||||
if (opt_reader >= ctx->reader_count || opt_reader < 0) {
|
||||
fprintf(stderr, "Illegal reader number. Only %d reader(s) configured.\n", ctx->reader_count);
|
||||
err = 1;
|
||||
|
@ -1161,7 +1156,7 @@ int main(int argc, char * const argv[])
|
|||
err = 3;
|
||||
goto end;
|
||||
}
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
fprintf(stderr, "Connecting to card in reader %s...\n", ctx->reader[opt_reader]->name);
|
||||
r = sc_connect_card(ctx->reader[opt_reader], 0, &card);
|
||||
if (r) {
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
const char *app_name = "opensc-explorer";
|
||||
|
||||
int opt_reader = -1, opt_debug = 0, opt_wait = 0;
|
||||
int opt_reader = -1, opt_wait = 0, verbose = 0;
|
||||
const char *opt_driver = NULL;
|
||||
|
||||
struct sc_file *current_file = NULL;
|
||||
|
@ -48,14 +48,14 @@ const struct option options[] = {
|
|||
{ "reader", 1, 0, 'r' },
|
||||
{ "card-driver", 1, 0, 'c' },
|
||||
{ "wait", 1, 0, 'w' },
|
||||
{ "debug", 0, 0, 'd' },
|
||||
{ "verbose", 0, 0, 'v' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
const char *option_help[] = {
|
||||
"Uses reader number <arg> [0]",
|
||||
"Forces the use of driver <arg> [auto-detect]",
|
||||
"Wait for card insertion",
|
||||
"Debug output -- maybe supplied several times",
|
||||
"Verbose operation. Use several times to enable debug output.",
|
||||
};
|
||||
|
||||
|
||||
|
@ -1241,7 +1241,6 @@ int do_quit(int argc, char **argv)
|
|||
struct command cmds[] = {
|
||||
{ "ls", do_ls, "list all files in the current DF" },
|
||||
{ "cd", do_cd, "change to another DF" },
|
||||
{ "debug", do_debug, "set the debug level" },
|
||||
{ "cat", do_cat, "print the contents of an EF" },
|
||||
{ "info", do_info, "display attributes of card file" },
|
||||
{ "create", do_create, "create a new EF" },
|
||||
|
@ -1357,12 +1356,12 @@ int main(int argc, char * const argv[])
|
|||
case 'c':
|
||||
opt_driver = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
opt_debug++;
|
||||
break;
|
||||
case 'w':
|
||||
opt_wait = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1371,8 +1370,8 @@ int main(int argc, char * const argv[])
|
|||
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
if (opt_debug)
|
||||
ctx->debug = opt_debug;
|
||||
if (verbose > 1)
|
||||
ctx->debug = verbose-1;
|
||||
|
||||
if (opt_driver != NULL) {
|
||||
err = sc_set_card_driver(ctx, opt_driver);
|
||||
|
|
|
@ -36,11 +36,10 @@
|
|||
const char *app_name = "opensc-tool";
|
||||
|
||||
static int opt_reader = -1,
|
||||
opt_debug = 0,
|
||||
opt_wait = 0;
|
||||
static char ** opt_apdus;
|
||||
static int opt_apdu_count = 0;
|
||||
static int quiet = 0;
|
||||
static int verbose = 0;
|
||||
|
||||
const struct option options[] = {
|
||||
{ "atr", 0, 0, 'a' },
|
||||
|
@ -52,9 +51,8 @@ const struct option options[] = {
|
|||
{ "send-apdu", 1, 0, 's' },
|
||||
{ "reader", 1, 0, 'r' },
|
||||
{ "card-driver", 1, 0, 'c' },
|
||||
{ "quiet", 0, 0, 'q' },
|
||||
{ "wait", 0, 0, 'w' },
|
||||
{ "debug", 0, 0, 'd' },
|
||||
{ "verbose", 0, 0, 'v' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -68,9 +66,8 @@ const char *option_help[] = {
|
|||
"Sends an APDU in format AA:BB:CC:DD:EE:FF...",
|
||||
"Uses reader number <arg> [0]",
|
||||
"Forces the use of driver <arg> [auto-detect]",
|
||||
"Quiet operation",
|
||||
"Wait for a card to be inserted",
|
||||
"Debug output -- may be supplied several times",
|
||||
"Verbose operation. Use several times to enable debug output.",
|
||||
};
|
||||
|
||||
struct sc_context *ctx = NULL;
|
||||
|
@ -337,13 +334,7 @@ int send_apdu(void)
|
|||
for (r = 0; r < len0; r++)
|
||||
printf("%02X ", buf[r]);
|
||||
printf("\n");
|
||||
#if 0
|
||||
ctx->debug = 5;
|
||||
#endif
|
||||
r = sc_transmit_apdu(card, &apdu);
|
||||
#if 0
|
||||
ctx->debug = opt_debug;
|
||||
#endif
|
||||
if (r) {
|
||||
fprintf(stderr, "APDU transmit failed: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
|
@ -415,11 +406,8 @@ int main(int argc, char * const argv[])
|
|||
case 'r':
|
||||
opt_reader = atoi(optarg);
|
||||
break;
|
||||
case 'q':
|
||||
quiet++;
|
||||
break;
|
||||
case 'd':
|
||||
opt_debug++;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'c':
|
||||
opt_driver = optarg;
|
||||
|
@ -436,8 +424,8 @@ int main(int argc, char * const argv[])
|
|||
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
if (opt_debug)
|
||||
ctx->debug = opt_debug;
|
||||
if (verbose > 1)
|
||||
ctx->debug = verbose-1;
|
||||
if (do_list_rdrivers) {
|
||||
if ((err = list_reader_drivers()))
|
||||
goto end;
|
||||
|
@ -465,18 +453,18 @@ int main(int argc, char * const argv[])
|
|||
}
|
||||
}
|
||||
|
||||
err = connect_card(ctx, &card, opt_reader, 0, opt_wait, quiet);
|
||||
err = connect_card(ctx, &card, opt_reader, 0, opt_wait, verbose);
|
||||
if (err)
|
||||
goto end;
|
||||
|
||||
if (do_print_atr) {
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Card ATR: ");
|
||||
hex_dump_asc(stdout, card->atr, card->atr_len, -1);
|
||||
action_count--;
|
||||
}
|
||||
if (do_print_name) {
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Card name: ");
|
||||
printf("%s\n", card->name);
|
||||
action_count--;
|
||||
|
|
|
@ -67,10 +67,9 @@ const struct option options[] = {
|
|||
{ "input-file", 1, 0, 'i' },
|
||||
{ "output-file", 1, 0, 'o' },
|
||||
{ "module", 1, 0, OPT_MODULE },
|
||||
{ "quiet", 0, 0, 'q' },
|
||||
|
||||
{ "test", 0, 0, 't' },
|
||||
{ "moz-cert", 1, 0, 'z' },
|
||||
{ "verbose", 0, 0, 'v' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -98,15 +97,15 @@ const char *option_help[] = {
|
|||
"Specify the input file",
|
||||
"Specify the output file",
|
||||
"Specify the module to load",
|
||||
"Quiet operation",
|
||||
|
||||
"Test (best used with the --login or --pin option)",
|
||||
"Test Mozilla-like keypair gen and cert req, <arg>=certfile"
|
||||
"Test Mozilla-like keypair gen and cert req, <arg>=certfile",
|
||||
"Verbose operation. Use several times to enable debug output.",
|
||||
};
|
||||
|
||||
const char * app_name = "pkcs11-tool"; /* for utils.c */
|
||||
|
||||
static int opt_quiet = 0;
|
||||
static int verbose = 0;
|
||||
static const char * opt_input = NULL;
|
||||
static const char * opt_output = NULL;
|
||||
static const char * opt_module = NULL;
|
||||
|
@ -312,8 +311,8 @@ main(int argc, char * const argv[])
|
|||
opt_file_to_write = optarg;
|
||||
action_count++;
|
||||
break;
|
||||
case 'q':
|
||||
opt_quiet++;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case OPT_SLOT:
|
||||
opt_slot = (CK_SLOT_ID) atoi(optarg);
|
||||
|
@ -516,13 +515,13 @@ list_slots(void)
|
|||
printf("(GetSlotInfo failed, error %u)\n", (unsigned int) rv);
|
||||
continue;
|
||||
}
|
||||
if (opt_quiet && !(info.flags & CKF_TOKEN_PRESENT)) {
|
||||
if ((!verbose) && !(info.flags & CKF_TOKEN_PRESENT)) {
|
||||
printf("(empty)\n");
|
||||
continue;
|
||||
}
|
||||
printf("%s\n", p11_utf8_to_local(info.slotDescription,
|
||||
sizeof(info.slotDescription)));
|
||||
if (!opt_quiet) {
|
||||
if (verbose) {
|
||||
printf(" manufacturer: %s\n", p11_utf8_to_local(info.manufacturerID,
|
||||
sizeof(info.manufacturerID)));
|
||||
printf(" hardware ver: %u.%u\n",
|
||||
|
@ -545,7 +544,7 @@ show_token(CK_SLOT_ID slot)
|
|||
|
||||
get_token_info(slot, &info);
|
||||
|
||||
if (!(info.flags & CKF_TOKEN_INITIALIZED) && opt_quiet) {
|
||||
if (!(info.flags & CKF_TOKEN_INITIALIZED) && (!verbose)) {
|
||||
printf(" token state: uninitialized\n");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@
|
|||
|
||||
const char *app_name = "pkcs15-crypt";
|
||||
|
||||
int opt_reader = -1, quiet = 0, opt_wait = 0;
|
||||
int opt_debug = 0;
|
||||
int opt_reader = -1, verbose = 0, opt_wait = 0;
|
||||
char * opt_pincode = NULL, * opt_key_id = NULL;
|
||||
char * opt_input = NULL, * opt_output = NULL;
|
||||
int opt_crypt_flags = 0;
|
||||
|
@ -61,10 +60,9 @@ const struct option options[] = {
|
|||
{ "sha-1", 0, 0, OPT_SHA1 },
|
||||
{ "md5", 0, 0, OPT_MD5 },
|
||||
{ "pkcs1", 0, 0, OPT_PKCS1 },
|
||||
{ "quiet", 0, 0, 'q' },
|
||||
{ "debug", 0, 0, 'd' },
|
||||
{ "pin", 1, 0, 'p' },
|
||||
{ "wait", 0, 0, 'w' },
|
||||
{ "verbose", 0, 0, 'v' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -78,10 +76,9 @@ const char *option_help[] = {
|
|||
"Input file is a SHA-1 hash",
|
||||
"Input file is a MD5 hash",
|
||||
"Use PKCS #1 v1.5 padding",
|
||||
"Quiet operation",
|
||||
"Debug output -- may be supplied several times",
|
||||
"Uses password (PIN) <arg>",
|
||||
"Wait for card insertion",
|
||||
"Verbose operation. Use several times to enable debug output.",
|
||||
};
|
||||
|
||||
struct sc_context *ctx = NULL;
|
||||
|
@ -445,7 +442,7 @@ static int get_key(unsigned int usage, sc_pkcs15_object_t **result)
|
|||
return 5;
|
||||
}
|
||||
free(pincode);
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
fprintf(stderr, "PIN code correct.\n");
|
||||
prev_pin = pin;
|
||||
}
|
||||
|
@ -498,11 +495,8 @@ int main(int argc, char * const argv[])
|
|||
case OPT_PKCS1:
|
||||
opt_crypt_flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
|
||||
break;
|
||||
case 'q':
|
||||
quiet++;
|
||||
break;
|
||||
case 'd':
|
||||
opt_debug++;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'p':
|
||||
opt_pincode = optarg;
|
||||
|
@ -519,14 +513,14 @@ int main(int argc, char * const argv[])
|
|||
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
if (opt_debug)
|
||||
ctx->debug = opt_debug;
|
||||
if (verbose > 1)
|
||||
ctx->debug = verbose-1;
|
||||
|
||||
err = connect_card(ctx, &card, opt_reader, 0, opt_wait, quiet);
|
||||
err = connect_card(ctx, &card, opt_reader, 0, opt_wait, verbose);
|
||||
if (err)
|
||||
goto end;
|
||||
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
fprintf(stderr, "Trying to find a PKCS #15 compatible card...\n");
|
||||
r = sc_pkcs15_bind(card, &p15card);
|
||||
if (r) {
|
||||
|
@ -534,7 +528,7 @@ int main(int argc, char * const argv[])
|
|||
err = 1;
|
||||
goto end;
|
||||
}
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
fprintf(stderr, "Found %s!\n", p15card->label);
|
||||
|
||||
if (do_decipher) {
|
||||
|
|
|
@ -165,9 +165,8 @@ const struct option options[] = {
|
|||
{ "card-profile", required_argument, 0, 'c' },
|
||||
{ "options-file", required_argument, 0, OPT_OPTIONS },
|
||||
{ "wait", no_argument, 0, 'w' },
|
||||
{ "debug", no_argument, 0, 'd' },
|
||||
{ "quiet", no_argument, 0, 'q' },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ "verbose", no_argument, 0, 'v' },
|
||||
|
||||
/* Hidden options for testing */
|
||||
{ "assert-pristine", no_argument, 0, OPT_ASSERT_PRISTINE },
|
||||
|
@ -214,9 +213,8 @@ const char * option_help[] = {
|
|||
"Specify the card profile to use",
|
||||
"Read additional command line options from file",
|
||||
"Wait for card insertion",
|
||||
"Enable debugging output",
|
||||
"Be less verbose",
|
||||
"Display this message",
|
||||
"Verbose operation. Use several times to enable debug output.",
|
||||
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -266,8 +264,6 @@ static struct sc_card * card = NULL;
|
|||
static struct sc_pkcs15_card * p15card = NULL;
|
||||
static unsigned int opt_actions;
|
||||
static int opt_reader = -1,
|
||||
opt_debug = 0,
|
||||
opt_quiet = 0,
|
||||
opt_extractable = 0,
|
||||
opt_unprotected = 0,
|
||||
opt_authority = 0,
|
||||
|
@ -295,6 +291,7 @@ static unsigned int opt_x509_usage = 0;
|
|||
static int ignore_cmdline_pins = 0;
|
||||
static struct secret opt_secrets[MAX_SECRETS];
|
||||
static unsigned int opt_secret_count;
|
||||
static int verbose = 0;
|
||||
|
||||
static struct sc_pkcs15init_callbacks callbacks = {
|
||||
get_pin_callback, /* get_pin() */
|
||||
|
@ -364,13 +361,13 @@ main(int argc, char **argv)
|
|||
/* XXX: should compare card to profile here to make
|
||||
* sure we're not messing things up */
|
||||
|
||||
if (!opt_quiet)
|
||||
if (verbose)
|
||||
printf("Found %s\n", p15card->label);
|
||||
|
||||
sc_pkcs15init_set_p15card(profile, p15card);
|
||||
}
|
||||
|
||||
if (!opt_quiet && action != ACTION_ASSERT_PRISTINE)
|
||||
if (verbose && action != ACTION_ASSERT_PRISTINE)
|
||||
printf("About to %s.\n", action_names[action]);
|
||||
|
||||
switch (action) {
|
||||
|
@ -436,12 +433,12 @@ open_reader_and_card(int reader)
|
|||
error("Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 0;
|
||||
}
|
||||
if (opt_debug) {
|
||||
ctx->debug = opt_debug;
|
||||
if (verbose > 1) {
|
||||
ctx->debug = verbose-1;
|
||||
ctx->debug_file = stderr;
|
||||
}
|
||||
|
||||
if (connect_card(ctx, &card, reader, 0, opt_wait, opt_quiet))
|
||||
if (connect_card(ctx, &card, reader, 0, opt_wait, verbose))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
@ -484,7 +481,7 @@ do_assert_pristine(struct sc_card *card)
|
|||
fprintf(stderr,
|
||||
"Card not pristine; detected (possibly incomplete) "
|
||||
"PKCS#15 structure\n");
|
||||
} else if (!opt_quiet) {
|
||||
} else if (verbose) {
|
||||
printf("Pristine card.\n");
|
||||
}
|
||||
|
||||
|
@ -945,7 +942,7 @@ do_generate_key(struct sc_profile *profile, const char *spec)
|
|||
keybits, NULL);
|
||||
if (r >= 0 || r != SC_ERROR_NOT_SUPPORTED)
|
||||
return r;
|
||||
if (!opt_quiet)
|
||||
if (verbose)
|
||||
printf("Warning: card doesn't support on-board "
|
||||
"key generation.\n"
|
||||
"Trying software generation\n");
|
||||
|
@ -1832,8 +1829,8 @@ handle_option(const struct option *opt)
|
|||
this_action = ACTION_STORE_DATA;
|
||||
opt_infile = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
opt_debug++;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'f':
|
||||
opt_format = optarg;
|
||||
|
@ -1855,9 +1852,6 @@ handle_option(const struct option *opt)
|
|||
case 'c':
|
||||
opt_card_profile = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
opt_quiet = 1;
|
||||
break;
|
||||
case 'r':
|
||||
opt_reader = atoi(optarg);
|
||||
break;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
const char *app_name = "pkcs15-tool";
|
||||
|
||||
int opt_reader = -1, opt_debug = 0, opt_wait = 0;
|
||||
int opt_reader = -1, opt_wait = 0;
|
||||
int opt_no_cache = 0;
|
||||
char * opt_auth_id;
|
||||
char * opt_cert = NULL;
|
||||
|
@ -38,7 +38,7 @@ u8 * opt_newpin = NULL;
|
|||
u8 * opt_pin = NULL;
|
||||
u8 * opt_puk = NULL;
|
||||
|
||||
static int quiet = 0;
|
||||
static int verbose = 0;
|
||||
|
||||
enum {
|
||||
OPT_CHANGE_PIN = 0x100,
|
||||
|
@ -76,11 +76,10 @@ const struct option options[] = {
|
|||
{ "new-pin", required_argument, 0, OPT_NEWPIN },
|
||||
{ "puk", required_argument, 0, OPT_PUK },
|
||||
{ "output", required_argument, 0, 'o' },
|
||||
{ "quiet", no_argument, 0, 'q' },
|
||||
{ "debug", no_argument, 0, 'd' },
|
||||
{ "no-cache", no_argument, 0, OPT_NO_CACHE },
|
||||
{ "auth-id", required_argument, 0, 'a' },
|
||||
{ "wait", no_argument, 0, 'w' },
|
||||
{ "verbose", no_argument, 0, 'v' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -101,11 +100,10 @@ const char *option_help[] = {
|
|||
"Specify New PIN (when changing or unblocking)",
|
||||
"Specify Unblock PIN",
|
||||
"Outputs to file <arg>",
|
||||
"Quiet operation",
|
||||
"Debug output -- may be supplied several times",
|
||||
"Disable card caching",
|
||||
"The auth ID of the PIN to use",
|
||||
"Wait for card insertion",
|
||||
"Verbose operation. Use several times to enable debug output.",
|
||||
};
|
||||
|
||||
struct sc_context *ctx = NULL;
|
||||
|
@ -138,7 +136,7 @@ int list_certificates(void)
|
|||
fprintf(stderr, "Certificate enumeration failed: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Card has %d certificate(s).\n\n", r);
|
||||
for (i = 0; i < r; i++) {
|
||||
print_cert_info(objs[i]);
|
||||
|
@ -259,7 +257,7 @@ int read_certificate(void)
|
|||
if (sc_pkcs15_compare_id(&id, &cinfo->id) != 1)
|
||||
continue;
|
||||
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Reading certificate with ID '%s'\n", opt_cert);
|
||||
r = sc_pkcs15_read_certificate(p15card, cinfo, &cert);
|
||||
if (r) {
|
||||
|
@ -296,7 +294,7 @@ int read_data_object(void)
|
|||
if (memcmp(opt_data, &cinfo->app_label, strlen(opt_data)) != 0)
|
||||
continue;
|
||||
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Reading data object with label '%s'\n", opt_data);
|
||||
r = sc_pkcs15_read_data_object(p15card, cinfo, &data_object);
|
||||
if (r) {
|
||||
|
@ -392,7 +390,7 @@ int list_private_keys(void)
|
|||
fprintf(stderr, "Private key enumeration failed: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Card has %d private key(s).\n\n", r);
|
||||
for (i = 0; i < r; i++) {
|
||||
print_prkey_info(objs[i]);
|
||||
|
@ -452,7 +450,7 @@ int list_public_keys(void)
|
|||
fprintf(stderr, "Private key enumeration failed: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Card has %d public key(s).\n\n", r);
|
||||
for (i = 0; i < r; i++) {
|
||||
print_pubkey_info(objs[i]);
|
||||
|
@ -475,7 +473,7 @@ int read_public_key(void)
|
|||
|
||||
r = sc_pkcs15_find_pubkey_by_id(p15card, &id, &obj);
|
||||
if (r >= 0) {
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Reading public key with ID '%s'\n", opt_pubkey);
|
||||
r = authenticate(obj);
|
||||
if (r >= 0)
|
||||
|
@ -484,7 +482,7 @@ int read_public_key(void)
|
|||
/* No pubkey - try if there's a certificate */
|
||||
r = sc_pkcs15_find_cert_by_id(p15card, &id, &obj);
|
||||
if (r >= 0) {
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Reading certificate with ID '%s'\n", opt_pubkey);
|
||||
r = sc_pkcs15_read_certificate(p15card,
|
||||
(sc_pkcs15_cert_info_t *) obj->data,
|
||||
|
@ -645,7 +643,7 @@ int list_pins(void)
|
|||
fprintf(stderr, "Private key enumeration failed: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Card has %d PIN code(s).\n\n", r);
|
||||
for (i = 0; i < r; i++) {
|
||||
print_pin_info(objs[i]);
|
||||
|
@ -699,7 +697,7 @@ int unblock_pin(void)
|
|||
fprintf(stderr, "PIN unblocking failed: %s\n", sc_strerror(r));
|
||||
return 2;
|
||||
}
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("PIN successfully unblocked.\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -753,7 +751,7 @@ int change_pin(void)
|
|||
fprintf(stderr, "PIN code change failed: %s\n", sc_strerror(r));
|
||||
return 2;
|
||||
}
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("PIN code changed successfully.\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -765,7 +763,7 @@ int read_and_cache_file(const struct sc_path *path)
|
|||
u8 buf[16384];
|
||||
int r;
|
||||
|
||||
if (!quiet) {
|
||||
if (verbose) {
|
||||
printf("Reading file ");
|
||||
hex_dump(stdout, path->value, path->len, "");
|
||||
printf("...\n");
|
||||
|
@ -777,7 +775,7 @@ int read_and_cache_file(const struct sc_path *path)
|
|||
}
|
||||
e = sc_file_get_acl_entry(tmpfile, SC_AC_OP_READ);
|
||||
if (e != NULL && e->method != SC_AC_NONE) {
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Skipping; ACL for read operation is not NONE.\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -926,11 +924,8 @@ int main(int argc, char * const argv[])
|
|||
case 'o':
|
||||
opt_outfile = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet++;
|
||||
break;
|
||||
case 'd':
|
||||
opt_debug++;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'a':
|
||||
opt_auth_id = optarg;
|
||||
|
@ -950,14 +945,14 @@ int main(int argc, char * const argv[])
|
|||
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||
return 1;
|
||||
}
|
||||
if (opt_debug)
|
||||
ctx->debug = opt_debug;
|
||||
if (verbose > 1 )
|
||||
ctx->debug = verbose-1;
|
||||
|
||||
err = connect_card(ctx, &card, opt_reader, 0, opt_wait, quiet);
|
||||
err = connect_card(ctx, &card, opt_reader, 0, opt_wait, verbose);
|
||||
if (err)
|
||||
goto end;
|
||||
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
fprintf(stderr, "Trying to find a PKCS#15 compatible card...\n");
|
||||
r = sc_pkcs15_bind(card, &p15card);
|
||||
if (r) {
|
||||
|
@ -967,7 +962,7 @@ int main(int argc, char * const argv[])
|
|||
}
|
||||
if (opt_no_cache)
|
||||
p15card->opts.use_cache = 0;
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
fprintf(stderr, "Found %s!\n", p15card->label);
|
||||
if (do_learn_card) {
|
||||
if ((err = learn_card()))
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "util.h"
|
||||
|
||||
int connect_card(sc_context_t *ctx, sc_card_t **cardp,
|
||||
int reader_id, int slot_id, int wait, int quiet)
|
||||
int reader_id, int slot_id, int wait, int verbose)
|
||||
{
|
||||
sc_reader_t *reader;
|
||||
sc_card_t *card;
|
||||
|
@ -67,7 +67,7 @@ int connect_card(sc_context_t *ctx, sc_card_t **cardp,
|
|||
}
|
||||
}
|
||||
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Connecting to card in reader %s...\n", reader->name);
|
||||
if ((r = sc_connect_card(reader, slot_id, &card)) < 0) {
|
||||
fprintf(stderr,
|
||||
|
@ -76,7 +76,7 @@ int connect_card(sc_context_t *ctx, sc_card_t **cardp,
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (!quiet)
|
||||
if (verbose)
|
||||
printf("Using card driver %s.\n", card->driver->name);
|
||||
|
||||
if ((r = sc_lock(card)) < 0) {
|
||||
|
|
|
@ -39,7 +39,7 @@ void error(const char *fmt, ...);
|
|||
void fatal(const char *fmt, ...);
|
||||
/* All singing all dancing card connect routine */
|
||||
int connect_card(struct sc_context *, struct sc_card **,
|
||||
int reader_id, int slot_id, int wait, int quiet);
|
||||
int reader_id, int slot_id, int wait, int verbose);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue