Commit Graph

6645 Commits

Author SHA1 Message Date
Nuno Goncalves 37844fc6c3 Revert "pkcs11-tool: re-login if pincache is disabled or expired"
This reverts commit 1bc09ddafa.

This commit had totally wrong.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-02-04 22:44:26 +01:00
rickyepoderi c906c5e375 Use struct sm_cwa_session from sm.h in dnie (#955)
* Use cm_ctx instead of a custom cwa struct. Get rid of sc_reset.


* Use ifd.sn and icc.sn from sm_cwa_session struct too

* Minor typo with sizeof

closes https://github.com/OpenSC/OpenSC/issues/930
2017-02-04 22:32:35 +01:00
Nuno Goncalves 68f8f0bfa7 pkcs15-init,pkcs15-tool: reword --no-prompt to --use-pinpad (close #944) (#957)
* pkcs15-init,pkcs15-tool: reword --no-prompt to --use-pinpad (close #944)

Wording was confusing for a novice user. Old option is mantained as an alias,
but will print to stderr a deprecation warning.

Deprecation related code is all marked with deprecated word to easy future removal.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>

* pkcs15-init,pkcs15-tool: document --use-pinpad

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-02-03 17:01:52 +01:00
Jakub Jelen 92765f612e iso7816: Parse TL using ASN1 parser to avoid (possibly) wrong assumptions about length of both parts 2017-01-28 01:11:54 +01:00
Jakub Jelen 7033510e44 Add ATR to detect CardOS 5.3 2017-01-28 01:11:54 +01:00
Nuno Goncalves bb905ec1ec pkcs11-tool: small format fix (#950)
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-01-28 00:59:28 +01:00
Jakub Jelen 6aa52ce753 coolkey: Properly initialize serial length (partially resolves #943) 2017-01-23 13:31:26 +01:00
Jakub Jelen 9fd8a60cfa mcrd: Clean up drv_data in case of failure during initialization (partly resolves #943) 2017-01-23 13:31:26 +01:00
Nuno Goncalves 4b93f447d5 pteid: support iso7816 logged_in
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-01-13 15:46:05 +01:00
Frank Morgner 81d16fcc27 iso7816: propagate the PIN status on verify/change 2017-01-10 13:00:26 +01:00
Frank Morgner b577e8edbc card-cardos: Support PIN queries for CardOS 5 2017-01-10 13:00:26 +01:00
Frank Morgner 5a9d7e1c42 pkcs15-init: Fixed segfault
regression introduced in de7aaa4197

fixes https://github.com/OpenSC/OpenSC/issues/934
closes https://github.com/OpenSC/OpenSC/pull/935
2017-01-10 12:57:53 +01:00
Michał Trojnara 645780e6d4 NULL parameter check moved to sc_file_free()
This fixes numerous issues where the check is *not* performed,
and also simplifies the code.
2017-01-10 12:46:44 +01:00
Jakub Jelen 2c6dadfb44 Fix Coolkey memory management around SimCLists 2017-01-10 12:42:27 +01:00
Frank Morgner 24b7507a69 pkcs11: don't shrink the number of slots
... as required by PKCS#11 2.30, if the application doesn't call
`C_GetSlotList` with `NULL`.

Fixes ghost tokens in Firefox when detaching a reader that contained a
card.

Fixes https://github.com/OpenSC/OpenSC/issues/629
2017-01-09 08:35:42 +01:00
Frank Morgner 7e6dc25c40 remove all login states when the token was removed 2017-01-09 08:35:42 +01:00
ricky 42a9df3bd9 Avoid warning because no dnie_match_card 2017-01-08 17:13:13 +01:00
ricky 39f619fbb3 Disable dnie if not defined ENABLE_SM (issue #927) 2017-01-08 17:13:13 +01:00
Nuno Goncalves ebf0a8b9f5 Do not print data to terminal when output file is given.
This brings --read-data-object behavior in line with
--read-certificate, which only print the object to
stdout if no output file is given.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-01-08 17:10:33 +01:00
Jakub Jelen b3f047619d Prevent leaking memory from PIV readers 2017-01-05 16:34:40 +01:00
Viktor Tarasov b4cfb14e4c asn1: print in log part of raw data to decode
closes #926
2017-01-01 13:58:48 +01:00
Hannu Honkanen cd621531be card-dnie: Fix to dnie_ask_user_consent. Undefined flag caused a compilation error. 2017-01-01 13:58:48 +01:00
Hannu Honkanen 7598c822ed myeid: added card capabilities check to ...
... correctly determine which algorithms and key sizes are supported.
2017-01-01 13:58:07 +01:00
Martin Paljak 27c9daeede opensc-tool: only show the card name if present, to avoid "(null)"
Before:

$ opensc-tool -lv

Nr.  Card  Features  Name
0    No              FujitsuTechnologySolutions GmbH SmartCase KB SCR eSIG [SmartCase Smartcard Reader] 00 00
1    Yes             ACS ACR 38U-CCID 01 00
     3b:6e:00:00:80:31:80:66:b0:84:0c:01:6e:01:83:00:90:00 (null)

After:

$ opensc-tool -lv

Nr.  Card  Features  Name
0    No              FujitsuTechnologySolutions GmbH SmartCase KB SCR eSIG [SmartCase Smartcard Reader] 00 00
1    Yes             ACS ACR 38U-CCID 01 00
     3b:6e:00:00:80:31:80:66:b0:84:0c:01:6e:01:83:00:90:00

Change-Id: Id2cb858897cd845d93609e28019c94736b04fa93

closes #921
2017-01-01 13:40:39 +01:00
Peter Popovec 539c89e581 opensc-explorer: show tag 0x82 for unknown files
For reserved/unknown file type print value of 0x82 tag, instead of "???" string.

closes #918
2016-12-18 12:50:11 +01:00
Frank Morgner e7f118d797 config: added disable_popups for internal UI
closes #916
2016-12-18 12:38:28 +01:00
ricky b97efe1374 cwa-dnie is empty if openssl not defined
closes #914
2016-12-18 12:21:58 +01:00
ricky 06292563bc dnie: force caching of pin if DNIe is version 3.0 2016-12-18 12:21:46 +01:00
ricky e1b4bf4d2c dnie: lost change in the previous pull request ...
... and disable SM mode too.
2016-12-18 12:21:02 +01:00
Viktor Tarasov f0f453781e tools: fix segfault with verbose log into 'stderr'
Issue #824

In Windows, file handles (including 'stderr', 'stdout') can not be shared
between DLL-s, and so, the log handle (File *), defined in one module, cannot
be reused in another.

That is the situation when, for example, the SM is processed
in external, dynamically loadable module as it currently implemented for
IAS/ECC card.

That's for the configuration option 're-open of log file on each message' was
introduced.

This 're-open' logic has not been tested in the particular case of opensc-*
tools used with verbose log into 'stderr' -- in dynamically loaded module the
'stderr' handle, defined in the 'main' module, was not recognized as 'stderr'
and there was an attempt to close it.

closes #910
2016-12-18 11:31:00 +01:00
Viktor Tarasov f6a5885348 travis: allow failed cross-builds
closes #911
2016-12-18 11:29:06 +01:00
Frank Morgner dce379b43d pkcs11-tool: fixed missing newline in test output
regression of 4441efa6da
2016-12-14 21:18:58 +01:00
Pieter Naaijkens 13463e2d18 Add missing comma to fix segfault when pkcs11-tool is called without arguments 2016-12-14 19:47:24 +01:00
Frank Morgner 9e6dddb7dd pkcs15-tool: workaround for Apple stupidity
Fixes https://github.com/OpenSC/OpenSC/issues/886
2016-11-29 21:56:52 +01:00
Nuno Goncalves e80a95bc64 Improve format in compact format
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-11-22 21:27:00 +01:00
Jakub Jelen f432caf72c coolkey: Improve return values logging in init_ex() function 2016-11-22 21:21:06 +01:00
Jakub Jelen 365e29caae coolkey: Update to new API, use simplified log functions 2016-11-22 21:21:06 +01:00
Jakub Jelen 24346062c0 libpkcs11: Prevent double-free when the dlopen fails 2016-11-22 21:21:06 +01:00
Leonardo Brondani Schenkel c7007b0bdc libopensc: allow setting driver via OPENSC_DRIVER environment variable (#882) 2016-11-20 19:38:59 +01:00
Jakub Jelen 3cb24ebc79 Restore blocking WaitForSlotEvent functionality for recent PCSC-Lite versions
* Add configure-time dependency on pcsclite (required version from comments in reader-pcsc.c)
 * The functionality is already supported in PCSC-Lite
 * For older PCSC-Lite versions still return CKR_FUNCTION_NOT_SUPPORTED

 # closes #899
2016-11-20 19:36:03 +01:00
ricky 282632f7e6 cwa-14890: little issue in cwa_external_auth
# closes #903
2016-11-20 19:21:03 +01:00
ricky e6dca49169 cwa-14890: force to re-establish the SM when disconnected by another process. 2016-11-20 19:04:29 +01:00
ricky 1d051dba6a dnie: changes to include DNIe 3.0 (PIN channel) 2016-11-20 19:04:18 +01:00
Doug Engert 65090e814e pkcs15-cert: fix double free issue, memory leak and comment
if no extensions are found, val was uninitialized.
If multiple extensions, val was not freed for non interestinf extensions.
COmments dind not have valid OID values.

 On branch piv-keyusage
 Changes to be committed:
	modified:   pkcs15-cert.c

 # VTA: closes #905
2016-11-20 18:47:37 +01:00
Doug Engert 67ea96d18b piv: use cert keyUsage to set PKCS#11 key attributes
This mod is for non federal issued PIV cards. It will set PKCS#11 key attributes
based on the keyUsage extension from the coresponding certificates.

This mod applies to a PIV or PIV-like card without a CHUID or without a FASC-N
or a FASC-N that startes with 9999.  A federal issued PIV card will have a CHUID
object with FASC-N that does not have the agency code 9999.

If the certificate does not have keyUsage,the current defaults will be used.
This avoids backword compatability issues with cards in the field.

To take advantage of this mod, make sure certificates have keyUsage extension.
This mod applies to all keys on the card including retiered keys.

The NIST 800-73 standards specify the key usage for each key and different keys
have different PIN requirements. This mod is designed to be used with  PIV-like
cards or devices.

 On branch piv-keyusage
 Changes to be committed:
	modified:   src/libopensc/pkcs15-piv.c

 # squashed by VTA with:

Remove use of llu  in integer literal

llu in literals is not supported in all compilers.
let the compiler expand the literal befor doing the & opetation
2016-11-20 18:47:10 +01:00
Doug Engert 3ff7309520 Pkcs11-tool.c changes to accommodate ECDH operations using SoftHSM. (#901)
PKCS#11 v2.20 in not clear on the format of the public key of the other party
pased during ECDH key derivation. Some implementations (OpenSC) pass just the value
of the public key (RAW), while others (SoftHSM) pass an ASN.1 DER encoded OCTET_STRING.

PKCS$11 v2.40 points out this problem and says implementations must support the
RAW format and may also support the DER format.

To allow pkcs11-tool.c to work with ECDH derivation and using the current libSoftHSM2.so
a new parameter was added to pkcs11-tool, --derive-pass-der.

Also added to teh template fot the new key were:

CKA_SENSITIVE = false
CKA_EXTRACTABLE = true
CKA_VALUE_LEN = size of key to be derived.

OpenSC currently only support derivation of ECDH session keys, (CKA_TOKEN = false)
The derived key must be CK_KEY_TYPE = CKK_GENERIC_SECRET
Additional changes could be made to support AES or DES3 keys.

It is not clear if there is a need to support CKA_TOKEN =  true which says the
derived key must be on the hardware token. For ECDH, these keys are short lived.

 On branch pkcs11-tool-simple-ecdh
 Changes to be committed:
	modified:   src/tools/pkcs11-tool.c
2016-11-20 18:28:42 +01:00
Nuno Goncalves a25a2484f1 pkcs15-tool: add compact output format
Closes https://github.com/OpenSC/OpenSC/pull/900
2016-11-17 09:46:51 +01:00
Nuno Goncalves a16aaed41e pkcs15-tool: add --list-info option
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-11-17 09:46:44 +01:00
Nuno Goncalves 6cbc57a161 pkcs15-tool: make --list* messages consistent
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-11-17 09:46:39 +01:00
Nuno Goncalves dc073114a0 pkcs15-pteid: new implementation
This implementation reads most of the data from the pkcs15 structure on card, so the objects list are greatly reduced.

This improves several pending issues:

* drop support for IAS card type
In accordance to [1] IAS card type is no longer issued since version
004.003.11 (2010-06-15) and as a legal requirement all documents have
been destroyed or declared lost.

[1] https://www.cartaodecidadao.pt/documentos/DOC_01-DCM-15_V3_CC_Controlo_Versao_2016-01-20.pdf

* fix pteid_cert_ids
The Signature and Authentication Sub CA certificates ids were wrong.

* add objects and fix flags
Add Root CA certificate.
Add data objects SOD and TRACe
Data object 'Citizen Notepad' doesn't require login to be read. Remove flags.

* Support PIN max tries and tries left report

* Properly report cards with 2048b keys.

Suggested-by: João Poupino <joao.poupino@gmail.com>
Suggested-by: André Guerreiro <andre.guerreiro@caixamagica.pt>
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>

-- closes #806
2016-11-08 13:02:03 +01:00