Commit Graph

5038 Commits

Author SHA1 Message Date
Andreas Jellinghaus 9fed9591ca Fix regression test crypt0007: it deals with 1024 bit keys (not 1048).
Signed-off-by: Andreas Jellinghaus <andreas@ionisiert.de>
2015-07-26 21:35:29 +02:00
Andreas Jellinghaus 4dfbf24a3e Fix regression test suite: rename parameters to new names.
Signed-off-by: Andreas Jellinghaus <andreas@ionisiert.de>
2015-07-26 21:34:51 +02:00
Frank Morgner 28de49b34c Merge pull request #448 from sschutte/patch-1
Create minidriver-italian-cns.reg
2015-07-23 13:11:39 +02:00
Frank Morgner ee68165b1d Merge pull request #474 from germanblanco/memory_allocation_5
Fixing part of the memory allocation problems in DNIe module. Issue #472
2015-07-23 13:10:14 +02:00
Frank Morgner 142323af10 Merge pull request #476 from germanblanco/dnie_ui_depends_on_ssl
Empty user-interface.c if there is no SSL support. Related with issue #362
2015-07-23 13:08:46 +02:00
Frank Morgner 7cec500e54 added flags to sc_context_t
- is initialized in sc_context_create with parm->flags
- removes members paranoid_memory and enable_default_driver
2015-07-22 17:30:21 +02:00
Frank Morgner edc839e072 restrict access to card handles after fork
fixes #333
closes #493
2015-07-22 16:46:04 +02:00
German Blanco 317cc302db making the size of e_tx in cwa-dnie.c dynamic 2015-07-10 12:38:22 +02:00
Nguyễn Hồng Quân d0e3d1be3d Fix tab & spaces 2015-07-04 00:21:38 +08:00
Hubitronic 5898eab373 Update card-muscle.c
re-enable opensc.conf flexibility again
2015-06-18 16:28:11 +02:00
German Blanco 030f4d1559 Empty user-interface.c if there is no SSL support. 2015-06-01 08:21:25 +02:00
German Blanco 0d14f3ffee Correct initializing of a variable in card-dnie and revert buffer size change in cwa-dnie. 2015-06-01 07:46:59 +02:00
German Blanco 76517b7d43 Fixing part of the memory allocation problems in DNIe module. 2015-05-26 21:44:13 +02:00
Doug Engert b48fa70308 sc_pkcs11_card improvements
This is name change only fix.

    The variable name "card" was being used to refer to a struct sc_card or a struct sc_pkcs11_card
    in some files including sc_pkcs11.h. In other files the variable name "p11card" is used for struct sc_pkcs11_card.
    This creates hard to read code, such as: slot->card->card.

    All definitations of sc_pkcs11_card *card now use p11card as the variable name.

Fix #471
2015-05-24 11:41:29 +02:00
David Woodhouse 8c94662e96 Add --test-fork option to pkcs11-tool
The PKCS#11 Usage Guide, at least up to v2.40, says that calling
C_Initialize() in the child after fork is "considered to be good
Cryptoki programming practice, since it can prevent the existence of
dangling duplicate resources that were created at the time of the fork()
call."

(It neglects to mention that doing so in the child of a multi-threaded
process is a clear violation of POSIX, mind you. Not to mention being
utterly pointless if all you're going to do in the child is exec something
else anyway.)

Regardless of the sagacity of this recommendation, we need to cope when
it happens. Historically, we've been quite bad at that. Let's add a test
to pkcs11-tool in the hope it'll help...

Fixes #464
2015-05-16 12:18:54 +02:00
vletoux 01b395e636 card-masktech.c: add 2 more ATR
Fixes #465
2015-05-16 12:09:08 +02:00
drew thomas 5be35fb3f4 muscle: change TyfoneAT historical bytes to 'Tyfone 242R2'
Fixes #467
2015-05-16 11:59:58 +02:00
Andreas Kemnade a09ca246a7 libopensc: initialize value returned by sc_select_file
several places in the code expect sc_select_file to set *file_out to NULL
in case of failure. Adjust the function to behave like this.

