Commit Graph

5038 Commits

Author SHA1 Message Date
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
Frank Morgner 9f318b829f remove slots of removed readers 2015-04-21 02:00:06 +02:00
Frank Morgner 02f3997632 added error handling to print_ssh_key 2015-04-21 01:32:37 +02:00
Frank Morgner e359b2a310 handle unexpected meltdown of PC/SC service 2015-04-21 01:09:21 +02:00
Frank Morgner cbc43eeb88 fixed compiler warning 2015-04-21 01:04:18 +02:00
Frank Morgner c8a7c8bc7a fixed typo 2015-04-21 01:04:18 +02:00
Frank Morgner 54f285d57a correctly handle readers that have been removed 2015-04-21 01:04:18 +02:00
Frank Morgner c45c90a337 sc_pkcs11_close_all_sessions: close all sessions even if closing one fails 2015-04-20 16:18:11 +02:00
Thomas Calderon 23ca1f101d pkcs11-tool: Add support for creating EC privkey
* This patch allows to create EC private keys. The feature re-use the GOST
  parsing function as instanciating an ECDSA key is the same as a GOST key.
2015-04-15 08:58:05 +02:00
Frank Morgner a7a903fd81 check ATRs even for forced card driver
some card drivers depend on a card type which is initialized by matching the card's ATR
2015-04-15 08:56:22 +02:00
Viktor Tarasov 96556dea7b fix #433: EC privateD octetstring may need leading zeros 2015-04-12 13:35:27 +02:00
German Blanco 6caa85f238 Issue 395. Avoiding a couple of memory leaks. 2015-04-12 11:35:09 +02:00
Frank Morgner 6e84ee0ba7 pkcs11-tool: honour unsupported signature mechs 2015-04-12 11:28:25 +02:00
Frank Morgner 643080baf9 honour key capabilities for decryption/verification
fixes #419
2015-04-12 11:28:25 +02:00
Frank Morgner d7ab0df51d export sc_pkcs15_bind_internal
allows bootstrapping an external pkcs15 driver
2015-04-12 11:28:25 +02:00
Viktor Tarasov 3e2d51e0ba iasecc: use PIN PAD with variable PIN length 2015-04-11 16:47:13 +02:00
Viktor Tarasov 5757d82cc9 libopensc: stored-length member in PIN CMD data 2015-04-11 16:45:17 +02:00
Viktor Tarasov 49598b6016 libopensc: invalid OID comparison for EC keys
Thanks to Peter Popovec <popovec.peter@gmail.com>
2015-04-09 11:49:05 +02:00
vletoux ce962c14f4 fix #425: guid computation issue
Compilation without OpenSSL - guid computation issue
This case is triggered when:
- built without OpenSSL
- called from a minidriver where id.len = 1
- card number is less than 15 bytes

(VTA: codding style slightly touched)
2015-04-08 18:41:51 +02:00
Dirk-Willem van Gulik 4000e6d5b0 Add missed option debug info
Fix misspelled key in --help output (thanks Philip Wendland).
2015-04-08 18:03:46 +02:00
vletoux 8ea328ff7f Minor code quality improvements.
Basically checks that the memory allocation succeed.

The ctbcs.c change improve the readability
because count = 0 and len > 254 does not add any value.

VTA: added few coding style changes
2015-04-05 13:15:57 +02:00
Frank Morgner db860c0d2a export sc_sm_stop 2015-04-04 22:09:22 +02:00
Philip Wendland fa045d44ec pkcs11-tool: Let the user choose the ECDSA signature format
Instead of hard-coding the format depending on whether OpenSC was compiled with
OpenSSL or not, the user should be able to choose the format himself.
The default format now is the normal concatenation of R,S both for CKM_ECDSA
and CKM_ECDSA_SHA1.
2015-04-04 22:01:22 +02:00
Philip Wendland f93835add9 Allow log functions to be called with ctx==NULL
This change allows functions to be used from places where there is no
sc_context (ctx) available.
2015-04-04 22:01:22 +02:00
Viktor Tarasov 95ad11a253 iasecc: special case for 'Gemalto GemPC Pinpad'
issue 424
VTA: this pinpad, the only available, do not accept different values
for min and max PIN lengths in P10 block.
2015-04-04 21:41:28 +02:00
Frank Morgner c0fac2a4f6 stop SM in case of SM errors 2015-04-02 09:54:41 +02:00
Frank Morgner e07c4bcfbb added sc_sm_stop
implementation taken from the ISO SM driver of
https://github.com/frankmorgner/vsmartcard/tree/master/npa
2015-04-02 09:54:41 +02:00
Frank Morgner 30b24e79c0 fixed memory corruption in encode_file_structure
as suggested by Peter Popovec
2015-04-01 09:42:21 +02:00
Dirk-Willem van Gulik 88ec461bc5 tool: RFC4716 compliant key output
Add a comment field to the ssh key output if a label is set on the key. Add RFC4716 compliant key output for the new breed of modern (mobile) SSH clients.

