Commit Graph

6990 Commits

Author SHA1 Message Date
Peter Marschall dbe2fcef2c test-manpages.sh: make more robust & more easily readable
Call the tools to be tested with option '--help' to avoid
triggering automatic actions when no option is given.

Exampleswhy the old behaviour is bad:
- opensc-notify: blocks the build
- opensc-explorer: tries to open the card
2018-06-06 22:43:46 +02:00
Peter Marschall 59412aeee3 src/tools: stop building man pages here (see doc/tools)
They have been moved to doc/tools and are generated there.
2018-06-06 22:43:46 +02:00
Peter Marschall 5a3134556b doc/tools: slight markup improvements
* get rid of hard-coded markup like e.g. { ... | ... } or [ ... ]
  in favour of DocBook's proper tags
* use tags better matching the purpose,
  e.g. use <filename class"directory"> instead of <command> for directories
* improve consistency in <replaceable>s
2018-06-06 22:43:46 +02:00
Peter Marschall 98c9a1588b doc/tools/tools.xml: sort, remove duplicates, add new tools 2018-06-06 22:43:46 +02:00
Peter Marschall ad6b46ea45 doc/tools: add DocBook sources for new tools
* egk-tool.1.xml
* npa-tool.1.xml
* opensc-asn1.1.xml
* opensc-notify.1.xml
2018-06-06 22:43:46 +02:00
Peter Marschall a884953c85 card-dnie: use size_t-specific format specifier in printf
Instead ogf blindly using "%lu", use "%"SC_FORMAT_LEN_SIZE_T"u"
to cope with the various implementations.

This fixes a bug introduced in commit 20b1d829
2018-06-04 12:00:42 +02:00
Peter Marschall 8d503df754 OpenPGP: add missing symbolic constants for card versions 2018-05-31 10:16:23 +02:00
Peter Marschall 3e3e478476 OpenPGP: correctly parse hist_bytes
Instead of simply searching for a trigger byte with the risk of
getting garbage, correctly parse historical bytes from ATR as well
as the "historical bytes" DO as compact TLV structures.

In addition
- prepare for additional data used in OpenPGP cards 3.x
- ignore [per the spec] chaining capability fo OpenPGP cards 1.x
2018-05-31 10:16:23 +02:00
Peter Marschall c725c9c2e7 OpenPGP: 1st go at better parsing of hist_bytes
Use hist_bytes from already parsed ATR in reader->atr_info.hist_bytes
instead of the raw ATR from card->atr
2018-05-31 10:16:23 +02:00
Frank Morgner 4d0e740947 card-npa: Use EF.DIR for card recognition
This is also done in the official AusweisApp2 and avoids confusion with
other tokens that also have an EF.CardAccess and are capable of
verifying the PIN via PACE.

Fixes https://github.com/OpenSC/OpenSC/issues/1360
2018-05-28 22:34:13 +02:00
Peter Marschall d70c140d7a opensc-notify: fix typo 2018-05-27 23:18:13 +02:00
Peter Marschall 0352f298cc npa-tool: fix typo in option parsing 2018-05-27 23:18:13 +02:00
Frank Morgner 42833b6129 added more missing files
fixes https://github.com/OpenSC/OpenSC/issues/1368
2018-05-24 13:51:12 +02:00
Frank Morgner 5985bf13ee ignore more files 2018-05-23 22:31:32 +02:00
Frank Morgner 1aa85671db added missing files to distribution
fixes https://github.com/OpenSC/OpenSC/issues/1368
2018-05-23 22:26:39 +02:00
rmartinc 20b1d829b9 Always allocate resp buffer in DNIe. 2018-05-23 14:22:28 +02:00
Frank Morgner 19df418fb6 fixed usage of get_challenge 2018-05-23 14:20:28 +02:00
Frank Morgner 784435d00c starcos: check for the maximum length of GET RANDOM
Some cards only support fetching 8 bytes and less
2018-05-23 14:20:28 +02:00
Frank Morgner cbba3b82f2 SC-HSM: Check maximum for get_challenge 2018-05-23 14:20:28 +02:00
Frank Morgner 410cdf0dcc refactored sc_get_challenge
Let sc_get_challenge() do sc_lock() and loop through the card driver's
get_challenge() until enough bytes were collected. The card driver's
get_challenge() now returns the number of bytes collected (less or equal
than requested) or an error code.

- Allow more code re-use.
- PIV driver now uses ASN.1 parser for reading the random bytes
2018-05-23 14:20:28 +02:00
Doug Engert 91812cf40f Context Specific Login Using Pin Pad Reader Fix
sc_pkcs15_verify_pin say:

/* if pin cache is disabled, we can get here with no PIN data.
 * in this case, to avoid error or unnecessary pin prompting on pinpad,
 * check if the PIN has been already verified and the access condition
 * is still open on card.
 */

