Commit Graph

5807 Commits

Author SHA1 Message Date
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 9f3dbaa39d honour warnings 2015-02-20 19:54:40 +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 45a4def5fd Merge pull request #382 from dengert/piv-fix1
Add brackets   in card-piv.c
2015-02-16 10:57:01 -06:00
Doug Engert d7475c8180 Add brackets in card-piv.c 2015-02-16 10:43:19 -06:00
Doug Engert e37690aed5 Merge pull request #376 from dengert/piv-reverts
Fix-up changes caused by Coverity scan See #366 in PIV code
2015-02-16 10:29:36 -06:00
Doug Engert 572218c59c Fall through comment before break 2015-02-16 10:11:24 -06:00
Martin Paljak 14ed749a88 Create CONTRIBUTING.md
So that new issues and pull requests could get some information.
2015-02-13 16:52:10 +02: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
Frank Morgner a4c8d67110 fixed improper use of negative value 2015-02-04 09:03:27 +01:00
Frank Morgner 761e175212 fixed sc_driver_version check 2015-02-04 08:52:30 +01:00
Frank Morgner 5cafbe0f4b fixed undefined shift behaviour 2015-02-04 08:50:19 +01:00
Frank Morgner ed9572422f check return values 2015-02-05 01:37:53 +01:00
Frank Morgner 47df45f5f2 set le instead of p2 twice 2015-02-05 01:37:53 +01:00
Frank Morgner 5e3d54186a removed useless check for non-null array 2015-02-05 01:37:53 +01:00
Frank Morgner ac4da89d0d use memmove for overlapping memory 2015-02-05 01:37:53 +01:00
Frank Morgner 53e1992cc2 use strerror for failure of gettimeofday 2015-02-05 01:37:53 +01:00
Viktor Tarasov 9cb4a09e30 readme.md: add jenkins build status 2015-02-03 09:45:40 +01:00