Fixes #460
2015-05-13 10:19:38 +02:00
Andreas Kemnade 6a6ef61d1a some more error checks in minidriver in regards to card ejects 2015-05-13 10:11:05 +02:00
vletoux 492ffe0fd7 iso7816.c: allow file length stored in more than 2 bytes
as indicated in iso7816-4 chapter 7.4.3 table 10

Fixes #459
2015-05-13 10:01:29 +02:00
drew thomas 8b62221abc muscle: add ATR of Tyfone mSD card
Add Tyfone Connected Smart Card ATR to list for MUSCLE support.

SC_CARD_TYPE_MUSCLE_JCOP242_NO_APDU_EXT

Fixes #463
2015-05-13 09:50:21 +02:00
Doug Engert c7af08c68a PIV - read just length of object to get size
card-piv.c tries to read the first 8 bytes of an object to get object size
so it can allocate a buffer. It then reads the whole object. apdu.c has changed
over the years, and apdu.c will keep reading as long as the card returns
status of 61 XX  thus apdu.c will read the whole object while discarding
the extra data and returning to the caller only the first part of the data.
This in effect causes a double read of objects.

This patch sets SC_APDU_FLAGS_NO_GET_RESP to tell apdu to stop doing the
extra get-response commands thus avoiding most of the extra overhead.

This in not an optimal patch as it only works with T=1 cards/readers
but the patch is confined to just card-piv.c.
A better patch is in the works.

Fixes #462
2015-05-13 09:24:46 +02:00
Viktor Tarasov 72b5d8fe9a md: use 'store-or-update' store certificate mode 2015-05-10 15:04:44 +02:00
vletoux 8ec000e80d minidriver: change the icon of the pinpad dialog 2015-05-10 15:04:44 +02:00
vletoux ac82a96ccc minidriver: add my name in the author list
setup: change the url to match the new one
2015-05-10 15:04:44 +02:00
vletoux aede9b164b minidriver: fix compilation warnings on x64 (size_t <> DWORD) 2015-05-10 15:04:44 +02:00
vletoux 33cf161941 minidriver: pinpad authentication is now working for smart card logon !!! (still needs 5 pinpad entries)
minidriver: minor fixes
2015-05-10 15:04:41 +02:00
vletoux 6127fe6b77 minidriver: change the UI (remplace a messagebox by a nice dialog) ; add a translation function for errors 2015-05-10 15:04:41 +02:00
vletoux 7d225e28f7 minidriver: add support for the special msroot file which contains the root certificates stored on the card. 2015-05-10 15:04:41 +02:00
vletoux 6b58b1db01 minidriver: merge CardUnblockPin and CardChangeAuthenticator into CardChangeAuthenticatorEx 2015-05-10 15:04:41 +02:00
vletoux a671cf8fe2 CardAuthenticateEx: test for remaining attempts before ... 2015-05-10 15:04:41 +02:00
vletoux 659da4f538 minidriver: CardSignData - better parameter checking 2015-05-10 15:04:41 +02:00
vletoux f3c9525137 fix attempt remaining regression if the card is blocked 2015-05-10 15:04:40 +02:00
vletoux d96e53b102 minidriver: better error code if CARD_PIN_SILENT_CONTEXT is set 2015-05-10 15:04:40 +02:00
vletoux ad47d4d043 minidriver:
* factorize the code from CardAuthenticatePIN into CardAuthenticateEx
* allows authentication with the PINPAD without a UI

minidriver: fix some code analysis warnings
2015-05-10 15:04:36 +02:00
vletoux 8062eac145 minidriver: fix CardQueryCapabilities and CardGetProperty fKeyGen flag. A read only card cannot generate keys 2015-05-10 15:04:36 +02:00
vletoux f331b35c4e minidriver: make the parameter check be aware of pinpad capabilities 2015-05-10 15:04:36 +02:00
vletoux a5593afc78 minidriver: better parameter checking with CardQueryKeySizes and CardGetContainerProperty 2015-05-10 15:04:36 +02:00
vletoux 1e78e16e65 fix memory leak in minidriver: the virtual filesystem is never freed and in some case when an error occurs 2015-05-10 15:04:35 +02:00
vletoux 8036388f29 minidriver PINPAD: fix a regression issue (the parameter - message - can be set to null)
Improve the error code when the user cancel the operation ("The operation was canceled by the user" instead of "invalid parameter")

