Commit Graph

6506 Commits

Author SHA1 Message Date
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
Frank Morgner 83934db970 ignore some more generated files 2016-10-31 12:34:10 +01:00
Frank Morgner c4a99517af only build opensc when needed 2016-10-31 12:34:10 +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 b1aa79058a MacOSX/build-package: fix build for make multi jobs
If --jobs=... argument is used for make (or the equivalent MAKEFLAGS is
defined) then the command "make clean update depend" fails because the 3
actions must be done in sequence and not in parallel.
2016-10-14 14:12:15 +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
Ludovic Rousseau 0f69949bbf MacOSX: fix OpenSSL check in build-package.in
OpenSSL is configured to be installed in $PREFIX so the files should be
checked in $BUILDPATH/openssl_bin/$PREFIX/lib/pkgconfig and not
$BUILDPATH/openssl_bin/lib/pkgconfig
2016-10-14 14:02:21 +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 1893dcf3cb AppVeyor: use Github as zlib download mirror
fixes downloading problems with Sourceforge
2016-10-07 14:17:40 +02:00
Frank Morgner 84ba7dd551 AppVeyor: Use static names for artifacts
Allows Link to the latest Artifacts of master:
https://ci.appveyor.com/api/projects/LudovicRousseau/OpenSC/artifacts/OpenSC-win32_vs12-Release.msi?branch=master&job=Environment%3A%20VSVER%3D12%3B%20Configuration%3A%20Release%3B%20Platform%3A%20x86
https://ci.appveyor.com/api/projects/LudovicRousseau/OpenSC/artifacts/OpenSC-win64_vs12-Release.msi?branch=master&job=Environment%3A%20VSVER%3D12%3B%20Configuration%3A%20Release%3B%20Platform%3A%20x64
https://ci.appveyor.com/api/projects/LudovicRousseau/OpenSC/artifacts/OpenSC-win32_vs12-Light-Release.msi?branch=master&job=Environment%3A%20VSVER%3D12%3B%20Configuration%3A%20Light-Release%3B%20Platform%3A%20x86
https://ci.appveyor.com/api/projects/LudovicRousseau/OpenSC/artifacts/OpenSC-win64_vs12-Light-Release.msi?branch=master&job=Environment%3A%20VSVER%3D12%3B%20Configuration%3A%20Light-Release%3B%20Platform%3A%20x64
2016-10-07 14:17:40 +02:00
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