Commit Graph

958 Commits

Author SHA1 Message Date
Frank Morgner 32e1995300 fixed dead assignment 2019-02-14 09:22:23 +01:00
Frank Morgner 85485eb9b0 fixed unused assignments 2019-02-14 09:22:23 +01:00
Frank Morgner fdb0e6d581 Fixed Potential leak of memory 2019-02-14 09:22:23 +01:00
Hannu Honkanen ec176443e2 Fixes an issue that appeared in 6bf9685 (PR #1540). In case use_pinpad==0 && pinsize == 0, uninitialized pinbuf was passed to sc_pkcs15_verify_pin causing problems. 2019-01-30 22:01:52 +01:00
Alexander Paetzelt 09a594d0f0 OpenPGP Card v3 ECC support (#1506)
* pgp: initialize ecc keys for OPC3

* Add supported ECC algorithms by card version

* Add tasks identified so far

* pgp: Recognize ECC set on card

* pgp: get_pubkey_pem read ECC pubkey from card

* pgp: minor code changes for ECC compatibility

* pgp: expand sc_cardctl_openpgp_keygen_info to hold ec info

* Fix segfault problem in pkcs15-pubkey.c

* pgp: enable key generation with pkcs15-init and ECC

* pgp: adapt calculate_and_store_fingerprint to accept ECC

* pgp: adapt rest of pgp_gen_key and subfunctions to accept ECC

* pgp: add kdf parameters for ECDH fingerprint calculation

* pgp: enable key import with pkcs15-init and ECC

* pkcs15-pubkey: fix_ec_parameters onlz accpets explicit data or named_curve

* Fix some mistakes during merge

* More clean up for PR

* Fix some ugly alignments

* Improve code readability

* Prevent unitialized variable by using FUNC_RETURN

* OpenPGP: add length check

* pgp: save exponent length in bits for sc_cardctl_openpgp_keystore_info_t

* pgp: length checks and reallocations

* pgp: oid init added

* OpenPGP: slightly re-factor pgp_update_new_algo_attr()

* replace loop copy with memcpy()
* use ushort2bebytes() to set RSA modulus & exponent
* use symbolic name SC_OPENPGP_KEYFORMAT_RSA_STD for the key import format

* OpenPGP: slighly re-factor pgp_parse_and_set_pubkey_output()

* check for RSA modulus & exponent lengths not being a multiple of 8
* make sure RSA modulus & exponent lengths are always set
* remove a left-over RSA setting from the EC code

* pgp: adding BYTES4BITS

* pgp: initialization of values in pgp_build_extended_header_list based on key type

* pgp: add BYTES4BITS and remove unnecessary tests

* Fix broken pgp_update_new_algo_attr

* pgp: fix the ecpoint_len variable
2019-01-30 22:00:36 +01:00
Frank Morgner 7f7bcbff52 fixed misuse of realloc
calling it with size 0 leads to a free, which eventually may lead to a
double free corruption.
2019-01-30 21:57:59 +01:00
Frank Morgner 3fe198f21e treat records with size_t 2019-01-20 23:02:21 +01:00
Khem Raj 35cb70b5d6 Remove redundant logging
Same information is printed a few line below in same function, the only
difference is that there it takes care of case when label is NULL pointer
unlike this line

secondly, every function call to cosm_write_tokeninfo() in this file
passes label=NULL, and then it tries to print a null pointer

Fixes errors like
src/libopensc/log.h:48:47: error: '%s' directive argument is null
[-Werror=format-overflow=]

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2018-12-18 13:50:08 +01:00
Frank Morgner a899a46b09 replaced SC_TEST_RET with LOG_TEST_RET 2018-12-06 09:26:42 +01:00
Frank Morgner e3dda8894e log errors in verbose 2018-12-06 09:26:42 +01:00
Frank Morgner 00a150f74c replaced SC_FUNC_RETURN with LOG_FUNC_RETURN 2018-12-06 09:26:42 +01:00
Frank Morgner 24b50a4277 replace sc_debug with sc_log 2018-12-06 09:26:42 +01:00
Frank Morgner cf55cdc637 replace SC_FUNC_CALLED with LOG_FUNC_CALLED 2018-12-06 09:26:42 +01:00
Luka Logar 2552fde05f Fix some pinpad reader related issues (#1540)
1. Show pinpad reader capabilities even for uninitialised tokens. This way pinpad can be used during initialisation.
2. Make possible to create so-pin object during initialisation even if no so-pin was provided (on the command line) but pinpad reader is used and card profile contains so-pin data.
2018-12-05 12:41:58 +01:00
Hannu Honkanen ee8c80af4f Implemented handling of CKA_ALWAYS_AUTHENTICATE attribute when importing and generating keys, mapping it to pkcs#15 userConsent field. Added command line options to pkcs11-tool and pkcs15-init tool to use the feature. 2018-12-05 12:10:42 +01:00
Hannu Honkanen 7f91b6e07f MyEID: add AES algorithms to tokenInfo as supported during init. It is better to do it already in init, because adding them in C_UnwrapKey operations would require SO-PIN which is inconvenient.
pkcs15: added function to get a specific supported algorithm, checking also OID.
This is needed because for AES there are different OIDs for each key length.
2018-11-20 11:52:54 +01:00
Hannu Honkanen 3ec39919c3 pkcs15-lib: Must use keyargs->value_len instead of keyargs->key.data_len * 8 when calling check_key_compatibility(), to get correct result in key unwrap operations. In this case data_len is 0, but value_len contains the key length in bits. 2018-11-20 11:52:54 +01:00
Hannu Honkanen 7bb53423a1 Code cleanup and minor corrections according to review. pkcs15-lib: Extractable keys are now marked as native. Check return value of check_key_compatibility in more explicit way to avoid misunderstandings. 2018-10-31 10:36:41 +02:00
Hannu Honkanen 90ec7123ba Corrections and code cleanup as requested in review. Changed value to void* in sc_sec_env_param_t, because param_type defines type of the value. Fixed handling of secret key length in framework-pkcs15 and pkcs15-lib: CKA_VALUE_LEN from PKCS#11 is in bytes, PKCS#15 objects need key length in bits. Rebased on top of upstream/master and resolved merge conflicts. 2018-10-31 10:27:03 +02:00
Hannu Honkanen 4ce7e5289b Fixed setting secret key length. CKA_VALUE_LEN comes as number of bytes, so multiply it by 8 to set correct bit length to the key file. 2018-10-31 10:27:03 +02:00
Hannu Honkanen f74150b53d Proprietary attribute bits in FCP had to be adjusted due to conflicts with existing attributes. The needed changes were made to both card and OpenSC code. 2018-10-31 10:27:03 +02:00
Hannu Honkanen 2487bc18d1 When creating symmetric keys, use CKK_ definitions (key type) rather than CKM_ definitions (mechanism) to specify the key type. 2018-10-31 10:24:19 +02:00
Hannu Honkanen edd48b3200 pkcs15init:
- Added session_object flag to sc_pkcs15init_skeyargs to enable on-card session objects.
- Corrections to handling native and extractable flags
- Allow creating an empty secret key EF for receiving an unwrapped key later.
2018-10-31 10:24:19 +02:00
Hannu Honkanen 9d6ac01c27 pkcs15init: Handle user_consent and set new proprietary information flags in myeid_create_key(). 2018-10-31 10:24:19 +02:00
Hannu Honkanen a10480d50e Continued implementation of unwrap: Creation of a target key object on card to receive an unwrapped key. Setting target key path in sc_security_env_t. 2018-10-31 10:22:16 +02:00
Hannu Honkanen 5f51d5d315 Added implementation of C_UnwrapKey all the way from PKCS#11 interface to the card driver level.
Not yet complete, but can be run with CKA_TOKEN=FALSE set in the target object. Currently unwrapping emulated
with a decrypt operation in card-myeid.c. To be improved.
2018-10-31 10:22:16 +02:00
Peter Marschall 248ece23c6 OpenPGP: bail out on non-RSA key generation/import
Also add the necessary algorithm info where necessary.
2018-10-10 14:52:29 +02:00
Peter Marschall c2f02f72bd OpenPGP: adapt data structures to support RSA alternatives
* update callers to use the adapted structures.
2018-10-10 14:52:29 +02:00
Peter Marschall 772d20969a OpenPGP: first steps to support key types beyond RSA
- rename 'keytype' in some OpenPGP-specific types to 'key_id'
  because they key ID was what the field was used for
- introduce field 'algorithm' in the structures above
  to indicate the key's algorithm: RSA, ...
- define constant SC_OPENPGP_KEYALGO_RSA and use it
- rename constants SC_OPENPGP_KEYFORMAT_* to SC_OPENPGP_KEYFORMAT_RSA_*
  because they are RSA specific
2018-10-10 14:52:29 +02:00
gabrielmuller 6bf67f7917 onepin option also needs PIN to CREATE
I previously changed the default option but forgot to make the same change for onepin.
2018-10-08 21:35:23 +02:00
Jakub Jelen ef724e1e57 pkcs15-authentic: Do not confuse static analyzers 2018-10-01 23:07:34 +02:00
Jakub Jelen a1dfdbbdbc pkcs15-oberthur-awp: Do not confuse cppcheck 2018-10-01 23:07:34 +02:00
Jakub Jelen bce43e6855 Remove dead code 2018-10-01 23:07:34 +02:00
Jakub Jelen a85a4a8b48 pkcs15-authentic: Avoid memory leak on failure 2018-10-01 23:07:34 +02:00
Jakub Jelen b8133c2545 pkcs15-myeid: Return value checking 2018-10-01 23:07:34 +02:00
Jakub Jelen 8e0078a6f9 pkcs15-myeid: Do not confuse coverity with potential double-free 2018-10-01 23:07:34 +02:00
Gabriel Müller 551fcccb90 Changed outdated "STARCOS SPK 2.3" name to "STARCOS".
modified:   src/libopensc/pkcs15-infocamere.c
    modified:   src/libopensc/pkcs15-starcert.c
    modified:   src/pkcs15init/pkcs15-lib.c

Changed isf_acl to also need SO PIN for CREATE.
    modified:   src/pkcs15init/starcos.profile
2018-09-28 16:50:39 +02:00
Frank Morgner 496a9b571d fixed error handling 2018-09-25 12:13:57 +02:00
Frank Morgner 0ae825f8d9 fixed error checking
closes https://github.com/OpenSC/OpenSC/pull/1343
2018-09-25 11:09:07 +02:00
konstantinpersidskiy 0c3412bb37 Fix C_SetAttributeValue for CKA_VALUE for data obj 2018-09-25 10:51:10 +02:00
Priit Laes 1f06a76b1a openssl: Bump openssl requirement to 0.9.8 2018-09-14 08:21:40 +02:00
Frank Morgner 9294058d5c fixed requesting DWORD with sc_ctx_win32_get_config_value
the length of the value is not determined by strlen()
2018-08-05 11:35:12 +02:00
Frank Morgner 4de0d06a93 use single quotes for passing define
makes sure that the shell doesn't evaluate parts of the define
2018-07-17 14:49:27 +02:00
Frank Morgner 452e1d3b96 fixed used of uninitialized return value 2018-06-30 01:17:57 +02:00
Frank Morgner 259b7ec41c check return value 2018-06-29 17:14:55 +02:00
Frank Morgner c026f37677 warn about error in sc_enumerate_apps 2018-06-29 17:14:55 +02:00
Frank Morgner 6819759946 fixed memory leak 2018-06-29 17:14:55 +02:00
Andreas Kemnade 23706635a8 cardos: create pin in mf
If cardos cards are initialized by other software and there is a pinref
without the msb set, also the pin verify works without that bit set.

This patch changes pin initialisation so that the pin is created in mf
which has the effect that pin verify works without | 0x80 to the
pin ref.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
2018-06-08 08:23:37 +02:00
Frank Morgner f04a2654d9 card-muscle: be more relaxed in card initialization
closes https://github.com/OpenSC/OpenSC/pull/1248
2018-05-18 12:36:28 +02:00
Peter Marschall 5abe99d228 fix typos
Mass-typo fixing, almost exclusively in comments and text strings.

While at it also fixed a few (very few) grammar errors.
2018-04-15 09:34:45 +02:00