Commit Graph

1583 Commits

Author SHA1 Message Date
Frank Morgner ee1c8073c2 pkcs11-tool: allow tests with keys that don't require PIN
... such as the 9e key of a PIV card.
2020-01-17 16:04:39 +01:00
Peter Marschall 6b295e4207 tools: correctly check return value of getopt_long()
According to the specs, getopt_long() returns -1, which is often,
but not necessarily the value of EOF.
2020-01-12 09:42:30 +01:00
Peter Marschall a0adbc9ef2 dnie-tool: cleanup
- remove command line option '--card-driver';
- instead force driver 'dnie' and fail if card is not a DNIe card
- overhaul option parsing
  - remove unused variable 'long_optind'
  - bail out with usage message on all unknown/unhandled args
  - correctly terminate option parsing (no infinite loop)
- slight refactoring
  - avoid magic constant '0x0f'
  - make variable 'tries_left' more local
  - move dependent code into if block
2020-01-12 09:42:09 +01:00
Peter Marschall 58ecb4aba2 cardos-tool: cleanup
- remove command line option '--card-driver';
- instead force driver 'cardos' and fail if card is not a CardOS card
- overhaul option parsing
      - remove unused variable 'long_optind'
      - bail out with usage message on all unknown/unhandled args
      - correctly terminate option parsing (no infinite loop)
2020-01-12 09:40:54 +01:00
Peter Marschall 04f4f589a1 piv-tool: cleanup
- remove command line option '--card-driver';
- instead force driver 'PIV-II' and fail if card is not a PIV card
- overhaul option parsing
  - remove unused variable 'long_optind'
  - make work option '--reader' ( "r:" was missing in the optstring!!!)
  - bail out with usage message on all unknown/unhandled args
  - correctly terminate option parsing (no infinite loop)
2020-01-12 09:40:53 +01:00
Peter Marschall 5514a0529f dnie-tool: rename option '--driver' to '--card-driver'
Rename option '--driver' to '--card-driver' for increased consistency.

In addition, extend it the same way opensc-explorer was extended. I.e.
treat the question mark given as argument to option '--card-driver'
special: list all available drivers instead of stupidly bailing out.

In contrast to opensc-tool and opensc-explorer, which are card-agnostic,
I am not sure whether the option '--card-driver' makes sense on this
card-specific tool.
2020-01-12 09:36:49 +01:00
Peter Marschall a10368769c cardos-tool: make '--card-driver ?' list all available drivers
Extend cardos-tool the same way opensc-explorer was extended. I.e.
treat the question mark given as argument to option '--card-driver'
special: list all available drivers instead of stupidly bailing out.

In contrast to opensc-tool and opensc-explorer, which are card-agnostic,
I am not sure whether the option '--card-driver' makes sense on this
card-specific tool.
2020-01-12 09:36:49 +01:00
Peter Marschall 30fdc7de4a piv-tool: make '--card-driver ?' list all available drivers
Extend piv-tool the same way opensc-explorer was extended. I.e.
treat the question mark given as argument to option '--card-driver'
special: list all available drivers instead of stupidly bailing out.

