Commit Graph

3464 Commits

Author SHA1 Message Date
Frank Morgner 755ac78a02 added fuzzing with libFuzzer and OSS-Fuzz
makes cmocka detection not required for building tests
2019-07-26 15:23:02 +02:00
Rosen Penev 7159400086 treewide: Fix compilation without deprecated OpenSSL APIs 2019-07-26 08:49:18 +02:00
programatix 91b9aea42a Update pkcs15-sec.c
When card supports SC_ALGORITHM_RSA_PAD_PKCS1 but not SC_ALGORITHM_RSA_HASH_NONE, then the DigestInfo need to be removed.

Current check make requires the card to not support both SC_ALGORITHM_RSA_PAD_PKCS1 and SC_ALGORITHM_RSA_HASH_NONE to have the removal done.
2019-07-26 08:48:10 +02:00
Jó Ágila Bitsch a7766b3de3 allow chaining for pkcs15-init --store-private-key EC keys
when importing a private key onto a pkcs15 card, if the card does not support
extended APDUs, we need to use chaining to store keys longer than 255 bytes.

While for RSA keys, this check was included, it was missing for EC keys.
This patch adds the SC_APDU_FLAGS_CHAINING flag to apdu.flags if data length is
greater than 255 and the card caps does not include SC_CARD_CAP_APDU_EXT.

