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