It then call sc_pkcs15_get_pin_info

A context specific login is used in PKCS#11 to force the user
to enter the PIN again and a verify command be sent to the card.
(Actually it could be a different value for the PINi depending on the card)
sc_pkcs15_get_pin_info will then call the card driver, but does not
say why it is testing the login status.sc_pkcs15_get_pin_info may return
SC_PIN_STATE_LOGGED_IN=1 and sc_pkcs15_verify_pin will then skip sending
the actual verify command to the card via _sc_pkcs15_verify_pin

To avoid this, sc_pkcs15_get_pin_info will set data.pin_type = pin_info->auth_method;
In the case of a context specific login, this is SC_AC_CONTEXT_SPECIFIC
and the card driver can take action and can return SC_PIN_STATE_LOGGED_IN=0
so the verify will be done.

The PIV driver card-piv.c does this. Other drivers could do something similar.

 Date:      MOn May 21 20:40:00 2018 -0500

 On branch History-fixes
 Changes to be committed:
	modified:   card-piv.c
	modified:   pkcs15-pin.c
2018-05-23 14:19:05 +02:00
Doug Engert 08ec4b85e1 PIV Better Handling of Reset
If a PIV card does not have  or support a Discovery Object and
is known to lose the login state when the PIV AID is selected,
nothing was done  in piv_card_reader_lock_obtained.
If was_reset > 0 select the PIV AID to at least get the
PIV AID selected.

For other cards either reading the Discovery a object and/or
selecting the PIV AID will make sure the PIV AID is selected.
If multiple applications are using the card, this will allow
the first one to select the AID, and any others that handle
a reset will not cause interference wit the first.

 On branch History-fixes
 Changes to be committed:
	modified:   card-piv.c
2018-05-23 14:19:05 +02:00
Doug Engert d7d674129e PIV History Object Related Changes - Fixes #1330
&& is replaced by || in the test of valid key references
for retired keys found in the Historic object.

For retired keys, the user_consent flag was being set by default.
Thus a C_Login(CKU_CONTEXT_SPECIFIC) would be required.
NIST 800-73 only requires PIN_Always on the Sign Key.

To extend the usefullnes of "retired keys" on non government
issued PIV-like cards, code had already been added
to use the certificate keyUsage flags to override the NIST
defined key usage flags. The NONREPUDATION  flag is now used
to set the user_consent flag.

So rather then always requiring C_Login(CKU_CONTEXT_SPECIFIC)
for any retured key, the code only requires it for non government
cards where teh certificate has NONREPUDATION.

 Changes to be committed:
	modified:   card-piv.c
	modified:   pkcs15-piv.c
2018-05-23 14:19:05 +02:00
Jakub Jelen 6b85099401 pkcs11_enable_InitToken made global configuration option
* Previously, it was dependent on ATR blocks, but it did
   not allow enrolling various types of cards without knowning
   their ATR in advance.
 * Improved documnetation for this option in configuration files

Resolves: #1265
2018-05-23 14:16:34 +02:00
Frank Morgner 45e4f546c2 regenerated built files (gengetopt/help2man)
includes an explicit locale for help2man to recognize umlauts.

partially fixes https://github.com/OpenSC/OpenSC/issues/1365
2018-05-21 20:57:13 +02:00
Peter Marschall 4590d915b9 bootstrap.ci: stop echoing executed commands 2018-05-21 20:45:04 +02:00
Peter Marschall 882080cdf7 version.m4: remove unused macro PACKAGE_VERSION_REVISION 2018-05-21 20:45:04 +02:00
Peter Marschall 4cbdf53b8b bootstrap.ci: cleanup - remove unused code & options 2018-05-21 20:45:04 +02:00
Peter Marschall 8b3e53c730 bootstrap.ci: stop playing with unused PACKAGE_VERSION_REVISION
PACKAGE_VERSION_REVISION is not used outside bootstrap.ci;
remove everything  that deals with it.
2018-05-21 20:45:04 +02:00
Peter Marschall 59a7478011 configure.ac: extend AC_INIT
Define macro PRODUCT_URL and use it as additional argument to AC_INIT().
2018-05-21 20:45:04 +02:00
Peter Marschall e4cab31763 bootstrap.ci: flexibilize option -R
When -R is given, accept indication of -rc resp. ~rc version
strings in git describe's output.
2018-05-21 20:45:04 +02:00
Peter Marschall a6b596d09a version.m4: overhaul
- add macro PACKAGE_VERSION_REVISION dealt with in bootstrap.ci
- restrict to those macros only that are mangled by bootstrap.ci
- update comments on the file's purpose and the processes around it
2018-05-21 20:45:04 +02:00
Peter Marschall c57c743ed0 configure.ac: stop including version.m4
Do not blindly override already defined variables or macros with
outdated values by including version.m4