Fixes #1747
2019-07-24 01:25:49 +02:00
Daniel Kouril 916434f3a2 Fix using environmental variables on WIN32. 2019-07-22 13:32:46 +02:00
Frank Morgner ba19a467e4
Rutoken Lite (#1728)
* card-rtecp: Add Rutoken Lite

* avoid seperate rutoken lite driver

* added rutoken lite to minidriver

closes #1722
2019-07-22 13:05:32 +02:00
Dmitriy Fortinskiy 3c1624676d card-rtecp,card-rutoken: Set specific card types 2019-07-02 12:13:57 +02:00
Dmitriy Fortinskiy 60a2cf16c7 card-rtecp: Fix list_files on T0 cards
Rutoken ECP SC over T0 expects Get Response after SW1=61 which
is not called with zero le.
2019-07-02 12:13:57 +02:00
Timo Teräs 19711d0a13 myeid: fix EC key upload, and avoid data copying
Fixes regression from commit 3688dfe which did not consider that
the zero prefixing tests were too generic and matched EC keys too.

This simplifies the code even further and avoids data copying
when possible. Proper test is now included to do data value prefixing
only for the RSA keys it is needed.

Closes #1701.
2019-06-17 15:19:08 +02:00
Jakub Jelen 9197dfe5ae myeid: Detect also OsEID card in the MyEID driver and difference them with separate types 2019-06-17 12:49:11 +02:00
Jakub Jelen 07c0a47b37 card-openpgp: Fix typo in the EC Key size 2019-06-17 12:49:11 +02:00
Jakub Jelen 86fd200462 sc-hsm: Check the operation first 2019-06-17 12:49:11 +02:00
Jakub Jelen 10abef9206 pkcs15-sec: Drop unused code (copied from RSA decipher) 2019-06-17 12:49:11 +02:00
Jakub Jelen 6d751e8b22 opensc.h: Add missing raw ecdh algorithm 2019-06-17 12:49:11 +02:00
Jakub Jelen 293760c0d0 Fix derive operation detection in MyEID and sc-hsm drivers 2019-06-17 12:49:11 +02:00
Andreas Schwier 58fa53ac91 sc-hsm: Add missing secp384r1 curve parameter 2019-06-14 14:29:58 +02:00
Frank Morgner 94388f9538 fixed more clang-tidy warnings 2019-06-05 13:48:51 +02:00
Nuno Goncalves 0322401aae gemsafeV1: remove redundant match card call to allow for opensc.conf match
At the point when gemsafe_match_card is called, the card type is already known,
either because of a previous match at card.c, or because it is forced at opensc.conf.

With this redundant match it's not possible to force selection on opensc.conf.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2019-06-05 13:43:52 +02:00
Frank Morgner 3a665f6479 allow single character strings with sc_hex_to_bin
fixes https://github.com/OpenSC/OpenSC/issues/1684
fixes https://github.com/OpenSC/OpenSC/issues/1669
2019-05-31 14:15:37 +02:00
Nuno Goncalves e3ff3be4fe pteid: add new ATRs
One ATR have been confirmed on my personal card and also added to the official middleware:

https://svn.gov.pt/projects/ccidadao/changeset/321/middleware-offline/trunk/_src/eidmw/minidriver/makemsi/pteidmdrv.inf

There is another ATR I am adding blind from the official middleware:

https://svn.gov.pt/projects/ccidadao/changeset/321/middleware-offline/trunk/_src/eidmw/minidriver/makemsi/pteidmdrv.inf

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2019-05-31 14:12:12 +02:00
Frank Morgner b7b501d0a5 fixed issues reported by clang-analyzer 2019-05-21 19:34:46 +02:00
Frank Morgner 3c83a80b57 fixed printing non primitive tag
fixes undefined bitshift
2019-05-21 19:34:46 +02:00
Frank Morgner 1423c6bb90 CI: integrate clang-tidy (disabled)
files that have warnings are currently excluded
2019-05-21 19:34:46 +02:00
Raul Metsma 1e59643caa Remove process_arr unused file argument and fix clang-tidy warnings
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-05-21 19:34:46 +02:00
Frank Morgner 65d607af66 fixed 325860 Dereference before null check 2019-05-14 14:50:17 +02:00
Frank Morgner 630bcbedd4 fixed 337490 Unchecked return value 2019-05-14 14:50:17 +02:00
Martin Paljak 2829c5870f Address review comments
Change-Id: I9aa97c8a9878dddd3e6f1a2baa877d188b9d7fe5
2019-05-02 11:51:02 +03:00
Martin Paljak 5f5d40521e Avoid 6282 reply for a successful operation
Change-Id: I5d4d3103692fc6db51f13fc5338360289c26af9a
2019-05-02 11:51:02 +03:00
Martin Paljak fc8e9bf3f3 Address review comments and further reduce LOC
and make sure the card is always handled emulated card first

Change-Id: I60174c2793bb882fb73716f62a652d84e028382c
2019-05-02 11:51:02 +03:00
Martin Paljak b3d4a0d69a EstEID 2018+ driver
This adds support for a minimalistic, small and fast card profile based on IAS-ECC.

Based on information from https://installer.id.ee/media/id2019/TD-ID1-Chip-App.pdf
and proprietary driver snoops.

Thanks to @metsma and @frankmorgner.

Change-Id: I2e4b4914d8a3b991d9a639728695abf4a2362ca0
2019-05-02 11:47:31 +03:00
Andreas Kemnade 9ca836975a Starcos: added another ATR for 2nd gen. eGK (TK) 2019-05-02 10:09:08 +02:00
Raul Metsma 63fd71c245 Remove unused sc_pkcs15emu_opt_t structure
Only usage was removed SC_PKCS15EMU_FLAGS_NO_CHECK flag

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-05-02 10:08:46 +02:00
Raul Metsma 5123531e62 Fix EstEID 3.4 signing
opensc master requires now SC_ALGORITHM_RSA_HASH_NONE

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-05-02 10:06:19 +02:00
Frank Morgner 7df789ec5d fixed 337490 Unchecked return value 2019-04-25 15:44:11 +02:00
Raul Metsma bbec50bfdb Remove unused SC_PKCS15EMU_FLAGS_NO_CHECK flag
Fixes #1634

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-25 14:53:25 +02:00
Timo Teräs 3688dfe238 MyEID: simplify key component loading
Encode the component ID to be key type and component ID. This allows
each combination to be unique and direct mapping to card component
ID type in the code by just taking the low byte. This simplifies
the code, and reduces confusion as there is now only one #define
for each component.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2019-04-25 14:53:10 +02:00
Timo Teräs 3f832ca6da MyEID: implement support for 4K RSA keys (MyEID 4.5+)
MyEID starting version 4.5 supports 4K RSA keys. The card also
now supports proper APDU chainging (for sending large APDUs) and
receiving large responses via GET_RESPONSE splitting.

This updates the following:
* detection code properly announces 3K and 4K RSA support
  when available
* APDU chaining is used when possible
* use ISO GET_RESPONSE handling for large responses
* max_recv_size is set to 256 which it always was supposed to be
  as the old cards respond with that large responses too
* use the 2K signing kludge only on cards that need it
* unwrap and decipher code paths unified to the extent possible

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2019-04-25 14:53:10 +02:00
Timo Teräs 0e25c1d2a6 MyEID: detect card from ATR historical data instead of full ATR
This will simplify the matching code, and match prototype cards.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2019-04-25 14:53:10 +02:00
Jakub Jelen 13429baed0 cac: Avoid signed/unsigned casting reported by coverity
src/libopensc/card-cac.c:1707: negative_returns: "val_len" is passed to a parameter that cannot be negative.
2019-04-23 14:49:45 +02:00
Dmitriy Fortinskiy aff2059ec1 card-rtecp: Fix SELECT FILE 2019-04-17 16:38:49 +02:00
Dmitriy Fortinskiy fe4dae4d31 card-rtecp: Add Rutoken ECP SC ATR 2019-04-17 16:38:49 +02:00
Frank Morgner fd20ffe608
optimize bin/hex low parsing level functions (#1646)
* optimize sc_hex_to_bin

* optimize sc_bin_to_hex

* added documentation

closes https://github.com/OpenSC/OpenSC/pull/1643

thanks to carblue <ka6613-496@online.de>
2019-04-04 12:52:08 +02:00
Raul Metsma 9ba8f56037 Change u8 *data to const because sc_apdu unsigned char *data is const
Name sc_format_apdu parameters for IDE help hints

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-03 22:15:54 +02:00
Raul Metsma 4ba086bfd4 Use strdup and fix all casts
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-01 12:53:33 +02:00
Martin Paljak ea74308512 iso7816_read_binary: do not assume that 6282 is returned with data
Instead of a double check_sw call in case there is no data, assume
that a SW is properly sent by the card and do not expose
SC_ERROR_FILE_END_REACHED outside of the function
(like sc_pkcs15_read_file)

This is to facilitate Estonian eID 2018+ that instead of properly returning
6282 with trunkated data, 9000 is returned and next READ BINARY returns
6b00 (invalid p1/p2). The change should be generally harmless for well-behaving
cards.

Change-Id: I7511ab4841d3bcdf8d6f4a37a9315ea4ac569b10
2019-04-01 12:51:00 +02:00
Frank Morgner b389b19ca5
Merge pull request #1633 from metsma/esteid
Only EstEID 3.5 has EC 384 keys
2019-03-25 14:31:02 +01:00
Raul Metsma 7ae54f490d Remove dead code (#1638) 2019-03-25 14:28:53 +01:00
Frank Morgner 8dea0a9028 fix overlapping memcpy
Fixes https://github.com/OpenSC/OpenSC/issues/1631
2019-03-18 23:33:24 +01:00
Raul Metsma 4d2254a092 Only EstEID 3.5 has EC 384 keys
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-03-13 23:01:07 +02:00
Raul Metsma 1e6d3df201 Remove un-lincenced header file
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-03-13 21:19:26 +01:00