VTA: use short form of log call in iso7816
2015-03-31 19:09:25 +02:00
Frank Morgner 0790969b97 recognize short EF identifier 2015-03-31 18:48:57 +02:00
Thomas Calderon 4a4d750e73 iasecc: Fix log output is always displayed
* iasecc_read_public_key function uses SC_SUCCESS instead of log level
  value, hence the log output is always displayed. This uses
  SC_LOG_DEBUG_NORMAL instead.

VTA: updated to use short form of LOG macro
2015-03-31 18:47:11 +02:00
Thomas Calderon 117f3a74be iasecc: Fix key usage when provisioning card
* Avoids overriding key_usage when creating objects on the card.
2015-03-31 18:25:54 +02:00
Robert Quattlebaum 548c2780d3 Add support for ACOS5-64 cards.
The ACOS5-64 cards have a different ATR than the original
ACOS5-32 cards. This change simply adds this ATR so that it
will be recognized properly.
2015-03-29 14:09:35 +02:00
vletoux 5007e9fc9f md: fix build without OPENSSL_VERSION_NUMBER
Fix the WCHAR / CHAR conversion problem in CardAuthenticateEx in case of PinPAD (vs->wzPinContext is UNICODE)
Fix UNICODE compilation problem( MessageBoxA instead of MessageBox)
2015-03-29 13:59:21 +02:00
vletoux 3b873adad2 win32: allows UNICODE built.
UNICODE is set by default by Visual Studio (but can be deactived)
The trick is to force ANSI version by appending a A to the function calls.
2015-03-29 13:54:51 +02:00
Philip Wendland c8d206ece1 IsoApplet: Increase indicated version to 00.06
Backward compatiblity with 00.05 is kept.
2015-03-29 13:34:58 +02:00
Philip Wendland 9078856675 IsoApplet: register ECC mechanisms only when ECC is supported by card
There are few Java Cards that do not support ECDSA at all.
Starting with IsoApplet version 00.06, the applet returns whether the card
supports ECDSA or not. This commit uses this information to decider whether to
register ECDSA mechanisms or not.
2015-03-29 13:34:58 +02:00
Philip Wendland 76facf0d73 IsoApplet: add support for GET CHALLENGE 2015-03-29 13:34:58 +02:00
Philip Wendland e258cec13e IsoApplet: Add nistp224, secp192k1 and secp256k1 curves
secp*k1 curves are only supported applet version >= 0.6.0 because of an issue
with encoding ECC public keys with small parameters.
2015-03-29 13:34:58 +02:00
Philip Wendland ab5ca331b2 IsoApplet: Obtain applet version and card capabilities *after* match_card() 2015-03-29 13:34:58 +02:00
Philip Wendland bba6e17aa9 isoApplet: Fix indentation of isoApplet.profile 2015-03-29 13:34:58 +02:00
Viktor Tarasov 090aed2fc2 ec: fix length of allocated mem for EC signature
discussion in PR #398
2015-03-29 13:08:01 +02:00
Philip Wendland 4b51b99748 pkcs11-tool: harmonize supported ECC curves
pkcs15-pubkey.c holds a struct containing supported ECC curves. The contents of
this struct are being harmonized with pkcs11-tool supported curves.
2015-03-29 12:55:54 +02:00
Frank Morgner f3573ede0d fixed requesting PACE features 2015-03-29 12:42:13 +02:00
Andreas Schwier b1bdfae200 sc-hsm: revert broken a4c8d671
sc-hsm: Fixed minimum value for number of password shares
2015-03-29 12:40:44 +02:00
Wouter Verhelst 5149dd3e62 belpic: Support 2K cards
Recent BELPIC cards (issued since March 2014) have a validity of 10
years (rather than 5 as before), and therefore also increased the key
size from 1024 bits to 2048 bits.

