Commit Graph

6475 Commits

Author SHA1 Message Date
Doug Engert 0d6fc02e23 reader-pcsc: improved logging and handling of reset
A sleep(1) is added after SCARD_W_CARD_RESET as done in other parts of reader-pcsc.c

Extra debugging messages are output.

SCard routines return "LONG" which may be different then "long" on some systems
were "LONG" is 32 bits and "long" is 64 bits.
Make sure printf format of 0x%08lx has a matching "long" input variable.

This closes #816
2016-07-19 15:20:49 +02:00
Doug Engert edf24d0e2e PIV and PIV-Want-To-Be Issues
Not all PIV cards follow the  NIST 800-73-3 standard. This commit is designed to address some
of the issues.  OpenSC developers don't have access to all the different versions of devices
or access to release notes for the devices to see when a bug was introduced and when it is fixed.

To make OpenSC code changes easier,  the code is divided into four sections:

(1) Identify the card/token as best possible by looking at the "Historical bytes" in the ATR.
For the Yubico devices read their version number and log it via sc_debug.

(2) Define the card_issues  CI_* defines in card-piv.c. There are 8 of them at the moment.
See below.

(3) based on the card->type and possibly Yubico version set the priv->card_issues flags that
apply to  current card or device.

(4) Implement in the code changes needed for each issue.

Other issues can be added. As more info is obtained (3) can be updated using the version
number as needed.

The card issues are:

CI_VERIFY_630X - VERIFY "tries left" returns 630X rather then 63CX

CI_VERIFY_LC0_FAIL - VERIFY Lc=0 never returns 90 00 if PIN not needed. Will also test after
first PIN verify if protected object can be used instead

CI_CANT_USE_GETDATA_FOR_STATE - No object to test verification in place of VERIFY Lc=0

CI_LEAKS_FILE_NOT_FOUND - GET DATA of empty object returns 6A 82 even if PIN not verified

CI_OTHER_AID_LOSE_STATE - Other drivers match routines may reset our security state and lose AID

CI_NFC_EXPOSE_TOO_MUCH - PIN, crypto and objects exposed over NFS in violation of 800-73-3

CI_NO_RSA2048 - does not have RSA 2048

CI_NO_EC384 - does not have EC 384

The piv_card_match and piv_init interactions were cleaned up.

 Changes to be committed:
	modified:   card-piv.c
	modified:   cards.h
2016-07-19 15:17:28 +02:00
Frank Morgner b232c9b675 card-starcos: use transceive length from EF.ATR
fixes https://github.com/OpenSC/OpenSC/issues/765
2016-07-19 14:30:45 +02:00
Frank Morgner 2909ba28a9 parse Extended Length Information in EF.ATR/INFO 2016-07-19 14:30:38 +02:00
Frank Morgner 9a325fc1db EF.ATR: removed IAS/ECC workaround
- IAS/ECC has the category indicator byte in EF.ATR, which is a
  violation of ISO 7816-4, where it is only allowed in the historical
  bytes of ATR. Removing the IAS/ECC specific modification of EF.ATR
  allows reading ISO complient EF.ATR again.
- IAS/ECC parsing should still be successfull. We now always try to
  check for ISO7816_TAG_II_STATUS_SW ignoring the category indicator
  byte
2016-07-19 14:30:31 +02:00
HAMANO Tsukasa cb1da562f4 JPKI: fix prkey usage 2016-07-19 10:23:31 +02:00
HAMANO Tsukasa 33a16b4f4e New: jpki card driver
VTA: cosmetic touch and rebase to one commit
close PR #801
2016-07-17 16:36:13 +02:00
Frank Morgner 2f10de4f5c use sc_pkcs15_get_pin_info in C_GetTokenInfo
introduced paramter to signal back the login state
- used for the pin command SC_PIN_CMD_GET_INFO
- implemented in accordance to ISO 7816-4; all other implementations
  are currently set to an unknown login state

implemented and exporeted sc_pkcs15_get_pin_info

use sc_pkcs15_get_pin_info in C_GetTokenInfo

C_GetSessionInfo: Check whether a logout was done

Closes https://github.com/OpenSC/OpenSC/pull/624

