Commit Graph

7989 Commits

Author SHA1 Message Date
Frank Morgner c212776f45 fixed dashes 2020-02-27 23:12:54 +01:00
Frank Morgner 906108bb69 dnie: fixed length checking of uncompressed data
fixes https://oss-fuzz.com/testcase-detail/5632848910614528
2020-02-27 23:12:54 +01:00
Frank Morgner 261e0b6b0d unified documentation of handling PIN/PUK on CLI 2020-02-27 23:12:54 +01:00
Frank Morgner 6b1770e7ad pkcs15-init: removed --options-file
use an environment variable to pass a hidden PIN code instead of the
options file

fixes 13814 Resource leak as reported by Coverity Scan
2020-02-27 23:12:54 +01:00
Frank Morgner dca02dd9a0 fixed 323588 Uninitialized scalar variable
accessing uninitialized data with mlock is undefined behavior
2020-02-27 23:12:54 +01:00
Peter Marschall 21ee26b070 openpgp-tool: fix key generation with non-standard exponent length
Address issue #1949 by reading non-default algorithm attributes for
key generation from the key's algorithm attributes DO, if that exists.
2020-02-27 22:59:05 +01:00
Peter Marschall 81ace3689d opensc-explorer: extend do_info()
* distinguish between Internal and Working EFs
* add information optionally available in sc_file_t
  - record_count
  - record_length
  - type_attr
* align all labelled values
2020-02-27 22:55:38 +01:00
Peter Marschall 95cae64f83 opensc-explorer: replace magic numbers by SC_MAX_PIN_SIZE
Replace magic numbers, used as size of PIN-type buffers,
with the symbolic constant SC_MAX_PIN_SIZE, fixing
- readability / understandability
- too small sizes (e.g. for GnuPG cards)
2020-02-27 22:54:50 +01:00
Frank Morgner 70716be815 macOS: register CTK driver on installation 2020-02-27 22:49:27 +01:00
Frank Morgner 6a9241b532 macOS: unregister CTK driver on uninstallation
fixes https://github.com/frankmorgner/OpenSCToken/issues/24
2020-02-27 22:49:27 +01:00
Frank Morgner 8f4a6c703b align comment with implementation order 2020-02-20 01:42:18 +01:00
Frank Morgner 31d8c2dfd1 Revert "pkcs11: fixed slotIDs when a new slot list is requested"
This reverts commit 7fb72ccf7b.
2020-02-19 16:09:20 +01:00
Peter Marschall cd5c91b8ef iso7816: extend iso7816_process_fci()
* define file type SC_FILE_TYPE_UNKNOWN
* explicitly set file->type to SC_FILE_TYPE_UNKNOWN for unkown files
* store full-length file type attributes via sc_file_set_type_attr()
* parse # of records for record-oriented EFs
* parse record length for for EFs with fixed-size records
  Note: I am not sure, parsing the record length only for EFs with fixed-
        size records is the correct approach.
        My interpretation of the norm is slightly different, but it seems
        to be in-line what's currently in opensc:
        - there's a comment hinting at that interpretation
        - otherwise variable size records fail to be read in opensc-explorer
        So I leave it this way for now.
2020-02-18 20:47:26 +01:00
Frank Morgner e0b27af205 fixed Undefined-shift
fixes https://oss-fuzz.com/testcase-detail/5644419049193472
2020-02-13 10:39:41 +01:00
Frank Morgner 6c855c561c fixed memory leak
fixes https://oss-fuzz.com/testcase-detail/5739164513599488
2020-02-12 04:48:40 +01:00
Frank Morgner 0d82c95a02 removed unused call to sc_detect_card_presence() 2020-02-12 04:34:45 +01:00
Jakub Jelen 5450f61681 Unbreak build with -fno-common (default in gcc10) 2020-02-11 07:36:31 +01:00
Frank Morgner 1fb1341389 ignore OpenPACE man page generation
fixes https://github.com/frankmorgner/OpenSCToken/issues/26
2020-02-11 04:12:10 +01:00
Frank Morgner a0e1bf7ae5 fixed compiler error 2020-02-10 10:17:16 +01:00
Frank Morgner ea2991ea69 fixed memory leak
also, use sc_file_free instead of free