Key size can be detected by checking the applet version, for which we
have to issue a "GetCardData" command. If the applet is version 0x17 or
higher, keys are 2048 bits.

Use #defines rather than magic numbers

Keeps the code slightly more readable.

While we're at it, refactor slightly so that the code which issues the
GET CARD DATA command doesn't just keep the applet version, but also
makes other things available.

This latter in preparation of setting the serial number.
2015-03-29 12:11:44 +02:00
Frank Morgner c019a62309 pkcs11: parameter checking for 'get_mechanism_list'
fixes #409
2015-03-29 12:11:08 +02:00
Thomas Calderon 435291f216 iasecc: initial support for Morpho IAS Agent Card
* This commit adds initial support for Morpho French Agent card which is an
    IAS card. Signature operations are working. Since my test card was
    read-only, I was unable to test object management functions.

  * Add missing copy of AID in structure
2015-03-29 12:10:55 +02:00
Viktor Tarasov c0c8a89126 mcrd: move driver to the end of detection list
the drivers that need to probe the AIDs to recognize its supported card
have to be placed at the end of the list of internal drivers
2015-03-20 18:08:18 +01:00
Hannu Honkanen 2fffbce65c myeid: update EC support for MyEID-v4 card 2015-03-14 17:47:44 +01:00
Viktor Tarasov 877fa862d9 isoApplet: prototype of asn1_sig_value_sequence_to_rs() has changed 2015-03-10 09:09:14 +01:00
viktorTarasov 595be37fee Merge pull request #305 from philipWendland/master
Add support for the IsoApplet Java Card applet
2015-03-07 23:36:25 +01:00
Viktor Tarasov 2abe135f97 asn1: re-fix error in EC signature encode helper
see comment for 8cf99a9372
2015-03-07 22:40:43 +01:00
Viktor Tarasov 1739300657 pkcs15: fix name of EC curve, add new ones 2015-03-05 10:32:54 +01:00
Viktor Tarasov 6f6286de99 pkcs11: generate EC key: use allocated EC params
For internal use allocate and copy the EC params data from the caller's template,
rather then use them directly as a pointer in internal public key data.
2015-03-04 19:47:13 +01:00
Viktor Tarasov 31124ac4f9 pkcs15init: allocate EC parameters 2015-03-04 19:46:21 +01:00
Viktor Tarasov 1123768ac3 libopensc: invalid 'free' and 'assign NULL' order 2015-03-04 19:45:23 +01:00
Viktor Tarasov 8cf99a9372 asn1: fix error in EC signature encode helper
The raw format of EC signature was invalid when 'r' and 's' had different length.
https://github.com/OpenSC/OpenSC/pull/381#issuecomment-77016382