rebased by @viktorTarasov
2016-07-17 14:07:43 +02:00
Nuno Goncalves 1198197586 pkcs11-tool: use CKF_{SO,USER}_PIN_* flags to provide alerts to the user
rebased by @viktorTarasov
initial version in PR-795
2016-07-17 13:22:55 +02:00
Nguyễn Hồng Quân 46d8264f08 pkcs15-openpgp: Change sprintf to snprintf. 2016-07-17 13:22:55 +02:00
Nguyễn Hồng Quân 91fc129f19 PKCS15-OpenPGP: Change error log
Only one DO is supported now.
2016-07-17 13:22:55 +02:00
Frank Morgner 14b57ffb3e Merge pull request #743 from Jakuje/jjelen-truncate-ecdsa-signature
Truncate data for ECDSA signature to the size of the key
2016-07-08 01:35:34 +02:00
Frank Morgner 1c661ca023 Merge pull request #732 from metsma/P11Label
Move PIN type label front of description
2016-07-08 01:34:37 +02:00
Frank Morgner e98315a196 libsm: fixed out of bounds write
`sm_incr_ssc` performed an out of bounds write when `ssc` is bigger than
255. The local variable `ii` needs to be decremented instead of
incremented in the `for`-loop.

This was introduced in d30cd83a, wheras The previous implementation did
actually decrement `ii`, see d30cd83ad4

Fixes https://github.com/OpenSC/OpenSC/issues/785
2016-06-30 21:57:47 +02:00
David von Oheimb 4441efa6da pkcs11-tool: various improvements, extensions, fixes, cleanup
========================================
rebased by VTA -- commits are forged to one,
excluding the following chunk
(reason -- if not explicitely indicated, the mechanism has to be found out using the mechanism flags):

