Commit Graph

6964 Commits

Author SHA1 Message Date
Frank Morgner 54097c0fc0 fixed .travis.yml 2018-04-07 14:32:53 +02:00
Frank Morgner 647b623357 (hopefully) fixed .travis.yml 2018-04-07 13:04:27 +02:00
Frank Morgner 148bc25238 fixed coverity issues
- CID 145623 (#1 of 1): Resource leak (RESOURCE_LEAK)
- CID 269069 (#1 of 1): Resource leak (RESOURCE_LEAK)
- CID undefined (#1 of 1): Dereference before null check (REVERSE_INULL)
2018-04-07 12:27:12 +02:00
Frank Morgner e1bc515363 optionally try covertiy_scan with every build on master
idea from https://github.com/umlaeute/Gem/blob/master/.travis.yml
2018-04-07 12:08:08 +02:00
Laurent Bigonville 491e5a47fc Clean up the belpic driver
Remove all the code related to the old GUI and PIN PAD.

This code was initially developed by Zetes and had the ability to
display a dialog to request the PIN to the user. It was also able to
manage some specific proprietary pin pads.

As the Belgian government/fedict has now its own implementation, all
these old crufts can be removed.

https://github.com/OpenSC/OpenSC/issues/1296
2018-04-06 12:42:12 +02:00
Frank Morgner fc64c87c5c with keep_alive, use cache only within the transaction
fixes https://github.com/OpenSC/OpenSC/issues/1159
2018-04-06 12:20:32 +02:00
Frank Morgner 74bdcad4e8 fixed description of --disable-strict 2018-04-06 12:20:32 +02:00
Frank Morgner 445ae0919b rename opensc-notify goi app id
fixes https://github.com/OpenSC/OpenSC/issues/1309
2018-04-05 21:13:23 +02:00
Doug Engert 0911982bef Various PIV changes
Some ActivIdentity CAC/PIV cards lose the login state when selecting
the PIV AID SC_CARD_TYPE_PIV_II_CAC and CI_PIV_AID_LOSE_STATE were added
so piv_card_reader_lock_obtained will  try and do a SELECT PIV AID.

card->type is reset to its original value if piv_match_card_continued
fails to match a card as PIV.

pkcs15-piv.c now uses sc_card_ctl which checks card->ops->card_ctl for NULL.

closes https://github.com/OpenSC/OpenSC/pull/1307
fixes https://github.com/OpenSC/OpenSC/issues/1297
2018-04-05 15:23:16 +02:00
Jakub Jelen a5839bb83c Temporarily disable tests to make CI pass 2018-04-04 21:43:01 +02:00
Jakub Jelen 8a63103229 Properly report errors from make check in travis 2018-04-04 21:43:01 +02:00
Jakub Jelen eb646dd370 Do not create getSUBJECT without OpenSSL 2018-04-04 21:43:01 +02:00
Jakub Jelen 58cd9aaeb6 card-authentic.c: Initialize variables and make it build
Ammends: #1205
2018-04-04 21:43:01 +02:00
Jakub Jelen 0997c33a30 pkcs11-tool: Print also SUBJECT of certificate
List also the names of generated functions for better searchability
2018-04-04 21:43:01 +02:00
Jakub Jelen a6e6cfb6de Log return value of C_GenerateRandom() 2018-04-04 21:43:01 +02:00
Jakub Jelen 0c974a0cc7 Incorporate the first manpage integrity check 2018-04-04 21:43:01 +02:00
Jakub Jelen db2ceff911 Avoid circullar dependency 2018-04-04 21:43:01 +02:00
Jakub Jelen 161e83a243 Add missing pkcs11-tool options to man page 2018-04-04 21:43:01 +02:00
Jakub Jelen e193b31e1a Log the used config file after processing it 2018-04-04 21:43:01 +02:00
Mouse b7dc5a0890 Retrieve OpenPGP applet version from OpenPGP applet on YubiKey token (#1262) 2018-04-04 21:41:39 +02:00
Frank Morgner 3e22daf7b5 OpenPGP: fixed memory leak 2018-04-04 10:02:30 +02:00
sergioag 098eed146f [AuthentIC v3] Correctly handle APDUs with more than 256 bytes (#1205) 2018-03-31 21:51:11 +02:00
AnthonyA 74885fb1c1 pkcs11-tool: allow mechanism to be specified in hexadecimal
To support vendor mechanisms, let -m accept hexadecimal strings,
e.g., -m 0x80001234
2018-03-31 21:39:53 +02:00
Frank Morgner 45ad44e311 fixed handling SC_ASN1_TAG_EOC from sc_asn1_read_tag
We can't check for `tag == SC_ASN1_TAG_EOC` directly, because this
would also be true for a tag of 0x80 (with `class ==
SC_ASN1_CLASS_CONSTRUCTED`). So what we do is we check for the output
buffer to be NULL!

fixes https://github.com/OpenSC/OpenSC/issues/1273
2018-03-30 08:28:51 +02:00
Frank Morgner fe0d6f9187 fixed invalid read 2018-03-22 15:09:25 +01:00
Frank Morgner a84bf918af fixed memory leak 2018-03-22 14:54:50 +01:00
Frank Morgner b643bbbe40 fixed memory in case of a certificate parsing problem 2018-03-22 14:34:02 +01:00
Vadim Penzin e1d6f0869b Add missing initialisation of variables to pacify Clang.
1. src/libopensc/card-openpgp.c:pgp_store_key().
2. src/libopensc/cwa14890.c:cwa_verify_icc_certificates().
3. src/libopensc/cwa14890.c:cwa_prepare_external_auth().
4. src/libopensc/pkcs15-itacns.c:itacns_check_and_add_keyset().

(Discovered by Clang 4.0.0 on OpenBSD 6.2.)
2018-03-19 09:48:21 +01:00
Vadim Penzin 1ac08f96e7 epass2003: Fix buffer underrun in epass2003_decipher(), etc.
1. Buffer underrun in epass2003_decipher().
2. The parameter `data' in update_secret_key() must be constant.

(Discovered by Clang 4.0.0 on OpenBSD 6.2.)
2018-03-19 09:48:21 +01:00
AnthonyA ea4baf50d5 pkcs11-tool: make ECPoint behaviour standards compliant by default
Fixes #1286. The behaviour of pkcs11-tool will follow the standard -
send DER. If EC_POINT_NO_ASN1_OCTET_STRING is defined then it will
write plain bytes.
2018-03-19 09:39:10 +01:00
Frank Morgner 7ca16a7531
Merge pull request #1256 from dengert/piv-aid-discovery
PIV detection of AID using Discovery Object before doing select AID - Partial 
 #1243
2018-03-16 22:06:16 +01:00
Igor Castañeda Ferreira 5d5caecfab Fix DNIe UI integration (#1280) 2018-03-09 14:37:38 +01:00
Frank Morgner a97fc86cc9 starcos: reverted deactivation of pin cmd for 2.X
It simply uses the implementation of iso7816. Fixes regression from
19bbfc76f5
2018-03-09 14:36:55 +01:00
Frank Morgner 6f58a97906 md: added STARCOS 3.5 ATRs 2018-03-09 14:36:55 +01:00
Frank Morgner 01810fcb66 STARCOS: Added support for 3.5
ATR and differences between 3.4/3.5 are based on
https://github.com/CardContact/sc-hsm-embedded
Actually, 3.5 is untested, but 3.4 is almost identical, so we hope that
for 3.5 everything is fine.
2018-03-09 14:36:55 +01:00
Frank Morgner 196c838957 fixed use after free
ICCSN and CHN pointed into EF.GDO's content, which was freed
preemptively. Regression of 0502a839c6
2018-03-09 14:36:55 +01:00
Frank Morgner b403934718 PKCS#15: prevent use of empty serial number in TokenInfo
... and initialize the serial number with the card's serial number if
nothing useful is in EF.TokenInfo
2018-03-09 14:36:55 +01:00
Frank Morgner e8e8153cda md: prevent endless loop for card without sn 2018-03-09 14:36:55 +01:00
Frank Morgner d29bdf9da0 md: register starcos cards 2018-03-09 14:36:55 +01:00
Frank Morgner c3ffdecd0b rename SC_SEC_ENV_KEY_REF_ASYMMETRIC to SC_SEC_ENV_KEY_REF_SYMMETRIC
This reflects the actual use of the identifier by the card drivers.
2018-03-09 14:36:55 +01:00
Frank Morgner e2ba2f8192 Starcos 3.4: implemented PSO:DEC 2018-03-09 14:36:55 +01:00
Frank Morgner b05273b01e starcos: fixed key reference for "local" key id 2018-03-09 14:36:55 +01:00
Doug Engert 4222036a60 PIV completely separate piv_match_card from piv_init
In order to satisfy some concerns over the use of <card>_match_card
and <card>_init, this modification will do that at the cost of additional
overhead of repeating some card commands.

Hopefully this commit will not be needed.

 On branch piv-aid-discovery
 Changes to be committed:
	modified:   card-piv.c
2018-02-28 13:49:14 -06:00
Doug Engert aee62c7c67 Requested changed to not rely on success *_match_card being followed by *_init
As requested and as the alternative solution see:
https://github.com/OpenSC/OpenSC/pull/1256#issuecomment-365319444

In order to not pass a card lock and the card->drv_data from piv_match_card
piv_match_card is split in 2 parts.

the piv_match_card_continued is called from piv_init. piv_init may
now return with SC_ERROR_INVALID_CARD to single to sc_connect_card to look
for additional drivers.

Cosmetic change to indicate neo_version is really a Yubico version.
Change wording on the comments when setting card_issues.

 On branch piv-aid-discovery

 Changes to be committed:
	modified:   src/libopensc/card-piv.c
2018-02-22 09:48:43 -06:00
Doug Engert efe7eb598f Some CAC / PIV cards do not support Discovery Object
Some CAC card return '6A80` Incorrect parameters in APDU when trying to
read the Discovery object. If it fails other then not found, then we can
not use the Discovery object to test for the active AID.

The test is done in piv_match_card just after doing a SELECT AID for the PIV.
and set CI_DISCOVERY_USELESS if needed. piv_card_reader_lock_obtained will
then not use the Discovery object.

Some older PIV cards, prior to the introduction of the PIV
Discovery and History objects, may get errors trying to read them.
Ignore these errors too.

Remove comment and remove code to check verify Lc=0 as requested in:

https://github.com/OpenSC/OpenSC/pull/1256#pullrequestreview-96124443

They can easily be added back in.

 On branch piv-aid-discovery

 Changes to be committed:
	modified:   src/libopensc/card-piv.c
2018-02-22 09:40:42 -06:00
Doug Engert 27add2ee3c Inform pkcs15 and card drivers of PKCS#11 C_Login(CKU_CONTEXT_SPECIFIC)"
Framework-pkcs15.c will now set pin_info->auth_method to SC_AC_CONTEXT_SPECIFIC

iso7816.c iso7816_build_pin_apdu treats this the same as SC_AC_CHV

card-piv.c piv_pin_cmd sets priv->xcontext_specific=1 and calls sc_lock before
the verify command. If the verify fails sc_unlock is called.
Later after the next card command returns, if priv->context_specific==1 piv_check_sw
will call sc_unlock as the application may not have requested the crypto but
some other command.

Some additional calls to sc_lock and sc_unlock have been added to make sure
PIV internal command sequences including the crypto command ('87') and any get
responses are always protected by a lock.

This guarantees the card is locked for verify and the next command
which should be the crypto operation. The PIV card also inforces this restriction
on the card.

This is based on suggestions in:
://github.com/OpenSC/OpenSC/pull/1256#issuecomment-361975751

 On branch piv-aid-discovery

 Changes to be committed:
	modified:   src/libopensc/card-piv.c
	modified:   src/libopensc/iso7816.c
	modified:   src/libopensc/types.h
	modified:   src/pkcs11/framework-pkcs15.c
2018-02-22 09:37:46 -06:00
Doug Engert 3fea6b7927 PIV detection of AID using Discovery Object before doing select AID
Many OpenSC drivers try and detect during match if the card supports
their AID by doing a SELECT FILE for the AID.

But this can cause problems with cards such as Yubico that do not ignore
SELECT AID commands for applications they do not support. Other cards may
have the same problems. Selecting the wrong AID can also lose the security
state.

The card-piv.c will now uses the GET DATA to read the PIV Discovery Object '7E'
which is a ISO standard template that will contain the AID of the currently
active application. The driver will then double check that the template is
for the PIV application.

If the template contains the PIV AID, then no SELECT AID is done.
PIV standards say there can only be one PIV application on a card.
PIV standards also say PIV must be the the default application,
but Yubico does not follow this.

The command fails only then will a SELECT AID be done.

Thus this can avoid the Yubico problem.

This logic is used in both "match" and in the piv_card_reader_lock_obtained
routine.

Additional logic was in piv_card_reader_lock_obtained was added to handle
when the card reset was received by some other program. Multiple programs
may be trying to use the PIV application on the card, and thus multiple
programs will all receive that the card was reset. The first program to receive
the card was reset will do all of the above logic, and may leave the card in
a state will cause other programs to not  have to do much at all.

 The intent of all of this is to avoid sending extra commands to the card
 including SELECT AID that could change the card state when not needed.

 On branch piv-aid-discovery
 Changes to be committed:
	modified:   card-piv.c
2018-02-22 09:37:46 -06:00
Doug Engert 8cc0c3911a Yubico PIV application fixed CI_VERIFY_LC0_FAIL in version 4.3.2
Also add PIV card types to  sc_pkcs15_is_emulation_only

 On branch piv-aid-discovery

 Changes to be committed:
	modified:   src/libopensc/card-piv.c
	modified:   src/libopensc/pkcs15-syn.c
2018-02-22 09:33:30 -06:00
Frank Morgner 1d4f59ea51 compiler fix 2018-02-20 22:16:51 +01:00
Frank Morgner 86350d3f72 fixed compilation proble 2018-02-20 22:16:51 +01:00