Commit Graph

6473 Commits

Author SHA1 Message Date
Frank Morgner b32d1e8d1e AppVeyor: Build on as many platforms as we can
reverts bd1e7aa032
2016-10-07 14:17:40 +02:00
Frank Morgner 28958af559 added compatibility function for VC14 2016-10-07 14:17:40 +02:00
Frank Morgner 6dc6d4c05d Documented reader's max_recv_size/max_send_size
Closes https://github.com/OpenSC/OpenSC/issues/802
2016-10-07 14:13:53 +02:00
Viktor Tarasov 3b352d5eca sm: no SHA256 for OpenSSL version < 0.9.8 2016-10-05 11:04:35 +02:00
Viktor Tarasov 30261ceaec pkcs15-tool: remove overall card unlock
In a complement to c6db68f -- card is not more locked when connected.
2016-10-04 18:26:50 +02:00
Viktor Tarasov 0f22c0fd77 travis for OCX: fix missing 'sed'
Due to bugs in Travis CI:
$ ./bootstrap
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: running: glibtoolize --copy --force
/usr/local/bin/glibtoolize: line 401: /usr/local/Library/ENV/4.3/sed: No such file or directory
/usr/local/bin/glibtoolize: line 401: /usr/local/Library/ENV/4.3/sed: No such file or directory
/usr/local/bin/glibtoolize: line 401: /usr/local/Library/ENV/4.3/sed: No such file or directory

Apply solution from https://github.com/mkrufky/libdvbtee/issues/22 .

