tools: harmonize card initialization
This commit is contained in:
parent
4d8b2c12ed
commit
b11cc3871e
|
@ -63,14 +63,14 @@ smart cards and similar security tokens based on Siemens Card/OS M4.
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -131,14 +131,14 @@
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -83,14 +83,14 @@
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -50,10 +50,10 @@
|
||||||
<option>-r</option> <replaceable>arg</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
Specify the reader to use.
|
Number of the reader to use. By default, the first
|
||||||
Use <literal>-1</literal> as <replaceable>arg</replaceable>
|
reader with a present card is used. If
|
||||||
to automatically detect the reader to use.
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
By default, the first reader with a present card is used.
|
reader with a matching card will be chosen.
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
|
|
@ -66,14 +66,14 @@
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -84,9 +84,9 @@
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>argument</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -34,13 +34,13 @@
|
||||||
<variablelist>
|
<variablelist>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -71,14 +71,14 @@
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -52,10 +52,10 @@
|
||||||
<option>-r</option> <replaceable>arg</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
Specify the reader to use.
|
Number of the reader to use. By default, the first
|
||||||
Use <literal>-1</literal> as <replaceable>arg</replaceable>
|
reader with a present card is used. If
|
||||||
to automatically detect the reader to use.
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
By default, the first reader with a present card is used.
|
reader with a matching card will be chosen.
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
|
|
@ -179,14 +179,14 @@
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
|
@ -76,14 +76,14 @@
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -112,14 +112,14 @@
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -151,14 +151,14 @@
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -129,14 +129,14 @@
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>N</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>N</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -644,14 +644,14 @@ puk 87654321
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -278,13 +278,13 @@
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>
|
<option>--reader</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -201,14 +201,14 @@
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -148,14 +148,14 @@
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<option>--reader</option> <replaceable>num</replaceable>,
|
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||||
<option>-r</option> <replaceable>num</replaceable>
|
<option>-r</option> <replaceable>arg</replaceable>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Specify the reader to use. By default, the first
|
Number of the reader to use. By default, the first
|
||||||
reader with a present card is used. If
|
reader with a present card is used. If
|
||||||
<replaceable>num</replaceable> is an ATR, the
|
<replaceable>arg</replaceable> is an ATR, the
|
||||||
reader with a matching card will be chosen.
|
reader with a matching card will be chosen.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
|
@ -84,10 +84,14 @@ dnie_tool_LDADD = $(OPTIONAL_OPENSSL_LIBS)
|
||||||
gids_tool_SOURCES = gids-tool.c util.c
|
gids_tool_SOURCES = gids-tool.c util.c
|
||||||
gids_tool_LDADD = $(OPTIONAL_OPENSSL_LIBS)
|
gids_tool_LDADD = $(OPTIONAL_OPENSSL_LIBS)
|
||||||
|
|
||||||
npa_tool_SOURCES = npa-tool.c fread_to_eof.c $(NPA_TOOL_BUILT_SOURCES)
|
npa_tool_SOURCES = npa-tool.c fread_to_eof.c util.c $(NPA_TOOL_BUILT_SOURCES)
|
||||||
npa_tool_LDADD = $(top_builddir)/src/libopensc/libopensc.la \
|
npa_tool_LDADD = $(top_builddir)/src/libopensc/libopensc.la \
|
||||||
$(OPENPACE_LIBS)
|
$(OPENPACE_LIBS)
|
||||||
npa_tool_CFLAGS = -I$(top_srcdir)/src $(OPENPACE_CFLAGS) $(OPENSSL_CFLAGS)
|
npa_tool_CFLAGS = -I$(top_srcdir)/src $(OPENPACE_CFLAGS) $(OPENSSL_CFLAGS)
|
||||||
|
npa_tool_CFLAGS += -Wno-unused-but-set-variable
|
||||||
|
if HAVE_UNKNOWN_WARNING_OPTION
|
||||||
|
npa_tool_CFLAGS += -Wno-unknown-warning-option
|
||||||
|
endif
|
||||||
|
|
||||||
npa-tool.c: $(abs_builddir)/npa-tool.ggo $(NPA_TOOL_BUILT_SOURCES)
|
npa-tool.c: $(abs_builddir)/npa-tool.ggo $(NPA_TOOL_BUILT_SOURCES)
|
||||||
|
|
||||||
|
@ -117,7 +121,7 @@ $(OPENSC_NOTIFY_BUILT_SOURCES):
|
||||||
$(abs_builddir)/opensc-notify.ggo: opensc-notify.ggo.in
|
$(abs_builddir)/opensc-notify.ggo: opensc-notify.ggo.in
|
||||||
$(do_subst) < $(abs_srcdir)/opensc-notify.ggo.in > $@
|
$(do_subst) < $(abs_srcdir)/opensc-notify.ggo.in > $@
|
||||||
|
|
||||||
egk_tool_SOURCES = egk-tool.c $(EGK_TOOL_BUILT_SOURCES)
|
egk_tool_SOURCES = egk-tool.c util.c $(EGK_TOOL_BUILT_SOURCES)
|
||||||
egk_tool_LDADD = $(top_builddir)/src/libopensc/libopensc.la $(OPTIONAL_ZLIB_LIBS)
|
egk_tool_LDADD = $(top_builddir)/src/libopensc/libopensc.la $(OPTIONAL_ZLIB_LIBS)
|
||||||
egk_tool_CFLAGS = -I$(top_srcdir)/src $(OPTIONAL_ZLIB_CFLAGS)
|
egk_tool_CFLAGS = -I$(top_srcdir)/src $(OPTIONAL_ZLIB_CFLAGS)
|
||||||
egk_tool_CFLAGS += -Wno-unused-but-set-variable
|
egk_tool_CFLAGS += -Wno-unused-but-set-variable
|
||||||
|
|
|
@ -27,14 +27,14 @@ opensc-notify.exe: opensc-notify-cmdline.obj versioninfo-opensc-notify.res $(LIB
|
||||||
link $(LINKFLAGS) /pdb:$*.pdb /out:$@ $*.obj opensc-notify-cmdline.obj versioninfo-opensc-notify.res $(LIBS) gdi32.lib shell32.lib User32.lib ws2_32.lib
|
link $(LINKFLAGS) /pdb:$*.pdb /out:$@ $*.obj opensc-notify-cmdline.obj versioninfo-opensc-notify.res $(LIBS) gdi32.lib shell32.lib User32.lib ws2_32.lib
|
||||||
mt -manifest exe.manifest -outputresource:$@;1
|
mt -manifest exe.manifest -outputresource:$@;1
|
||||||
|
|
||||||
npa-tool.exe: npa-tool-cmdline.obj fread_to_eof.obj $(LIBS)
|
npa-tool.exe: npa-tool-cmdline.obj fread_to_eof.obj util.obj $(LIBS)
|
||||||
cl $(COPTS) /c $*.c
|
cl $(COPTS) /c $*.c
|
||||||
link $(LINKFLAGS) /pdb:$*.pdb /out:$@ $*.obj npa-tool-cmdline.obj fread_to_eof.obj $(LIBS) $(OPENPACE_LIB) $(OPENSSL_LIB) gdi32.lib shell32.lib User32.lib ws2_32.lib
|
link $(LINKFLAGS) /pdb:$*.pdb /out:$@ $*.obj npa-tool-cmdline.obj fread_to_eof.obj util.obj $(LIBS) $(OPENPACE_LIB) $(OPENSSL_LIB) gdi32.lib shell32.lib User32.lib ws2_32.lib
|
||||||
mt -manifest exe.manifest -outputresource:$@;1
|
mt -manifest exe.manifest -outputresource:$@;1
|
||||||
|
|
||||||
egk-tool.exe: egk-tool-cmdline.obj $(LIBS)
|
egk-tool.exe: egk-tool-cmdline.obj util.obj $(LIBS)
|
||||||
cl $(COPTS) /c $*.c
|
cl $(COPTS) /c $*.c
|
||||||
link $(LINKFLAGS) /pdb:$*.pdb /out:$@ $*.obj egk-tool-cmdline.obj $(LIBS) $(ZLIB_LIB) gdi32.lib shell32.lib User32.lib ws2_32.lib
|
link $(LINKFLAGS) /pdb:$*.pdb /out:$@ $*.obj egk-tool-cmdline.obj util.obj $(LIBS) $(ZLIB_LIB) gdi32.lib shell32.lib User32.lib ws2_32.lib
|
||||||
mt -manifest exe.manifest -outputresource:$@;1
|
mt -manifest exe.manifest -outputresource:$@;1
|
||||||
|
|
||||||
opensc-asn1.exe: opensc-asn1-cmdline.obj fread_to_eof.obj $(LIBS)
|
opensc-asn1.exe: opensc-asn1-cmdline.obj fread_to_eof.obj $(LIBS)
|
||||||
|
|
|
@ -33,22 +33,22 @@ const char *gengetopt_args_info_versiontext = "";
|
||||||
const char *gengetopt_args_info_description = "";
|
const char *gengetopt_args_info_description = "";
|
||||||
|
|
||||||
const char *gengetopt_args_info_help[] = {
|
const char *gengetopt_args_info_help[] = {
|
||||||
" -h, --help Print help and exit",
|
" -h, --help Print help and exit",
|
||||||
" -V, --version Print version and exit",
|
" -V, --version Print version and exit",
|
||||||
" -r, --reader=INT Number of the PC/SC reader to use (-1 for autodetect)\n (default=`-1')",
|
" -r, --reader=STRING Number of the reader to use. By default, the first\n reader with a present card is used. If the arguement\n is an ATR, the reader with a matching card will be\n chosen.",
|
||||||
" -v, --verbose Use (several times) to be more verbose",
|
" -v, --verbose Use (several times) to be more verbose",
|
||||||
"\nHealth Care Application (HCA):",
|
"\nHealth Care Application (HCA):",
|
||||||
" --pd Show 'Persönliche Versicherungsdaten' (XML) (default=off)",
|
" --pd Show 'Persönliche Versicherungsdaten' (XML)\n (default=off)",
|
||||||
" --vd Show 'Allgemeine Versicherungsdaten' (XML) (default=off)",
|
" --vd Show 'Allgemeine Versicherungsdaten' (XML)\n (default=off)",
|
||||||
" --gvd Show 'Geschützte Versicherungsdaten' (XML) (default=off)",
|
" --gvd Show 'Geschützte Versicherungsdaten' (XML)\n (default=off)",
|
||||||
" --vsd-status Show 'Versichertenstammdaten-Status' (default=off)",
|
" --vsd-status Show 'Versichertenstammdaten-Status' (default=off)",
|
||||||
"\nReport bugs to https://github.com/OpenSC/OpenSC/issues\n\nWritten by Frank Morgner <frankmorgner@gmail.com>",
|
"\nReport bugs to https://github.com/OpenSC/OpenSC/issues\n\nWritten by Frank Morgner <frankmorgner@gmail.com>",
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {ARG_NO
|
typedef enum {ARG_NO
|
||||||
, ARG_FLAG
|
, ARG_FLAG
|
||||||
, ARG_INT
|
, ARG_STRING
|
||||||
} cmdline_parser_arg_type;
|
} cmdline_parser_arg_type;
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -83,7 +83,7 @@ static
|
||||||
void clear_args (struct gengetopt_args_info *args_info)
|
void clear_args (struct gengetopt_args_info *args_info)
|
||||||
{
|
{
|
||||||
FIX_UNUSED (args_info);
|
FIX_UNUSED (args_info);
|
||||||
args_info->reader_arg = -1;
|
args_info->reader_arg = NULL;
|
||||||
args_info->reader_orig = NULL;
|
args_info->reader_orig = NULL;
|
||||||
args_info->pd_flag = 0;
|
args_info->pd_flag = 0;
|
||||||
args_info->vd_flag = 0;
|
args_info->vd_flag = 0;
|
||||||
|
@ -190,6 +190,7 @@ static void
|
||||||
cmdline_parser_release (struct gengetopt_args_info *args_info)
|
cmdline_parser_release (struct gengetopt_args_info *args_info)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
free_string_field (&(args_info->reader_arg));
|
||||||
free_string_field (&(args_info->reader_orig));
|
free_string_field (&(args_info->reader_orig));
|
||||||
|
|
||||||
|
|
||||||
|
@ -1051,6 +1052,7 @@ int update_arg(void *field, char **orig_field,
|
||||||
char *stop_char = 0;
|
char *stop_char = 0;
|
||||||
const char *val = value;
|
const char *val = value;
|
||||||
int found;
|
int found;
|
||||||
|
char **string_field;
|
||||||
FIX_UNUSED (field);
|
FIX_UNUSED (field);
|
||||||
|
|
||||||
stop_char = 0;
|
stop_char = 0;
|
||||||
|
@ -1084,24 +1086,18 @@ int update_arg(void *field, char **orig_field,
|
||||||
case ARG_FLAG:
|
case ARG_FLAG:
|
||||||
*((int *)field) = !*((int *)field);
|
*((int *)field) = !*((int *)field);
|
||||||
break;
|
break;
|
||||||
case ARG_INT:
|
case ARG_STRING:
|
||||||
if (val) *((int *)field) = strtol (val, &stop_char, 0);
|
if (val) {
|
||||||
|
string_field = (char **)field;
|
||||||
|
if (!no_free && *string_field)
|
||||||
|
free (*string_field); /* free previous string */
|
||||||
|
*string_field = gengetopt_strdup (val);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* check numeric conversion */
|
|
||||||
switch(arg_type) {
|
|
||||||
case ARG_INT:
|
|
||||||
if (val && !(stop_char && *stop_char == '\0')) {
|
|
||||||
fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
|
|
||||||
return 1; /* failure */
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* store the original value */
|
/* store the original value */
|
||||||
switch(arg_type) {
|
switch(arg_type) {
|
||||||
|
@ -1203,12 +1199,12 @@ cmdline_parser_internal (
|
||||||
cmdline_parser_free (&local_args_info);
|
cmdline_parser_free (&local_args_info);
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
case 'r': /* Number of the PC/SC reader to use (-1 for autodetect). */
|
case 'r': /* Number of the reader to use. By default, the first reader with a present card is used. If the arguement is an ATR, the reader with a matching card will be chosen.. */
|
||||||
|
|
||||||
|
|
||||||
if (update_arg( (void *)&(args_info->reader_arg),
|
if (update_arg( (void *)&(args_info->reader_arg),
|
||||||
&(args_info->reader_orig), &(args_info->reader_given),
|
&(args_info->reader_orig), &(args_info->reader_given),
|
||||||
&(local_args_info.reader_given), optarg, 0, "-1", ARG_INT,
|
&(local_args_info.reader_given), optarg, 0, 0, ARG_STRING,
|
||||||
check_ambiguity, override, 0, 0,
|
check_ambiguity, override, 0, 0,
|
||||||
"reader", 'r',
|
"reader", 'r',
|
||||||
additional_error))
|
additional_error))
|
||||||
|
|
|
@ -39,9 +39,9 @@ struct gengetopt_args_info
|
||||||
{
|
{
|
||||||
const char *help_help; /**< @brief Print help and exit help description. */
|
const char *help_help; /**< @brief Print help and exit help description. */
|
||||||
const char *version_help; /**< @brief Print version and exit help description. */
|
const char *version_help; /**< @brief Print version and exit help description. */
|
||||||
int reader_arg; /**< @brief Number of the PC/SC reader to use (-1 for autodetect) (default='-1'). */
|
char * reader_arg; /**< @brief Number of the reader to use. By default, the first reader with a present card is used. If the arguement is an ATR, the reader with a matching card will be chosen.. */
|
||||||
char * reader_orig; /**< @brief Number of the PC/SC reader to use (-1 for autodetect) original value given at command line. */
|
char * reader_orig; /**< @brief Number of the reader to use. By default, the first reader with a present card is used. If the arguement is an ATR, the reader with a matching card will be chosen. original value given at command line. */
|
||||||
const char *reader_help; /**< @brief Number of the PC/SC reader to use (-1 for autodetect) help description. */
|
const char *reader_help; /**< @brief Number of the reader to use. By default, the first reader with a present card is used. If the arguement is an ATR, the reader with a matching card will be chosen. help description. */
|
||||||
unsigned int verbose_min; /**< @brief Use (several times) to be more verbose's minimum occurreces */
|
unsigned int verbose_min; /**< @brief Use (several times) to be more verbose's minimum occurreces */
|
||||||
unsigned int verbose_max; /**< @brief Use (several times) to be more verbose's maximum occurreces */
|
unsigned int verbose_max; /**< @brief Use (several times) to be more verbose's maximum occurreces */
|
||||||
const char *verbose_help; /**< @brief Use (several times) to be more verbose help description. */
|
const char *verbose_help; /**< @brief Use (several times) to be more verbose help description. */
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "egk-tool-cmdline.h"
|
#include "egk-tool-cmdline.h"
|
||||||
#include "libopensc/log.h"
|
#include "libopensc/log.h"
|
||||||
#include "libopensc/opensc.h"
|
#include "libopensc/opensc.h"
|
||||||
|
#include "util.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -81,59 +82,7 @@ void dump_binary(void *buf, size_t buf_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned char aid_hca[] = {0xD2, 0x76, 0x00, 0x00, 0x01, 0x02};
|
const unsigned char aid_hca[] = {0xD2, 0x76, 0x00, 0x00, 0x01, 0x02};
|
||||||
|
static const char *app_name = "egk-tool";
|
||||||
static int initialize(int reader_id, int verbose,
|
|
||||||
sc_context_t **ctx, sc_reader_t **reader)
|
|
||||||
{
|
|
||||||
unsigned int i, reader_count;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
if (!ctx || !reader)
|
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
|
||||||
|
|
||||||
r = sc_establish_context(ctx, "");
|
|
||||||
if (r < 0 || !*ctx) {
|
|
||||||
fprintf(stderr, "Failed to create initial context: %s", sc_strerror(r));
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*ctx)->debug = verbose;
|
|
||||||
(*ctx)->flags |= SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER;
|
|
||||||
|
|
||||||
reader_count = sc_ctx_get_reader_count(*ctx);
|
|
||||||
|
|
||||||
if (reader_count == 0) {
|
|
||||||
sc_log(*ctx, "No reader not found.\n");
|
|
||||||
return SC_ERROR_NO_READERS_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reader_id < 0) {
|
|
||||||
/* Automatically try to skip to a reader with a card if reader not specified */
|
|
||||||
for (i = 0; i < reader_count; i++) {
|
|
||||||
*reader = sc_ctx_get_reader(*ctx, i);
|
|
||||||
if (sc_detect_card_presence(*reader) & SC_READER_CARD_PRESENT) {
|
|
||||||
reader_id = i;
|
|
||||||
sc_log(*ctx, "Using the first reader"
|
|
||||||
" with a card: %s", (*reader)->name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((unsigned int) reader_id >= reader_count) {
|
|
||||||
sc_log(*ctx, "No card found, using the first reader.");
|
|
||||||
reader_id = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((unsigned int) reader_id >= reader_count) {
|
|
||||||
sc_log(*ctx, "Invalid reader number "
|
|
||||||
"(%d), only %d available.\n", reader_id, reader_count);
|
|
||||||
return SC_ERROR_NO_READERS_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
*reader = sc_ctx_get_reader(*ctx, reader_id);
|
|
||||||
|
|
||||||
return SC_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int read_file(struct sc_card *card, char *str_path, unsigned char **data, size_t *data_len)
|
int read_file(struct sc_card *card, char *str_path, unsigned char **data, size_t *data_len)
|
||||||
{
|
{
|
||||||
|
@ -196,26 +145,29 @@ main (int argc, char **argv)
|
||||||
struct gengetopt_args_info cmdline;
|
struct gengetopt_args_info cmdline;
|
||||||
struct sc_path path;
|
struct sc_path path;
|
||||||
struct sc_context *ctx;
|
struct sc_context *ctx;
|
||||||
struct sc_reader *reader = NULL;
|
|
||||||
struct sc_card *card;
|
struct sc_card *card;
|
||||||
unsigned char *data = NULL;
|
unsigned char *data = NULL;
|
||||||
size_t data_len = 0;
|
size_t data_len = 0;
|
||||||
int r;
|
int r;
|
||||||
|
sc_context_param_t ctx_param;
|
||||||
|
|
||||||
if (cmdline_parser(argc, argv, &cmdline) != 0)
|
if (cmdline_parser(argc, argv, &cmdline) != 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
r = initialize(cmdline.reader_arg, cmdline.verbose_given, &ctx, &reader);
|
memset(&ctx_param, 0, sizeof(ctx_param));
|
||||||
if (r < 0) {
|
ctx_param.ver = 0;
|
||||||
fprintf(stderr, "Can't initialize reader\n");
|
ctx_param.app_name = app_name;
|
||||||
|
|
||||||
|
r = sc_context_create(&ctx, &ctx_param);
|
||||||
|
if (r) {
|
||||||
|
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sc_connect_card(reader, &card) < 0) {
|
r = util_connect_card_ex(ctx, &card, cmdline.reader_arg, 0, 0, cmdline.verbose_given);
|
||||||
fprintf(stderr, "Could not connect to card\n");
|
if (r)
|
||||||
sc_release_context(ctx);
|
goto err;
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
sc_path_set(&path, SC_PATH_TYPE_DF_NAME, aid_hca, sizeof aid_hca, 0, 0);
|
sc_path_set(&path, SC_PATH_TYPE_DF_NAME, aid_hca, sizeof aid_hca, 0, 0);
|
||||||
if (SC_SUCCESS != sc_select_file(card, &path, NULL))
|
if (SC_SUCCESS != sc_select_file(card, &path, NULL))
|
||||||
|
|
|
@ -2,9 +2,8 @@ package "egk-tool"
|
||||||
purpose "@PACKAGE_SUMMARY@"
|
purpose "@PACKAGE_SUMMARY@"
|
||||||
|
|
||||||
option "reader" r
|
option "reader" r
|
||||||
"Number of the PC/SC reader to use (-1 for autodetect)"
|
"Number of the reader to use. By default, the first reader with a present card is used. If the arguement is an ATR, the reader with a matching card will be chosen."
|
||||||
int
|
string
|
||||||
default="-1"
|
|
||||||
optional
|
optional
|
||||||
option "verbose" v
|
option "verbose" v
|
||||||
"Use (several times) to be more verbose"
|
"Use (several times) to be more verbose"
|
||||||
|
|
|
@ -35,7 +35,7 @@ const char *gengetopt_args_info_description = "";
|
||||||
const char *gengetopt_args_info_help[] = {
|
const char *gengetopt_args_info_help[] = {
|
||||||
" -h, --help Print help and exit",
|
" -h, --help Print help and exit",
|
||||||
" -V, --version Print version and exit",
|
" -V, --version Print version and exit",
|
||||||
" -r, --reader=INT Number of the PC/SC reader to use (-1 for\n autodetect) (default=`-1')",
|
" -r, --reader=STRING Number of the reader to use. By default, the\n first reader with a present card is used. If\n the arguement is an ATR, the reader with a\n matching card will be chosen.",
|
||||||
" -v, --verbose Use (several times) to be more verbose",
|
" -v, --verbose Use (several times) to be more verbose",
|
||||||
"\nPassword Authenticated Connection Establishment (PACE):",
|
"\nPassword Authenticated Connection Establishment (PACE):",
|
||||||
" -p, --pin[=STRING] Run PACE with (transport) eID-PIN",
|
" -p, --pin[=STRING] Run PACE with (transport) eID-PIN",
|
||||||
|
@ -100,7 +100,6 @@ const char *gengetopt_args_info_help[] = {
|
||||||
typedef enum {ARG_NO
|
typedef enum {ARG_NO
|
||||||
, ARG_FLAG
|
, ARG_FLAG
|
||||||
, ARG_STRING
|
, ARG_STRING
|
||||||
, ARG_INT
|
|
||||||
} cmdline_parser_arg_type;
|
} cmdline_parser_arg_type;
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -181,7 +180,7 @@ static
|
||||||
void clear_args (struct gengetopt_args_info *args_info)
|
void clear_args (struct gengetopt_args_info *args_info)
|
||||||
{
|
{
|
||||||
FIX_UNUSED (args_info);
|
FIX_UNUSED (args_info);
|
||||||
args_info->reader_arg = -1;
|
args_info->reader_arg = NULL;
|
||||||
args_info->reader_orig = NULL;
|
args_info->reader_orig = NULL;
|
||||||
args_info->pin_arg = NULL;
|
args_info->pin_arg = NULL;
|
||||||
args_info->pin_orig = NULL;
|
args_info->pin_orig = NULL;
|
||||||
|
@ -400,7 +399,6 @@ free_string_field (char **s)
|
||||||
|
|
||||||
/** @brief generic value variable */
|
/** @brief generic value variable */
|
||||||
union generic_value {
|
union generic_value {
|
||||||
int int_arg;
|
|
||||||
char *string_arg;
|
char *string_arg;
|
||||||
const char *default_string_arg;
|
const char *default_string_arg;
|
||||||
};
|
};
|
||||||
|
@ -448,6 +446,7 @@ static void
|
||||||
cmdline_parser_release (struct gengetopt_args_info *args_info)
|
cmdline_parser_release (struct gengetopt_args_info *args_info)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
free_string_field (&(args_info->reader_arg));
|
||||||
free_string_field (&(args_info->reader_orig));
|
free_string_field (&(args_info->reader_orig));
|
||||||
free_string_field (&(args_info->pin_arg));
|
free_string_field (&(args_info->pin_arg));
|
||||||
free_string_field (&(args_info->pin_orig));
|
free_string_field (&(args_info->pin_orig));
|
||||||
|
@ -1558,9 +1557,6 @@ int update_arg(void *field, char **orig_field,
|
||||||
case ARG_FLAG:
|
case ARG_FLAG:
|
||||||
*((int *)field) = !*((int *)field);
|
*((int *)field) = !*((int *)field);
|
||||||
break;
|
break;
|
||||||
case ARG_INT:
|
|
||||||
if (val) *((int *)field) = strtol (val, &stop_char, 0);
|
|
||||||
break;
|
|
||||||
case ARG_STRING:
|
case ARG_STRING:
|
||||||
if (val) {
|
if (val) {
|
||||||
string_field = (char **)field;
|
string_field = (char **)field;
|
||||||
|
@ -1573,17 +1569,6 @@ int update_arg(void *field, char **orig_field,
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* check numeric conversion */
|
|
||||||
switch(arg_type) {
|
|
||||||
case ARG_INT:
|
|
||||||
if (val && !(stop_char && *stop_char == '\0')) {
|
|
||||||
fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
|
|
||||||
return 1; /* failure */
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* store the original value */
|
/* store the original value */
|
||||||
switch(arg_type) {
|
switch(arg_type) {
|
||||||
|
@ -1688,8 +1673,6 @@ void update_multiple_arg(void *field, char ***orig_field,
|
||||||
*orig_field = (char **) realloc (*orig_field, (field_given + prev_given) * sizeof (char *));
|
*orig_field = (char **) realloc (*orig_field, (field_given + prev_given) * sizeof (char *));
|
||||||
|
|
||||||
switch(arg_type) {
|
switch(arg_type) {
|
||||||
case ARG_INT:
|
|
||||||
*((int **)field) = (int *)realloc (*((int **)field), (field_given + prev_given) * sizeof (int)); break;
|
|
||||||
case ARG_STRING:
|
case ARG_STRING:
|
||||||
*((char ***)field) = (char **)realloc (*((char ***)field), (field_given + prev_given) * sizeof (char *)); break;
|
*((char ***)field) = (char **)realloc (*((char ***)field), (field_given + prev_given) * sizeof (char *)); break;
|
||||||
default:
|
default:
|
||||||
|
@ -1701,8 +1684,6 @@ void update_multiple_arg(void *field, char ***orig_field,
|
||||||
tmp = list;
|
tmp = list;
|
||||||
|
|
||||||
switch(arg_type) {
|
switch(arg_type) {
|
||||||
case ARG_INT:
|
|
||||||
(*((int **)field))[i + field_given] = tmp->arg.int_arg; break;
|
|
||||||
case ARG_STRING:
|
case ARG_STRING:
|
||||||
(*((char ***)field))[i + field_given] = tmp->arg.string_arg; break;
|
(*((char ***)field))[i + field_given] = tmp->arg.string_arg; break;
|
||||||
default:
|
default:
|
||||||
|
@ -1715,12 +1696,6 @@ void update_multiple_arg(void *field, char ***orig_field,
|
||||||
} else { /* set the default value */
|
} else { /* set the default value */
|
||||||
if (default_value && ! field_given) {
|
if (default_value && ! field_given) {
|
||||||
switch(arg_type) {
|
switch(arg_type) {
|
||||||
case ARG_INT:
|
|
||||||
if (! *((int **)field)) {
|
|
||||||
*((int **)field) = (int *)malloc (sizeof (int));
|
|
||||||
(*((int **)field))[0] = default_value->int_arg;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ARG_STRING:
|
case ARG_STRING:
|
||||||
if (! *((char ***)field)) {
|
if (! *((char ***)field)) {
|
||||||
*((char ***)field) = (char **)malloc (sizeof (char *));
|
*((char ***)field) = (char **)malloc (sizeof (char *));
|
||||||
|
@ -1863,12 +1838,12 @@ cmdline_parser_internal (
|
||||||
cmdline_parser_free (&local_args_info);
|
cmdline_parser_free (&local_args_info);
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
case 'r': /* Number of the PC/SC reader to use (-1 for autodetect). */
|
case 'r': /* Number of the reader to use. By default, the first reader with a present card is used. If the arguement is an ATR, the reader with a matching card will be chosen.. */
|
||||||
|
|
||||||
|
|
||||||
if (update_arg( (void *)&(args_info->reader_arg),
|
if (update_arg( (void *)&(args_info->reader_arg),
|
||||||
&(args_info->reader_orig), &(args_info->reader_given),
|
&(args_info->reader_orig), &(args_info->reader_given),
|
||||||
&(local_args_info.reader_given), optarg, 0, "-1", ARG_INT,
|
&(local_args_info.reader_given), optarg, 0, 0, ARG_STRING,
|
||||||
check_ambiguity, override, 0, 0,
|
check_ambiguity, override, 0, 0,
|
||||||
"reader", 'r',
|
"reader", 'r',
|
||||||
additional_error))
|
additional_error))
|
||||||
|
|
|
@ -39,9 +39,9 @@ struct gengetopt_args_info
|
||||||
{
|
{
|
||||||
const char *help_help; /**< @brief Print help and exit help description. */
|
const char *help_help; /**< @brief Print help and exit help description. */
|
||||||
const char *version_help; /**< @brief Print version and exit help description. */
|
const char *version_help; /**< @brief Print version and exit help description. */
|
||||||
int reader_arg; /**< @brief Number of the PC/SC reader to use (-1 for autodetect) (default='-1'). */
|
char * reader_arg; /**< @brief Number of the reader to use. By default, the first reader with a present card is used. If the arguement is an ATR, the reader with a matching card will be chosen.. */
|
||||||
char * reader_orig; /**< @brief Number of the PC/SC reader to use (-1 for autodetect) original value given at command line. */
|
char * reader_orig; /**< @brief Number of the reader to use. By default, the first reader with a present card is used. If the arguement is an ATR, the reader with a matching card will be chosen. original value given at command line. */
|
||||||
const char *reader_help; /**< @brief Number of the PC/SC reader to use (-1 for autodetect) help description. */
|
const char *reader_help; /**< @brief Number of the reader to use. By default, the first reader with a present card is used. If the arguement is an ATR, the reader with a matching card will be chosen. help description. */
|
||||||
unsigned int verbose_min; /**< @brief Use (several times) to be more verbose's minimum occurreces */
|
unsigned int verbose_min; /**< @brief Use (several times) to be more verbose's minimum occurreces */
|
||||||
unsigned int verbose_max; /**< @brief Use (several times) to be more verbose's maximum occurreces */
|
unsigned int verbose_max; /**< @brief Use (several times) to be more verbose's maximum occurreces */
|
||||||
const char *verbose_help; /**< @brief Use (several times) to be more verbose help description. */
|
const char *verbose_help; /**< @brief Use (several times) to be more verbose help description. */
|
||||||
|
|
|
@ -22,15 +22,16 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_OPENPACE
|
#ifdef ENABLE_OPENPACE
|
||||||
#include "npa-tool-cmdline.h"
|
|
||||||
#include "fread_to_eof.h"
|
#include "fread_to_eof.h"
|
||||||
#include "sm/sslutil.h"
|
#include "npa-tool-cmdline.h"
|
||||||
#include "sm/sm-eac.h"
|
#include "sm/sm-eac.h"
|
||||||
|
#include "sm/sslutil.h"
|
||||||
|
#include "util.h"
|
||||||
#include <eac/pace.h>
|
#include <eac/pace.h>
|
||||||
|
#include <libopensc/card-npa.h>
|
||||||
#include <libopensc/log.h>
|
#include <libopensc/log.h>
|
||||||
#include <libopensc/opensc.h>
|
#include <libopensc/opensc.h>
|
||||||
#include <libopensc/sm.h>
|
#include <libopensc/sm.h>
|
||||||
#include <libopensc/card-npa.h>
|
|
||||||
#include <sm/sm-eac.h>
|
#include <sm/sm-eac.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -111,59 +112,7 @@ IMPLEMENT_ASN1_FUNCTIONS(ASN1_AUXILIARY_DATA_NPA_TOOL)
|
||||||
label, (unsigned int) len, len==1?"":"s", len==0?"":":\n", sc_dump_hex(data, len)); \
|
label, (unsigned int) len, len==1?"":"s", len==0?"":":\n", sc_dump_hex(data, len)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static int initialize(int reader_id, int verbose,
|
static const char *app_name = "npa-tool";
|
||||||
sc_context_t **ctx, sc_reader_t **reader)
|
|
||||||
{
|
|
||||||
unsigned int i, reader_count;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
if (!ctx || !reader)
|
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
|
||||||
|
|
||||||
r = sc_establish_context(ctx, "");
|
|
||||||
if (r < 0 || !*ctx) {
|
|
||||||
fprintf(stderr, "Failed to create initial context: %s", sc_strerror(r));
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*ctx)->debug = verbose;
|
|
||||||
(*ctx)->flags |= SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER;
|
|
||||||
|
|
||||||
reader_count = sc_ctx_get_reader_count(*ctx);
|
|
||||||
|
|
||||||
if (reader_count == 0) {
|
|
||||||
sc_log(*ctx, "No reader not found.\n");
|
|
||||||
return SC_ERROR_NO_READERS_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reader_id < 0) {
|
|
||||||
/* Automatically try to skip to a reader with a card if reader not specified */
|
|
||||||
for (i = 0; i < reader_count; i++) {
|
|
||||||
*reader = sc_ctx_get_reader(*ctx, i);
|
|
||||||
if (sc_detect_card_presence(*reader) & SC_READER_CARD_PRESENT) {
|
|
||||||
reader_id = i;
|
|
||||||
sc_log(*ctx, "Using the first reader"
|
|
||||||
" with a card: %s", (*reader)->name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((unsigned int) reader_id >= reader_count) {
|
|
||||||
sc_log(*ctx, "No card found, using the first reader.");
|
|
||||||
reader_id = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((unsigned int) reader_id >= reader_count) {
|
|
||||||
sc_log(*ctx, "Invalid reader number "
|
|
||||||
"(%d), only %d available.\n", reader_id, reader_count);
|
|
||||||
return SC_ERROR_NO_READERS_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
*reader = sc_ctx_get_reader(*ctx, reader_id);
|
|
||||||
|
|
||||||
return SC_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void read_dg(sc_card_t *card, unsigned char sfid, const char *dg_str,
|
static void read_dg(sc_card_t *card, unsigned char sfid, const char *dg_str,
|
||||||
unsigned char **dg, size_t *dg_len)
|
unsigned char **dg, size_t *dg_len)
|
||||||
|
@ -361,7 +310,7 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
sc_context_t *ctx = NULL;
|
sc_context_t *ctx = NULL;
|
||||||
sc_card_t *card = NULL;
|
sc_card_t *card = NULL;
|
||||||
sc_reader_t *reader = NULL;
|
sc_context_param_t ctx_param;
|
||||||
|
|
||||||
int r, tr_version = EAC_TR_VERSION_2_02;
|
int r, tr_version = EAC_TR_VERSION_2_02;
|
||||||
struct establish_pace_channel_input pace_input;
|
struct establish_pace_channel_input pace_input;
|
||||||
|
@ -428,17 +377,19 @@ main (int argc, char **argv)
|
||||||
eac_default_flags |= EAC_FLAG_DISABLE_CHECK_CA;
|
eac_default_flags |= EAC_FLAG_DISABLE_CHECK_CA;
|
||||||
|
|
||||||
|
|
||||||
r = initialize(cmdline.reader_arg, cmdline.verbose_given, &ctx, &reader);
|
memset(&ctx_param, 0, sizeof(ctx_param));
|
||||||
if (r < 0) {
|
ctx_param.ver = 0;
|
||||||
fprintf(stderr, "Can't initialize reader\n");
|
ctx_param.app_name = app_name;
|
||||||
|
|
||||||
|
r = sc_context_create(&ctx, &ctx_param);
|
||||||
|
if (r) {
|
||||||
|
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sc_connect_card(reader, &card) < 0) {
|
r = util_connect_card_ex(ctx, &card, cmdline.reader_arg, 0, 0, cmdline.verbose_given);
|
||||||
fprintf(stderr, "Could not connect to card\n");
|
if (r)
|
||||||
sc_release_context(ctx);
|
goto err;
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
EAC_init();
|
EAC_init();
|
||||||
if (cmdline.cvc_dir_given)
|
if (cmdline.cvc_dir_given)
|
||||||
|
|
|
@ -2,9 +2,8 @@ package "npa-tool"
|
||||||
purpose "@PACKAGE_SUMMARY@"
|
purpose "@PACKAGE_SUMMARY@"
|
||||||
|
|
||||||
option "reader" r
|
option "reader" r
|
||||||
"Number of the PC/SC reader to use (-1 for autodetect)"
|
"Number of the reader to use. By default, the first reader with a present card is used. If the arguement is an ATR, the reader with a matching card will be chosen."
|
||||||
int
|
string
|
||||||
default="-1"
|
|
||||||
optional
|
optional
|
||||||
option "verbose" v
|
option "verbose" v
|
||||||
"Use (several times) to be more verbose"
|
"Use (several times) to be more verbose"
|
||||||
|
|
|
@ -1176,7 +1176,7 @@ cmdline_parser_internal (
|
||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'R': /* See notify_card_inserted in opensc.conf. */
|
case 'R': /* See notify_card_removed in opensc.conf. */
|
||||||
args_info->standard_mode_counter += 1;
|
args_info->standard_mode_counter += 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,8 @@ struct gengetopt_args_info
|
||||||
const char *message_help; /**< @brief Main text of the notification help description. */
|
const char *message_help; /**< @brief Main text of the notification help description. */
|
||||||
int notify_card_inserted_flag; /**< @brief See notify_card_inserted in opensc.conf (default=off). */
|
int notify_card_inserted_flag; /**< @brief See notify_card_inserted in opensc.conf (default=off). */
|
||||||
const char *notify_card_inserted_help; /**< @brief See notify_card_inserted in opensc.conf help description. */
|
const char *notify_card_inserted_help; /**< @brief See notify_card_inserted in opensc.conf help description. */
|
||||||
int notify_card_removed_flag; /**< @brief See notify_card_inserted in opensc.conf (default=off). */
|
int notify_card_removed_flag; /**< @brief See notify_card_removed in opensc.conf (default=off). */
|
||||||
const char *notify_card_removed_help; /**< @brief See notify_card_inserted in opensc.conf help description. */
|
const char *notify_card_removed_help; /**< @brief See notify_card_removed in opensc.conf help description. */
|
||||||
int notify_pin_good_flag; /**< @brief See notify_pin_good in opensc.conf (default=off). */
|
int notify_pin_good_flag; /**< @brief See notify_pin_good in opensc.conf (default=off). */
|
||||||
const char *notify_pin_good_help; /**< @brief See notify_pin_good in opensc.conf help description. */
|
const char *notify_pin_good_help; /**< @brief See notify_pin_good in opensc.conf help description. */
|
||||||
int notify_pin_bad_flag; /**< @brief See notify_pin_bad in opensc.conf (default=off). */
|
int notify_pin_bad_flag; /**< @brief See notify_pin_bad in opensc.conf (default=off). */
|
||||||
|
|
Loading…
Reference in New Issue