Commit Graph

308 Commits

Author SHA1 Message Date
Viktor Tarasov 7f732d49b6 pkcs15: log parsed TokenInfo.serial 2016-03-31 13:24:17 +02: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
Frank Morgner 75c14ce815 Fixed possible NULL dereference
fixes https://github.com/OpenSC/OpenSC/issues/656
2016-01-14 05:02:28 +01:00
Frank Morgner decd5ab987 Merge pull request #580 from frankmorgner/select
Fix issues related to selecting a file
2015-10-29 13:30:37 +01:00
vletoux 35175a814c minidriver: fix according to frank's comments 2015-10-15 22:40:36 +02:00
Frank Morgner 15f204c5d6 fixed indenting 2015-10-14 22:32:51 +02:00
vletoux 75d76f5ce4 Merge branch 'master' of https://github.com/OpenSC/OpenSC into OpenSC-master
Conflicts:
	src/minidriver/minidriver.c
2015-10-14 22:22:19 +02:00
vletoux b968fcfb1f minidriver: Windows x509 enrollment works
Removed cmap_record in sc_pkcs15_prkey_info (not used by any driver nor code)
Remove cardcf specific code (cardcf neutralized by CP_CACHE_MODE_NO_CACHE and it maintened by the Base CSP/KSP, not the minidriver)
Add conversion code for Windows GUID / OpenSC self computed GUID
2015-10-11 15:20:04 +02:00
Frank Morgner 5b0332528f fixed accessing app_label in sc_pkcs15_data_info_t 2015-10-05 08:23:02 +02:00
Frank Morgner 6e3f94b3c9 fixed bad string comparison
fixes #547
2015-09-10 08:31:30 +02:00
Frank Morgner 9263da49aa pkcs15: fixed resource leak 2015-05-08 09:10:47 +02:00
Frank Morgner d7ab0df51d export sc_pkcs15_bind_internal
allows bootstrapping an external pkcs15 driver
2015-04-12 11:28:25 +02:00
vletoux ce962c14f4 fix #425: guid computation issue
Compilation without OpenSSL - guid computation issue
This case is triggered when:
- built without OpenSSL
- called from a minidriver where id.len = 1
- card number is less than 15 bytes

(VTA: codding style slightly touched)
2015-04-08 18:41:51 +02:00
Philip Wendland faaa11e091 Prefer serial number from EF(TokenInfo) and cached serials over CARDCTL
sc_pkcs15_get_object_guid() should prefer the serial number from
EF(TokenInfo) over card->serialnr because the user may override the
card's serial number with "pkcs15-init -C --serial". The card->serialnr
should be used before calling card CTL with SC_CARDCTL_GET_SERIALNR
because it might contain a cached value.

This change *should* allow cards to be used with the minidriver even if
SC_CARDCTL_GET_SERIALNR is not implemented. For example, a driver might
set card->serialnr at initialization or the user might initialize a
PKCS#15 card with its own "--serial".

See also the discussion at the mailing list:
[Opensc-devel] AT_SIGNATURE and AT_EXCHANGE Problem
2015-02-07 19:48:10 +01:00
Viktor Tarasov 08eb700b97 revert or partially revert some of recent commits
b94c163 - invalid, non-tested
11881a6 -- src/libopensc/card-iasecc.c -- return from select has to be ignored,
3a92bf7 -- src/pkcs11/slot.c -- SEGFAULT issue #373
3a92bf7 -- src/tools/piv-tool.c -- confirmed by author
6759c04 -- src/pkcs15init/pkcs15-lib.c -- file instantiation error has to be ignored
2015-02-07 19:31:17 +01:00
Frank Morgner 3a92bf7af5 fixed resource leaks 2015-02-05 01:38:41 +01:00
Frank Morgner 6759c04b26 don't ignore errors 2015-01-28 04:45:08 +01:00
Joachim Bauch 2f6b5174a8 Support "D-TRUST card 2.4 2ce". 2014-06-06 10:25:24 +02:00
Frank Morgner a64326e768 fixed compiler warnings (partially submitted)
Signed-off-by: Frank Morgner <morgner@informatik.hu-berlin.de>