According to PKCS#11 v2.20:
"If r and s have different octet length, the shorter of both must
be padded with leading zero octets such that both have the same octet length."
2015-03-04 19:43:15 +01:00
Philip Wendland 74aeb8c923
IsoApplet: register supported EC curve *per curve* 2015-02-22 23:08:18 +01:00
Doug Engert 58d1f1db3f Merge pull request #385 from darconeous/patch-2
Allow PKCS15 cache to work with PIV cards (if enabled)
2015-02-21 21:51:50 -06:00
Philip Wendland 85d16fbc57
IsoApplet: use helper function sc_asn1_sig_value_sequence_to_rs() introduced in #381 2015-02-20 23:02:04 +01:00
Philip Wendland 1aeebdaf1c
IsoApplet: react to changes of _sc_card_add_ec_alg() in fa923831f8 2015-02-20 22:56:23 +01:00
Philip Wendland 59eeacb74b
IsoApplet: react to removal of sc_pkcs15_ec_parameters in fa923831f8 2015-02-20 22:07:49 +01:00
Philip Wendland a9d43af4bf
IsoApplet: use a buffer large enough when generating EC keys larger than 320 bit 2015-02-20 21:55:35 +01:00
Philip Wendland da05fa2a47
IsoApplet: try to fix EC parameters when importing private keys from file 2015-02-20 21:55:35 +01:00
Philip Wendland 44d724b012
IsoApplet: fix more (comment) alignment issues with tabstop=8 2015-02-20 21:55:35 +01:00
Philip Wendland 5628a06353
IsoApplet: Align comments with spaces instead of tabs
Better view with tabstop=8.
2015-02-20 21:55:35 +01:00
Philip Wendland 43fa99c0f2
IsoApplet: Move the key gen debug info to the right places 2015-02-20 21:55:35 +01:00
Philip Wendland 0473decae4
IsoApplet: clear memory after prkey import.
Private key import via plain APDUs is dangerous and not recommended anyway, but clearing the apdu buffer does not hurt anyone.
2015-02-20 21:55:34 +01:00
Philip Wendland 73b391731b
IsoApplet: Don't set ECC field length of 512
512 is wrong for EC FP (correct would be 521 bit), and neither of those
two are currently supported by OpenSC.
2015-02-20 21:55:34 +01:00
Philip Wendland e791948e42
IsoApplet: Simplify the private key import
Use the new features of sc_asn1_put_tag introduced in OpenSC/OpenSC#314.
Additionally, a RSA private key is sent from one large buffer using either extended APDUs or chaining (in compliance to IsoApplet API version 00.05).
2015-02-20 21:55:34 +01:00
Philip Wendland 6cdf6c08a5
IsoApplet: use AID directly when selecting applet
Now that apdu.data is const (see ef94c6b875), this can be done without discarding the const qualifier of the aid parameter.
2015-02-20 21:55:34 +01:00
Philip Wendland 09acfd7ec0
IsoApplet: ECDSA signatures - only strip excess zeroes
It is required to strip excessive zeroes returned by some Java Cards when removeing the ASN1 structural information for PKCS#11 so that the x/y can be calculated by dividing the signature length by 2. However, the leading zero may only be stripped if it is excessive (outside the field length). Otherwise generated signatures are wrong in rare cases (1 out of 256).
2015-02-20 21:55:33 +01:00
Philip Wendland c463f1a7a1
IsoApplet: Do not set RSA hashes
See: 189e998486
The IsoApplet requires the host to do the hashes with RSA. OpenSC will
add all hashes that are available in software and will not expect the
card to do the hashing.
2015-02-20 21:55:33 +01:00
Philip Wendland e3cc851b72
IsoApplet: EC key-gen rework and refactorings
Rework the EC key generation mechanism to send the curve parameters to
the card. In earlier versions, the applet had a copy of the curve
parameters and there was a different algorithm reference for every
curve. This is unfeasible when trying to support a larger number of
curves because of size limitations of the applet.
This commit additionally includes some refactorings that should not
change the functionality.
2015-02-20 21:55:33 +01:00
Philip Wendland 6f9e894ebe
IsoApplet: set lock when doing command chaining 2015-02-20 21:55:33 +01:00
Philip Wendland 48bd6b0964
Add support for the IsoApplet (Java Card applet)
The IsoApplet can be found here:
https://github.com/philipWendland/IsoApplet
Add read/write support for this applet, including RSA and
ECC support.
2015-02-20 21:55:26 +01:00
Frank Morgner bff0ea4837 fixed compiler warning 2015-02-20 19:54:40 +01:00
Frank Morgner 16ea926d29 fixed indentation 2015-02-20 19:54:40 +01:00
Frank Morgner 236e68b17c fixed NULL dereference 2015-02-20 19:54:40 +01:00
Frank Morgner da07e22c97 use memmove for overlapping memory 2015-02-20 19:54:40 +01:00
Pedro Martelletto ced77ae6c7 cardos: overwrite content of deleted private key
when deleting a private key object, overwrite its contents so the key can no longer be used.

