Commit Graph

3442 Commits

Author SHA1 Message Date
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
Frank Morgner 71b85d15e4 opensc.conf: Configure handling of private_certificate
possible choices: ignore, protect, declassify

fixes https://github.com/OpenSC/OpenSC/issues/1430
2019-03-13 21:18:57 +01:00
Frank Morgner 1e0743b29f removed untested use of SC_SEC_OPERATION_AUTHENTICATE
fixes https://github.com/OpenSC/OpenSC/issues/1271
2019-03-13 21:17:54 +01:00
Frank Morgner 106b3a28b1 acos5: removed incomplete driver
fixes https://github.com/OpenSC/OpenSC/issues/1204
2019-03-13 21:17:54 +01:00
Frank Morgner 9fa1722f73 sc_bin_to_hex returns a Nul terminated string 2019-03-13 21:17:00 +01:00
Frank Morgner eb8f28db20 fixed error handling 2019-03-13 21:17:00 +01:00
Frank Morgner d4f1decd15 Make sure card's strings are Nul terminated
Avoids out of bounds reads when using internal operations with the given string
2019-03-13 21:17:00 +01:00
Pierre Ossman bc4eeda573 Remove readers when smart card service stops
The code already removes all active cards when the service goes
away, but it doesn't remove the reader. This can be a bit confusing
since they will still be polled and listed.
2019-03-07 21:51:02 +02:00
Pierre Ossman 9ed5f63c17 Fix smart card removal handling for older PC/SC
Older PC/SC doesn't have the code SCARD_E_NO_READERS_AVAILABLE, so fix
the code to handle such systems as well.
2019-03-07 21:51:02 +02:00
Pierre Ossman 9e9bdac2f1 Handle reader going missing
It might just be this specific reader going missing, and not all
of them.
2019-03-07 21:51:02 +02:00
Raul Metsma b227fb8b9f Cleanup EstEID 1.0/1.1 lefovers
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-03-07 21:31:08 +02:00
Frank Morgner e8f8f0bfbb fixed 333714 Uninitialized scalar variable 2019-03-06 00:42:38 +01:00
Frank Morgner 27526de021 implemented sc_format_apdu_ex 2019-03-05 13:54:13 +01:00
Frank Morgner 155b197932 sc-hsm: require T=1 connection 2019-03-05 13:47:45 +01:00
Frank Morgner 20daced605 fixed special case of deletion in gnuk_write_certificate 2019-02-14 09:22:23 +01:00
Frank Morgner 1a61ae849f fixed Null pointer argument in call to memcpy 2019-02-14 09:22:23 +01:00
Frank Morgner b6fadb469f fixed sc_decompress_zlib_alloc return code 2019-02-14 09:22:23 +01:00
Frank Morgner 6e48de83c7 avoid allocation of 0 bytes 2019-02-14 09:22:23 +01:00
Frank Morgner c858d4b3d1 fixed argument checking 2019-02-14 09:22:23 +01:00
Frank Morgner 6fdb29a470 fixed use of uninitialized values 2019-02-14 09:22:23 +01:00
Frank Morgner 01d515a026 fixed use of garbage value 2019-02-14 09:22:23 +01:00
Frank Morgner 8ea77a83e0 fixed misuse of realloc 2019-02-14 09:22:23 +01:00
Frank Morgner 32e1995300 fixed dead assignment 2019-02-14 09:22:23 +01:00