Commit Graph

111 Commits

Author SHA1 Message Date
Frank Morgner 74ec7b04ff sc-hsm: Add support for SoC
- eac: allow CA without EF.CardSecurity
- sc-hsm: implemented CA based on document PKI
- sc-hsm: adds receive limit for SoC card
- introduces dedicated card type for SoC card
- md: integrate card's PIN pad capabilities
- installer: added SC-HSM SoC card to registry
- pkcs15-tool: Added support for PIN entry on card
- change/unblock PIN: add support for PIN entry on card
- added OpenPACE to macOS build
- travis-ci: install gengetopt/help2man via brew
- sc-hsm: Cache EF.C_DevAut
- sc-hsm: Prevent unnecessary applet selection and state resets
- sc-hsm: added support for session pin
- sc-hsm: avoid multiple AID selection
- sc-hsm: Use the information from match_card for all subsequent selections of the applet
- sc-hsm: cache optional files as empty files (Decoding the files will reveal that they were not existing prior caching. This avoids selecting the file though we have already tried to cache the file before.)
- use dedicated directory for CVC trust anchors
- appveyor: added OpenPACE to windows build
2017-05-22 16:25:08 +02:00
Hannu Honkanen e6f7373ef0 Added a check to sc_pkcs15_verify_pin to find out if the access condition is already open on card. This check is performed only if this function is called with empty data. This change fixes a problem with pinpad readers, when PIN cache is disabled and prevents unnecessary PIN queries. 2017-04-19 10:57:54 +02:00
Frank Morgner e7915ec198 replace assert with error handling 2017-04-04 09:11:35 +02:00
Maciej S. Szmigiero 62cbda6cd9 Fix log messages format and parameter issues flagged by GCC
Since "Add GCC format checking attributes to log functions" commit GCC
warns us about problems with format strings and their arguments provided
to OpenSC message logging functions.

This commit fixes all cases where GCC warned about incorrect format on
64-bit Linux, 32-bit and 64-bit mingw builds (with SM and OpenSSL enabled).
Well, almost all since on mingw GCC does not recognize "ll" size specifier
(present at least since Visual Studio 2005, also in mingw own CRT) so these
(few) warnings about it remain.

In most cases format size specifier for size_t type was missing (usually
size was left at default int level, with is different on 64-bit x86).
Some formats had too few / too many arguments.
In some cases pointers were printed as integers.
Some long variables were missing "l" prefix (especially with regard to %x
format).

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2017-03-27 11:05:16 +02:00
Nuno Goncalves ccc7e2f109 Improve pinpad use detection
Pinpad is used it it is present and if no pin string is provided (pinlen==0).

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-02-04 22:44:26 +01:00
Nuno Goncalves c6a9201b62 Validate PIN before verification
_validate_pin was not being called at all during a PIN verification.