PR-222: commit 0b567dbaa8
partially submitted by Viktor Tarasov
2014-05-03 21:47:15 +02:00
Viktor Tarasov 034cff91d8 pkcs15: unify error codes of 'internal' and 'syntetic' binds
if no valid PKCS#15 file system found
  'internal' bind procedure returns 'non-supported-card' error
  the same as 'syntetic' bind procedure.
  this return code is used by pkcs11 framework to accept non-binded cards

some codding style issues
2014-01-01 18:21:06 +01:00
Viktor Tarasov 4d5b80fd3f libopensc: general usage method to allocate generalized time 2013-12-29 22:00:12 +01:00
Viktor Tarasov 0dc39c1125 pkcs15: use value/length pair to hold the object's GUID
GUID can be presented by non-printable string
2013-12-29 19:47:42 +01:00
Viktor Tarasov 98325ab7f2 pkcs15: export 'sc_pkcs15_serialize_guid' ...
change name of exported 'sc_pkcs15_get_guid' to 'sc_pkcs15_get_object_guid' ;
add more 'CALLED' and 'RETURN' macros ;
2013-12-29 19:46:56 +01:00
Viktor Tarasov 40570143b9 pkcs15: include MD data into sc_pkcs15 data type
New data are used to support the card specific minidriver on-card files.
Beeing included into internal pkcs15 data type,
these new data are accessible at the all frameworks: emulation of pkcs15 and pkcs15init, minidriver.
2013-12-29 19:46:56 +01:00
Viktor Tarasov e855ac800e pkcs15: introduce 'cmap-record' data into the private key info
existing  'guid' obejct's data replaced by the one in private-key info
New CMAP record data used by pkcs15init emulator for the cards that have
the MD specific on-card data
2013-12-29 19:46:30 +01:00
Viktor Tarasov 00faad3af6 pkcs15: in 'pkcs15_object' data: new attr. 'md_flags'
also change name of 'guid' attribute for 'md_guid'
These attributes are used to parse and generate the minidriver CMAP records
2013-12-29 17:38:52 +01:00
Viktor Tarasov f641ebd248 fixed errors reported by cppcheck: part 1
partially applied the pull request #182 from Frank Morgner -- updated the common frameworks source files
2013-09-29 20:28:45 +02:00
Frank Morgner 3d0064e983 don't expect the card to specify the file length in generic tools
if sc_file_t.size == 0 we try to read 1024 bytes by default.
2013-09-29 18:52:48 +02:00
Frank Morgner e3649fb7de fixed even more compiler warnings 2013-08-02 15:43:25 +02:00
Viktor Tarasov d525ca97e3 libopensc: OID with only zeros in array do not valid 2012-09-23 21:02:31 +02:00
Viktor Tarasov 58b4304957 libopensc: 'init', 'format', 'compare', 'is-valid' OID procedures
In a reason of number of bugs(*) that concern the OID management,
the general usage OID procedures 'init', 'format', 'compare', 'is-valid' are introduced.
These procedures should be used by all actors: libopensc, pkcs15, pkcs11, tools, ....

(*)
This bug reported by Andreas Schwier :
8e75d971cb (commitcomment-1792477)

In pkcs15-algo sc_asn1_get_algorithm_info() can return the OID without ending '-1's:
https://github.com/OpenSC/OpenSC/blob/staging/src/libopensc/pkcs15-algo.c#L452
https://github.com/OpenSC/OpenSC/blob/staging/src/libopensc/pkcs15-algo.c#L459
2012-09-06 10:47:29 +02:00
Doug Engert a3b516a1e1 Add pin_cache_ignore_user_consent parameter to opensc.conf
When OpenSC is used with a card that enforces user_consent
and the calling PKCS#11 application does not understand how
to handle the CKA_ALWAYS_AUTHENTICATE, signature operations
will fail.