This makes sure the definitions of variables or macros defined earlier
in configure.ac remain intact; e.g. it keeps the macro PRODUCT_BUGREPORT
set to the GitHub URL instead of pointing to a SourceForge mail address.
2018-05-21 20:45:04 +02:00
Jakub Jelen 9b4e00b24b gp.c: Properly check the SWs of the APDU when selecting AID 2018-05-18 23:52:01 +02:00
Jakub Jelen b6e08e008e Move the Global Platform related commands to separate file and port existing code to that 2018-05-18 23:52:01 +02:00
Jakub Jelen 8d4fbc34c3 coolkey: Make uninitialized cards working as expected with ESC
Original patch from John Magne <jmagne@redhat.com>
2018-05-18 23:52:01 +02:00
Jakub Jelen 58aeb62573 OPENSC_DRIVER: restrict driver list instead of forcing one (#1277)
Using the forced-driver prevents parsing of additional constructions
in configuration files (for example flags based on ATRs). This
implementation replaces transparently the existing list defined in
card_drivers.

Resolves: #1266
2018-05-18 23:50:26 +02:00
Frank Morgner c463985fed
Removed code for obsolete cards from D-Trust (#1261) 2018-05-18 23:49:59 +02:00
Frank Morgner 439a95f2d2
If card initialization fails, return SC_ERROR_INVALID_CARD (#1251)
fixes https://github.com/OpenSC/OpenSC/issues/946
2018-05-18 23:49:29 +02:00
Frank Morgner ae31408f81 fixed checking SW in iso7816_read_binary_sfid
fixes https://github.com/OpenSC/OpenSC/issues/1360
2018-05-18 23:39:16 +02:00
Frank Morgner 01f712d5da
Use explicit locking for OpenSC tools (#1344)
* opensc-explorer: use explicit locking

fixed https://github.com/OpenSC/OpenSC/issues/1043

* opensc-tool: use explicit locking

* pkcs15-crypt: use explicit locking
2018-05-18 23:21:14 +02:00
Alon Bar-Lev 62de900b1a build: fix --disable-sm 2018-05-18 23:20:21 +02:00
Florian Bezdeka af72682072 Fixed gcc 8 compilation errors (#1353)
The following errors occured during a compilation using gcc 8:

In function »gids_create_file.constprop«,
    inserted by »gids_save_certificate.isra.8« beicard-gids.c:1548:7:
card-gids.c:465:2: Error: »strncpy« output may be truncated copying 8 bytes from a string of length 8 [-Werror=stringop-truncation]
  strncpy(record->filename, filename, 8);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pkcs15-oberthur.c: In function »sc_pkcs15emu_oberthur_add_prvkey«:
pkcs15-oberthur.c:741:5: Error: »strncpy« output may be truncated copying 254 bytes from a string of length 254 [-Werror=stringop-truncation]
     strncpy(kobj.label, objs[ii]->label, sizeof(kobj.label) - 1);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2018-05-18 18:54:56 +02:00
David Ward 14afdf38e3 Do not temporarily set SC_READER_REMOVED on all readers (#1335)
* reader-pcsc: Do not temporarily set SC_READER_REMOVED on all readers

Fixes #1324.

* reader-cryptotokenkit: Do not temporarily set SC_READER_REMOVED on all readers

See #1324.
2018-05-18 13:11:49 +02:00
Frank Morgner 36b88c3ad7 reader-pcsc: allow fixing the length of a PIN
fixes https://github.com/OpenSC/OpenSC/issues/1221
closes https://github.com/OpenSC/OpenSC/pull/1288
2018-05-18 12:57:46 +02:00
Frank Morgner 078e99fdca Removed unused configuration option `zero_ckaid_for_ca_certs`
It was used to make pkcs11-tool work with vendor defined PKCS#11
modules. If this behavior is still desired, pass the define
ZERO_CKAID_FOR_CA_CERTS during the build
2018-05-18 12:46:51 +02:00
Frank Morgner d11e05fe1f Generalized configuration option `ignored_readers` 2018-05-18 12:46:51 +02:00
Frank Morgner 4fca7d08c1 removed configuration option `force_card_driver`
Use `card_drivers` or `OPENSC_DRIVER` instead
2018-05-18 12:46:51 +02:00
Frank Morgner 6ab6d7bad9 removed configuration option `reopen_debug_file`
Simply re-open the debug file every time on Windows and don't do it
everywhere else.
2018-05-18 12:46:51 +02:00
Frank Morgner 5d7ed37246 Removed configuration option `paranoid-memory`
Don't pretend that we're capable of performing memory locking. The
implementation of that, `sc_mem_alloc_secure()` (also removed), was
almost unused anyway.
2018-05-18 12:46:51 +02:00