Signed-off-by: vletoux <vincent.letoux@gmail.com>
2015-05-10 15:04:35 +02:00
vletoux cb38657d47 CardSignData: add support for missing hash algorithm 2015-05-10 15:04:35 +02:00
vletoux c5efcae029 CardRSADecrypt: better parameter checking
CardRSADecrypt & CardSignData: better OpenSC -> minidriver error code translation
2015-05-10 15:04:28 +02:00
vletoux 9544844d83 CardSignData: better error message if the card do not support the signing operation with the algorithm
(replace the return code from internal error to unsupported)
2015-05-10 14:35:42 +02:00
vletoux 54f462368b Fix CardSignData "invalid signature" bug when called from CryptSignHash(CRYPT_NOHASHOID) 2015-05-10 14:35:42 +02:00
vletoux 6aaf9d462c fix a problem: CardDeauthenticate(ex) do nothing, but the base CSP think that the user is deauthenticate from the card.
The user is still authenticated !
2015-05-10 14:35:41 +02:00
vletoux b7f000d6b8 add parameter checking for CardSignData 2015-05-10 14:35:41 +02:00
vletoux 2667394f22 better parameter checks for CardGetProperty and CardSetProperty
Added value for secure key injection (to reject it properly because it is not implemented)
2015-05-10 14:35:41 +02:00
vletoux 6a2e9aa3b6 Merge branch 'upstream/master'
Conflicts:
	src/libopensc/card-openpgp.c
	src/libopensc/pkcs15-gemsafeV1.c
	src/pkcs11/mechanism.c
2015-05-10 14:35:41 +02:00
Viktor Tarasov e0aec3764a pkcs15init: 'store-or-update' certificate option 2015-05-10 14:35:41 +02:00
Viktor Tarasov 3cf56d8fb7 pkcs15init: fix non-unique-ID control 2015-05-10 14:35:41 +02:00
vletoux f154cdcaa4 pkcs15-pin: sc_pkcs15_unblock_pin: avoid to ask the PUK twice 2015-05-08 22:37:04 +02:00
Viktor Tarasov 3e0356b170 register CKM_ECDSA and CKM_ECDSA_SHA1 depending on card capabilities
fix #429
2015-05-08 20:45:56 +02:00
Philip Wendland 254320e34c myeid: seperate ECC from RSA flags
Should keep the existing behavior, but improve readability.
2015-05-08 20:45:37 +02:00
Philip Wendland 4142456c74 PIV, sc-hsm, myeid: register ECDH card capabilites
Prior to 066132327c71300188aa66180fde2fb3d90c5140, CKM_ECDH1_DERIVE and
CKM_ECDH1_COFACTOR_DERIVE were always registered for cards that support
SC_ALGORITHM_ECDSA_RAW.
The mentioned commit changed this behavior, so that the ECDH mechanisms
are only registered for cards that set the SC_ALGORITHM_ECDH_CDH_RAW
capability flag.
To keep the existing behavior for the cards, they need to set this flag
in the card driver.
2015-05-08 20:45:37 +02:00
Philip Wendland 78e434da93 register EC mechanisms with flags independent of RSA flags
Prior to this commit, all hashes registered for RSA or other key types were
registered for ECDSA as well.

register ECDH mechanism only when supported by card

ECDH should only be registered if the card driver sets the
SC_ALGORITHM_ECDH_CDH_RAW flag.

register software PKCS#1 (1.5) padding only when RAW RSA is supported by card

If OpenSC supports PSS/OAEP padding or other padding mechanisms in
future, and there would be a card that enforces hardware PSS/OAEP
padding, the PKCS#1 v1.5 padding mechanism should not be registered.
2015-05-08 20:45:27 +02:00
Philip Wendland 37b6f0bbdf IsoApplet: fix EC mechanism ext_flag 2015-05-08 20:19:36 +02:00
Hector Sanjuan fd3d07a884 Issue #451: Newer DNIe not working with OpenSC.
This patch fixes 3 issues which consecutively have shown up when debugging the original problem:

