Commit Graph

5543 Commits

Author SHA1 Message Date
Maciej S. Szmigiero d84ee6c96a Initialize PIN logged_in field for cards that do not support PIN info
Commit 2f10de4f5c ("use sc_pkcs15_get_pin_info in C_GetTokenInfo")
introduced dependency of logged in state returned for session
by C_GetTokenInfo() on logged_in field of that session slot PIN.

This field is updated by sending pin_cmd of type SC_PIN_CMD_GET_INFO to
card.
However, not all cards support such pin_cmd type (in fact, majority of
them don't). In this case logged_in field is usually left zero-initialized
which means SC_PIN_STATE_LOGGED_OUT.

With such logged_in field value C_GetTokenInfo() always returns
CKS_R{O,W}_PUBLIC_SESSION, instead of CKS_R{O,W}_USER_FUNCTIONS when
logged in.

At least Firefox (and probably other NSS-based software, too) is confused
by such value and keeps repeating PIN prompts a few times until it
ultimately considers that logging in to this slot has failed.

Fix this by initializing PIN logged_in field to SC_PIN_STATE_UNKNOWN for
cards that do not support SC_PIN_CMD_GET_INFO pin_cmd.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-09-01 02:03:42 +02:00
Frank Morgner 526ae18696 PKCS#11: Don't use ':' in the token name
Fixes https://github.com/OpenSC/OpenSC/issues/849
2016-09-01 01:25:29 +02:00
Maciej S. Szmigiero dc476a9f33 Improve handling of OpenPGP card PIN change and unblock commands
"CHANGE REFERENCE DATA" (PIN change) and "RESET RETRY COUNTER"
(PIN unblock) commands in OpenPGP card have various limitations.
These also depend on whether the card is version 1.x or 2.x.

Provide helpful debug messages for user in case he is trying to do
a PIN command in a way that isn't supported by the card.

Also, take into account that version 2.x cards don't support references to
PW1-mode 2 (82) in these commands - change them to PW1 (81).

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-08-30 23:30:43 +02:00
Maciej S. Szmigiero 80f5c8b835 Code files don't need execute permission
Some .c files had execute permission bit set needlessly.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-08-30 23:30:43 +02:00
Maciej S. Szmigiero 3e3528bb68 OpenPGP card doesn't support raw RSA so don't set such algo flag
According to descriptions of commands "PSO: COMPUTE DIGITAL SIGNATURE",
"PSO: DECIPHER" and "INTERNAL AUTHENTICATE" in OpenPGP card spec (versions
1.1 and 2.1.1) the card adds / strips and checks PKCS#1 padding
automatically.
There is no documented way to perform raw RSA operations on this card so
SC_ALGORITHM_RSA_RAW flag shouldn't be set.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-08-30 23:30:43 +02:00
Maciej S. Szmigiero 0a6c1c4fb3 Make OpenPGP card user/signature PIN order match PKCS#11 framework
_get_auth_object_by_name() in pkcs11/framework-pkcs15.c needs user PIN
to be the first one and then next one can be signature PIN, but OpenPGP
card had it reversed.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-08-30 23:30:43 +02:00
Jakub Jelen e4f5f84512 libopensc: generic parse of certificate extensions
The code attempted to handle extensions assuming extensions were ordered. The
only extension it handled was crl's, but the handling was wrong and I didn't
find any actual use of the crl code. I've changed it to cache all the extensions
and then provided accessors functions to read a specific extension. I needed this
to read the key Usage, but the extension fetching code can work with any extension
(though the caller will need to parse the result. I also added code that parses DN
and returns a specifically requested DN component. I needed this to get the Common
Name for the certificate Subject. This gives the token a 'unique' name rather than
some generic name (like CAC-I or CAC-II). Both of these can be used to enhance the
piv support as well.

rebased by VTA
Closes #852
2016-08-28 16:41:01 +02:00
Viktor Tarasov ce82e56411 pkcs15init: fix using PINPAD to verify PIN
on the way to fix problem observed in #856
2016-08-28 13:44:12 +02:00
Jakuje 952fb7cb93 Get rid of misleading indentation warnings (GCC6 -Wmisleading-indentation) (#859) 2016-08-27 23:19:52 +02:00
Ian Young f64c71da28 Don't free file if pointer is null (#858)
Protect against segmentation

closes #854.
2016-08-27 23:14:04 +02:00
Viktor Tarasov 98568fe13e libopensc: no cache for the zero length PIN
fixes problem with the revalidation of PIN with PINPAD
observed in #856
2016-08-27 15:30:30 +02:00
Sid-Ali TEIR 01c92fe37f pkcs11-tool: fixed --id for C_GenerateKey, DES and DES3 keygen mechanism
fixed --id for C_GenerateKey, added DES and DES3 keygen mechanism and added ability to delete denerated secret key.

This closes #857
2016-08-27 13:11:21 +02:00
Viktor Tarasov 64ba32f2c6 pkcs11-tool: for WIN32 define STDOUT_FILENO
fix bug introduced in 6cd28cfc7c
2016-08-16 10:34:48 +02:00
Doug Engert bb2d863e4f piv: add a piv_card_reader_lock_obtained function
When sc_lock obtains a reader lock  this function is called
If the card was reset the PIV AID is seletcted and logged_in is reset.
This is need for some PIV cards where the default AID is not the PIV AID
and some other process has reset the card.

closes #842
2016-08-15 13:34:50 +02:00
Doug Engert 84a69ce2ba libopensc: introduce 'reader_lock_obtained' card operation
Add card_reader_lock_obtained function to sc_card_operations

During sc_lock, if card->reader->ops->lock is called, card->ops->card_reader_lock_obtained will be called.
If PCSC is being used as the reader driver, this occures just after pcsc_lock  has done a SCardBeginTransaction
and our process has exclusive control over the card. The card driver can then determine if the state of the
card has changed, and take action to get the card into an acceptable state.

If card->reader->ops->lock returns SC_ERROR_CARD_RESET, indicating some other process has interefered
with the state of the card. was_reset=1 is passed to card->ops->card_reader_lock_obtained.

Some examples of actions that could be done by the card driver is to select the AID and reset logged_in.

Currently the card driver is not notified. So no default card_reader_lock_obtained is defined in iso7816.c
2016-08-15 13:31:08 +02:00
Hannu Honkanen 6cd28cfc7c myeid: fix to ECDH implementation
fixing #756
rebased by VTA
2016-08-13 20:50:01 +02:00
Nuno Goncalves 6ad229e9f6 pkcs11-tool: Simplify PIN warnings messages logic
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-08-05 10:13:32 +02:00
Frank Morgner ff335fe87f sc-hsm: cache certificates 2016-08-03 23:08:12 +02:00
Doug Engert 1e82dbe5c7 libopensc: fix reopen SM after reader reconnect
After card reset detected, run SM open under new transaction

Before trying to reestablish SM session or onte code that may
need to use a transaction,  get the transaction that will be
used by the caller od sc_lock.

closes #837
2016-07-29 17:29:38 +02:00
Nuno Goncalves 1bc09ddafa pkcs11-tool: re-login if pincache is disabled or expired
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>

closes #839
2016-07-29 17:26:17 +02:00
Viktor Tarasov eb21c41e53 piv: coding style, use short log calls 2016-07-24 20:40:58 +02:00
Doug Engert 9c7f67309f piv: logout place holder
Until a full logout function can be implemented, return SC_ERROR_NOT_SUPPORTED

closes #832
2016-07-24 20:40:44 +02:00
carblue 1ab99f3756 pkcs11-tool: in 4rd test use other signature keys
also increase signature buffer in framework-pkcs15

closes #814
2016-07-24 19:26:10 +02:00
Viktor Tarasov 49a4eaaef3 pkcs15: no PIN cache update in pincache-revalidate
PIN cache is not updated when PIN is verified using the PIN value from cache.
That's the case of validating PIN in 'revalidate' context.

Few source format fixes included

closes #805
2016-07-24 18:49:51 +02:00
Frank Morgner c5a95d4a5a sc-hsm: use PKCS#15 file cache
fix invalid certificate path
2016-07-24 17:19:18 +02:00
Frank Morgner 8efca4d6db pkcs15: don't require-L for file caching
File caching is done transparently when the user sets the config option.
2016-07-24 17:19:18 +02:00
Frank Morgner 21fd6f0d95 libopensc: cache EF.ODF and EF.TokenInfo 2016-07-24 17:19:18 +02:00
Frank Morgner 60f2d06308 libopensc: fetch card's UID
Fetch card's UID.
For file caching, use UID if SN is not available.
2016-07-24 17:16:29 +02:00
Viktor Tarasov cee092a930 piv: change driver's short name to 'PIV-II'
closes #828
2016-07-19 15:27:26 +02:00
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 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 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 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 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 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 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
Jakub Jelen e309d0f06f [p15dump] Do not attempt to access NULL pointer 2016-05-23 11:41:48 +02:00
Jakub Jelen 462bebd380 Unbreak tests without arguments (automatic selection of the reader) 2016-05-23 11:41:48 +02:00
Viktor Tarasov 0e1c8f9c04 libopensc: avoid call to memset() with zero length
@mouse07410 has asked for it in
https://github.com/OpenSC/OpenSC/issues/688#issuecomment-219433611

VTA: I do not see the difference (if the other arguments are properly used),
but assume that @mouse07410 has it's own valid reasons

Also included the few coding style touches.
2016-05-23 11:41:48 +02:00
Henrik Andersson 74493ca73f Add support for RSA with keylength 2048
This solves sign issues with swedish eID cards which have
RSA keys with length 2048. This also solves the issue #726.
2016-05-16 11:12:53 +02:00
Jakub Jelen ae47e06d57 Typos 2016-05-16 10:58:22 +02:00
Frank Morgner 343c0f8d57 pkcs15-starcert.c: Use two hex digits with sc_pkcs15_format_id 2016-05-12 09:58:28 +02:00
Frank Morgner b568bbc256 pkcs15-pteid.c: Use two hex digits with sc_pkcs15_format_id 2016-05-12 09:58:28 +02:00
Frank Morgner 03b4740b2e pkcs15-infocamere.c: Use two hex digits with sc_pkcs15_format_id 2016-05-12 09:58:28 +02:00
Frank Morgner 3f0de6e638 pkcs15-gemsafeGPK.c: Use two hex digits with sc_pkcs15_format_id 2016-05-12 09:58:28 +02:00
Frank Morgner a2e05e8869 pkcs15-atrust-acos.c: Use two hex digits with sc_pkcs15_format_id 2016-05-12 09:58:28 +02:00
Doug Engert e46bfea8b9 Use two hex digits with sc_pkcs15_format_id
Avoid having problems with sc_hex_to_bin  when called from sc_pkcs15_format_id
both for id and auth_id numbers

 Changes to be committed:
	modified:   pkcs15-piv.c
2016-05-12 09:58:28 +02:00
Viktor Tarasov ca2c1c56c8 libopensc: sc_hex_to_bin() accepts hex string with length 1
fix issue #751
2016-05-12 09:58:28 +02:00
Viktor Tarasov e9786bfb34 oberthur: use short form of debug message calls 2016-04-28 11:16:03 +02:00
Viktor Tarasov fc76e4ee6d oberthur: fix max recv size when reading component 2016-04-28 11:15:27 +02:00
Viktor Tarasov 91a28c613c libopensc: few debug messages more 2016-04-28 10:51:49 +02:00
Viktor Tarasov 6d4a4dfae0 oberthur: set to '0' memory of temp path 2016-04-27 20:09:29 +02:00
Viktor Tarasov 00b8416ba3 oberthur: allow read of info files without authentication 2016-04-27 20:08:45 +02:00
Viktor Tarasov a4dfb7b07a tools: fix help message 2016-04-27 20:07:54 +02:00
Viktor Tarasov 5be51ea3e2 pkcs15init: authentIC: init card/pin not supported 2016-04-27 15:48:18 +02:00
Andreas Schwier c63ba858e3 Detect premature end hexstring 2016-04-26 18:29:51 +02:00
Viktor Tarasov 163fc42ee6 readers: coding style for log messages 2016-04-26 18:26:46 +02:00
Viktor Tarasov e95b515163 reader: by default only short APDU supported
default values of reader's max send/receive sizes correspond to only short APDU supported;
these values can be overwritten by reader itself with the proper value of dwMaxAPDUDataSize from TLV properties,
or with the corresponding options in OpenSC configuration.

resolves issue #735
2016-04-26 18:26:43 +02:00
Andreas Schwier 41f34fdbcf sc-hsm: Fix public key usage for keys extracted from CVC 2016-04-17 13:06:46 +02:00
velter 73b5d8421a Fix for #720
This is a cleaner fix for #720 which take part of #721 and #730
A driver private struct is used which allow to remove all globals which might changed base on the token in use.
2016-04-17 13:05:35 +02:00
Thomas König a3e7ebec42 Proposed fix for #723 2016-04-17 13:00:37 +02:00
Viktor Tarasov 09cbcd80f4 md: use register to enable debug log 2016-04-17 12:43:27 +02:00
Viktor Tarasov 66515989d8 win32: method to get config option from registers 2016-04-17 12:43:18 +02:00
Raul Metsma 22f9ad704a Move PIN type label front of description
With very long labels it is unable identify which PIN Firefox is asking.
PKCS11 label is 32 char's and it gets truncated.

Current format "LABEL (PIN1)"
New format "PIN1: LABEL"
2016-04-13 13:57:32 +03:00
Viktor Tarasov 89a5b5893b md: use GUID without frame 2016-04-08 11:02:53 +02:00
Viktor Tarasov 5c0a37c53d pkcs15init: use aux-data to set MD container GUID 2016-04-08 11:02:53 +02:00
Viktor Tarasov 5bbc86eb39 md: replace card specific with pkcs15 'aux-data' facilities 2016-04-08 11:02:53 +02:00
Viktor Tarasov 9abf8ee04c pkcs15 iasecc: parse-df handler to set MD guid 2016-04-08 10:48:58 +02:00
Viktor Tarasov 9ac4120594 pkcs15: 'aid' argument for emulator init
Allows to PKCS#15 emulator to bind more then one application
2016-04-08 10:48:58 +02:00
Viktor Tarasov 47eb21175c p15: auxiliary data in prkey info data type 2016-04-08 10:48:58 +02:00
Viktor Tarasov 77898e6175 gids: fix invalid get-gids-driver
When compiled without zlib 'get-gids-driver' returns invalid pointer.
2016-04-08 10:48:58 +02:00
Viktor Tarasov 6de3f93e9b gids: fix invalid get-gids-driver
When compiled without zlib 'get-gids-driver' returns invalid pointer.
2016-04-07 19:43:56 +02:00
Viktor Tarasov 07493c11d8 iasecc: select parent before fixing ACLs of a new file
With MD, after card rebinding, the context to fix ACLs for a
new certificate file can be changed.
2016-04-01 18:09:04 +02:00
Viktor Tarasov 56f2319fcc pkcs11-tool: few named curves more 2016-04-01 18:08:00 +02:00
Hannu Honkanen fe2312dd19 myeid: fixed a bug in setting card->name
Fixed a bug in setting card->name in myeid_init and myeid_get_info:
The buffer containing the card name fell out of scope.
2016-03-31 13:33:28 +02:00
Viktor Tarasov 7f732d49b6 pkcs15: log parsed TokenInfo.serial 2016-03-31 13:24:17 +02:00
Viktor Tarasov 4b51d70969 tools: print OpenSC package version 2016-03-28 20:41:19 +02:00
Viktor Tarasov 696e4119a5 pkcs15-crypt: allow decipher for key with 'unwrap' usage 2016-03-28 19:59:28 +02:00
Doug Engert 81e91c70f3 Handle C and C++ "inline" and "restrict" keywords for various compilers
simclist.h is changed to either accept a predefined inline and/or
predefined restrict macro or tests for known compilers and sets
simclist_inline and simclist_restrict with the approprate keyword
for the compiler being used or defines them as blank.

The logic used is based on code in OpenSSL-1.1 e_os2.h

For example, "configure" could define inline and/or restrict.
But OpenSC is built on other platforms without a config.h and thus
changes to simclist.h are still needed.

simclist.c is changed by replacing inline with simclist_inline
and restrict with simclist_restrict.

The one and only use of inline in card-dnie.c is removed as there
is no need to have the function inline. This avoids any inline issues.

If inline is needed in other OpenSC code or in card-dnie.c,
simclist_inline could be used.

(Another option is to just remove all inline and restrict keywords
from OpenSC code.)

 Changes to be committed:
	modified:   src/common/simclist.c
	modified:   src/common/simclist.h
	modified:   src/libopensc/card-dnie.c
2016-03-22 15:51:36 +01:00
Viktor Tarasov 6f667e0510 pkcs15: fix warning Wsign-compare 2016-03-21 07:55:02 +01:00
Viktor Tarasov 8b9ce2cf4a coverity: INTEGER_OVERFLOW 2016-03-17 11:30:40 +01:00
Viktor Tarasov bd84e18f45 coverity-scan: supplement to #710 2016-03-15 19:10:52 +01:00
Viktor Tarasov 1329597e33 pkcs15: use file cache for path with AID
also try to resolve TOCTOU coverity-scan issue

Fix #709
2016-03-15 18:11:03 +01:00
Viktor Tarasov 220d80fcec pkcs15: fix length of 'last-update' read 2016-03-15 17:42:09 +01:00
Viktor Tarasov 260b7711b9 coverity-scan: OVERRUN in ctbs.c
Fix #710
2016-03-15 17:40:15 +01:00
Viktor Tarasov 9a22f146f8 pkcs15: fix argument for 'read-tag' call 2016-03-10 11:39:59 +01:00
Viktor Tarasov 205acbd573 coverify-scan: muscle: use return value 2016-03-10 11:23:39 +01:00
viktorTarasov a5550f980b Merge pull request #706 from frankmorgner/npa-generic
generic changes from #611
2016-03-10 11:04:12 +01:00
Viktor Tarasov 1fb741338a pkcs11: remove hot-plug-anb-play
updated version of PR #687

Discussion and motivation in PR #687 and PR #704

Fix #687
Fix #704
2016-03-10 10:43:18 +01:00
Viktor Tarasov 0838520b62 rtecp: fix delete private key
when deleting private key, delete also it's internal public part
Fix #671
Fix #705
2016-03-10 10:33:42 +01:00
Viktor Tarasov f98c8cd37c asn1: tagnum size has not exceed 3 bytes
3 bytes is the size of SC_ASN1_TAG_MASK used when composing
the asn1 templates with 'struct sc_asn1_entry'.
With this limitation maximal supported ASN.1 tag number is 2^^14-1 .

Fixed 'dead-code' coverity-scan issue.

Close #707
2016-03-10 10:13:27 +01:00
Viktor Tarasov 196e476330 coverity: check returned value 2016-03-07 18:30:56 +01:00
Frank Morgner 5403899444 use SCardGetAttrib to initialize reader's metadata 2016-03-07 10:39:42 +01:00
Frank Morgner 415f15e3e2 use autoconf metadata for PKCS#11 library 2016-03-07 10:39:42 +01:00
Frank Morgner c3527f4a5b fixed dylib extensions 2016-03-07 10:39:42 +01:00
Frank Morgner ef40021417 use sc_debug_hex for hexdump 2016-03-07 10:39:42 +01:00
Viktor Tarasov 2173450664 log: print file-id in 'create-file' 2016-03-06 19:28:59 +01:00
Frank Morgner 9985144d45 Merge pull request #702 from viktorTarasov/fix/issue700/invalid-parameter
pkcs11-tool: fix invalid parameter for 'find-mechanism'
2016-03-05 21:37:31 +01:00
Frank Morgner 34a69aeac8 Merge pull request #701 from CardContact/fix698
sc-hsm: Remove path for newly generated key pairs
2016-03-04 17:23:00 +01:00
Hannu Honkanen 91aad373be Added a new ATR that will be used in some new MyEID cards
Closes https://github.com/OpenSC/OpenSC/pull/696
2016-03-04 17:20:37 +01:00
Hannu Honkanen cf04d01676 Removed define MYEID_ECC_SUPPORT as unnecessary.
ECC support is determined by checking MyEID applet version.
2016-03-04 17:20:29 +01:00
Hannu Honkanen 2de41f4a6d Added support for 521 bit ECC keys
Includes ECC related bux fixes.
2016-03-04 17:20:20 +01:00
Frank Morgner 1c0ab2a2d2 Merge pull request #697 from viktorTarasov/feature/package-revision
tools: print package revision
2016-03-04 17:14:26 +01:00
Viktor Tarasov 36b945aa22 tools: print package revision 2016-03-04 14:16:06 +01:00
Viktor Tarasov 998a1e10c5 pkcs11-tool: fix invalid parameter for 'find-mechanism'
Fixes #700
2016-03-04 11:30:51 +01:00
Ludovic Rousseau ae67f16e9b card-iasecc.c: fix 1 compiler warning
card-iasecc.c:3206:3: error: variable 'rv' is used uninitialized whenever 'if'
      condition is false [-Werror,-Wsometimes-uninitialized]
  ...LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Need RSA_HASH_SHA1 or RSA_HASH_SHA256 algorithm");
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/libopensc/log.h:90:36: note: expanded from macro 'LOG_TEST_RET'
  ...r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/libopensc/log.h:84:6: note: expanded from macro 'SC_TEST_RET'
        if (_ret < 0) { \
            ^~~~~~~~
card-iasecc.c:3207:20: note: uninitialized use occurs here
        LOG_TEST_RET(ctx, rv, "Cannot get QSign data");
                          ^~
../../src/libopensc/log.h:90:77: note: expanded from macro 'LOG_TEST_RET'
  ...r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
                                                       ^
../../src/libopensc/log.h:83:14: note: expanded from macro 'SC_TEST_RET'
        int _ret = (r); \
                    ^
card-iasecc.c:3206:3: note: remove the 'if' if its condition is always true
                LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Need RSA_...
                ^
../../src/libopensc/log.h:90:36: note: expanded from macro 'LOG_TEST_RET'
                                   ^
../../src/libopensc/log.h:84:2: note: expanded from macro 'SC_TEST_RET'
        if (_ret < 0) { \
        ^
card-iasecc.c:3185:8: note: initialize the variable 'rv' to silence this warning
        int rv;
              ^
               = 0
2016-03-02 15:01:19 +01:00
Ludovic Rousseau d86ada1c64 card-iasecc.c: fix 1 compiler warning
card-iasecc.c:2322:58: error: address of 'data->pin2.data' will always evaluate
      to 'true' [-Werror,-Wpointer-bool-conversion]
  ...if (!data->pin1.data && !data->pin1.len && &data->pin2.data && !data->pi...
                                             ~~  ~~~~~~~~~~~^~~~
2016-03-02 14:59:27 +01:00
Ludovic Rousseau ad11c9937c card-authentic.c: fix 1 compiler warning
card-authentic.c:1452:57: error: address of 'data->pin2.data' will always
      evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
        if (!data->pin1.data && !data->pin1.len && &data->pin2.data && !...
                                                ~~  ~~~~~~~~~~~^~~~
2016-03-02 14:57:42 +01:00
Ludovic Rousseau d45ae3ba80 sm-card-iasecc.c: fix compiler warning
sm-card-iasecc.c: In function ‘sm_iasecc_get_apdu_delete_file’:
sm-card-iasecc.c:188:25: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  unsigned int file_id = (unsigned int)sm_info->cmd_data;
                         ^
2016-03-02 14:50:57 +01:00
Andreas Schwier 69eaa66e83 sc-hsm: Fix #698 2016-03-02 14:20:51 +01:00
Ludovic Rousseau 89ec66fbe8 framework-pkcs15.c: fix compiler warning
framework-pkcs15.c:706:1: warning: unused function
      '__pkcs15_create_secret_key_object' [-Wunused-function]
__pkcs15_create_secret_key_object(struct pkcs15_fw_data *fw_data,
^
2016-02-29 20:19:42 +01:00
Ludovic Rousseau 7a7fb19a7d iasecc-sm.c: fix compiler warning
iasecc-sm.c:697:22: warning: cast to 'void *' from smaller integer type
      'unsigned int' [-Wint-to-void-pointer-cast]
        sm_info->cmd_data = (void *)file_id;
                            ^
2016-02-29 20:19:42 +01:00
Ludovic Rousseau ed30d4ebb7 pkcs15-isoApplet.c: fix compiler warning
pkcs15-isoApplet.c:268:38: warning: address of 'df->path' will always evaluate
      to 'true' [-Wpointer-bool-conversion]
        if(!pin || !pin_len || !df || !&df->path)
                                      ~ ~~~~^~~~
2016-02-29 20:19:42 +01:00
Ludovic Rousseau a8c741002d reader-pcsc.c: fix compiler warning
der-pcsc.c:1101:11: warning: comparison of integers of different signs:
      'LONG' (aka 'int') and 'unsigned int' [-Wsign-compare]
                        if (rv == SCARD_E_NO_SERVICE) {
                            ~~ ^  ~~~~~~~~~~~~~~~~~~
2016-02-29 20:19:42 +01:00
Ludovic Rousseau 80a313fb2a pkcs11-spy.c: fix 1 warning
pkcs11-spy.c:259:49: warning: format specifies type 'long' but the argument has
      type 'int' [-Wformat]
        fprintf(spy_output, "%s.%03ld\n", time_string, tv.tv_usec / 1000);
                                ~~~~~                  ^~~~~~~~~~~~~~~~~
                                %03d
2016-02-29 20:19:42 +01:00