OpenSC will not cache a PIN that protects a user_consent
object as one would expect.

This mods allows PINs to be cached even if protecting a
user_consent object by adding
 pin_cache_ignore_user_consent = true;
option in opensc.conf.

Thunderbird is the prime example of this situation.
Mozilla has accepted mods (357025 and 613507) to support
CKA_ALWAYS_AUTHENTICATE that will appear in NSS-3.14 but
this may be some time before this version is in vendor
distribution.
2012-08-12 00:11:03 +02:00
Viktor Tarasov 6c2fa7b462 pkcs15-skey: support for 'SecretKey' object type
For a while only implemented decoding of 'genericSecretKey', 'desKey', 'des2Key' and 'des3Key' keys.
2012-05-31 11:36:04 +02:00
Viktor Tarasov 6337149ef7 pkcs15: decode 'seInfo', 'profileIndication', 'lastUpdate'
Encode,decode  'lastUpdate', 'seInfo', 'profileIndication' of TokenInfo (CIAInfo).
Trailing whitespaces.
2012-05-30 09:03:27 +02:00
Viktor Tarasov bf752f3c61 pkcs15: new procedure to find an Auth PKCS#15 object (PIN) by flags 2012-05-25 09:19:19 +02:00
Viktor Tarasov 80266ff466 pkcs15: new procedure to get application by it's symbolic name
At the moment symbolic names for the on-card applications are 'generic', 'protected'.
This distinction used by pkcs11 and minidriver module to select the
'master' application in the cases when only reduced number of slots (one)
can be exposed by module (minidriver) or particular configuration (pkcs11).
2012-05-23 08:50:18 +02:00
Viktor Tarasov 66aa2b3896 pkcs15: throw an error when trying to read from DF
Change-Id: Ifac6777436f889393e3d3981d98a78149fd6cb17
2012-04-09 11:07:15 +02:00
Alon Bar-Lev df8715849d Remove libltdl: Remove ltld references
http://www.opensc-project.org/pipermail/opensc-devel/2011-December/017490.html
cherry-picked from 'libtool' branch of Alon Barlev's github project git://github.com/alonbl/OpenSC.git
and rebased

Remove libltdl: Remove ltld references
(cherry picked from commit a350326c520c5b0cb185f90946648633f4d0e456)

Remove libltdl: Detect libdl
(cherry picked from commit 51e7de45c11823460e776492dcbd40e60583a7eb)

Remove libltdl: Use libscdl
(cherry picked from commit 09f3eadb8a1a47407c011dcd3d5ce461516f3b87)

Remove libltdl: Cleanup libscdl
(cherry picked from commit 52d5f1be01146079e3a6fad1c88ebb0f577d0a94)

Remove libltdl: Cleanup libscdl usage at Microsoft VC build

Untested, I don't have the environment, Martin, please test.
(cherry picked from commit 7fb18f8d0b0bae6d181981a0c71190440e917c2c)

Change-Id: I73c98ccb9365584b12f4b0b97b69316a190b6e45
2012-03-17 20:55:05 +01:00
Stef Walter 6ed52a06b8 libopensc: Don't fail to allocate memory when mlock fails
* Print out warning when mlock fails, and continue.
 * The warning required a ctx to be passed in, so that means
   changing a few function signatures.

https://www.opensc-project.org/opensc/ticket/389
2012-02-17 10:02:55 +01:00
andre 947cdad801 pkcs15.c: In function ‘compare_obj_flags’:
pkcs15.c:1115: warning: unused variable ‘data’

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5555 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-07 06:33:01 +00:00
vtarasov d888b3fd55 pkcs15: use general 'AuthenticationObject' instead of 'PinObject'
now the attributes of the previous 'pin-info' data type are included
as the sub-type attributes of the general 'auth-info' data .
It will allow to include support of the 'biometricTemplate' and 'authKey' authentication types.