1 - Newer DNIe report a byte count for public certificates which is the compressed size,
while older DNIe report the uncompressed size. This resulted in short-reading the x509 certificates,
and in an error parsing. Therefore, during initialization we proceed to set path->count for
public certificates to -1. This ensures that the lenght of the certificates for reading
will be set to file-> length, which has the correct size.

2 - pkcs11-tool -t was broken for DNIe (old and new)as it tried to strip pcks11 padding
from the data to sign and OpenSC tried signatures with non-padded data
(as the card had SC_ALGORITHM_RSA_RAW).
The new algoflags (SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PKCS1) and the
removal of the strip-padding call fix the issue.

3 - The new cards won't allow setting the LE bytes when calculating the TLV, when LE equals
256. This caused an wrong SM object error response (0x69 0x88). Therefore,
we don't send the LE bytes anymore in this case.

The patch has been tested to work on the new problematic card and on another old one.

close #451
2015-05-08 09:17:01 +02:00
Frank Morgner ef4edb74ba fixed invalid free
We duplicate mechanisms based on OpenSSL so that they can be freed along
all the card's algorithms created via sc_pkcs11_new_fw_mechanism. Fixes
regression from eaf548aa3dab80a9bbf51da8291e7db978e3a2ad
2015-05-08 09:11:55 +02:00
Frank Morgner e338b7c1ab framework-pkcs15: fixed memory leak when encoding pubkey 2015-05-08 09:11:55 +02:00
Frank Morgner e84951a5bf fix resource leaks in while registering PKCS#11 mechanisms
introduces a free_mech_data for sc_pkcs11_mechanism_type_t to clear the
mechanisms private memory
2015-05-08 09:11:55 +02:00
Frank Morgner 2c32575e89 pkcs11-tool: fixed resource leak 2015-05-08 09:11:55 +02:00
Frank Morgner ecc9b9dac9 openssl: fixed resource leak 2015-05-08 09:11:55 +02:00
Frank Morgner 8838388ceb pkcs15-infocamere: fixed resource leak 2015-05-08 09:11:55 +02:00
Frank Morgner bbb803ff2e sc-hsm-tool: fixed resource leak 2015-05-08 09:11:54 +02:00
Frank Morgner d96f25c147 pkcs15-tool: fixed resource leak 2015-05-08 09:11:54 +02:00
Frank Morgner 1f16f24052 pkcs15-init: fixed resource leak 2015-05-08 09:11:54 +02:00
Frank Morgner a83da8a947 pkcs15-crypt: fixed resource leak 2015-05-08 09:11:54 +02:00
Frank Morgner c65caed7f4 openpgp-tool: fixed resource leak
VTA: slightly touched, original commit f0ddbf4
2015-05-08 09:11:54 +02:00
Frank Morgner b0a708b0bb pintest: fixed resource leak 2015-05-08 09:11:54 +02:00
Frank Morgner efbd4068af sm-cwa14890: fixed resource leak 2015-05-08 09:11:54 +02:00
Frank Morgner 01e573b987 profile: fixed resource leak 2015-05-08 09:11:54 +02:00
Frank Morgner 6cb99be821 pkcs15-setcos: fixed resource leak 2015-05-08 09:11:54 +02:00
Frank Morgner 44253c63d0 pkcs15-rtecp: fixed resource leak 2015-05-08 09:11:54 +02:00
Viktor Tarasov d636338eaf pkcs15-oberthur: fix memory leakage 2015-05-08 09:11:54 +02:00
Viktor Tarasov ac84d282b1 myeid: fixed resource leak
pkcs15-myeid: fix memory leakage
myeid: fix memory leakage
2015-05-08 09:11:40 +02:00
Viktor Tarasov 475ce71453 iasecc: fixed resource leak
pkcs15-iasecc: fix memory leakage
iasecc: fix memory leakage
2015-05-08 09:11:20 +02:00
Frank Morgner 68becc8fc4 pkcs15-gpk: fixed resource leak 2015-05-08 09:11:19 +02:00
Frank Morgner d4fd135e20 pkcs15-cflex: fixed resource leak 2015-05-08 09:11:19 +02:00
Frank Morgner 4af4308d19 authentic: fixed resource leak
pkcs15-authentic: fixed resource leak
card-authentic: fixed resource leak
2015-05-08 09:10:48 +02:00
Frank Morgner e215b7b4fb sm-common: fixed resource leak 2015-05-08 09:10:48 +02:00
Frank Morgner 3cfb44d704 pkcs15-syn: fixed resource leak 2015-05-08 09:10:48 +02:00
Frank Morgner 841d89dda6 pkcs15-pubkey: fixed resource leak 2015-05-08 09:10:47 +02:00
Viktor Tarasov 18e962942b pkcs15-data: fix memory leakage 2015-05-08 09:10:47 +02:00
Frank Morgner 3a6c4a0e1d pkcs15-cache: fixed resource leak 2015-05-08 09:10:47 +02:00
Frank Morgner 9263da49aa pkcs15: fixed resource leak 2015-05-08 09:10:47 +02:00
Frank Morgner c7afbb4ca2 pkcs15-algo: fixed resource leak 2015-05-08 09:10:47 +02:00
Frank Morgner 1f69a0d687 fixed indenting 2015-05-08 09:08:24 +02:00
Frank Morgner 6523f3fcb9 added LOG_TEST_GOTO_ERR and SC_TEST_GOTO_ERR
Don't forget to set the error label!
2015-05-08 09:08:24 +02:00
vletoux 689ece205a card-masktech.c: code improvements
fixes #457
2015-05-08 09:07:40 +02:00
vletoux 976db5cb04 card-masktech: initial commit
card-masktech.c: fix building issues on the integration platform