@@ -1713,8 +1713,9 @@ static int gen_keypair(CK_SLOT_ID slot, CK_SESSION_HANDLE session,
                        int ii;

                        if (!opt_mechanism_used)
+                               opt_mechanism = CKM_EC_KEY_PAIR_GEN;
                                if (!find_mechanism(slot, CKF_GENERATE_KEY_PAIR, mtypes, mtypes_num, &opt_mechanism))
-                                       util_fatal("Generate EC key mechanism not supported\n");
+                                       util_warn("Generate EC key mechanism not listed as supported");

                        for (ii=0; ec_curve_infos[ii].name; ii++)   {
                                if (!strcmp(ec_curve_infos[ii].name, type + 3))

will close PR #747
2016-06-29 14:18:56 +02:00
Viktor Tarasov 76e0e19460 pkcs11-tool: no error when getting sensitive attr. value
resolves PR #807
2016-06-29 10:34:20 +02:00
Viktor Tarasov 3dbcc0b035 pkcs11-tool: generate secret key
resolve PR #808
2016-06-29 10:32:30 +02:00
Frank Morgner 97b8bf4fd1 Merge pull request #789 from jasp00/dnie-ui
Fix interaction with DNIe UI
2016-06-25 22:43:07 +02:00
Frank Morgner 072ec98301 Merge pull request #772 from vletoux/gids_maintenance
gids bug fixing
2016-06-25 22:32:37 +02:00
vletoux 0ae4b4ac0d gids bux fixing
fix the problem if the serial number is entered in the command line
2016-06-24 21:20:40 +02:00
Frank Morgner 0898d06944 fixed and cleaned up nmake Makefiles 2016-06-23 07:35:53 +02:00
Frank Morgner ab2a65e049 added cardos ATRs to minidriver installation 2016-06-21 09:31:48 +02:00
Frank Morgner 25b52f6ada don't use a def file for PKCS#11 modules
exports are already declared in pkcs11.h. declaring them twice will
yield LNK4197.
2016-06-14 14:58:11 +02:00
Frank Morgner 84d4b0630c compile zlib with -MT instead of -MD 2016-06-14 14:58:11 +02:00
Frank Morgner 050c62f7df added parameter checking to `sc_right_trim`
fixes conversion from 'size_t' to 'long', possible loss of data
2016-06-14 14:58:11 +02:00
Frank Morgner 836842a6bb remove unused `scconf_entry` 2016-06-14 14:57:58 +02:00
Frank Morgner 72dda66be8 fixed possible loss of data 2016-06-14 14:57:08 +02:00
Frank Morgner 9983c4185f fixed incompatible types ('DWORD *' to 'size_t *') 2016-06-14 14:11:26 +02:00
Frank Morgner 2746a7f430 Merge pull request #793 from michaelansel/patch-1
Relax XML parsing regexes for bash_completion
2016-06-13 13:39:33 +02:00
Michael Ansel da4446a822 Relax XML parsing regexes for bash_completion
Unnecessarily strict regex was failing for some unknown reason on OS X. Easier to just relax the regex than understand what's wrong (and then relax the regex).
Fixes #782
2016-06-09 14:34:31 -07:00
Frank Morgner 6b27d7392a Merge pull request #790 from nunojpg/master
fix #788 pkcs15-tool --read-ssh-key crash
2016-06-06 21:40:03 +02:00
Jakub Jelen f52f6bb310 [p15dump] Error message with a reason for missing unusedSpace file 2016-06-06 21:36:09 +02:00
Nuno Goncalves d97ee79333 fix #788 pkcs15-tool --read-ssh-key crash
Don't try to free again pubkey if the parent cert has already been freed.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-06-06 18:29:03 +01:00
Javier Serrano Polo eee4d74721 Fixed interaction with DNIe UI 2016-06-06 01:56:51 +02:00
Frank Morgner 9066d8f999 simplyfied netkey-tool
fixes conversion from 'long' to 'u8', possible loss of data
2016-06-05 02:28:50 +02:00
Frank Morgner b9cefa6825 removed unused variable 2016-06-05 02:28:50 +02:00
Jakub Jelen 587a29b7f5 Truncate data for ECDSA signature to the size of the key
Based on the paragraph from PKCS#11 MECHANISMS V2.30: 6.3.1 EC Signatures:

	If the length of the hash value is larger than the bit length of n, only
	the leftmost bits of the hash up to the length of n will be used. Any
	truncation is done by the token.

This is affecting NIST PIV Test cards with non-hashed mechanisms.
2016-06-04 09:53:00 +02:00
Frank Morgner a1fbf46731 Merge pull request #714 from dengert/fix-Makefile.am
Compile from a separate build directory
2016-06-04 02:02:02 +02:00
Frank Morgner 192c3f6182 Merge pull request #694 from germanblanco/dnie_memory_leaks_and_sm_wrapping
DNIe. Removing all memory leaks and using SM wrapping and unwrapping.
2016-06-04 01:58:22 +02:00
Frank Morgner c524930e2b use a user defined PKG_CONFIG_PATH
closes https://github.com/OpenSC/OpenSC/pull/779
2016-06-04 01:36:53 +02:00
Frank Morgner 04825d8d7e avoid using an uninitialized buffer 2016-06-04 01:22:28 +02:00
Viktor Tarasov 7eeba1fba8 Merge branch 'towards-opensc-0.16.0'
version.m4 updated for official release 0.16.0
coverity scan switched to 'master'
2016-06-03 11:19:51 +02:00
Viktor Tarasov a2a17186c2 autoconf: option to disable -Werror=declaration-after-statement
old GCCs (distributed with RedHat 5) do not understand this option
2016-06-03 11:13:09 +02:00
Viktor Tarasov b8dcf91515 pkcs11-tool: print in hex the code of unknown mechanism 2016-06-03 11:12:03 +02:00
Mouse 2ba87640d2 Fixed bug in derive_key(), where correct execution depended on undefined compiler behavior 2016-05-31 01:59:40 +02:00
Frank Morgner 59152e1acf Merge pull request #766 from frankmorgner/towards-opensc-0.16.0
Fixed memory problems
2016-05-31 01:50:21 +02:00
Frank Morgner 46efb02fec fixed memory leak of reader's vendor name 2016-05-26 14:39:41 +02:00
Frank Morgner fcf9b9e706 fixed missing initialisation and bad memory access 2016-05-26 13:46:57 +02:00
Viktor Tarasov 1da49757cb fix NEWS, few debug messages more 2016-05-26 10:59:58 +02:00
Viktor Tarasov 88f85a2ef1 travis: run coverity for 'towards-opensc-0.16.0' 2016-05-23 13:59:01 +02:00