fixes https://oss-fuzz.com/testcase-detail/4905082200260608
2020-02-10 10:17:16 +01:00
Frank Morgner 2493c5de07 fixed memory leak
fixes https://oss-fuzz.com/testcase-detail/6237284133502976
2020-02-10 10:17:16 +01:00
Frank Morgner d7e02d3bf5 fixed memory leak
Fixes https://oss-fuzz.com/testcase-detail/5151975710916608
2020-02-10 10:17:16 +01:00
Peter Marschall 8e466ad568 OpenPGP: add 3 more OpenPGP card vendors
* taken from GnuPG's git
2020-02-10 00:41:02 +01:00
Charlène 2f7d0cf20f Put user supplied CFLAGS on top priority 2020-02-07 08:57:26 +01:00
Jakub Jelen 34dad7f543 idprime: Add missing terminator in ATR list
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20510
2020-02-04 15:44:19 +01:00
Jakub Jelen 63435adc68 coolkey: Do not return bogus error if read already failed 2020-02-04 13:57:15 +01:00
Jakub Jelen 2a0f53dd4f coolkey: Avoid heap buffer overflow
for malformend combinded objects, the ID and header were parsed before
making sure we have at least that lenght available.

Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20131
2020-02-04 13:57:15 +01:00
Jakub Jelen 09531d720a cac: Avoid stack overflow on infinite recursion in CCC chaining
Thanks oss-fuzz

Fixes: #1920

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19725
2020-02-04 13:57:15 +01:00
Frank Morgner e9308a2011 addeed zlib test data 2020-02-04 13:56:53 +01:00
Frank Morgner f1044f3645 tccardos: fixed error checking 2020-02-04 13:56:53 +01:00
Frank Morgner c339136c73 tccardos: fixed freeing file object 2020-02-04 13:56:53 +01:00
Frank Morgner 723176d62f avoid calling memcpy with length 0 2020-02-04 13:56:53 +01:00
Frank Morgner 3687f71bf7 fixed 123497 Dereference after null check
Thanks to Coverity Scan
2020-02-04 13:56:53 +01:00
Frank Morgner 5475dbcb3c fixed Uninitialized scalar variable
Thanks to Coverity Scan
2020-02-04 13:56:53 +01:00
Frank Morgner 3dede423e6 fixed Out-of-bounds access
Thanks to Coverity scan
2020-02-04 13:56:53 +01:00
Frank Morgner 8db1cbe35f use a more explicit assignment 2020-02-04 13:56:53 +01:00
Frank Morgner 40b3aeb626 travis: output results of unittests on errors 2020-02-04 13:56:53 +01:00
Frank Morgner d138522e33 added detection of zlib compression
... and always set outLen to 0 in case of an error in sc_decompress
2020-02-04 13:56:53 +01:00
Frank Morgner 094aa68632 fixed Explicit null dereferenced
Thanks to Coverity Scan
2020-02-04 13:56:53 +01:00
Frank Morgner 72836fa3cb Fixed Dereference before null check
As reported by coverity scan
2020-02-04 13:56:53 +01:00
Doug Engert 0fd77d642c Minidriver additionl fixes
Use __FUNCTION__ as defind in log.h so will compile with any compiler.
logprint additional handles as size_t

Add check in reader-pcsc.c pcsc_user_reader for minidriver only.

 On branch minidriver-5
 Changes to be committed:
	modified:   src/libopensc/reader-pcsc.c
	modified:   src/minidriver/minidriver.c
2020-02-01 22:42:02 +01:00
Doug Engert 111246f1d2 Better error debug messages for Minidriver
Add MD_FUNC_CALLED(pCardData, level) and  MD_FUNC_RETURN(pCardData, level, ...)
macros.

Handles are type __int3264 in VS2015 are casted as size_t when printing so
all bytes are printed. size_t on Windows are also treated as 32 or 64 bits.
SC_FORMAT_LEN_SIZE is used in the format.
 (Works with VS2105 needs to be tested on other platforms.)

 On branch minidriver-4

 Changes to be committed:
	modified:   minidriver.c

