Commit Graph

5543 Commits

Author SHA1 Message Date
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
Nuno Goncalves b2f6abded3 card-gemsafeV1: use iso7816 pin_cmd implementation
GemsafeV1 is compatible with iso7816 pin commands, including
SC_PIN_CMD_GET_INFO so it doesn't need to customize it.

Acked-by: João Poupino <joao.poupino@gmail.com>
Tested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-11-08 10:52:37 +01:00
Nuno Goncalves 68cbc288de card-gemsafeV1: fix driver name
Acked-by: João Poupino <joao.poupino@gmail.com>
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-11-08 10:52:37 +01:00
Doug Engert 16591d4182 prkey_fixup_rsa changes for OpenSSL-1.1.0
Remove restrictions in prkey_fixup_rsa:
  /* Not thread safe, but much better than a memory leak */
  /* TODO put on stack, or allocate and clear and then free */
Compute dmp1, dmp1 and/or iqmp if not in sc_pkcs15_prkey_rsa

Remove the GETBN macro that was causing problems.

 Changes to be committed:
	modified:   src/pkcs15init/pkcs15-lib.c

-- closes #894
2016-11-08 10:44:44 +01:00
Jakub Jelen 790ed5fcd7 Add Coolkey driver
Author: Robert Relyea <rrelyea@redhat.com>

Coolkey driver improvements:
 * Remove hardcoded list and use SimCList
 * Whitespace cleanup
 * Remove bogus if
 * drop inline keywords
 * proper path to include sys/types.h
 * full name of ushort type
 * condition to use compression
 * proper include path
 * Resolve template name conflict in Tokend

Clean up the copyright headers

-- rebased into one commit by VTA
-- closes #896
2016-11-08 10:40:07 +01:00
Frank Morgner de7aaa4197 pkcs15init: explicitly lock the card
Fixes https://github.com/OpenSC/OpenSC/issues/703
2016-10-31 12:35:22 +01:00
Frank Morgner 51c27f57a0 hex_to_bin: don't strip leading null-bytes
fixes https://github.com/OpenSC/OpenSC/issues/838

