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>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -131,14 +131,14 @@
|
|||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -83,14 +83,14 @@
|
|||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -50,10 +50,10 @@
|
|||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<listitem><para>
|
||||
Specify the reader to use.
|
||||
Use <literal>-1</literal> as <replaceable>arg</replaceable>
|
||||
to automatically detect the reader to use.
|
||||
By default, the first reader with a present card is used.
|
||||
Number of the reader to use. By default, the first
|
||||
reader with a present card is used. If
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
|
|
|
@ -66,14 +66,14 @@
|
|||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -84,9 +84,9 @@
|
|||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>argument</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -34,13 +34,13 @@
|
|||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -71,14 +71,14 @@
|
|||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -52,10 +52,10 @@
|
|||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<listitem><para>
|
||||
Specify the reader to use.
|
||||
Use <literal>-1</literal> as <replaceable>arg</replaceable>
|
||||
to automatically detect the reader to use.
|
||||
By default, the first reader with a present card is used.
|
||||
Number of the reader to use. By default, the first
|
||||
reader with a present card is used. If
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
|
|
|
@ -179,14 +179,14 @@
|
|||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<listitem><para>
|
||||
Specify the reader to use. By default, the first
|
||||
reader with a present card is used. If
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
Number of the reader to use. By default, the first
|
||||
reader with a present card is used. If
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -76,14 +76,14 @@
|
|||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -112,14 +112,14 @@
|
|||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -151,14 +151,14 @@
|
|||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -129,14 +129,14 @@
|
|||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>N</replaceable>,
|
||||
<option>-r</option> <replaceable>N</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -644,14 +644,14 @@ puk 87654321
|
|||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -278,13 +278,13 @@
|
|||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -201,14 +201,14 @@
|
|||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -148,14 +148,14 @@
|
|||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--reader</option> <replaceable>num</replaceable>,
|
||||
<option>-r</option> <replaceable>num</replaceable>
|
||||
<option>--reader</option> <replaceable>arg</replaceable>,
|
||||
<option>-r</option> <replaceable>arg</replaceable>
|
||||
</term>
|
||||
<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
|
||||
<replaceable>num</replaceable> is an ATR, the
|
||||
<replaceable>arg</replaceable> is an ATR, the
|
||||
reader with a matching card will be chosen.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -84,10 +84,14 @@ dnie_tool_LDADD = $(OPTIONAL_OPENSSL_LIBS)
|
|||
gids_tool_SOURCES = gids-tool.c util.c
|
||||
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 \
|
||||
$(OPENPACE_LIBS)
|
||||
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)
|
||||
|
||||
|
@ -117,7 +121,7 @@ $(OPENSC_NOTIFY_BUILT_SOURCES):
|
|||
$(abs_builddir)/opensc-notify.ggo: 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_CFLAGS = -I$(top_srcdir)/src $(OPTIONAL_ZLIB_CFLAGS)
|
||||
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
|
||||
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
|
||||
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
|
||||
|
||||
egk-tool.exe: egk-tool-cmdline.obj $(LIBS)
|
||||
egk-tool.exe: egk-tool-cmdline.obj util.obj $(LIBS)
|
||||
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
|
||||
|
||||
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_help[] = {
|
||||
" -h, --help Print help 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')",
|
||||
" -v, --verbose Use (several times) to be more verbose",
|
||||
" -h, --help Print help and exit",
|
||||
" -V, --version Print version and exit",
|
||||
" -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",
|
||||
"\nHealth Care Application (HCA):",
|
||||
" --pd Show 'Persönliche Versicherungsdaten' (XML) (default=off)",
|
||||
" --vd Show 'Allgemeine Versicherungsdaten' (XML) (default=off)",
|
||||
" --gvd Show 'Geschützte Versicherungsdaten' (XML) (default=off)",
|
||||
" --vsd-status Show 'Versichertenstammdaten-Status' (default=off)",
|
||||
" --pd Show 'Persönliche Versicherungsdaten' (XML)\n (default=off)",
|
||||
" --vd Show 'Allgemeine Versicherungsdaten' (XML)\n (default=off)",
|
||||
" --gvd Show 'Geschützte Versicherungsdaten' (XML)\n (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>",
|
||||
0
|
||||
};
|
||||
|
||||
typedef enum {ARG_NO
|
||||
, ARG_FLAG
|
||||
, ARG_INT
|
||||
, ARG_STRING
|
||||
} cmdline_parser_arg_type;
|
||||
|
||||
static
|
||||
|
@ -83,7 +83,7 @@ static
|
|||
void clear_args (struct gengetopt_args_info *args_info)
|
||||
{
|
||||
FIX_UNUSED (args_info);
|
||||
args_info->reader_arg = -1;
|
||||
args_info->reader_arg = NULL;
|
||||
args_info->reader_orig = NULL;
|
||||
args_info->pd_flag = 0;
|
||||
args_info->vd_flag = 0;
|
||||
|
@ -190,6 +190,7 @@ static void
|
|||
cmdline_parser_release (struct gengetopt_args_info *args_info)
|
||||
{
|
||||
|
||||
free_string_field (&(args_info->reader_arg));
|
||||
free_string_field (&(args_info->reader_orig));
|
||||
|
||||
|
||||
|
@ -1051,6 +1052,7 @@ int update_arg(void *field, char **orig_field,
|
|||
char *stop_char = 0;
|
||||
const char *val = value;
|
||||
int found;
|
||||
char **string_field;
|
||||
FIX_UNUSED (field);
|
||||
|
||||
stop_char = 0;
|
||||
|
@ -1084,24 +1086,18 @@ int update_arg(void *field, char **orig_field,
|
|||
case ARG_FLAG:
|
||||
*((int *)field) = !*((int *)field);
|
||||
break;
|
||||
case ARG_INT:
|
||||
if (val) *((int *)field) = strtol (val, &stop_char, 0);
|
||||
case ARG_STRING:
|
||||
if (val) {
|
||||
string_field = (char **)field;
|
||||
if (!no_free && *string_field)
|
||||
free (*string_field); /* free previous string */
|
||||
*string_field = gengetopt_strdup (val);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
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 */
|
||||
switch(arg_type) {
|
||||
|
@ -1203,12 +1199,12 @@ cmdline_parser_internal (
|
|||
cmdline_parser_free (&local_args_info);
|
||||
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),
|
||||
&(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,
|
||||
"reader", 'r',
|
||||
additional_error))
|
||||
|
|
|
@ -39,9 +39,9 @@ struct gengetopt_args_info
|
|||
{
|
||||
const char *help_help; /**< @brief Print help 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_orig; /**< @brief Number of the PC/SC reader to use (-1 for autodetect) original value given at command line. */
|
||||
const char *reader_help; /**< @brief Number of the PC/SC reader to use (-1 for autodetect) help description. */
|
||||
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 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 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_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. */
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "egk-tool-cmdline.h"
|
||||
#include "libopensc/log.h"
|
||||
#include "libopensc/opensc.h"
|
||||
#include "util.h"
|
||||
#include <ctype.h>
|
||||
#include <stdlib.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};
|
||||
|
||||
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;
|
||||
}
|
||||
static const char *app_name = "egk-tool";
|
||||
|
||||
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 sc_path path;
|
||||
struct sc_context *ctx;
|
||||
struct sc_reader *reader = NULL;
|
||||
struct sc_card *card;
|
||||
unsigned char *data = NULL;
|
||||
size_t data_len = 0;
|
||||
int r;
|
||||
sc_context_param_t ctx_param;
|
||||
|
||||
if (cmdline_parser(argc, argv, &cmdline) != 0)
|
||||
exit(1);
|
||||
|
||||
r = initialize(cmdline.reader_arg, cmdline.verbose_given, &ctx, &reader);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Can't initialize reader\n");
|
||||
memset(&ctx_param, 0, sizeof(ctx_param));
|
||||
ctx_param.ver = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
if (sc_connect_card(reader, &card) < 0) {
|
||||
fprintf(stderr, "Could not connect to card\n");
|
||||
sc_release_context(ctx);
|
||||
exit(1);
|
||||
}
|
||||
r = util_connect_card_ex(ctx, &card, cmdline.reader_arg, 0, 0, cmdline.verbose_given);
|
||||
if (r)
|
||||
goto err;
|
||||
|
||||
|
||||
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))
|
||||
|
|
|
@ -2,9 +2,8 @@ package "egk-tool"
|
|||
purpose "@PACKAGE_SUMMARY@"
|
||||
|
||||
option "reader" r
|
||||
"Number of the PC/SC reader to use (-1 for autodetect)"
|
||||
int
|
||||
default="-1"
|
||||
"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."
|
||||
string
|
||||
optional
|
||||
option "verbose" v
|
||||
"Use (several times) to be more verbose"
|
||||
|
|
|
@ -35,7 +35,7 @@ const char *gengetopt_args_info_description = "";
|
|||
const char *gengetopt_args_info_help[] = {
|
||||
" -h, --help Print help 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",
|
||||
"\nPassword Authenticated Connection Establishment (PACE):",
|
||||
" -p, --pin[=STRING] Run PACE with (transport) eID-PIN",
|
||||
|
@ -100,7 +100,6 @@ const char *gengetopt_args_info_help[] = {
|
|||
typedef enum {ARG_NO
|
||||
, ARG_FLAG
|
||||
, ARG_STRING
|
||||
, ARG_INT
|
||||
} cmdline_parser_arg_type;
|
||||
|
||||
static
|
||||
|
@ -181,7 +180,7 @@ static
|
|||
void clear_args (struct gengetopt_args_info *args_info)
|
||||
{
|
||||
FIX_UNUSED (args_info);
|
||||
args_info->reader_arg = -1;
|
||||
args_info->reader_arg = NULL;
|
||||
args_info->reader_orig = NULL;
|
||||
args_info->pin_arg = NULL;
|
||||
args_info->pin_orig = NULL;
|
||||
|
@ -400,7 +399,6 @@ free_string_field (char **s)
|
|||
|
||||
/** @brief generic value variable */
|
||||
union generic_value {
|
||||
int int_arg;
|
||||
char *string_arg;
|
||||
const char *default_string_arg;
|
||||
};
|
||||
|
@ -448,6 +446,7 @@ static void
|
|||
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->pin_arg));
|
||||
free_string_field (&(args_info->pin_orig));
|
||||
|
@ -1558,9 +1557,6 @@ int update_arg(void *field, char **orig_field,
|
|||
case ARG_FLAG:
|
||||
*((int *)field) = !*((int *)field);
|
||||
break;
|
||||
case ARG_INT:
|
||||
if (val) *((int *)field) = strtol (val, &stop_char, 0);
|
||||
break;
|
||||
case ARG_STRING:
|
||||
if (val) {
|
||||
string_field = (char **)field;
|
||||
|
@ -1573,17 +1569,6 @@ int update_arg(void *field, char **orig_field,
|
|||
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 */
|
||||
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 *));
|
||||
|
||||
switch(arg_type) {
|
||||
case ARG_INT:
|
||||
*((int **)field) = (int *)realloc (*((int **)field), (field_given + prev_given) * sizeof (int)); break;
|
||||
case ARG_STRING:
|
||||
*((char ***)field) = (char **)realloc (*((char ***)field), (field_given + prev_given) * sizeof (char *)); break;
|
||||
default:
|
||||
|
@ -1701,8 +1684,6 @@ void update_multiple_arg(void *field, char ***orig_field,
|
|||
tmp = list;
|
||||
|
||||
switch(arg_type) {
|
||||
case ARG_INT:
|
||||
(*((int **)field))[i + field_given] = tmp->arg.int_arg; break;
|
||||
case ARG_STRING:
|
||||
(*((char ***)field))[i + field_given] = tmp->arg.string_arg; break;
|
||||
default:
|
||||
|
@ -1715,12 +1696,6 @@ void update_multiple_arg(void *field, char ***orig_field,
|
|||
} else { /* set the default value */
|
||||
if (default_value && ! field_given) {
|
||||
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:
|
||||
if (! *((char ***)field)) {
|
||||
*((char ***)field) = (char **)malloc (sizeof (char *));
|
||||
|
@ -1863,12 +1838,12 @@ cmdline_parser_internal (
|
|||
cmdline_parser_free (&local_args_info);
|
||||
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),
|
||||
&(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,
|
||||
"reader", 'r',
|
||||
additional_error))
|
||||
|
|
|
@ -39,9 +39,9 @@ struct gengetopt_args_info
|
|||
{
|
||||
const char *help_help; /**< @brief Print help 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_orig; /**< @brief Number of the PC/SC reader to use (-1 for autodetect) original value given at command line. */
|
||||
const char *reader_help; /**< @brief Number of the PC/SC reader to use (-1 for autodetect) help description. */
|
||||
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 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 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_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. */
|
||||
|
|
|
@ -22,15 +22,16 @@
|
|||
#endif
|
||||
|
||||
#ifdef ENABLE_OPENPACE
|
||||
#include "npa-tool-cmdline.h"
|
||||
#include "fread_to_eof.h"
|
||||
#include "sm/sslutil.h"
|
||||
#include "npa-tool-cmdline.h"
|
||||
#include "sm/sm-eac.h"
|
||||
#include "sm/sslutil.h"
|
||||
#include "util.h"
|
||||
#include <eac/pace.h>
|
||||
#include <libopensc/card-npa.h>
|
||||
#include <libopensc/log.h>
|
||||
#include <libopensc/opensc.h>
|
||||
#include <libopensc/sm.h>
|
||||
#include <libopensc/card-npa.h>
|
||||
#include <sm/sm-eac.h>
|
||||
#include <stdint.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)); \
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static const char *app_name = "npa-tool";
|
||||
|
||||
static void read_dg(sc_card_t *card, unsigned char sfid, const char *dg_str,
|
||||
unsigned char **dg, size_t *dg_len)
|
||||
|
@ -361,7 +310,7 @@ main (int argc, char **argv)
|
|||
|
||||
sc_context_t *ctx = 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;
|
||||
struct establish_pace_channel_input pace_input;
|
||||
|
@ -428,17 +377,19 @@ main (int argc, char **argv)
|
|||
eac_default_flags |= EAC_FLAG_DISABLE_CHECK_CA;
|
||||
|
||||
|
||||
r = initialize(cmdline.reader_arg, cmdline.verbose_given, &ctx, &reader);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Can't initialize reader\n");
|
||||
memset(&ctx_param, 0, sizeof(ctx_param));
|
||||
ctx_param.ver = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
if (sc_connect_card(reader, &card) < 0) {
|
||||
fprintf(stderr, "Could not connect to card\n");
|
||||
sc_release_context(ctx);
|
||||
exit(1);
|
||||
}
|
||||
r = util_connect_card_ex(ctx, &card, cmdline.reader_arg, 0, 0, cmdline.verbose_given);
|
||||
if (r)
|
||||
goto err;
|
||||
|
||||
EAC_init();
|
||||
if (cmdline.cvc_dir_given)
|
||||
|
|
|
@ -2,9 +2,8 @@ package "npa-tool"
|
|||
purpose "@PACKAGE_SUMMARY@"
|
||||
|
||||
option "reader" r
|
||||
"Number of the PC/SC reader to use (-1 for autodetect)"
|
||||
int
|
||||
default="-1"
|
||||
"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."
|
||||
string
|
||||
optional
|
||||
option "verbose" v
|
||||
"Use (several times) to be more verbose"
|
||||
|
|
|
@ -1176,7 +1176,7 @@ cmdline_parser_internal (
|
|||
goto failure;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ struct gengetopt_args_info
|
|||
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). */
|
||||
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). */
|
||||
const char *notify_card_removed_help; /**< @brief See notify_card_inserted in opensc.conf help description. */
|
||||
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_removed in opensc.conf help description. */
|
||||
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. */
|
||||
int notify_pin_bad_flag; /**< @brief See notify_pin_bad in opensc.conf (default=off). */
|
||||
|
|
Loading…
Reference in New Issue