Fixes #881
2016-10-04 11:01:24 +02:00
Leonardo Brondani Schenkel 7b9bd60030 openssl: allow building against libressl (#878) 2016-09-26 14:54:58 +02:00
Frank Morgner 96ef5c0dc2 exclude DNIe 3.0 from supported cards 2016-09-20 15:21:59 +02:00
Frank Morgner 8d67adb06c Merge pull request #864 from maciejsszmigiero/openpgp-fixes-small
OpenPGP card small fixes
2016-09-20 14:48:20 +02:00
Frank Morgner d42aab11ab sc-hsm-tool: hide --print-dkek-share from the user
closes https://github.com/OpenSC/OpenSC/pull/821
2016-09-20 11:25:38 +02:00
Remy a6dff51c6b add dkek share hex print 2016-09-20 11:20:20 +02:00
Frank Morgner abd1595f60 winconfig.h: use more values from configure.ac
fixes #866
2016-09-20 09:33:38 +02:00
Nikos Mavrogiannopoulos 2059f79793 install opensc.pc
This allows applications to detect opensc version, as well as
link against opensc's pkcs11 library if needed.
2016-09-20 01:47:37 +02:00
Frank Morgner c6db68fdee pkcs15-tool: don't unconditionally lock the card 2016-09-19 23:55:41 +02:00
CardContact Systems GmbH 905d78093c Allow tools to enable card lock (#875)
Closes #868
2016-09-19 17:49:34 +02:00
Ian Young 678f2bb1a6 Make pkcs15-tool --dump object formatting consistent (#867)
Properly terminate "Encoded serial" lines so that the blank line after
X.509 certificate blocks isn't consumed doing so.
2016-09-08 22:05:17 +02:00
Raul Metsma 14a5e628be pkcs15-esteid: remove openssl dependency (#863)
Uses e4f5f84512 API instead
2016-09-02 21:48:44 +02:00
Frank Morgner 73ed21aeb7 sc-hsm: fixed parsing EF.TokenInfo (#865)
fixes https://github.com/OpenSC/OpenSC/issues/862
2016-09-01 21:43:06 +02:00
Frank Morgner cda3a2b5ad Initialize PIN logged_in field for default PKCS#15 data 2016-09-01 02:17:29 +02:00
Maciej S. Szmigiero d84ee6c96a Initialize PIN logged_in field for cards that do not support PIN info
Commit 2f10de4f5c ("use sc_pkcs15_get_pin_info in C_GetTokenInfo")
introduced dependency of logged in state returned for session
by C_GetTokenInfo() on logged_in field of that session slot PIN.

This field is updated by sending pin_cmd of type SC_PIN_CMD_GET_INFO to
card.
However, not all cards support such pin_cmd type (in fact, majority of
them don't). In this case logged_in field is usually left zero-initialized
which means SC_PIN_STATE_LOGGED_OUT.

With such logged_in field value C_GetTokenInfo() always returns
CKS_R{O,W}_PUBLIC_SESSION, instead of CKS_R{O,W}_USER_FUNCTIONS when
logged in.

At least Firefox (and probably other NSS-based software, too) is confused
by such value and keeps repeating PIN prompts a few times until it
ultimately considers that logging in to this slot has failed.

Fix this by initializing PIN logged_in field to SC_PIN_STATE_UNKNOWN for
cards that do not support SC_PIN_CMD_GET_INFO pin_cmd.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-09-01 02:03:42 +02:00
Frank Morgner 526ae18696 PKCS#11: Don't use ':' in the token name
Fixes https://github.com/OpenSC/OpenSC/issues/849
2016-09-01 01:25:29 +02:00
Maciej S. Szmigiero dc476a9f33 Improve handling of OpenPGP card PIN change and unblock commands
"CHANGE REFERENCE DATA" (PIN change) and "RESET RETRY COUNTER"
(PIN unblock) commands in OpenPGP card have various limitations.
These also depend on whether the card is version 1.x or 2.x.

Provide helpful debug messages for user in case he is trying to do
a PIN command in a way that isn't supported by the card.

Also, take into account that version 2.x cards don't support references to
PW1-mode 2 (82) in these commands - change them to PW1 (81).

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-08-30 23:30:43 +02:00
Maciej S. Szmigiero 80f5c8b835 Code files don't need execute permission
Some .c files had execute permission bit set needlessly.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-08-30 23:30:43 +02:00
Maciej S. Szmigiero 3e3528bb68 OpenPGP card doesn't support raw RSA so don't set such algo flag
According to descriptions of commands "PSO: COMPUTE DIGITAL SIGNATURE",
"PSO: DECIPHER" and "INTERNAL AUTHENTICATE" in OpenPGP card spec (versions
1.1 and 2.1.1) the card adds / strips and checks PKCS#1 padding
automatically.
There is no documented way to perform raw RSA operations on this card so
SC_ALGORITHM_RSA_RAW flag shouldn't be set.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-08-30 23:30:43 +02:00
Maciej S. Szmigiero 0a6c1c4fb3 Make OpenPGP card user/signature PIN order match PKCS#11 framework
_get_auth_object_by_name() in pkcs11/framework-pkcs15.c needs user PIN
to be the first one and then next one can be signature PIN, but OpenPGP
card had it reversed.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-08-30 23:30:43 +02:00
Jakub Jelen e4f5f84512 libopensc: generic parse of certificate extensions
The code attempted to handle extensions assuming extensions were ordered. The
only extension it handled was crl's, but the handling was wrong and I didn't
find any actual use of the crl code. I've changed it to cache all the extensions
and then provided accessors functions to read a specific extension. I needed this
to read the key Usage, but the extension fetching code can work with any extension
(though the caller will need to parse the result. I also added code that parses DN
and returns a specifically requested DN component. I needed this to get the Common
Name for the certificate Subject. This gives the token a 'unique' name rather than
some generic name (like CAC-I or CAC-II). Both of these can be used to enhance the
piv support as well.

rebased by VTA
Closes #852
2016-08-28 16:41:01 +02:00
Viktor Tarasov ce82e56411 pkcs15init: fix using PINPAD to verify PIN
on the way to fix problem observed in #856
2016-08-28 13:44:12 +02:00
Jakuje 952fb7cb93 Get rid of misleading indentation warnings (GCC6 -Wmisleading-indentation) (#859) 2016-08-27 23:19:52 +02:00
Ian Young f64c71da28 Don't free file if pointer is null (#858)
Protect against segmentation

closes #854.
2016-08-27 23:14:04 +02:00
Viktor Tarasov 98568fe13e libopensc: no cache for the zero length PIN
fixes problem with the revalidation of PIN with PINPAD
observed in #856
2016-08-27 15:30:30 +02:00
Sid-Ali TEIR 01c92fe37f pkcs11-tool: fixed --id for C_GenerateKey, DES and DES3 keygen mechanism
fixed --id for C_GenerateKey, added DES and DES3 keygen mechanism and added ability to delete denerated secret key.

This closes #857
2016-08-27 13:11:21 +02:00
Viktor Tarasov 64ba32f2c6 pkcs11-tool: for WIN32 define STDOUT_FILENO
fix bug introduced in 6cd28cfc7c
2016-08-16 10:34:48 +02:00
Doug Engert bb2d863e4f piv: add a piv_card_reader_lock_obtained function
When sc_lock obtains a reader lock  this function is called
If the card was reset the PIV AID is seletcted and logged_in is reset.
This is need for some PIV cards where the default AID is not the PIV AID
and some other process has reset the card.

closes #842
2016-08-15 13:34:50 +02:00
Doug Engert 84a69ce2ba libopensc: introduce 'reader_lock_obtained' card operation
Add card_reader_lock_obtained function to sc_card_operations

During sc_lock, if card->reader->ops->lock is called, card->ops->card_reader_lock_obtained will be called.
If PCSC is being used as the reader driver, this occures just after pcsc_lock  has done a SCardBeginTransaction
and our process has exclusive control over the card. The card driver can then determine if the state of the
card has changed, and take action to get the card into an acceptable state.

If card->reader->ops->lock returns SC_ERROR_CARD_RESET, indicating some other process has interefered
with the state of the card. was_reset=1 is passed to card->ops->card_reader_lock_obtained.

Some examples of actions that could be done by the card driver is to select the AID and reset logged_in.

Currently the card driver is not notified. So no default card_reader_lock_obtained is defined in iso7816.c
2016-08-15 13:31:08 +02:00
Hannu Honkanen 6cd28cfc7c myeid: fix to ECDH implementation
fixing #756
rebased by VTA
2016-08-13 20:50:01 +02:00
Nuno Goncalves 6ad229e9f6 pkcs11-tool: Simplify PIN warnings messages logic
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-08-05 10:13:32 +02:00
Frank Morgner ff335fe87f sc-hsm: cache certificates 2016-08-03 23:08:12 +02:00
Doug Engert 1e82dbe5c7 libopensc: fix reopen SM after reader reconnect
After card reset detected, run SM open under new transaction

Before trying to reestablish SM session or onte code that may
need to use a transaction,  get the transaction that will be
used by the caller od sc_lock.

closes #837
2016-07-29 17:29:38 +02:00
Nuno Goncalves 1bc09ddafa pkcs11-tool: re-login if pincache is disabled or expired
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>

closes #839
2016-07-29 17:26:17 +02:00
Viktor Tarasov eb21c41e53 piv: coding style, use short log calls 2016-07-24 20:40:58 +02:00
Doug Engert 9c7f67309f piv: logout place holder
Until a full logout function can be implemented, return SC_ERROR_NOT_SUPPORTED

closes #832
2016-07-24 20:40:44 +02:00
carblue 1ab99f3756 pkcs11-tool: in 4rd test use other signature keys
also increase signature buffer in framework-pkcs15

closes #814
2016-07-24 19:26:10 +02:00
Viktor Tarasov 49a4eaaef3 pkcs15: no PIN cache update in pincache-revalidate
PIN cache is not updated when PIN is verified using the PIN value from cache.
That's the case of validating PIN in 'revalidate' context.

Few source format fixes included

closes #805
2016-07-24 18:49:51 +02:00
Frank Morgner c5a95d4a5a sc-hsm: use PKCS#15 file cache
fix invalid certificate path
2016-07-24 17:19:18 +02:00
Frank Morgner 8efca4d6db pkcs15: don't require-L for file caching
File caching is done transparently when the user sets the config option.
2016-07-24 17:19:18 +02:00
Frank Morgner 21fd6f0d95 libopensc: cache EF.ODF and EF.TokenInfo 2016-07-24 17:19:18 +02:00
Frank Morgner 60f2d06308 libopensc: fetch card's UID
Fetch card's UID.
For file caching, use UID if SN is not available.
2016-07-24 17:16:29 +02:00
Viktor Tarasov cee092a930 piv: change driver's short name to 'PIV-II'
closes #828
2016-07-19 15:27:26 +02:00
Doug Engert 0d6fc02e23 reader-pcsc: improved logging and handling of reset
A sleep(1) is added after SCARD_W_CARD_RESET as done in other parts of reader-pcsc.c

Extra debugging messages are output.

SCard routines return "LONG" which may be different then "long" on some systems
were "LONG" is 32 bits and "long" is 64 bits.
Make sure printf format of 0x%08lx has a matching "long" input variable.

This closes #816
2016-07-19 15:20:49 +02:00
Doug Engert edf24d0e2e PIV and PIV-Want-To-Be Issues
Not all PIV cards follow the  NIST 800-73-3 standard. This commit is designed to address some
of the issues.  OpenSC developers don't have access to all the different versions of devices
or access to release notes for the devices to see when a bug was introduced and when it is fixed.

To make OpenSC code changes easier,  the code is divided into four sections:

(1) Identify the card/token as best possible by looking at the "Historical bytes" in the ATR.
For the Yubico devices read their version number and log it via sc_debug.

(2) Define the card_issues  CI_* defines in card-piv.c. There are 8 of them at the moment.
See below.

(3) based on the card->type and possibly Yubico version set the priv->card_issues flags that
apply to  current card or device.

(4) Implement in the code changes needed for each issue.

Other issues can be added. As more info is obtained (3) can be updated using the version
number as needed.

The card issues are:

CI_VERIFY_630X - VERIFY "tries left" returns 630X rather then 63CX

CI_VERIFY_LC0_FAIL - VERIFY Lc=0 never returns 90 00 if PIN not needed. Will also test after
first PIN verify if protected object can be used instead

CI_CANT_USE_GETDATA_FOR_STATE - No object to test verification in place of VERIFY Lc=0

CI_LEAKS_FILE_NOT_FOUND - GET DATA of empty object returns 6A 82 even if PIN not verified

CI_OTHER_AID_LOSE_STATE - Other drivers match routines may reset our security state and lose AID

CI_NFC_EXPOSE_TOO_MUCH - PIN, crypto and objects exposed over NFS in violation of 800-73-3

CI_NO_RSA2048 - does not have RSA 2048

CI_NO_EC384 - does not have EC 384

The piv_card_match and piv_init interactions were cleaned up.

 Changes to be committed:
	modified:   card-piv.c
	modified:   cards.h
2016-07-19 15:17:28 +02:00