In contrast to opensc-tool and opensc-explorer, which are card-agnostic,
I am not sure whether the option '--card-driver' makes sense on this
card-specific tool.
2020-01-12 09:36:49 +01:00
Peter Marschall 94288b438e opensc-tool: make '--card-driver ?' list all available drivers
Extend opensc-tool the same way opensc-explorer was extended. I.e.
treat the question mark given as argument to option '--card-driver'
special: list all available drivers instead of stupidly bailing out.
2020-01-12 09:36:49 +01:00
Peter Marschall 5da40bf027 opensc-explorer: make '--card-driver ?' list all available drivers
Make opensc-explorer a bit more user friendly by treating the question mark
given as argument to option '--card-driver' special: list all available
drivers instead of stupidly bailing out.
2020-01-12 09:36:49 +01:00
Peter Marschall a40cde2d04 util: refactor listing card drivers
Make util_list_card_drivers() a function in util.c to allow
consistent listing of available card drivers from tools.
2020-01-12 09:36:49 +01:00
Jakub Jelen aaa302ca35 asn1: Allow non-strict INTEGER parsing for other code paths (FCI parsing) 2020-01-07 14:50:47 +01:00
Jakub Jelen 3a3a465e6b Add basic support for OEAP decryption in OpenSC internals 2020-01-07 13:30:28 +01:00
Jakub Jelen 40c41cee0c pkcs11-tool: Make the SHA256 default for OAEP decryption
It is already default in all the other functions and it really makes sense since
the SHA1 is being obsoleted
2020-01-07 13:29:53 +01:00
carblue f14043aad6 opensc-explorer get: prevent sc_read_binary applied on record-based files 2020-01-07 10:35:39 +01:00
carblue c1fb5b130e opensc-tool print_file: fix addressing records 2020-01-07 10:24:10 +01:00
Priit Laes 0b4b7fbaf0 openssl: Drop all compatibility checks for <=openssl-1.0.0 2020-01-06 15:47:07 +01:00
Khem Raj 05e3f7b667 Fix misleading code indentation
Fixes
error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
         if(cipher)
         ^
../../../git/src/libopensc/card-entersafe.c:369:2: note: previous statement is here
        if(sbuf)
        ^
2019-12-28 18:18:06 +01:00
Julian Strobl e9aa163fe5 pkcs11-tool: fix output of test_decrypt
Before the output looked like this, if a public key was not found:
```
  testing key 1 (IDKey2)
    RSA-X-509: OK
    RSA-PKCS: OK
  testing key 2 (IDKey3)
couldn't find the corresponding pubkey for validation
couldn't find the corresponding pubkey for validation
    RSA-X-509:     RSA-PKCS:   testing key 3 (IDKey4)
couldn't find the corresponding pubkey for validation
couldn't find the corresponding pubkey for validation
```

Now:
```
  testing key 1 (IDKey2)
    RSA-X-509: OK
    RSA-PKCS: OK
  testing key 2 (IDKey3) -- can't find corresponding public key, skipping
  testing key 3 (IDKey4) -- can't find corresponding public key, skipping
```
2019-12-28 18:15:55 +01:00
Julian Strobl 81940e123b pkcs11-tool: align output for test_signature
Before it was a bit confusing, e.g.:
```
  testing key 1 (2048 bits, label=IDKey2) with 1 signature mechanism
    RSA-X-509: OK
couldn't find the corresponding pubkey
  testing key 2 (0 bits, label=IDKey3) with 1 signature mechanism -- can't be used to sign/verify, skipping: can't obtain modulus
```

The error message in line 3 is for IDKey3 and not for IDKey2.