(VTA: original commit touched to use LOG macros and add debug logs)
2015-02-20 18:03:37 +01:00
Viktor Tarasov b08671fab5 pkcs15-crypt: option for output format of ECDSA signature 2015-02-20 14:20:28 +01:00
Viktor Tarasov 80c496671f helper functions to change format of ECDSA signature 2015-02-20 14:20:19 +01:00
Viktor Tarasov fa923831f8 introduce EC curve OID into algorithm info data
needed to store information about EC curve supported by card.
Primary usage is when importing/generating key to get know if particular curve is supported by card.
2015-02-20 13:49:18 +01:00
Doug Engert d7475c8180 Add brackets in card-piv.c 2015-02-16 10:43:19 -06:00
Doug Engert 572218c59c Fall through comment before break 2015-02-16 10:11:24 -06:00
Robert Quattlebaum 0ffad3f3bb Fix for bad caching behavior of PIV PKCS15 emulator. 2015-02-12 16:42:17 -08:00
Doug Engert 981a0fbbaf Fix-up changes caused by Coverity scan
piv-tool.c add  /* fall through */ to avoif false warning
card-piv.c - clean up if sc_lock fails.
2015-02-11 13:39:59 -06:00
Viktor Tarasov 3c1d8ad695 accept no output for 'SELECT' MF and 'SELECT' DF_NAME
PR #342
2015-02-07 21:46:44 +01:00
Martin Campbell d162143964 Updating to fix failure of ePass2003 USB smart card due to failure to re-authenticate secure messaging when card is reset due to multiple applications using PKCS11 sessions 2015-02-07 21:46:44 +01:00
Thomas Calderon 22fb49b554 PKCS#11: Improve compliance for public keys.
* Key usage required when calling C_CreateObject for public key are not used.
    This adds the logic to convert from PKCS#11 attributes to PKCS#15 in the
    structure that is sent to underlying _store_pubkey functions.
2015-02-07 20:17:12 +01:00
Viktor Tarasov 96265e6d08 pkcs15init: superpluous 'ec-params' in init data
Pkcs15init data, used to import/generate key objects, includes twice the same EC parameters data:
 - explicit 'params' data
 - part of sc_pkcs15_pubkey/sc_pkcs15_prkey
Explicit 'ec-params' data is removed.
2015-02-07 20:00:41 +01:00
Viktor Tarasov e374f88b82 pkcs15-pubkey: add EC params in SPKI encoding 2015-02-07 19:55:08 +01:00
Viktor Tarasov 9148f21cd1 pkcs15-pubkey: possible NULL dereference, logs
... remove obsolete comments, minor coding style corrections
2015-02-07 19:55:08 +01:00
Philip Wendland faaa11e091 Prefer serial number from EF(TokenInfo) and cached serials over CARDCTL
sc_pkcs15_get_object_guid() should prefer the serial number from
EF(TokenInfo) over card->serialnr because the user may override the
card's serial number with "pkcs15-init -C --serial". The card->serialnr
should be used before calling card CTL with SC_CARDCTL_GET_SERIALNR
because it might contain a cached value.

This change *should* allow cards to be used with the minidriver even if
SC_CARDCTL_GET_SERIALNR is not implemented. For example, a driver might
set card->serialnr at initialization or the user might initialize a
PKCS#15 card with its own "--serial".

See also the discussion at the mailing list:
[Opensc-devel] AT_SIGNATURE and AT_EXCHANGE Problem
2015-02-07 19:48:10 +01:00
Viktor Tarasov 08eb700b97 revert or partially revert some of recent commits
b94c163 - invalid, non-tested
11881a6 -- src/libopensc/card-iasecc.c -- return from select has to be ignored,
3a92bf7 -- src/pkcs11/slot.c -- SEGFAULT issue #373
3a92bf7 -- src/tools/piv-tool.c -- confirmed by author
6759c04 -- src/pkcs15init/pkcs15-lib.c -- file instantiation error has to be ignored
2015-02-07 19:31:17 +01:00
Frank Morgner 3a92bf7af5 fixed resource leaks 2015-02-05 01:38:41 +01:00
Frank Morgner 11881a61b8 removed/fixed dead code 2015-02-05 01:38:41 +01:00
Frank Morgner a3fc62f79f fixed NULL dereference (or warning thereof) 2015-02-05 01:38:40 +01:00
Frank Morgner 8d902d1ed3 fixed out of bounds read/write/access 2015-02-04 09:24:50 +01:00