Minidriver.c and reader-pcsc.c - reuse OpenSC reader structure

Windows CNG is managing the insertion and removal of the reader and the card
and will call CardAcquireContext and CardDeleteContext as needed if
the card or reader change. But different processes or threads may establish
different PCSC connects to the same reader and card but with different handles.

Reuse the OpenSC reader when windows uses the same reader but with different
handles. Tests show the certutil -v -scinfo works the same.
Associate_card is only need when called from
CardAcquireContext and disassociate_card is only need when called from
CardDeleteContext.
No need to call reinit_card_for(pCardData, name) just because the handles changed.

This may be the fix for #1763 because calls like CardCreateContainerEx remain
in card state rather then being lost when the handles changed.

 Changes to be committed:
	modified:   src/libopensc/reader-pcsc.c
	modified:   src/minidriver/minidriver.c
2020-02-01 22:42:02 +01:00
Doug Engert 348551c920 Add EC parameters to PKCS15 public key in OpenPGP driver - Fixes #1906
The EC Parameters are the way the EC curve is presented to the outside world,
and in most cases is present in a matching certificate in the SPKI.

card-openpgp.c is modified to add the EC named_curve to the PKCS15 public key.
OpenPGP specs only provide this via the "Algorithm Attributes" for the 3 keys
via tags C1, C2 and C3 These contain the OID (not DER encoded) for the EC curve.

PKCS15 has two ways to encode a "pubkey" as it was originally written for RSA.
But other algorithms have parameters. X509 certificates encode the public key
in the SPKI and PKIX requires the parameters to be in the SPKI. PKCS15
allows for using a SPKI as source for a public key.

pgp_get_pubkey_pem will return the DER encoded RSA pubkey as before by
calling sc_pkcs15_encode_pubkey
pgp_get_pubkey_pem will return the DER encoded EC pubkey with parameters by
calling sc_pkcs15_encode_pubkey_as_spki which calls sc_pkcs15_fix_ec_parameters
internally to map DER encoded OID to named_curve.

For readability, "sc_pkcs15_pubkey_t pubkey;" definitions are changed to
"sc_pkcs15_pubkey_t p15pubkey;"

sc_pkcs15_erase_pubkey is used to avoid memory leaks.

 On branch openpgp-ec-pub-curve

 Date:      Tue Jan 21 09:43:56 2020 -0600
 Changes to be committed:
	modified:   src/libopensc/card-openpgp.c
2020-02-01 22:39:05 +01:00
Frank Morgner 0cd19b59e1 pkcs11-tool: add --usage-wrap (disabled by default)
fixes https://github.com/OpenSC/OpenSC/issues/1913
2020-02-01 22:29:35 +01:00
Frank Morgner 7e0465370f
Merge pull request #1914 from marschap/PGPtool-fixes
PGPtool fixes
2020-02-01 22:27:58 +01:00
Frank Morgner 8d4af9eb0b pkcs11: fixed right padding of token label with ' '
fixes https://github.com/OpenSC/OpenSC/issues/1922
2020-02-01 22:20:48 +01:00
Lewis Porter 723129bc12 Check if card name is null in acos atrust driver
opensc-tool segfaults when trying to read a card  that doen’t populate the name field. This commit adds a null check before calling strcmp().
2020-01-31 16:15:23 +01:00
Frank Morgner 45a77ab88d
Merge pull request #1772 from Jakuje/idprime
Add support for Gemalto IDPrime smart cards
2020-01-31 15:49:29 +01:00
Frank Morgner a501c0d185
sc_decompress_zlib_alloc: check inputs, avoid int underflow (#1907)
- turns out, you can shrink a buffer with realloc on some implementations
- realloc is never called with 0 (which would free the data)
- length checking is done in zlib, we just do the allocation

closes https://github.com/OpenSC/OpenSC/issues/1905
2020-01-30 09:45:44 +01:00
Frank Morgner b119781b02 myeid: fixed memory leak
Credits to OSS-Fuzz

Fixes https://oss-fuzz.com/testcase-detail/5671550682660864
2020-01-29 14:47:12 +01:00