card-masktech.c: fix linux compilation errors

honour HAVE_CONFIG_H

card-masktech.c: take in account Frank's remark about extended APDU in masktech_decipher

remove trailing spaces
2015-05-05 10:13:26 +02:00
vletoux 1586f240f4 iso7816.c: fix SC_PIN_CMD_IMPLICIT_CHANGE with pinpad
When a pinpad is used, the old pin is asked whatever, even if a previous authentication happenened or if the card doesn't support it.
2015-05-05 09:56:39 +02:00
Andreas Schwier ed588d2443 pkcs11: fixed broken C_Decrypt
Fixed broken C_Decrypt from 643080baf9

fix #449
2015-04-30 15:57:44 +02:00
Viktor Tarasov f0189e8378 pkcs11-tool: option to 'decrypt some data' 2015-04-30 15:57:44 +02:00
Andreas Schwier 0dba2d453f sc-hsm: fix signed char for ARM platforms
char is unsigned by default on ARM

fix #450
2015-04-30 12:03:01 +02:00
viktorTarasov c754e3f197 Merge pull request #444 from frankmorgner/pkcs11-error-handling
Improved error handling for PKCS#11 module
2015-04-25 13:04:07 +02:00
Thomas Calderon 0a754b694e pkcs11-tool: pass key usage flags to created objs
* Command-line parameters were introduced to specify key usage
  (--usage-{sign,decrypt,derive}). However, those are not used when importing
  external objects using C_CreateObject function.

fix #445
2015-04-25 12:28:48 +02:00
Doug Engert ee23d28654 EC field_length changes for non-multiple of 8 bits curves
In OpenSC the EC field_length is the number of bits in the field.
Most curves have a field_length which is a multiple of 8 bits
but there are many that are not.

The X and Y points and privateD are stored in octetstrings
so there may need to be an extra byte in the octetstring.

An OpenSSL BIGNUM will drop leading zero bytes, so its size can not be used
to determine the field_length.

fix #440
fix #433
2015-04-25 12:21:39 +02:00
Shaun Schutte 665807d6de Rename minidriver-italian-cns to minidriver-italian-cns.reg 2015-04-24 09:45:20 +02:00
Shaun Schutte e456074fd9 Create minidriver-italian-cns
These are the required registry values to get the Italian CNS card working under Windows 7 32 bit and 64 bit.
2015-04-23 16:54:11 +02:00
Frank Morgner bcb5fc15e5 honour HAVE_CONFIG_H 2015-04-22 23:55:33 +02:00