... and hopefully doesn't have any side effects
2016-10-31 12:34:44 +01:00
Nikos Mavrogiannopoulos c0196b4246 src/libopensc/Makefile.am: add missing header (#895)
That ensures that sc-ossl-compat.h is included on releases.
2016-10-31 12:12:18 +01:00
Doug Engert 0362439563 Move include for internal.h from aux-date.h to aux-data.c (#888)
with #861 internal.h, includes sc-ossl-compat.h  which requires
openssl header files. the tests/Makefile.am did not include the
openssl CFLAGS.
2016-10-16 20:09:00 +02:00
Ludovic Rousseau fad79ac2c3 pkcs15-tool: Fix compiler warning
pkcs15-tool.c:1201:5: warning: no previous prototype for ‘unlink_cb’ [-Wmissing-prototypes]
 int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
     ^~~~~~~~~
2016-10-14 17:36:19 +02:00
Ludovic Rousseau 8b761b830b pkcs11-tool.c: fix compiler warning
pkcs11-tool.c:2992:1: warning: control reaches end of non-void function
      [-Wreturn-type]
}
^
2016-10-14 17:36:19 +02:00
Ludovic Rousseau a3bf2efd53 src/tests/Makefile.am: fix compilation with OpenSSL
OpenSSL header files are used indirectly by the binaries.

Fix the compilation error:
  CC       base64.o
In file included from base64.c:6:
In file included from ../../src/libopensc/asn1.h:29:
In file included from ../../src/libopensc/pkcs15.h:29:
In file included from ../../src/libopensc/aux-data.h:31:
In file included from ../../src/libopensc/internal.h:44:
../../src/libopensc/sc-ossl-compat.h:30:10: fatal error: 'openssl/opensslv.h'
      file not found
         ^
1 error generated.
2016-10-14 14:06:07 +02:00
Feitian Technologies 426f266dfa Solve #871 #731 #730
1. Solved multiple epss2003
2. check expats point to prevent memory leak
3. Add new ATR for entersafe PKI card
4. declare all variables at the beginning of block
5. Solved Incorrect PIN raise wrong CKR error, no token flags change

Closes https://github.com/OpenSC/OpenSC/pull/879
2016-10-10 22:41:01 +02:00
Jakuje 12f4026160 Fix Coverity remarks (#876) 2016-10-10 22:21:46 +02:00
Doug Engert c6dba96f55 Add support for LibreSSL compatability as well as OpenSSL-1.1.0
This commit is based on input from https://github.com/lbschenkel
LibreSSL is based on OpenSSL 1.0.1. API.

 Changes to be committed:
	modified:   libopensc/sc-ossl-compat.h
	modified:   tools/pkcs11-tool.c
	modified:   tools/pkcs15-init.c
	modified:   tools/sc-hsm-tool.c
2016-10-08 06:17:44 -05:00
Doug Engert 5fb4db6373 Use OpenSSL versions OpenSSL-0.9.7 to 1.1.0a for OpenSC
OpenSSL-1.1.0 was released 8/25/2016
OpenSSL-1.1.0a was released 9/22/2016

  https://www.openssl.org/news/openssl-1.1.0-notes.html

Changes to allow the OpenSC code base to work with OpenSSL versions from
0.9.7 to 1.1.0 with few changes.

This is an update and rebased version of my prep-openssl-1.1.0-pre6 branch.

No attempt was made to back port any OpenSSL features. These changes
just allow an updated OpenSC code base to use what is in the various OpenSSL
releases.

A new header libopensc/sc-ossl-compat.h contains extra defines
to reduce the need for so many #if OPENSSL_VERSION_NUMBER statements
in the source code.

The OpenSC source can now use the OpenSSL 1.1 API. The libopensc/sc-ossl-compat.h
has defines for the new API for use with older versions of OpenSSL.

sc-ossl-compat.h is included by libopensc/internal.h so all OpenSC
library routines can take advantage of it. For the tools, which do not use
libopensc/internal.h, libopensc/sc-ossl-compat.h is included by the tools.

The OpenSC source has been modified to use OpenSSL functions to access
hidden structures, such X509, BIGNUM, EVP_CIPHER_CTX, and use XXX_new
functions to allocate structures which must use pointer such as
BIGNUM and EVP_CIPHER_CTX.

For backward compatability sc-ossl-compat.h now defines inline routines
to emulate the RSA and DSA  access routines in OpenSSL-1.1.0. Thus
the same OpenSC source code can be used with openSSL versions from
0.9.7 to 1.1.0.

Inline routines were chosen, because using macros does not work on all platforms.
Having OpenSC versions of these routines in libopensc would be a posibility,
but they are only used for older version of OpenSSL, and could be removed in
the future.
 Changes to be committed:
	modified:   src/libopensc/card-entersafe.c
	modified:   src/libopensc/card-epass2003.c
	modified:   src/libopensc/card-gids.c
	modified:   src/libopensc/card-gpk.c
	modified:   src/libopensc/card-oberthur.c
	modified:   src/libopensc/card-piv.c
	modified:   src/libopensc/card-westcos.c
	modified:   src/libopensc/cwa-dnie.c
	modified:   src/libopensc/cwa14890.c
	modified:   src/libopensc/internal.h
	modified:   src/libopensc/p15card-helper.c
	modified:   src/libopensc/pkcs15-itacns.c
	modified:   src/libopensc/pkcs15-prkey.c
	modified:   src/libopensc/pkcs15-pubkey.c
	new file:   src/libopensc/sc-ossl-compat.h
	modified:   src/pkcs11/openssl.c
	modified:   src/pkcs15init/pkcs15-lib.c
	modified:   src/pkcs15init/pkcs15-oberthur-awp.c
	modified:   src/pkcs15init/pkcs15-oberthur.c
	modified:   src/pkcs15init/pkcs15-oberthur.h
	modified:   src/pkcs15init/pkcs15-westcos.c
	modified:   src/tools/cryptoflex-tool.c
	modified:   src/tools/gids-tool.c
	modified:   src/tools/netkey-tool.c
	modified:   src/tools/piv-tool.c
	modified:   src/tools/pkcs11-tool.c
	modified:   src/tools/pkcs15-init.c
	modified:   src/tools/sc-hsm-tool.c
	modified:   src/tools/westcos-tool.c
2016-10-08 06:15:06 -05:00
Frank Morgner 44694a0cf3 pkcs15-tool: implemented --clear-cache (#873) 2016-10-07 14:19:03 +02:00
Frank Morgner 28958af559 added compatibility function for VC14 2016-10-07 14:17:40 +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
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
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
Frank Morgner b232c9b675 card-starcos: use transceive length from EF.ATR
fixes https://github.com/OpenSC/OpenSC/issues/765
2016-07-19 14:30:45 +02:00
Frank Morgner 2909ba28a9 parse Extended Length Information in EF.ATR/INFO 2016-07-19 14:30:38 +02:00
Frank Morgner 9a325fc1db EF.ATR: removed IAS/ECC workaround
- IAS/ECC has the category indicator byte in EF.ATR, which is a
  violation of ISO 7816-4, where it is only allowed in the historical
  bytes of ATR. Removing the IAS/ECC specific modification of EF.ATR
  allows reading ISO complient EF.ATR again.
- IAS/ECC parsing should still be successfull. We now always try to
  check for ISO7816_TAG_II_STATUS_SW ignoring the category indicator
  byte
2016-07-19 14:30:31 +02:00
HAMANO Tsukasa cb1da562f4 JPKI: fix prkey usage 2016-07-19 10:23:31 +02:00
HAMANO Tsukasa 33a16b4f4e New: jpki card driver
VTA: cosmetic touch and rebase to one commit
close PR #801
2016-07-17 16:36:13 +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
Nuno Goncalves 1198197586 pkcs11-tool: use CKF_{SO,USER}_PIN_* flags to provide alerts to the user
rebased by @viktorTarasov
initial version in PR-795
2016-07-17 13:22:55 +02:00
Nguyễn Hồng Quân 46d8264f08 pkcs15-openpgp: Change sprintf to snprintf. 2016-07-17 13:22:55 +02:00
Nguyễn Hồng Quân 91fc129f19 PKCS15-OpenPGP: Change error log
Only one DO is supported now.
2016-07-17 13:22:55 +02:00
Frank Morgner 14b57ffb3e Merge pull request #743 from Jakuje/jjelen-truncate-ecdsa-signature
Truncate data for ECDSA signature to the size of the key
2016-07-08 01:35:34 +02:00
Frank Morgner 1c661ca023 Merge pull request #732 from metsma/P11Label
Move PIN type label front of description
2016-07-08 01:34:37 +02:00
Frank Morgner e98315a196 libsm: fixed out of bounds write
`sm_incr_ssc` performed an out of bounds write when `ssc` is bigger than
255. The local variable `ii` needs to be decremented instead of
incremented in the `for`-loop.

This was introduced in d30cd83a, wheras The previous implementation did
actually decrement `ii`, see d30cd83ad4

Fixes https://github.com/OpenSC/OpenSC/issues/785
2016-06-30 21:57:47 +02:00
David von Oheimb 4441efa6da pkcs11-tool: various improvements, extensions, fixes, cleanup
========================================
rebased by VTA -- commits are forged to one,
excluding the following chunk
(reason -- if not explicitely indicated, the mechanism has to be found out using the mechanism flags):

@@ -1713,8 +1713,9 @@ static int gen_keypair(CK_SLOT_ID slot, CK_SESSION_HANDLE session,
                        int ii;

                        if (!opt_mechanism_used)
+                               opt_mechanism = CKM_EC_KEY_PAIR_GEN;
                                if (!find_mechanism(slot, CKF_GENERATE_KEY_PAIR, mtypes, mtypes_num, &opt_mechanism))
-                                       util_fatal("Generate EC key mechanism not supported\n");
+                                       util_warn("Generate EC key mechanism not listed as supported");

                        for (ii=0; ec_curve_infos[ii].name; ii++)   {
                                if (!strcmp(ec_curve_infos[ii].name, type + 3))

will close PR #747
2016-06-29 14:18:56 +02:00
Viktor Tarasov 76e0e19460 pkcs11-tool: no error when getting sensitive attr. value
resolves PR #807
2016-06-29 10:34:20 +02:00
Viktor Tarasov 3dbcc0b035 pkcs11-tool: generate secret key
resolve PR #808
2016-06-29 10:32:30 +02:00
Frank Morgner 97b8bf4fd1 Merge pull request #789 from jasp00/dnie-ui
Fix interaction with DNIe UI
2016-06-25 22:43:07 +02:00
Frank Morgner 072ec98301 Merge pull request #772 from vletoux/gids_maintenance
gids bug fixing
2016-06-25 22:32:37 +02:00
vletoux 0ae4b4ac0d gids bux fixing
fix the problem if the serial number is entered in the command line
2016-06-24 21:20:40 +02:00
Frank Morgner 0898d06944 fixed and cleaned up nmake Makefiles 2016-06-23 07:35:53 +02:00