http://www.opensc-project.org/pipermail/opensc-devel/2011-May/016655.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5550 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 15:46:25 +00:00
vtarasov f9b1a1e102 pkcs15: in 'TokenInfo' data the 'serialNumber' attribut is optional
If 'serialNumber' attribute is absent in the 'TokenInfo' data,
in the parsed data, this attribute will be set to the value of the card's serial.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5547 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 15:01:15 +00:00
andre a9eba2b205 libopensc: Remove unused parameter 'file_out' in function 'sc_pkcs15_read_file'.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5546 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 11:08:36 +00:00
andre dfbb55777c pkcs15.c: In function ‘__sc_pkcs15_search_objects’:
pkcs15.c:981: warning: unused variable ‘ctx’


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5530 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-31 15:12:31 +00:00
vtarasov 2e8df6d226 libopensc: eliminate repetetive debug messages
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5525 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 18:50:33 +00:00
vtarasov 5e50a14b3f libopensc: introduce 'key-params' data type that contains pointer, size and 'free' handler ...
http://www.opensc-project.org/pipermail/opensc-devel/2011-April/016441.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5413 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-01 19:18:14 +00:00
vtarasov 54fb422831 pkcs15: include EC private/public key types into the pkcs#15 object search procedures
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5322 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-11 11:30:45 +00:00
vtarasov b614444aae libopensc: use short debug macros in pkcs15.c
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5318 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-10 09:18:25 +00:00
andre 3169f14b32 libopensc: Removes useless attribute 'file' in 'struct sc_pkcs15_df'
There is no need to carry around that attribute, because it's easy to look up the 'file' as needed. This is done by issuing a single sc_select_file command in sc_pkcs15init_update_any_df (pkcs15-lib.c).

