opensc-tool: add 'call-SM-handler' command
'open' and 'close' handlers of the card's SM driver can be called
This commit is contained in:
parent
3f30e14087
commit
4c1c39f3e4
|
@ -475,6 +475,15 @@
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<command>sm</command> <replaceable>[open]</replaceable>|<replaceable>[close]</replaceable>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>Calls the card's <replaceable>open</replaceable> or <replaceable>close</replaceable> Secure Messaging handler.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
|
@ -104,6 +104,7 @@ static int do_random(int argc, char **argv);
|
||||||
static int do_get_data(int argc, char **argv);
|
static int do_get_data(int argc, char **argv);
|
||||||
static int do_put_data(int argc, char **argv);
|
static int do_put_data(int argc, char **argv);
|
||||||
static int do_apdu(int argc, char **argv);
|
static int do_apdu(int argc, char **argv);
|
||||||
|
static int do_sm(int argc, char **argv);
|
||||||
static int do_asn1(int argc, char **argv);
|
static int do_asn1(int argc, char **argv);
|
||||||
static int do_help(int argc, char **argv);
|
static int do_help(int argc, char **argv);
|
||||||
static int do_quit(int argc, char **argv);
|
static int do_quit(int argc, char **argv);
|
||||||
|
@ -186,6 +187,9 @@ static struct command cmds[] = {
|
||||||
{ do_asn1,
|
{ do_asn1,
|
||||||
"asn1", "[<file id>]",
|
"asn1", "[<file id>]",
|
||||||
"decode an ASN.1 file" },
|
"decode an ASN.1 file" },
|
||||||
|
{ do_sm,
|
||||||
|
"sm", "open|close",
|
||||||
|
"call SM 'open' or 'close' handlers, if available"},
|
||||||
{ do_debug,
|
{ do_debug,
|
||||||
"debug", "[<value>]",
|
"debug", "[<value>]",
|
||||||
"get/set the debug level" },
|
"get/set the debug level" },
|
||||||
|
@ -1639,6 +1643,40 @@ err:
|
||||||
return -err;
|
return -err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int do_sm(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int r = SC_ERROR_NOT_SUPPORTED, ret = -1;
|
||||||
|
|
||||||
|
if (argc != 1)
|
||||||
|
return usage(do_sm);
|
||||||
|
|
||||||
|
#ifdef ENABLE_SM
|
||||||
|
if (!strcmp(argv[0],"open")) {
|
||||||
|
if (!card->sm_ctx.ops.open) {
|
||||||
|
printf("Not supported\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
r = card->sm_ctx.ops.open(card);
|
||||||
|
}
|
||||||
|
else if (!strcmp(argv[0],"close")) {
|
||||||
|
if (!card->sm_ctx.ops.close) {
|
||||||
|
printf("Not supported\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
r = card->sm_ctx.ops.close(card);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (r == SC_SUCCESS) {
|
||||||
|
ret = 0;
|
||||||
|
printf("Success!\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("Failure: %s\n", sc_strerror(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int do_help(int argc, char **argv)
|
static int do_help(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct command *cmd;
|
struct command *cmd;
|
||||||
|
|
Loading…
Reference in New Issue