With this patch the output is aligned with `test_verify`:
```
  testing key 1 (IDKey2) with 1 mechanism
    RSA-X-509: OK
  testing key 2 (IDKey3) with 1 mechanism -- can't find corresponding public key, skipping
```
2019-12-28 18:15:55 +01:00
Frank Morgner 39c1400fac opensc-notify: fixed name in plist 2019-12-04 14:55:23 +01:00
carblue d4823541b7 pkcs15-init: Fix issue #1219 2019-11-23 21:38:14 +01:00
Frank Morgner 07cff0e168 fixed 341844 Incorrect deallocator used 2019-11-05 21:49:30 +01:00
Frank Morgner 3a1bd36e20
Use onepin-opensc-pkcs11.so for Chromium (#1828)
* pkcs11-register: Fixed detection of already registered OpenSC

Anny configuration of onepin-opensc-pkcs11.so and opensc-pkcs11.so
should be enough to skip registering the default module again.

* Use onepin module for generic NSS DB

fixes https://github.com/OpenSC/OpenSC/issues/1818

May have the disadvantage that some other programs that use NSS don't
see the signature keys. However, we currently only know for sure that
Chromium is using the generic NSS DB.
2019-10-16 13:16:22 +02:00
Frank Morgner 53ff7182fb
pkcs11-tool: disable wrap/unwrap test (#1808)
... until https://github.com/OpenSC/OpenSC/issues/1796 is resolved
2019-10-01 11:52:33 +02:00
Frank Morgner e2491a7d7f
pkcs11-tool: fixed displaying secret key attributes (#1807)
fixes https://github.com/OpenSC/OpenSC/issues/1805
2019-10-01 11:51:55 +02:00
Frank Morgner 25bc8fc167 fix https://github.com/OpenSC/OpenSC/issues/1786
Thanks to Alexandre Gonzalo
2019-09-16 13:06:38 +02:00
Peter Popovec 5b8095ca2c string null-termination fix
strncpy does not generate null-terminated string, fixed by memcpy.
2019-09-02 09:32:12 +02:00
Frank Morgner a1d3e76999 openpgp: handle cards with static algorithms
fixes https://github.com/OpenSC/OpenSC/issues/1659
2019-08-28 11:06:55 +02:00
Peter Popovec d7a86d397f opensc-tool: do not connect card if not neccesary, fix util.c errors
opensc-tool: for options --version, --list-readers, -D, etc. we do not
need to connect card/reader. This removes unnecessary error messages
if card is not present in card reader or if reader is not available.
util.c: use symbolic error codes, pass error codes to caller without change.
2019-08-20 13:38:51 +02:00
Frank Morgner b6be87a348 make sc_format_apdu_ex agnostic to card properties 2019-08-20 13:38:20 +02:00
Peter Popovec 426772298a pkcs15-tool: inconsistent -r option fix
Option -r is used in other opensc tools to specify card reader.  pkcs15-tool
uses -r to specify cerfificate.  This fix intorduces warning message if -r
is used, and for future versions of pkcs15-tool -r is used to specify
reader.
2019-08-05 01:14:35 +02:00
carblue 709fa98bb5 opensc-tool: fix --list-algorithms for AES 2019-07-22 13:09:30 +02:00
Peter Marschall 229dd32e3a opensc-explorer: fix APDU command
Do not ignore first parameter.
2019-06-21 14:34:38 +02:00
Raul Metsma 3a192e2c87 pkcs11-tool: Add extractable option to key import
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-06-03 10:59:58 +02:00
Doug Engert a2dd500624 Fix pkcs11-tool encryption error Fix #1694
Make sure data being encrypted is less then the modulus.

 On branch pkcs11-tool-encryption
 Changes to be committed:
	modified:   ../tools/pkcs11-tool.c
2019-05-31 14:16:24 +02:00
Frank Morgner b7b501d0a5 fixed issues reported by clang-analyzer 2019-05-21 19:34:46 +02:00
Jakub Jelen e501c5ae81 Unbreak build without OpenSSL 2019-05-21 18:44:06 +02:00
Frank Morgner e275b34269 fixed 339157 Unused value 2019-05-14 14:50:17 +02:00
Andreas Kemnade c3a9458fa8 egk-tool: fix missed initialisation of card pointer
If util_connect_card_ex() fails, sc_disconnect_card() will use a
random pointer leading to segmentation faults.
2019-05-02 10:09:08 +02:00
Andreas Kemnade 209be72979 eGK: fix path for vd/gvd
path was wrong, the same as for pd
2019-05-02 10:09:08 +02:00
Frank Morgner f0a6a568f4 fixed Local variable hides global variable 2019-05-02 10:08:28 +02:00
Frank Morgner 86ba3ea489 fixed Wrong type of arguments to formatting function 2019-05-02 10:08:28 +02:00
Frank Morgner c671083ee3 fixed missing file 2019-04-25 16:46:07 +02:00
Frank Morgner 8382f243b2 fixed 337891 Out-of-bounds write 2019-04-25 15:44:11 +02:00
Frank Morgner bfa94dc90d
Merge pull request #1600 from AlexandreGonzalo/trustonic_pkcs11 2019-04-25 14:51:54 +02:00
alegon01 e21cb5712c Fix in encrypt_decrypt(), initialize the mgf 2019-04-24 14:03:35 +02:00
Dmitriy Fortinskiy 8cf1e6f769 pkcs11-tool: List supported GOST mechanisms 2019-04-17 16:42:12 +02:00
Dmitriy Fortinskiy a5382d32fd pkcs11-tool: Show GOSTR3410-2012 keys 2019-04-17 16:42:12 +02:00
Dmitriy Fortinskiy 0e12b1dc71 pkcs11-tool: Generate GOSTR3410-2012 keys 2019-04-17 16:42:12 +02:00
Dmitriy Fortinskiy 4614beb87e pkcs11-tool: Add keys access flags 2019-04-17 16:40:41 +02:00
Raul Metsma 91a1dd9af4 Option to delete object by index
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-17 14:38:40 +02:00
Raul Metsma 3935d501bf Implement Secret Key write object
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-17 14:37:49 +02:00
Frank Morgner 066c30bb4e opensc-notify: add to autostart 2019-04-08 11:16:13 +02:00
Frank Morgner 159821497c egk-tool: fixed verbose logging 2019-04-08 11:16:13 +02:00
Frank Morgner fe95520e3e explicitly import libpkcs11.h 2019-04-08 11:16:13 +02:00
Frank Morgner 6f9b58af72 added pkcs11-register 2019-04-08 11:16:13 +02:00
Jakub Jelen fc4d600634 pkcs11-tool: Allow to set CKA_ALLOWED_MECHANISMS when creating an objects
Also list them in the attributes listing
2019-04-08 11:15:19 +02:00
alegon01 f631b5f733 Fix in encrypt_decrypt(), check for (in_len <= sizeof orig_data) 2019-04-05 10:39:52 +02:00
alegon01 4913feadb8 Fix in encrypt_decrypt(), check for (in_len <= sizeof orig_data) 2019-04-05 10:38:12 +02:00
Peter Popovec f070c99b65 opensc-tool: do not use card driver to read ATR
If card driver fails to connect to card, 'opensc-tool -a' may fail to print
ATR even if ATR is available from card reader.  Before use of card driver,
do only card reader connect, then print ATR.  Only if it is neccesary, use
card driver for the rest of opensc-tool functions.
2019-03-25 14:34:26 +01:00
Frank Morgner 2f4df1b93e tools: unified handling of gengetopt 2019-03-25 14:30:09 +01:00
Frank Morgner fc9277b778 use compat_getopt_long if getopt_long is not available
uses the autoconf way for replacing getopt.h

fixes https://github.com/OpenSC/OpenSC/issues/1527
2019-03-25 14:30:09 +01:00
Frank Morgner 6aa5410e73 goid-tool: live with short length APDUs 2019-03-18 13:59:11 +01:00
Frank Morgner d953998aa3 npa-tool: force default card driver 2019-03-13 12:01:09 +01:00
alegon01 31831c300b Remove the call to OPENSSL_init_crypto() which is not needed. I have a segmentation fault when the process exits. 2019-03-12 08:52:06 +01:00
Frank Morgner 6472027848 tools: release context when card connection fails 2019-03-07 22:18:54 +02:00
Scott Gayou 0d79675497 Small memory leak fix (CVE-2019-6502 in #1586)
CVE-2019-6502 was assigned to what appears to be a very minor
memory leak that only occurs on an error-case in a CLI tool.
If util_connect_card fails, we still need to release the sc
context previously allocated by sc_context_create else memory
will leak.
2019-03-06 19:51:43 +01:00
alegon01 728d099a53 FIX typo OpenSSL vs OpenSsl. 2019-03-06 11:35:11 +01:00
alegon01 b327b76134 FIX use pseudo_randomize() for a proper initialization of orig_data in encrypt_decrypt(). 2019-03-06 10:26:05 +01:00
Frank Morgner 070370895f fixed 333707 Dereference before null check 2019-03-06 00:42:38 +01:00
Frank Morgner ba185954c5 fixed 333709 Unchecked return value 2019-03-06 00:42:38 +01:00
Frank Morgner 9abe44f03c fixed 333715 Dereference after null check 2019-03-06 00:42:38 +01:00
Frank Morgner e876cf62eb fixed 333711 Dereference before null check 2019-03-06 00:42:38 +01:00
Frank Morgner b1a58c7925 removed dead code 2019-03-06 00:42:38 +01:00
Frank Morgner 27526de021 implemented sc_format_apdu_ex 2019-03-05 13:54:13 +01:00
alegon01 7271fe610b Add support for the OpenSsl signature format for the signature verification. 2019-02-18 16:03:41 +01:00
Frank Morgner f4fccfd94e fixed undefined bitshift 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 32e1995300 fixed dead assignment 2019-02-14 09:22:23 +01:00
Frank Morgner e4a01643a6 fixed possible NULL pointer dereference 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
alegon01 9ae507c5f8 Fix indentation. 2019-02-12 14:09:26 +01:00
alegon01 b63a868e68 Fix build when EVP_PKEY_CTX_set_rsa_oaep_md is not defined. 2019-02-12 10:42:39 +01:00
Frank Morgner 72cdc9d82e goid-tool: fixed confusion about always/never acl 2019-02-08 15:08:03 +01:00
Frank Morgner aca9d79f6d fixed parsing SoCManager info 2019-02-07 16:56:33 +01:00
alegon01 973625773b Fix encrypt_decrypt() for CKM_RSA_PKCS_OAEP. It is working fine now with OpenSsl 1.1.1a. 2019-02-07 10:42:48 +01:00
alegon01 084624f340 Fix CKM_RSA_PKCS in encrypt_decrypt(). 2019-02-05 12:03:51 +01:00
alegon01 9aa413bd7e Fix CKM_RSA_X_509 encrypt_decrypt(). Improve the code for CKM_RSA_PKCS and CKM_RSA_PKCS_OAEP. For these alogs, only CKM_SHA_1 is supported. 2019-02-05 11:35:42 +01:00
alegon01 d25fbe3cec Remove 2 useless comments in encrypt_decrypt(). 2019-02-05 11:24:33 +01:00
Frank Morgner 928fbf2f03 goid-tool: implented PIN/FP verification for PAccess 2019-02-04 16:01:56 +01:00
alegon01 3d09823df0 Fix build when OPENSSL_NO_RIPEMD and OPENSSL_NO_CAST are defined. Fix formatting. 2019-02-04 14:26:02 +01:00
alegon01 f030aa2c25 Add support for CKM_RSA_X_509 in encrypt_decrypt() and decrypt_data(). 2019-02-04 14:23:13 +01:00
alegon01 9b7605ff3c Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). Only set the OAEP params for CKM_RSA_PKCS_OAEP, I had an issue with a variable not initialized. 2019-02-01 15:27:55 +01:00
alegon01 cf617da4bd Before calling encrypt_decrypt() make sure that the mechanism is for RSA and supports decryption, otherwise skip it. 2019-02-01 11:37:47 +01:00
alegon01 2be799f739 Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). fix mechanism value in call to util_fatal(). fix formatting. 2019-02-01 11:35:25 +01:00
alegon01 16ca73ae40 Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). fix mechanism value in call to util_fatal(). 2019-02-01 11:19:33 +01:00
alegon01 968bfa8444 Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). 2019-02-01 09:16:59 +01:00
alegon01 ff3448fb18 Fix build when OPENSSL_NO_RIPEMD and OPENSSL_NO_CAST are defined. 2019-02-01 09:13:21 +01:00
alegon01 f412995811 Bug fix in verify_signature() when the buffer to verify is larger than 1025 bytes. In this case, the signature length given to C_VerifyFinal() was incorrect. 2019-02-01 09:10:02 +01:00
opensignature 84f0a88edb Remove postecert and infocamere support because no longer issued (#1584)
* Remove postecert and infocamere support because no longer issued

* Remove wrong changes

* reset NEWS

* EC_POINT_set_affine_coordinates_GFp and EC_POINT_get_affine_coordinates_GFp are
deprecated, use EC_POINT_set_affine_coordinates and EC_POINT_get_affine_coordinates

* If OPENSSL API version is < 3 use old functions EC_POINT_[sg]et_affine_coordinates_GFp

* Move the OpenSSL compatibility stuff to src/libopensc/sc-ossl-compat.h
2019-01-30 22:01:24 +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 993f6f5cc6 Use opensc-pkcs11.so for static build of pkcs11-tool
Statically link opensc-pkcs11 into pkcs11-tool with --disable-shared
2019-01-30 21:57:59 +01:00
Frank Morgner 83c4ebe9d6 goid-tool: reset authentication status 2019-01-30 13:00:14 +01:00
Frank Morgner fc08d89247 goid-tool: differ PAccess and SoCManager usage 2019-01-30 09:35:16 +01:00
Frank Morgner a8c84d490a handle multiple verifications when changing secret 2019-01-30 09:35:11 +01:00
Frank Morgner 6bf7c0d219 don't hide global variables 2019-01-20 23:02:21 +01:00
Frank Morgner 3fe198f21e treat records with size_t 2019-01-20 23:02:21 +01:00
Frank Morgner 4b30858092 pkcs11-tool: fixed argument type
reported by lgtm
2019-01-20 23:02:21 +01:00
Frank Morgner d806ee3245 fixed unsafe usage of gmtime
reported by lgtm
2019-01-20 23:02:21 +01:00
Frank Morgner b8b4f7c36f goid-tool: added error checking for verify/change 2019-01-18 23:02:36 +01:00
Martin Paljak c3a9837b10 Add mechanisms used by SoftHSM2
/Library/OpenSC/bin/pkcs11-tool --module /usr/local/lib/softhsm/libsofthsm2.so -M

will not show any more numeric mechanisms.

Source: https://www.cryptsoft.com/pkcs11doc/STANDARD/include/v240e01/pkcs11t.h
2019-01-15 13:07:58 +02:00
Raul Metsma 3c1d425eb9 Remove unused include
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-01-15 12:48:26 +02:00
Mat e19fe680c4 Add object type "secrkey" to help of --type switch in pkcs11-tool (#1575)
* Add object type "secrkey" to help of --type switch in pkcs11-tool

Reading an object with pkcs11-tool requires the `--type` switch. The help for that switch is currently incomplete as it is missing the (not very friendly named" *secrkey* option used to read out a secret key object.

I have added this information to the help description.

* Update man page

Describe secrkey option of pkcs11-tool's --type switch in man page
2019-01-15 07:32:41 +01:00
Frank Morgner 609e2d89cf added GoID Tool 2019-01-15 07:31:20 +01:00
Frank Morgner 1eda4c1795 sc-hsm-tool: add support for initializing biometry 2019-01-15 07:31:20 +01:00
Frank Morgner fbb4d1f843 tools: use consistent behavior of -v
-v switches to debug output to stderr in OpenSC tools regardless of the opensc.conf setting
2019-01-15 07:30:46 +01:00
Peter Marschall a6ee84f13d opensc-explorer: fix 'pin_info' command
Correctly treat 'data.pin1.logged_in' as tristate instead of boolean.
While at it, fix visual glitch to not wrap around a stand-alone period.
2019-01-02 09:08:00 +01:00
Peter Marschall dc505be808 openpgp-tool: use binary OR for calculating 32-bit integers from byte
Also avoid potential unintended sign extension (SIGN_EXTENSION).
2018-12-27 14:13:41 +01:00
Frank Morgner b11cc3871e tools: harmonize card initialization 2018-12-18 14:50:45 +01:00
Frank Morgner 907c9479e2 replace sc_debug_hex with sc_log_hex 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
Luka Logar 18dc38a618 Fix some pkcs15-init issues
1. pkcs15-init is using XKU but it should use cert KU to check private key usage instead.
2. Don't mark imported keys as ALWAYSSENSITIVE and NEVEREXTRACTABLE as they are not.
3. When importing keys from PKCS#12 files (with several certs inside), use consecutive IDs for additional certificates (instead of starting from 45).
2018-12-05 12:43:08 +01:00
Hannu Honkanen 9e5a324903 Edited according to PR review: CKA_ALWAYS_AUTHENTICATE only associated with private keys. Defined a custom attribute to achieve same functionality with secret keys. Updated man pages. 2018-12-05 12:10:42 +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
Frank Morgner b01ca2dcc9
added support for colors (#1534)
because everyone loves colors
2018-11-25 22:08:36 +01:00
Jakub Jelen f1f98f829c pkcs11-tool: Unbreak signature and verification in pkcs11-tool 2018-11-25 22:07:33 +01:00
Doug Engert 764c61446e pkcs15-crypt - Handle keys with user_consent - Fixes #1292
This fixes problem as stated in:
https://github.com/OpenSC/OpenSC/issues/1292#issuecomment-431879472

pkcs15-crypt.c will treat keys with user_consent like PKCS#11 would.
SC_AC_CONTEXT_SPECIFIC is set when doing a verify so a card driver can
take action if needed.

card-piv.c is currently the only driver doing so.
It uses this to hold the card lock so both the VERIFY and following crypto
operations are in the same transaction. The card enforces this restriction.
Without this additional APDUs may be sent before every transaction to test
that the expected applet is selected.

Unlike the circumvention of using ignore_user_consent=true and pin caching
this modification allows a pin pad reader to be used for keys requiring user_consent.

 On branch pkcs15-context-specific
 Changes to be committed:
	modified:   pkcs15-crypt.c
2018-11-20 11:53:57 +01:00
Frank Morgner 3c0a16dc39 CID 321790 (#1 of 1): Resource leak (RESOURCE_LEAK) 2018-11-06 15:53:17 +01:00
Peter Marschall c6d252611b openpgp-tool: add missing length check in prettify_name() 2018-11-06 12:41:19 +01:00
Peter Marschall 4e5805dc5d openpgp-tool: don't uppercase hex string 2018-11-06 12:41:19 +01:00
Peter Marschall afda163dc6 openpgp-tool: fix typo 2018-11-06 12:41:19 +01:00
Peter Marschall ec3830fe66 openpgp-tool: use more compatible strftime() format spec
Replace the Single UNIX specific shorthand %T for %H:%M:%S with the latter
to keep MingW happy.
2018-11-06 12:41:19 +01:00
Peter Marschall 85258f2951 openpgp-tool: use key type to indicate key to generate
Instead of only expecting a key length, and implicitly assuming RSA
as the key algorithm, introduce option --key-type to pass the key type
as a string.

When generating the key determine key algorithm and attributes based on
the key type passed.

If no key was given, default to "rsa2048".
2018-11-06 12:41:19 +01:00
Peter Marschall c9f5e05aca openpgp-tool: new option --key-info to display key info 2018-11-06 12:41:19 +01:00
Peter Marschall 1866c3e930 openpgp-tool: new option --card-info to display card info 2018-11-06 12:41:19 +01:00
Hannu Honkanen 351e0d2bd6 Merge remote-tracking branch 'upstream/master' into wrapping-rebased and resolve conflicts 2018-11-02 13:42:41 +02:00
Peter Marschall 26025b2f5d pkcs15-tool: list & dump cleanups
* when listing public keys, do not cut object labels in compact mode
* when listing private keys in compact mode, left align labels
* make hex codes at least 2 chars wide by changing "0x%X" to "0x%02X"
2018-11-01 12:25:04 +01:00
Frank Morgner c70888f9ab allow compilation with --disable-shared 2018-11-01 00:17:22 +01:00
Hannu Honkanen 9772edc7d1 Handle -u option (x509-usage) when storing secret keys. 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
Peter Marschall a8db9cb4f0 openpgp-tool: harmonize error messages
* use symbolic constants for errors & success
* use util_error() to show errors
* print error messages to stderr
2018-10-04 09:41:31 +02:00
Peter Marschall e4a0b09968 openpgp-tool: remove unnecessary variable
* 'opt_keylen' was only set, but never used => remove
* passing the key length is not an action => do not mark it as such
2018-10-04 09:41:31 +02:00
Jakub Jelen a5daaaff0c piv-tool: Error checking 2018-10-01 23:07:34 +02:00
Jakub Jelen e920ef8eb8 opensc-explorer: Make static analyzers happy 2018-10-01 23:07:34 +02:00