The parameter 'file' of sc_pkcs15_add_df (pkcs15.c) became useless too and was removed in turn.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5316 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-10 04:09:33 +00:00
vtarasov f8ba3ea76d libopensc: general routines to get serialized GUID
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5302 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-07 16:42:23 +00:00
andre ac3a48d7ca pkcs15.h: Fixes type inconsistency, because in [http://www.opensc-project.org/opensc/browser/trunk/src/libopensc/opensc.h?rev=5190#L148 opensc.h] algo_ref is defined as unsigned int.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5299 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-06 22:46:46 +00:00
martin 7ab9b7f10d Fix a typo reported by lintian
I: libopensc3: spelling-error-in-binary ./usr/lib/libopensc.so.3.0.0 extention extension

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5238 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-20 12:18:55 +00:00
vtarasov a076397671 pkcs15: without AID specified return the first available PKCS#15 application ...
revert accidential commit, thanks to Pierre Ossman.
http://www.opensc-project.org/pipermail/opensc-devel/2011-March/016149.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5232 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-14 18:13:38 +00:00
vtarasov b1a1dc245a pkcs15: accept more then one xDF file of the same type ...
partial revert of r4096, thanks to Pierre Ossman
http://www.opensc-project.org/pipermail/opensc-devel/2011-March/016148.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5231 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-14 18:09:48 +00:00
andre 12df79c14b pkcs15.c: Avoid compiler warning:
pkcs15.c:286: warning: unused variable ‘conf_block’


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5223 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-07 18:10:11 +00:00
vtarasov 33f44f8dc1 pkcs15: pin references are always positive integers ...
In the OpenSC versions previous to 0.11.5 the references greater then
127 were erroneously encoded by one byte (negative value ecording to the
ASN.1 rules).
Actually some other proprietary PKCS#15 cards have also this infirmity.

Actual commit makes general the application of the hack used for 'starcos' card.

http://www.opensc-project.org/pipermail/opensc-devel/2011-February/016062.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5220 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-06 12:35:35 +00:00
martin ffb46d2573 core: reanimate the sc_dlopen API for dynamic loading
* shift libpkcs11 from src/pkcs11 to src/common as it is not used to implement the OpenSC PKCS#11 module
 * invent a "libscdl" mini library that implements either libltdl based dynamic loading or uses native interfaces
 * drop hard requirement for libltl to build OpenSC
 * native Windows build does not need libltdl any more
 * specify CNGSDK include dir to find cardmod.h. CNGSDK only registers with a handful of compilers

Deals with #323

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5201 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-16 19:02:11 +00:00
martin 43be49b4a3 libopensc: correct ASN.1 parsing of EF(TokenInfo).
Two fields should be optional. This also fixes #322

Thanks to Toni for finding and Andre for fixing the problem.
See http://www.opensc-project.org/pipermail/opensc-devel/2011-January/015613.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5194 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-10 20:31:34 +00:00
ludovic.rousseau 3da2a84b0d Remove dead code
pkcs15.c:1033:3: warning: Value stored to 'r' is never read
                r = sc_pkcs15_parse_df(p15card, df);
                ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkcs15.c:1677:3: warning: Value stored to 'obj_len' is never read
                obj_len = p - oldp;
                ^         ~~~~~~~~
pkcs15.c:1948:4: warning: Value stored to 'r' is never read
                        r = len;
                        ^   ~~~
pkcs15.c:1942:6: warning: Value stored to 'record_len' is never read
                                        record_len = head[2] * 256 + head[3];
                                        ^            ~~~~~~~~~~~~~~~~~~~~~~~


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5158 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-05 21:11:59 +00:00
andre 13dd004198 pkcs15.c: Check info->label for NULL before calling strdup(). Avoids segmentation fault in the case where info->label == NULL. Fixes #318.
Thanks lmamane.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5125 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-27 22:18:16 +00:00
vtarasov 41c0090321 pkcs15: redesign sc_pkcs15_make_absolute_path() ...
- do nothing if child has 'aid';
- child inherit the parents's 'aid' if this one exists;
- child inherit parents's path of type 'DF NAME' as  'aid';
- return if child path is zero length;

- finaly concatenate parent and child paths.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5108 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-18 16:02:09 +00:00
vtarasov 5ab90b9219 libopensc: avoid using of the not completely initialized 'sc_path' variables
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5106 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-18 09:48:26 +00:00
vtarasov 2a8fc56402 pkcs15: add array with supported algos references to the key info data type ...
and imlement API to access it


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5089 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-13 14:05:19 +00:00
vtarasov 7f5ea5b013 libopensc: export sc_find_app(), remove debug message, ...
avoid double '::' separator in path_print();
touch authentic profile file


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5087 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-12 17:41:10 +00:00
vtarasov 56c05c6a6a pkcs15: asn1: extend DDO with 'ddoAID' and 'ddoIIN' ...
This extension is used by multi-applications cards when EF.ODF with EF.tokenInfo 
and xDF with (secure) data objects are placed in a different applications.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5082 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-11 10:19:57 +00:00
vtarasov aaa92eeb3d libopensc: adapt 'make_absolute_path' to the path with valid 'aid' member ...
use make_absolute_path() to compose path to 'ODF' and 'tokenInfo'


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5076 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-09 17:23:10 +00:00
vtarasov eb4f283c6a pkcs15: do not call sc_parse_ef_atr() ...
it should be called in the 'init' handle of the card driver 
when EF.ATR is present


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5060 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-07 16:09:39 +00:00
vtarasov cb5b141391 pkcs15: remove unused variables
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5057 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-07 15:44:13 +00:00
vtarasov 82adc9361e pkcs15: in sc_pkcs15_card include the pointer to the application that the card was binded to
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5056 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-07 13:31:30 +00:00
vtarasov 209224816a libopensc: introduce TLV and LV data type, use it to store DDO data
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5051 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-06 16:16:24 +00:00
vtarasov 0761a61a65 libopensc: use 'struct sc_aid' instead of 'u8 *aid, size_t aid_len'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5048 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-05 15:42:36 +00:00
vtarasov 121260b846 pkcs15: some changes to the discovery on-card applications code ...
; 'known' pkcs#15 applications are moved to the head of the card applications array;
; card specific 'bind finalization' code moved to the dedicated procedures;
; remove unused sc_application member, procedures;
; remove commented code;
; add debug messages;


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5045 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-05 14:53:52 +00:00
vtarasov f2924672d8 pkcs15: add 'aid' parameter to the prototype of the 'bind' functions ...
prepare for the multi-application support


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5041 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-05 14:21:04 +00:00
vtarasov 898b62bf56 libopensc: more of debug messages, code layout
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5028 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-02 14:32:11 +00:00
vtarasov d45fb4ca1b libopensc: set 'enumerated' flag for xDF if corresponding EF file was successfully read ...
it's an extention of r4983, that was not properly working for the existing but empty xDF files.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5023 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-02 14:22:38 +00:00
andre 33a67cac5b pkcs15.c: Fixes a bug that occurs in the situation where a PKCS15 EF contains partially invalid data. I.e. the last object in the EF is broken and thus can't be decoded successfully. In that case the whole EF becomes never flagged as enumerated. This in turn results in endless processing of that EF. Thereby the first valid objects became attached to the internal obj_list over and over again.
That patch prevents the repeated attachment of objects to obj_list, because it marks an EF as enumerated as soon the first object was successfully appended.

Left over from #266.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4983 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-22 21:45:43 +00:00
andre 50567141f0 Rename of SC_NO_ERROR to SC_SUCCESS.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4954 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-16 05:04:37 +00:00
andre f9acbf9073 pkcs15.h: Fixing type of parameter to avoid compiler warning: 'comparison between signed and unsigned'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4951 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-15 13:47:58 +00:00
andre 35fd3c10c1 pkcs15.c: Use size_t as type of vector-index.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4937 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-09 19:49:42 +00:00
andre 3b270b8d27 pkcs15.c: use int instead of bool as type of configuration option pin_cache_counter
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4923 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-06 18:15:12 +00:00
andre 5a183a8dc7 framework-pkcs15.c: new logic to discover objects that were hidden before PIN verification
pkcs15.c: object search continues with normal processing, even if enumeration of some files failed
pkcs15.h: obsolete prototype removed
pkcs15-syn.c: now obsolete function sc_pkcs15emu_postponed_load removed

fixes: #266

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4877 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-18 23:31:08 +00:00
andre 0ad6771346 {{{more verbose messages for debug in:__sc_pkcs15_search_objectssc_pkcs15_parse_dfsc_pkcs15_read_file}}}
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4876 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-18 18:47:42 +00:00
martin f5a21e417b pkcs15: don't play with TokenInfo.version. 0 means PKCS#15 v1.1. The flag is not used by OpenSC.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4789 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-05 16:02:57 +00:00
martin 50f99a20f8 libopensc: move TokenInfo fields from sc_pkcs15_card_t to a separate structure.
Thanks to Andre Zepezauer for the patch.

See http://www.opensc-project.org/pipermail/opensc-devel/2010-September/015076.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4788 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-05 15:44:58 +00:00
martin c51156875f libopensc: remove meaningless sc_card_valid()
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4785 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-05 14:58:50 +00:00
viktor.tarasov 58c1c88efa libopensc: homogenise line ending in the debug messages
continuating r4759


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4774 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-25 20:35:59 +00:00
viktor.tarasov 602d170c3d libopensc: pkcs15: more of debug messages
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4685 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-04 20:21:34 +00:00
martin 5e3f7b10d0 Whitespace fix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4664 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-01 06:23:37 +00:00
martin 12a1e9d49b pkcs15: don't override TokenInfo PRNG flag. pkcs11: announce CKF_RNG if the card driver supports it, bypassing PKCS#15.
GET CHALLENGE and RNG don't match 1:1 anyway.

Thanks to Andre Zepezauer for noticing this.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4661 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-01 06:23:17 +00:00
ludovic.rousseau f47416d60e Do not cast the return value of malloc(3) and calloc(3)
From http://en.wikipedia.org/wiki/Malloc#Casting_and_type_safety
" Casting and type safety

malloc returns a void pointer (void *), which indicates that it is a
pointer to a region of unknown data type. One may "cast" (see type
conversion) this pointer to a specific type, as in

int *ptr = (int*)malloc(10 * sizeof (int));

When using C, this is considered bad practice; it is redundant under the
C standard. Moreover, putting in a cast may mask failure to include the
header stdlib.h, in which the prototype for malloc is found. In the
absence of a prototype for malloc, the C compiler will assume that
malloc returns an int, and will issue a warning in a context such as the
above, provided the error is not masked by a cast. On certain
architectures and data models (such as LP64 on 64 bit systems, where
long and pointers are 64 bit and int is 32 bit), this error can actually
result in undefined behavior, as the implicitly declared malloc returns
a 32 bit value whereas the actually defined function returns a 64 bit
value. Depending on calling conventions and memory layout, this may
result in stack smashing.

The returned pointer need not be explicitly cast to a more specific
pointer type, since ANSI C defines an implicit conversion between the
void pointer type and other pointers to objects. An explicit cast of
malloc's return value is sometimes performed because malloc originally
returned a char *, but this cast is unnecessary in standard C
code.[4][5] Omitting the cast, however, creates an incompatibility with
C++, which does require it.

The lack of a specific pointer type returned from malloc is type-unsafe
behaviour: malloc allocates based on byte count but not on type. This
distinguishes it from the C++ new operator that returns a pointer whose
type relies on the operand. (see C Type Safety). "

See also
http://www.opensc-project.org/pipermail/opensc-devel/2010-August/014586.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4636 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-18 15:08:51 +00:00
viktor.tarasov f18ba7d984 pkcs15: decode 'supportedAlgorithms' in 'TokenInfo'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4510 c6295689-39f2-0310-b995-f0e70906c6a9
2010-07-05 12:54:23 +00:00
viktor.tarasov be3670600b emulator fix #125: thanks to Thomas Harning: emulator specific 'clear' handler
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4255 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-18 16:38:49 +00:00
aj 6545b42c02 cleanup of the debug code:
* reduce to a few, supported functions.
* change all functions to take the debug level as parameter.
* use symbolic names for the debug levels.
* fix tools to pass "verbose"/"opt_debug" as ctx->debug.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4118 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-15 12:17:13 +00:00
aj 02768fb5dc remove "split-key" option and emulat sign for sign,decrypt keys with padding
and decrypt() for cardos.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4113 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-13 22:52:51 +00:00
viktor.tarasov 22f067863a libopensc emu: more general implementation of the postponed DF parsing
In previous version the card specific 'parse_df' handler was a part of 'sc_pkcs15_df'.

Now the placehold ('sc_pkcs15_operations') created for the all card emulator specific operations .


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4109 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-13 19:48:09 +00:00
viktor.tarasov 0027a21204 libopensc emu: sorry, fix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4098 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-09 17:11:31 +00:00
viktor.tarasov 3a2f0415fe libopensc emu: postponed object loading
Some non-pkcs15 cards protect the reading of the private objects attributes. 

For the emulated pkcs15 cards, the 'init' emu-handler was the only place where pkcs15 objects could be loaded.
This handler is called before the card is binded, and so, for an application there was no 'normal' way to verify PIN and load the objects with protected attributes.

Actually it's possible to complete list of the pkcs15 objects after the emulated pkcs15 card has been binded. 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4096 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-09 16:49:00 +00:00
viktor.tarasov c837196134 libopensc: homogenize name of 'struct sc_pkcs15_card' parameters and variables
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4090 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-08 12:32:35 +00:00
aj d22a2483c0 Header file cleanup.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4081 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-04 08:14:36 +00:00