After this tools report correctly when the PIN length is invalid, even on pkcs11 layer.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-02-04 22:44:26 +01:00
Jakuje 12f4026160 Fix Coverity remarks (#876) 2016-10-10 22:21:46 +02:00
Frank Morgner cda3a2b5ad Initialize PIN logged_in field for default PKCS#15 data 2016-09-01 02:17:29 +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
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
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 2f10de4f5c use sc_pkcs15_get_pin_info in C_GetTokenInfo
introduced paramter to signal back the login state
- used for the pin command SC_PIN_CMD_GET_INFO
- implemented in accordance to ISO 7816-4; all other implementations
  are currently set to an unknown login state

implemented and exporeted sc_pkcs15_get_pin_info

use sc_pkcs15_get_pin_info in C_GetTokenInfo

C_GetSessionInfo: Check whether a logout was done

Closes https://github.com/OpenSC/OpenSC/pull/624

rebased by @viktorTarasov
2016-07-17 14:07:43 +02:00
Andreas Schwier 83a28a1bc3 pkcs15: Observe path.aid for PIN operation 2015-09-25 11:56:32 +02:00
Andreas Schwier c41153aa13 pkcs15: Select application defined by path.aid for PIN verification 2015-09-23 15:36:56 +02:00
vletoux f154cdcaa4 pkcs15-pin: sc_pkcs15_unblock_pin: avoid to ask the PUK twice 2015-05-08 22:37:04 +02:00
Frank Morgner bcb5fc15e5 honour HAVE_CONFIG_H 2015-04-22 23:55:33 +02:00
Viktor Tarasov 46c86fcb66 coding style: use short form of debug macros 2014-01-19 19:19:17 +01:00
Viktor Tarasov 3f023d3342 pkcs15: PIN value not validated in pkcs15-verify
In pkcs15-verify the value of PIN is not more validated for conformity with PIN policy,
value is only checked for maximal allowed length.

So that, no more need of 'ignore-pin-length' configuration option - now it's default behavior of common framework.
2014-01-19 19:19:17 +01:00
Doug Engert a3b516a1e1 Add pin_cache_ignore_user_consent parameter to opensc.conf
When OpenSC is used with a card that enforces user_consent
and the calling PKCS#11 application does not understand how
to handle the CKA_ALWAYS_AUTHENTICATE, signature operations
will fail.

OpenSC will not cache a PIN that protects a user_consent
object as one would expect.

This mods allows PINs to be cached even if protecting a
user_consent object by adding
 pin_cache_ignore_user_consent = true;
option in opensc.conf.

Thunderbird is the prime example of this situation.
Mozilla has accepted mods (357025 and 613507) to support
CKA_ALWAYS_AUTHENTICATE that will appear in NSS-3.14 but
this may be some time before this version is in vendor
distribution.
2012-08-12 00:11:03 +02:00
Viktor Tarasov 1d2661c7ce pkcs15-pin: 'PIN' as particular choice of 'AuthenticationType'
Encode/decode 'PIN' pkcs15 object as particular choice of 'AuthenticationType' data.
Rudimental encoding/decoding of 'authKey' object.
2012-05-31 10:37:38 +02:00
Stef Walter 6ed52a06b8 libopensc: Don't fail to allocate memory when mlock fails
* Print out warning when mlock fails, and continue.
 * The warning required a ctx to be passed in, so that means
   changing a few function signatures.

https://www.opensc-project.org/opensc/ticket/389
2012-02-17 10:02:55 +01:00
vtarasov d888b3fd55 pkcs15: use general 'AuthenticationObject' instead of 'PinObject'
now the attributes of the previous 'pin-info' data type are included
as the sub-type attributes of the general 'auth-info' data .
It will allow to include support of the 'biometricTemplate' and 'authKey' authentication types.

http://www.opensc-project.org/pipermail/opensc-devel/2011-May/016655.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5550 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 15:46:25 +00:00
andre 3442649b42 pkcs15-pin: Fixing the method of obtaining objects protected by a particular PIN. Now it's in accordance with PKCS15. See [http://www.opensc-project.org/pipermail/opensc-devel/2011-January/015818.html discussion].
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5222 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-07 16:15:41 +00:00
vtarasov 33f44f8dc1 pkcs15: pin references are always positive integers ...
In the OpenSC versions previous to 0.11.5 the references greater then
127 were erroneously encoded by one byte (negative value ecording to the
ASN.1 rules).
Actually some other proprietary PKCS#15 cards have also this infirmity.

Actual commit makes general the application of the hack used for 'starcos' card.

http://www.opensc-project.org/pipermail/opensc-devel/2011-February/016062.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5220 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-06 12:35:35 +00:00
martin 03be594243 core: Fix PIN caching for PIN codes protecting user consent keys, broken in r4048
Such PIN codes were erroneously cached in memory, even though not used with revalidation..
User consent relates to private keys, not PIN codes.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5124 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-27 14:25:35 +00:00
vtarasov 47f997983e pkcs15: simplify PIN's path assignement
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5110 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-18 16:17:15 +00:00
andre 752af86f2b pkcs15-pin.c: fixes segmentation fault in the case where p15card->app == NULL
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5104 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-17 21:09:48 +00:00
vtarasov 2c6d3ee9fa pkcs15: comments and debug messages
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5094 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-17 13:11:21 +00:00
vtarasov e98dee0092 pkcs15: asn1: local PIN should have a path defined ...
if there is no 'path' in the 'PinAttributes', use DDO.AID or application path as a PIN's path.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5081 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-11 10:12:42 +00:00
andre 5b69b39c33 sc_pkcs15_pincache_revalidate: Avoid compiler warning 'discards qualifiers from pointer target type'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4927 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-06 18:59:49 +00:00
andre ea4ddf8f17 pkcs15-pin: If the usage counter of a cached PIN is expired, then free that cached PIN instead of freeing the objects content that is protected by the PIN.
If re-validation of a cached PIN fails, then free that cached PIN to ensure that it isn't used again for re-validation.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4924 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-06 18:33:17 +00:00
viktor.tarasov 58c1c88efa libopensc: homogenise line ending in the debug messages
continuating r4759


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4774 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-25 20:35:59 +00:00
martin befff1b0d4 libopensc: PIN usage counter is decreased every time it is sent to the card, no matter what the card replies (should probably reply with success)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4665 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-01 06:23:43 +00:00
viktor.tarasov d9b0d643de libopensc: in sc_pkcs15_verify_pin() if no PIN provided try to use pin pad
It's a complement to the r4361.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4362 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-19 08:37:29 +00:00
aj 6545b42c02 cleanup of the debug code:
* reduce to a few, supported functions.
* change all functions to take the debug level as parameter.
* use symbolic names for the debug levels.
* fix tools to pass "verbose"/"opt_debug" as ctx->debug.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4118 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-15 12:17:13 +00:00
viktor.tarasov 052881c38f libopensc: in pkcs15 PIN commands 'pin_info' parameter replaced by 'pin_object'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4103 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-10 09:23:01 +00:00
aj d22a2483c0 Header file cleanup.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4081 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-04 08:14:36 +00:00
viktor.tarasov 975d703c0d libopensc: remove unused variables
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4063 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-21 20:46:59 +00:00
martin 23b7c2673c pincache: pkcs15-pin.c:515: warning: unused variable ‘i’
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4061 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-21 19:54:59 +00:00
martin 7b6d2525da pincache: correct message for user consent PINs (it is a matter of policy not software support)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4060 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-21 19:53:53 +00:00
viktor.tarasov 9c964e3d71 pincache: implement pincache as the content of the AUTH pkcs15 object
; in 'sc_pkcs15_pin_info' structure add 'auth_method' member to keep the PIN authentication method: CHV, AUT or SM;
; in pkcs15init profile add function to search PIN template by auth method and reference;
; in 'sc_pkcs15_remove_object' return silently if object to delete is NULL;
; in 'sc_pkcs15_object' structure add 'usage_counter' member;
; new 'sc_pkcs15_find_pin_by_type_and_reference' procedure to search PIN pkcs15 object by auth method and reference;
 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4048 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-20 22:04:07 +00:00
viktor.tarasov 7f0abe80bb libopensc pkcs15: path is optional for PinAttributes of PinObject
- for 'global' PINs path in not encoded into the AODF;
- when selecting pin_reference, start from value defined in profile.




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3946 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 17:03:04 +00:00
martin d006b1845e libopensc:
- Remove slot abstraction from internal API and all reader drivers. CT-API (from where it all comes from) readers with multiple slots (if still found) can be presented as separate readers, OpenCT should remove the slot abstraction, PC/SC never knew about it. None of the tools knew how to use slots.
 - Add sc_cancel (translates to SCardCancel)
 - Re-implement sc_wait_for_event; support a blocking call.
 - Replace the "int reader" API with "* sc_reader_t" style; add "Get reader by name" functionality.
 - Remove "action" parameter from sc_disconnect_card() (was not used)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3931 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 15:25:08 +00:00
aj f0484968a9 merge changes 0.11.11 -> 0.11.12
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3899 c6295689-39f2-0310-b995-f0e70906c6a9
2009-12-18 13:33:03 +00:00
viktor.tarasov 193ca76980 pkcs15-tool: change PIN with pinpad
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3883 c6295689-39f2-0310-b995-f0e70906c6a9
2009-12-03 12:51:12 +00:00
martin 95a5ab0654 Re-implement PIN cache on PKCS#15 layer; remove it from PKCS#11. Re-name and log PKCS#15 options to better reflect the purpose.
Data objects and PKCS#15 init are left broken currently.



git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3784 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-22 08:59:59 +00:00
alonbl e14cf57ad1 Better handle openct reader replug, revert last change in pkcs11-pin
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3512 c6295689-39f2-0310-b995-f0e70906c6a9
2008-05-10 09:55:01 +00:00
alonbl a40cf036bb Fix sc_pkcs15_verify_pin() to handle OpenCT hotplug correctly
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3511 c6295689-39f2-0310-b995-f0e70906c6a9
2008-05-09 22:22:41 +00:00
alonbl 96b0f4a670 Verify PIN support Plug&Play
If card was reset or reader reconnected, verify can restart
transaction, as upper level will not cache PIN in this case.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3508 c6295689-39f2-0310-b995-f0e70906c6a9
2008-05-02 17:56:52 +00:00
nils d08c8344ec encode max pin length as well
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3092 c6295689-39f2-0310-b995-f0e70906c6a9
2006-12-22 12:43:00 +00:00