Commit Graph

4453 Commits

Author SHA1 Message Date
Nguyễn Hồng Quân fefe8bf2e6 OpenPGP: Check data size in pgp_put_data. 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân f188a5dda3 OpenPGP: Implement pgp_update_binary() to update file content. 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân 935a7505d7 OpenPGP: Add Access Control List for emulated files. 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân c891544990 OpenPGP: Use command chaining to send large data if extended APDU is not supported. 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân f3955e2475 opensc-explorer: implement put_data
opensc-explorer: use larger buffer for put_data
2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân 5673d13c15 OpenPGP: implement pgp_delete_file() 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân 72088b6eeb OpenPGP: implement pgp_strip_path()
Strip away the non-existant DF 5015 from paths passed the driver.
2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân f7785ad1ec OpenPGP: correct use of pin_reference 2012-06-08 20:17:34 +02:00
Nguyễn Hồng Quân 3ac834e277 OpenPGP: implement pgp_put_data() 2012-06-08 20:17:34 +02:00
Nguyễn Hồng Quân a1ed22b6fd OpenPGP: implement pgp_do_iswritable() 2012-06-08 20:17:34 +02:00
Nguyễn Hồng Quân d8d6902699 OpenPGP: implement pgp_seek_blob() 2012-06-08 20:17:34 +02:00
Nguyễn Hồng Quân 7e24102f2b OpenPGP: Make DO 7F21 treated as simple DO
Make DO 7F21 treated as simple DO, to make certificate contained in it visible.
2012-06-08 20:17:34 +02:00
Ludovic Rousseau 02a2b3d887 Display the flags argument of C_Initialize()
The the pInitArgs argument of C_Initialize() is not NULL it is a pointer
to a CK_C_INITIALIZE_ARGS structure.
This structure contains a flags bitfield with possible values:
- CKF_LIBRARY_CANT_CREATE_OS_THREADS
- CKF_OS_LOCKING_OK

This flags parameter is now parsed and displayed.
2012-06-04 15:42:57 +02:00
Viktor Tarasov 2cff47d9b3 pkcs11-tool: support for secret-key objects
support of 'secret-key' objects
key conversion procedures are now in libopensc library
change name for OPENSC NON-REPUDIATION CKA attribute
2012-06-02 18:25:23 +02:00
Viktor Tarasov 53330f9f89 tools: avoid possible matching of zero length ATR 2012-06-01 16:58:47 +02:00
Viktor Tarasov c7258a6b52 pkcs15-tool: list secret keys objects ...
and print its attributes.
Print attributes of 'authentication-key' object.
2012-06-01 16:58:47 +02:00
Viktor Tarasov 525f61af73 pkcs15-init: 'erase-application', 'update-lastUpdate', ...
New operations:
- 'erase-application' -- erase on-card application indicated by it's AID;
- 'update-lastupdate' -- parse tokenInfo, set 'lastUpdate' value to the current date and write back tokenInfo content;
- 'ignore-ca-certificates' -- when importing PKCS#12 ignore all CA certificates;
2012-06-01 16:58:47 +02:00
Viktor Tarasov fbc9bb35dc opensc-explorer: when printing file content read entire file
When reading and printing file content, do not read it by small chunks,
but read an entire file.
It allows to verify how card driver reads the data of maximal size
that is allowed for one transaction ('max_recv_size').
2012-06-01 16:58:47 +02:00
Viktor Tarasov d7022d3300 ias-ecc: add tool with IAS/ECC specific query operations 2012-06-01 16:58:39 +02:00
Viktor Tarasov 635be92a0c pkcs15init: call sc_profile_finish() with 'app-info' data ...
call sc_profile_finish() with application info data as an argument;
in delete-by-path procedure, when getting authorization to delete file, make distinction between 'DELETE' and 'DELETE-SELF';
call card specific 'store' handler updating PrKDF and PubKDF files;
deduce the private key pkcs#15 attributes (like subject) from the friend certificate;
ignore SM authentication type when getting authorisation for operation;
copy GUID from the object create data to the pkcs#15 object attributes.
2012-05-31 18:33:50 +02:00
Viktor Tarasov 7819e5ab89 minidriver: 'write' mode
Picked from SM branch of OpenSC, where it was tested mostrly with IAS/ECC card.
Also was used with rutoken and other cards.
2012-05-31 17:21:21 +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 1d2661c7ce pkcs15-pin: 'PIN' as particular choice of 'AuthenticationType'
Encode/decode 'PIN' pkcs15 object as particular choice of 'AuthenticationType' data.
Rudimental encoding/decoding of 'authKey' object.
2012-05-31 10:37:38 +02:00
Viktor Tarasov 666e08ffde pkcs15-pubkey: add 'subjectName' to 'CommonPubKeyAttributes'
Decode/encode 'subjectName' attribute from the 'CommonPubkeyAttributes'
Use macros for the size of the asn1_entry tables.
Use short call form for debug messages.
Procedure to convert the pkcs15 public key to EVP_PKEY type key.
Coding style issues.
2012-05-31 10:26:38 +02:00
Viktor Tarasov 4be79f3d30 pkcs15-prkey: 'algReference' from 'CommonKeyAttributes'
Decoding/encoding of the 'algReference' attribute from the 'CommonKeyAttributes'.
Use macros for the size of the asn1_entry tables.
Use short call form for debug messages.
Procedure to deduce from certificate the attributes of private key PKCS#15 object.
Procedure to convert the pkcs15 private key to EVP_PKEY type key.
Coding style issues.
2012-05-31 09:32:21 +02:00
Viktor Tarasov f7b5a6b6af PIV: pickup card driver from the SM branch
... where it was tested by Douglas.
2012-05-30 19:40:05 +02:00
Viktor Tarasov fe80ffdbd2 pkcs11-spy: invalid ExpandEnvironmentStrings() call parameter
pkcs11-spy.c(168) : warning C4047: 'function' : 'DWORD' differs in levels of indirection from 'DWORD *'
pkcs11-spy.c(168) : warning C4024: 'ExpandEnvironmentStringsA' : different types for formal and actual parameter 3
pkcs11-spy.c(205) : warning C4047: 'function' : 'DWORD' differs in levels of indirection from 'DWORD *'
pkcs11-spy.c(205) : warning C4024: 'ExpandEnvironmentStringsA' : different types for formal and actual parameter 3
2012-05-30 10:08:30 +02:00
Peter Marschall aca314b1f8 opensc-explorer: remove outdated usage text for verify
Wuth the key types explicitly listed in the usage line,
it is not necessary to list them separately.
2012-05-30 09:39:12 +02:00
Peter Marschall f04a1c5fef OpenPGP: stricter validity checks in PKCS15 init
Only add private/public keys that habe been defined:
check finger prints & algorithm identifier
2012-05-30 09:39:12 +02:00
Peter Marschall 742186f32f OpenPGP: remove unnecessary call to sc_get_data 2012-05-30 09:39:12 +02:00
Peter Marschall d38d615025 OpenPGP: parse more (extended) capabilities on init
* parse more extened capabilities & features into a private enum
* for v2.0 cards, always parse the "historical bytes" DO
  reason: ATR may be static and thus cannot reflect the state
2012-05-30 09:39:12 +02:00
Peter Marschall 67136b1781 OpenPGP: revert 7b4532736e
PKCS#15 spec v1.1 says:
TokenInfo.version: This field contains the number of the particular version
of this specification the application is based upon. For this version of this
document, the value of version shall be 0 (v1).

Thanks to Martin Paljak for the finding.
2012-05-30 09:39:12 +02:00
Peter Marschall 93cb77079b tools: re-factor usage message function
* change order of long & short option names: letters first, then the long names
  Effect: nicely aligned short and long option names in the help text
* more space between option names and explanation
  Effect: better readability on long options
* print "Options:" header only if there is at least one non-hidden options
  Effect: nicer output when all options are hidden
* only show printable, non-space short options letters
  Effect: no control codes printed to terminal
* get rid of a temporary variable
2012-05-30 09:39:12 +02:00
Peter Marschall 367ebd94d4 tools: allow arguments to be printed in usage message
Extend util_print_usage_and_die() by a string argument that describes
further arguments to the program.

1st user: opensc-explorer
2012-05-30 09:39:12 +02:00
Peter Marschall 8238239852 OpenPGP: extend openpgp-tool 2012-05-30 09:39:12 +02:00
Peter Marschall 965d44ec40 opensc-explorer: use case-insensitive pin types in PACE 2012-05-30 09:39:12 +02:00
Peter Marschall cd2cdf77f6 opensc-explorer: explicitly mention key types 2012-05-30 09:39:12 +02:00
Peter Marschall 2276c7e7e4 opensc-explorer: do not use hard-coded string length
Determine length of prefix dynamically instead of using a hard-coded, common
value for all prefixes.
2012-05-30 09:39:12 +02:00
Peter Marschall 458517783c OpenPGP: fix access conditions for DOs
Follow the specs.
2012-05-30 09:39:11 +02:00
Peter Marschall 26aac71c9f OpenPGP: correct PIN type to UTF-8
OpenPGP card spec v1.1 and v2.0 make it absolutely clear:
"... The format of the CHVs is UTF-8 (case sensitive) ...".
2012-05-30 09:39:11 +02:00
Viktor Tarasov 6d4d1b4aca win32: do not export 'sc_pkcs15_remove_df' procedure
in source it replaced by static 'sc_pkcs15_remove_dfs'
2012-05-30 09:25:57 +02:00
Viktor Tarasov 177af40535 md: prototype of sc_pkcs15_get_guid() has been changed
introduced 'flags' parameter
2012-05-30 09:18:03 +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 be81263d8e log: config option to reopen debug file at every debug log ...
To be used in windows:
"In Windows, file handles can not be shared between DLL-s, each DLL has a separate file handle table.
For that reason reopen debug file before every debug message."

sc_context_repair() procedure from Hunter William
"Workaround some threading and data lifetime issues when card handle changes and need to re-associate card"
http://www.opensc-project.org/pipermail/opensc-devel/2011-December/017445.html
2012-05-29 19:44:54 +02:00
Viktor Tarasov 954d0b9375 pkcs15: DIR EF can have EF_LINEAR structure
and so, in this case the checking file size is not appropriate method to validate it.
;use short call form for the log messages;
2012-05-29 19:19:06 +02:00
Viktor Tarasov 9d5404bac6 libopensc: some usefull macros, crc32 calculation procedure
Introduce some usefull define macros, error code 'inconsistent configuration'.
Introduce procedure to calculate CRC32 digest,
to be used in minidriver to calculate the 'freshness' values.
2012-05-29 11:29:44 +02:00
Viktor Tarasov 9c882ff5c2 AuthentIC: add SM related procedures
Added to facilitate future SM merge,
for a while disabled by conditional macro.
2012-05-29 09:52:33 +02:00
Viktor Tarasov 230b782309 pkcs15: add 'sc_pkcs15_derive' missing for ECDH support
also, key path, that has to be selected before crypto operation,
can contain an aid.
2012-05-28 23:15:37 +02:00
Viktor Tarasov 9c5dbea883 pkcs11: ECHD and secret keys support from Douglas
This support were initially proposed by Douglas (https://github.com/dengert/OpenSC/commits/ecdh) and
then merged into SM branch (https://github.com/viktorTarasov/OpenSC-SM/tree/secure-messaging).
2012-05-28 20:06:23 +02:00
Viktor Tarasov 76b8ad8ad6 pkcs11-spy: timestamp, environment strings in paths
Add to the spy logs the timestamp with millisecond resolution.
Environment strings are accepted in the key registries paths related to spy module.

pkcs11-spy: code formatting
2012-05-28 20:05:28 +02:00
viktorTarasov 388d68fb1a Merge pull request #37 from marschap/staging
improvements to opensc-explorer & new tool openpgp-tool

Usefull improvement: probably could be used in automated tests.

I follow Ludovic and attract your attention onto the necessity, in the nearest future, 
to supply the doc/man for the tool newly introduced.
Without it the build of OpenSC package will simply not be possible.
2012-05-26 05:29:24 -07:00
Viktor Tarasov 363e374664 pkcs15init: syntax changed for the ias(ecc) profiles 2012-05-26 09:36:49 +02:00
Viktor Tarasov b432e9767f pkcs15init: add 'minidriver-style' profile option
The on-card support of minidriver could need some MD specific pkcs#15 (DATA) objects.
There is no standard for these objects.
New option will allow to choose one of the possible implementations.
2012-05-26 09:36:49 +02:00
Viktor Tarasov 10e1ad001d pkcs15init: change sc_pkcs15init_bind() prototype
Add new argument 'application-info',
that will allow to select the on-card application to by binded with.

pkcs11: use sc_pkcs15init_bind with 'AID' argument

Prototype of sc_pkcs15init_bind() has been changed to add argument with
AID of the on-card application to be binded with.
2012-05-26 09:36:25 +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 343fa20a00 pkcs11: create tokens and slots for multiple on-card applications
In card detection procedure bind all present applications
and create tokens for them.

Treatement of the different 'create-slots' configuration cases,
joining the objects from different applications into one slot
are previewed for the next commits.
2012-05-23 09:22:41 +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 14049fb806 pkcs11: prepare internal API for multi-application mode
- simplify some of framework handles: remove from it's prototype the arguments that can be derived from the other arguments;
for exemple: foo(slot, slot->card) --> foo(slot)
- add the 'application' argument to the bind, unbind and similar handles;
- preview more then one framework data attached to the pkcs11card object.
- placehold for the future 'derive' and 'can_do' handles.
2012-05-22 17:18:00 +02:00
Viktor Tarasov d1cf65754b pkcs11: no more 'hacked' mode and 'onepin' module version
'OnePIN' version of opensc-pkcs11 module is not installed.
Instead, in the 'pkcs11' section of OpenSC configuration,
there is a possibility to define in a different manner
how to create slots for the present PINs and applications.
2012-05-21 19:19:38 +02:00
Peter Marschall 38be3c1a4a opensc-explorer: better names for some functions 2012-05-20 18:20:24 +02:00
Peter Marschall 1f70902da5 opensc-explorer: add 'echo' command
Add 'echo' command that simply displays its arguments.

With the recently committed script interpreter feature and this echo command,
nice litte scripts can be written, like e.g.

 $ cat opengpg-userinfo
 #!/usr/bin/opensc-explorer
 cd 0065
 echo Name:
 cat 005B
 echo Language:
 cat 5F2D
 echo Gender:
 cat 5F35
 quit
2012-05-20 18:19:48 +02:00
Peter Marschall f8f02dbd65 opensc-explorer: allow acting as script interpreter
Take a filename as argument and interpret the commands in it.
2012-05-20 17:12:14 +02:00
Peter Marschall 69e9861ddd OpenPGP: first go at openpgp-tool 2012-05-20 00:00:14 +02:00
Viktor Tarasov 4b745f51af openpgp: 'ushort' type not defined for WIN32
Change-Id: Ifb28730af2d39440721be9d1e38ea1c6106167a2
2012-05-16 23:14:42 +02:00
Diego Elio Pettenò e88c08d138 build: allow cross-compilation build by reordering libraries' order.
If the system libraries are set before the locally built libraries,
libtool will pick the system copy of OpenSC instead of the local one,
and that can make cross-builds fail badly.

This patch is already applied in Gentoo for proper building.
2012-05-16 17:18:38 +02:00
Diego Elio Pettenò 3c324b8b73 build: fix parallel install by creating directory in the rule
Relying on the rule that creates the directory is a bad idea to be
parallel safe.
2012-05-16 17:18:38 +02:00
Peter Marschall 07d51bea36 OpenPGP: get PKCS#15 token info from preparsed card data
Determine data for sc_pkcs15_card's tokeninfo structure
from sc_pkcs15_card's card structure.
This makes sure the two stay consistent as much as possible.
2012-05-16 17:01:09 +02:00
Peter Marschall 7b4532736e OpenPGP: set version for PKCS#15 2012-05-16 17:01:09 +02:00
Peter Marschall bc0949140d OpenPGP: format paths more nicely 2012-05-16 17:01:09 +02:00
Peter Marschall 0283a6f24e OpenPGP: only add keys with legal algorithm identifier 2012-05-16 17:01:09 +02:00
Peter Marschall 671ac54b71 OpenPGP: more data driven logic
Tie together in a struct what belongs together instead of relying
on the ordering of multiple unrelated arrays.
2012-05-16 17:01:09 +02:00
Peter Marschall 076a4ed2dc OpenPGP: slight cleanup
Use typedef'd types instead of their underlying structs,
use helper functions instead of reinventing the wheel,
and fix typos.
2012-05-16 17:01:09 +02:00
Peter Marschall 4c09e290e1 OpenPGP: make logic more data driven
Instead of doing lots of special-cases in code, create data structures
decide once which variant of the data to use, and then use it.
2012-05-16 17:01:09 +02:00
Martin Paljak 7535f30738 OpenPGP: add the v1.0 spec URL as well to source code comments.
Even though it is obsolete, it makes it more complete;)
2012-05-16 17:01:09 +02:00
Martin Paljak 5f84400ef7 OpenPGP: more support for CryptoStick/OpenPGP v2.0
Using CryptoStick v1.2 with 4096bit keys now allows to authenticate to SSH  with all three keys.
2012-05-16 17:01:09 +02:00
Martin Paljak fb772cccf8 OpenPGP: use actual references in PKCS#15 emulation code for PIN codes. Only v1.1 has 3 PIN codes. 2012-05-16 17:01:09 +02:00
Martin Paljak 63b08786a0 OpenPGP: do not hardcode key sizes to 1024 but fetch actual values from the card.
OpenPGP 2.0 (especially CryptoStick v1.2) supports key sizes up to 4096
2012-05-16 17:01:09 +02:00
viktorTarasov fb1aa8ed11 Merge pull request #32 from frankmorgner/4d9ea43ab24a2e36fc36d1be81b3414cc003786f
new commands for opensc-explorer and bugfix for iso7816 driver

-  opensc-explorer: new find command:
   tested; nice, useful feature.
- opensc-explorer: pace:
   no means to test -- accepted.
- iso driver:
  really bug, thanks.
2012-05-16 06:17:37 -07:00
Viktor Tarasov 20bf3f5484 pkcs11: use short form of log messages
Change-Id: Ice298552238da9eeb0b646fc1ddfaf4d7a8ee4bb
2012-05-13 00:27:38 +02:00
Viktor Tarasov 5d1feb3051 pkcs15: throw an error if there is no valid public key data
Thanks to Nguyen Hong Quan.
http://www.opensc-project.org/pipermail/opensc-devel/2012-May/017997.html

Change-Id: I48bc6664909ca324ef71a2a10d9fddb9096ae598
2012-05-05 14:49:21 +02:00
Frank Morgner 4d9ea43ab2 iso driver: select with p2=0x0c when le is missing 2012-05-03 12:58:45 +02:00
Frank Morgner 59b214ec23 opensc-explorer: implemented `pace` 2012-05-03 12:58:45 +02:00
Frank Morgner 7b630962c1 opensc-explorer: `find [<start fid> [<end fid>]]` 2012-05-03 12:58:34 +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
Viktor Tarasov cb13633634 remove trailing whitespaces
inspired by
http://www.opensc-project.org/pipermail/opensc-devel/2012-March/017883.html

Change-Id: If170e830d8d9587a31742feffb6fff54cfdf75b4
2012-04-03 00:00:56 +02:00
Viktor Tarasov e57d443e86 pkcd15init: remove trailing whitespaces
inspired by
http://www.opensc-project.org/pipermail/opensc-devel/2012-March/017883.html

Change-Id: I817f903e67965942d9cc0c30931dbaea0c5f736e
2012-04-02 23:40:05 +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
Ludovic Rousseau 594427e516 Merge pull request #26 from viktorTarasov/staging
merge 'master' into 'staging'
2012-02-22 09:38:37 -08:00
Viktor Tarasov af559fbffd Merge branch 'master' into staging 2012-02-22 11:20:17 +01:00
Viktor Tarasov 2b63213e0a pkcs15-init tool: fix for pin auth_type comparison
partial merge of pull request
https://github.com/OpenSC/OpenSC/pull/8

Thanks to 'joelhockey'.
2012-02-22 09:42:30 +01:00
viktorTarasov 63eb4a4b4b Merge pull request #4 from marschap/iso7816-for-staging
iso7816 cleanups for staging
2012-02-22 00:28:07 -08:00
viktorTarasov e6c501f3de Merge pull request #13 from mjrider/master
2 small fixes for storing a private key
2012-02-22 00:20:49 -08:00
viktorTarasov bc8e320f84 Merge pull request #16 from mjrider/for-opensc-accessflags-fix
Agree,
it's better to fix the key access flags at the general pkcs15init level.
2012-02-22 00:13:57 -08:00
Ludovic Rousseau 006a97b8c8 Use the short form sc_log() instead of sc_debug()
Replace sc_debug(ctx, SC_LOG_DEBUG_NORMAL, ...) by sc_log(ctx, ...) as
suggested by Viktor Tarasov
2012-02-21 21:22:54 +01:00
Ludovic Rousseau 27c6652a1d Remove extra spaces and tabs at end of lines 2012-02-21 21:10:20 +01:00
Ludovic Rousseau af9dada86c Fix compilation error on Windows
SC_READER_CAP_PACE has been renamed to SC_READER_CAP_PACE_GENERIC during
patch discussion.
Thanks to Viktor Tarasov for the bug report
2012-02-21 21:10:20 +01:00
Ludovic Rousseau 97e6ac6ecb Merge pull request #22 from frankmorgner/1141ae520201c91b9859b0cd6cbb59f4ebfbd577
Add possibility to execute PACE on the reader (tested with Reiner SCT RFID standard/komfort)
2012-02-21 05:39:26 -08:00
Frank Morgner 1141ae5202 Add support for PACE-enabled readers
Implements PC/SC interface to PACE-enabled readers defined in PC/SC
pt. 10 AMD 1 and BSI TR-03119.

PACE can be started using `sc_perform_pace`. This function currently
calls the new `perform_pace` from `struct sc_reader_operations`, if the
reader has the needed capabilities. `sc_perform_pace` could also be
extended with a stand-alone implementation of PACE (code could be
imported from here http://vsmartcard.sourceforge.net/npa/README.html).

Note that the reader's PACE capabilities are correctly determined by
calling GetReaderPACECapabilities.

OpenSC's new PACE capabilities can be tested using the `npa-tool` from
the Virtual Smart Card Architecture (see link above).
2012-02-21 14:10:47 +01:00
Ludovic Rousseau c20cd12809 Fix lookup_enum_spec() prototype
A change introduced in c0072d16dd made the
compilation fail:
pkcs11-display.c:738:1: error: conflicting types for 'lookup_enum_spec'
pkcs11-display.h:64:13: note: previous declaration of 'lookup_enum_spec' was here
2012-02-20 14:01:53 +01:00
Viktor Tarasov c0072d16dd pkcs11: coding style
Signed-off-by: Viktor Tarasov <viktor.tarasov@gmail.com>
2012-02-20 11:54:02 +01:00
Viktor Tarasov 8f9bbbe780 pkcs11: win32 compilation error
pkcs11-display.c(139) : error C2275: 'CK_BYTE' : illegal use of this type as an expression

Signed-off-by: Viktor Tarasov <viktor.tarasov@gmail.com>
2012-02-20 11:34:22 +01:00
Ludovic Rousseau ec70ee5c4d Merge pull request #20 from LudovicRousseau/staging
Staging
2012-02-17 01:11:49 -08:00
Ludovic Rousseau 0c9717a82e Reformat: remove extra spaces and tabs 2012-02-17 10:06:57 +01:00
Stef Walter 00e02359a3 libopensc: Add 'paranoid-memory' setting for behavior when mlock() fails
* Setting paranoid-memory to true, and mlock() fails, then
   allocations which require non-pageable memory will return NULL
2012-02-17 10:02:55 +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
Robbert Müller 3248a6b122 Adding default accessflags to the do_store_private_key function in the same way do_generate_key has those accessflags
This seems the right thing to do, when you look at the initial commit which added the flags in do_generate_key and the ticket
http://www.opensc-project.org/opensc/ticket/198

Currently when storing a key, the accessflags are not set
2012-01-10 16:47:27 +01:00
Ludovic Rousseau 48f8f982a0 Display the ASCII equivalent of a hex dump
The output format of a hex dump has changed from:
    668C045A 1C3A4EF4 CF8550F3 20926525 1E8BF478
to:
    00000000  66 8C 04 5A 1C 3A 4E F4 CF 85 50 F3 20 92 65 25  f..Z.:N...P. .e%
    00000010  1E 8B F4 78                                      ...x

Is it now possible to find text strings inside a hex dump
2012-01-10 13:44:20 +01:00
Ludovic Rousseau 9252eec2d3 Fix compiler warning and real problem
openssl.c: In function 'sc_pkcs11_verify_data':
openssl.c:384:19: warning: 'pkey_ctx' may be used uninitialized in this function [-Wuninitialized]
openssl.c:325:16: note: 'pkey_ctx' was declared here
2012-01-09 11:02:31 +01:00
Robbert Müller 61ea63304b Changing default usage from sign to verify, because verify is the public key opposite of sign for the private key 2012-01-08 15:17:33 +01:00
Robbert Müller d97f239468 Setting usage flags for the public key when storing a private key 2012-01-08 13:50:46 +01:00
Doug Engert 51630a844e Cleanup PKCS15 PIV Card PIN flags
If PIV card Discovery Object is present and Global PIN is preferred,
turn off the LOCAL flag.
2011-12-15 14:58:02 -06:00
Martin Paljak ed7f0b8f79 Merge "Fix for ticket #400" into staging 2011-12-07 13:31:26 +00:00
João Poupino c6fcd68fbc Fix for ticket #400
Specify the path of the Address PIN for IAS-based cards in order to properly
read the Citizen Address Data object.  Remove the "Citizen Data" object
association with the Address PIN, as it incorrectly describes the card layout.

http://www.opensc-project.org/opensc/ticket/400.

Change-Id: I7ca81d6d15c5e2b137ff3c9a40b7471eb2fad55c
2011-12-07 12:49:17 +02:00
Martin Paljak 51804601e4 pkcs15-tool: also print the PIN reference in hex.
This eases debugging.
2011-09-16 14:08:39 +03:00
Martin Paljak 10ae35fd57 Add LGPL header with a generic copyright to util.c
Individual copyright should be delegated to individual commits.
2011-09-13 21:50:20 +03:00
Peter Marschall 931e913599 iso7816.c: clean up iso7816_restore_security_env()
No need for response buffers for APDUs of the APDU_CASE_1 type.

This should fix OpenSC Ticket #299.
2011-09-09 13:42:52 +02:00
Peter Marschall 93816b37cd iso7816.c: slightly clean up iso7816_delete_file()
Only set the APDU's data element for the APDU_CASE3_SHORT type;
no need to do it for the APDU_CASE_1 type.
2011-09-09 13:42:52 +02:00
Martin Paljak 17bc2c8809 FINeID: fix for broken organisation cards.
Certain FINeID cards for organisations return 6A88 instead of 6A82 for missing files.
This makes sc_enum_apps fail and will result in unknown card behavior from OpenSC.

See http://www.opensc-project.org/pipermail/opensc-devel/2011-June/016910.html
2011-07-13 17:25:09 +03:00
Martin Paljak ea4eee5dc2 Merge remote-tracking branch 'ludovic/master' into proposed 2011-06-28 11:18:23 +03:00
Martin Paljak 78adc76da3 Merge remote-tracking branch 'viktor/master' into proposed 2011-06-28 11:17:36 +03:00
Ludovic Rousseau a59ded782e Fix compiler warnings
ctx.c:679:7: warning: "ENABLE_CTAPI" is not defined
ctx.c:681:7: warning: "ENABLE_OPENCT" is not defined
2011-06-23 17:07:26 +02:00
Ludovic Rousseau b7c2836d94 C_Digest(): check context validity before logging
If the context is invalid (no C_Initialize) the we get a:
log.c:76: sc_do_log_va: Assertion `ctx != ((void *)0)' failed.
2011-06-23 16:10:46 +02:00
Ludovic Rousseau 1f6a85fea9 only C_GetFunctionList needs to be exported
Calling applicatinos must locate function pointers through
C_GetFunctionList() after dlopen().
2011-06-23 11:57:05 +02:00
Ludovic Rousseau b9c43b9214 Remove a useless cast in sc_dlopen() 2011-06-21 13:56:40 +02:00
Ludovic Rousseau d3c13fd471 Fix compiler warning
libscdl.c: In function 'sc_dlerror':
libscdl.c:86: warning: old-style function definition
2011-06-21 13:53:08 +02:00
Ludovic Rousseau ce2d3c09be Check the lib is initialized before logging
C_CloseSession() and C_CloseAllSessions() were calling sc_debug() before
any check on the validity of the context. So if C_Initialize() was not
previously called you get an assert:
log.c:76: sc_do_log_va: Assertion `ctx != ((void *)0)' failed.
2011-06-21 10:41:41 +02:00
Martin Paljak dcf9a8e0b2 setcos: remove useless #if 1 2011-06-17 12:12:38 +03:00
Martin Paljak 17c295ab1e Fix compiler warnings:
../../src/libopensc/cardctl.h:231:30: warning: comma at end of enumerator list
 ../../src/libopensc/cardctl.h:629:13: warning: comma at end of enumerator list
2011-06-16 15:58:55 +03:00
Martin Paljak bc307ae975 compiler warning: muscle.c:588:12: warning: unused variable ‘buffer_size’
Also remove asserts, production code is compiled with asserts turned off, thus the unused variable warning.
2011-06-16 15:49:04 +03:00
Martin Paljak 46e0c49d7b pcsc: correctly handle timeout situation when refreshing reader state.
The code that treated a timeout as success was never reached, because the
surrounding if eliminated the possibility of entering the block when the return code
from SCardGetStatusChange was SCARD_E_TIMEOUT.

Issue found by Coverity Scan.
2011-06-16 10:15:34 +03:00
Martin Paljak 1f870b0c07 pcsc: initialize variables
Patch by Frank Morgner

http://www.opensc-project.org/pipermail/opensc-devel/2011-May/016659.html
2011-06-16 10:08:04 +03:00
Martin Paljak f4a45da617 Merge branch 'proposed' of github.com:martinpaljak/OpenSC into proposed 2011-06-16 09:31:32 +03:00
Peter Marschall 6c24bd5cff opensc-explorer: silence compiler warnings 2011-06-16 09:30:55 +03:00
Martin Paljak 27572537ce FinnishEid: fix the symbolic names for FINeID v2 cards with 2048 keys and restore compatibility with v2 cards with 1024 keys.
The more proper name for the 2048bit cards could be "v2.5".

Thanks to jem@iki.fi, kivinen@iki.fi and tuju@iki.fi for the patch.
2011-06-15 14:10:37 +03:00
Martin Paljak 0ae996254f Merge branch 'pkcs11' into proposed 2011-06-15 11:07:23 +03:00
Martin Paljak f4c39e20b1 Merge remote-tracking branch 'ludovic/PCSCv2_PART10_PROPERTY_bMaxPINSize' into proposed 2011-06-15 11:06:38 +03:00
Martin Paljak 6690975498 Merge remote-tracking branch 'peter/tools-20110611' into proposed 2011-06-15 11:06:30 +03:00
Martin Paljak a3a8ae3ef9 Merge remote-tracking branch 'peter/OpenPGP-20110611' into proposed 2011-06-15 11:06:23 +03:00
Ludovic Rousseau 75524a5be8 Fix PIN min and max sizes for pinpads
Some pinpads do not support PIN size less than 4 or greater than 8.
PC/SC v2 part 10 allows to ask the driver/reader for the supported
values. This avoids to have the SECURE PIN CCID command rejected by the
reader.

This should fix OpenSC ticket #361 "card-entersafe should ask the pinpad
reader for the maximum pin size"
2011-06-14 15:54:49 +02:00
Ludovic Rousseau 3b63bf351e Add PCSCv2_PART10_PROPERTY_* values
These are the tag values returned by PC/SC v2 part 10
FEATURE_GET_TLV_PROPERTIES command.
2011-06-14 15:54:49 +02:00
Viktor Tarasov c2abd9fd16 win32: build static version of the onepin PKCS#11 module 2011-06-14 14:38:58 +02:00
Ludovic Rousseau 40cb1c9e35 Merge remote branch 'upstream/master' 2011-06-14 14:00:18 +02:00
Ludovic Rousseau 8936901e2b Correctly wait for card event
The timeout parameter of SCardGetStatusChange() is a DWORD (unsigned
int). An int timeout parameter was used instead.
The problem happens on 64-bits architectures where DWORD is 64-bits long
and int is only 32-bits long. The sign extension C mechanism transforms
the PC/SC value INFINITE into -1 instead of 4294967295.

See http://www.opensc-project.org/pipermail/opensc-devel/2011-June/016831.html
"Kobil KAAN Advanced Reader, "waiting for card" timeout"
2011-06-14 13:50:37 +02:00
Martin Paljak 5a23069671 pkcs11: only C_GetFunctionList needs to be exported, calling applicatinos must locate function pointers though it after dlopen() 2011-06-14 14:41:29 +03:00
Viktor Tarasov a7ea231989 win32: build only static version of the OpenSC minidriver 2011-06-14 11:51:21 +02:00
Viktor Tarasov b9f0513744 win32: build only static version of the PKCS#11 module 2011-06-14 11:47:01 +02:00
vtarasov a6b7743088 pkcs15: add comments for the authentication object data type
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5569 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-13 09:23:30 +00:00
vtarasov ba64c5573d pkcs11: framework-pkcs15: invalid function name
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5568 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-11 20:17:30 +00:00
Peter Marschall 2faad42325 opensc-explorer: consolidate filename generation
* add new function path_to_filename() that converts a path into
  filename, and returns a static buffer to it
* convert all occurrences where file names get generated
  to using this function

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall c03eedde54 opensc-explorer: use util_hex_dump() in do_info()
Use standard function util_hex_dump() in do_info() instead of
enumerating lists of bytes ourselves.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 12fce0f329 opensc-explorer: replace if..else with ?:
Use the easier to read & shorter expression
  path->type = (is_id) ? SC_PATH_TYPE_FILE_ID : SC_PATH_TYPE_PATH;
nstead of the longer, but equivalent if () .. else construction.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 52b601ee53 opensc-explorer: re-factor do_apdu()
* allow double-quoted strings besides hexdata in ADPU generation
* detect errors in parameter parsing
* use utility function to print bytes sent,
  fixing an error that only showed parts of the APDU wheni
  it was generated from multiple arguments

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 81aa02d598 opensc-explorer: convert all mapping tables to id2str_t
Use type id2str_t for all mapping tables mapping IDs<->names.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 1c437c049c opensc-explorer: simplify arg parsing in do_change() & do_unblock()
Simplify argument handling in do_change() and do_unblock(),
making the functions shorter and deasier to understand.,

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 61855ebd22 opensc-explorer: remove unnecessary var's in do_update_*()
The variables "in_str" in do_update_binary() & do_update_record()
do not serve a purpose: use argv[x] directly & remove them.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 291ec6bf1c opensc-explorer: remove hex2binary()
With the last users gone, there's no need to keep hex2binary().

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 4cc1ab41ff opensc-explorer: detect AID conversion errors in arg_to_path()
Convert arg_to_path() to using the standard sc_hex_to_binary() instead of
the local hex2binary().
While at it, return erros on failed conversions.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall c3ba355531 opensc-explorer: consolidate string parsing in do_update_record()
Update do_update_record() to use parse_string_or_hexdata() instead of the old
hex2binary().
This change allows to use double-quoted strings in the "update_record" command.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall aa7a5ae5f8 opensc-explorer: fix argc checks in do_update_*()
do_update_binary() and do_update_record() expect a fixed number of parameters
each: adapt the checks for argc so that they do the right thing.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 081bf9fc7e opensc-explorer: consolidate string/hexdata parsing
* add new function parse_string_or_hexdata() that parses
  a double-quoted string or a hex-data string (e.g: AA:BB:CC)
  into a buffer
* use parse_string_or_hexdata() wherever strings or hexdata
  gets parsed into a buffer

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 9c9317d11b opensc-explorer: centralize usage
* extend cmds struct by a new element args for a description of the arguments
* use args in help texts
* new function usage() for centralited dispaly of usage info
* harmonize argument strings for usage / help texts
* re-sort cmd list shown in help texts
* add function "help" to cwallow asking for for help
* space-police

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 8780ddb2e1 opensc-tool: no unnecessary spaces around "DF"
Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 9abb398750 opensc-tool: update EF structure names
Use EF structure names that are more sensible & grammatically more correct.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 78838812fb opensc-explorer: convert do_info() to using tables
* use ID<->name tables instead of arrays of strings where
  the index was treated like some "magic" constant.
  With the new mapping tables, the meaning is obvious.

* fix a bug with ac_ops_df[]: before the conversion, it was a list
  of pointers to strings but was in one case treated like it was a mapping table.
  With the conversion to a mapping table, and the adaption of other code parts
  this bug got fixed "automagically" ;-)

* use common code to cleanly print ACLs for DFs & EFs

* harmonize EF structure names to the ones used in ISO 7816-4

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 4939432304 OpenPGP: unlink blob from blob tree in pgp_free_blob()
Remove links pointing to the blob to be deleted from other blobs in the
blob tree structure, so that removing a subordinate blob does not hurt
its parent or siblings.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:30:46 +02:00
Peter Marschall da5a223e26 OpenPGP: use pgp_new_blob() to setup MF blob
Use the standard way to create blobs, pgp_new_blob(), also for the MF.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:30:46 +02:00
Peter Marschall 4ddec5d384 OpenPGP: add DO info entries for MF
For consistency, add DO info entries for the MF 3F00.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:30:46 +02:00
Peter Marschall 961a27c921 OpenPGP: update pgp_list_files()
* fail if buffer passed as parameter is too small
* only list readable objects

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:30:46 +02:00
Peter Marschall 2e7406922f OpenPGP: re-factor gpg_new_blob()
* get file as parameter & fail if it is NULL
* allow parent to be NULL
* do not rely on DO info to be passed as parameter,
  search it yourself using the global DO info list for the card.
* infer file type automatically from DO info matching the file ID.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:30:46 +02:00
Peter Marschall b6ee0e3d75 OpenPGP: immediately quit on allocation errors in init
Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:30:46 +02:00
Peter Marschall e3fca4ac11 OpenPGP: remove DO info entry for DO FF
DO FF is a "catch-all" DO that returns all the infos contained in the other
DOs in one hierarchy.
It is hence duplicate and not necessary.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:30:46 +02:00
Peter Marschall 01e63424f5 OpenPGP: fix algorithms & key lengths calculation
Also include forgotten DO C3 in keylength calculation.
It contains the parameters for the authentication key.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:30:46 +02:00
vtarasov 9863072845 pkcs11: framework-pkcs15: OpenSC specific 'non-repudiation' cryptoki attribute ...
In PKCS#11 there is no CKA_ attribute dedicated to the NON-REPUDIATION flag.
We need this flag in PKCS#15/libopensc to make dinstinction between 'signature' and 'qualified signature' key slots.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5567 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-10 16:46:41 +00:00
vtarasov a7607b8f30 pkcs11: framework-pkcs15: when storing private key, set the key usage from the object attributes
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5566 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-10 16:41:04 +00:00
jps 93cc9bef1a For CardOS 4.3B and 4.4, the Verify Retry Counter Package
can be loaded at ADMINISTRATION life cycle phase to change
the behavior of the VERIFY command in regard to return codes.
When that package is loaded, the return code of the VERIFY 
will be ISO7816-4 compliant (63Cx with x being the value of 
the remaining retry counter when required verification has failed).


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5565 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-10 09:14:02 +00:00
Ludovic Rousseau 00d9a5d7ac Merge remote branch 'upstream/master' 2011-06-10 11:06:36 +02:00
andre 93baf137c3 libopensc: Fix for drivers returning an error if a challenge of length zero was requested. Actually nothing is done when obtaining such a challenge, thus nothing could fail.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5564 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-09 10:59:04 +00:00
andre 8a5961e970 pkcs11-tool.c: At least CKS_RO_PUBLIC_SESSION is needed.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5563 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-08 08:50:42 +00:00
jps c5c2366a0b Revert 5558
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5562 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-08 07:58:51 +00:00
andre a28bacf02c libopensc: Reveal another Belpic hack introduced in r2117.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5561 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-08 07:35:03 +00:00
jps b422872813 For CardOS 4.3B and 4.4, the Verify Retry Counter Package
can be loaded at ADMINISTRATION life cycle phase to change
the behavior of the VERIFY command in regard to return codes.
When that package is loaded, the PIN can be created with this
"verifyRC" flag in cardos.profile if the return code must be 
ISO7816-4 compliant (63Cx with x being the value of the remaining 
retry counter when required verification has failed).



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5558 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-07 12:44:53 +00:00
Ludovic Rousseau 90272799f0 Fix compiler warning
Declare the function static to fix:
pkcs15-lib.c:1069: warning: no previous prototype for 'sc_pkcs15init_encode_prvkey_content'
2011-06-07 10:23:56 +02: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 f0ab932031 minidriver: 'PinObject-info' data type is changed for the 'AuthenticatioObject-info' data type
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5554 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 17:03:23 +00:00
vtarasov d5b8a6cd5f RuToken: 'use uninitialized variable' warning
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5553 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 16:53:07 +00:00
vtarasov 226bfaac74 pkcs15: add few attributes to the biometric authentication data type ...
to make happy VS compiler


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5552 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 16:51:36 +00:00
vtarasov efc5760646 win32: build also static version the pkcs11 module
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5551 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 16:14:11 +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 32d035a9ad AuthentIC: when returning PIN info set the 'tries-left' data to the 'non-initialized' value
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5549 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 15:13:06 +00:00
vtarasov f45f22ca73 westcos: resolve signed/unsigned comparison warning
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5548 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 15:05:58 +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
vtarasov c74d33d0b0 coding style: tiny indent style issue
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5545 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 19:43:10 +00:00
vtarasov a479c368a6 pkcs11-tool: allow non-interactive change of User/SO PIN
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5543 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 19:20:11 +00:00
vtarasov 438cf4b2d4 RuToken-ECP: profile option to allow the reset of User PIN with SoPIN
http://www.opensc-project.org/pipermail/opensc-devel/2011-May/016716.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5542 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 19:06:43 +00:00
vtarasov da0a77b8c0 authentic: spelling of message
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5541 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 18:22:42 +00:00
vtarasov d43e692e98 pkcs11: implement changing of SoPIN
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5540 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 18:17:02 +00:00
vtarasov 35bd07ed5e pkcs11: with 'init-pin-in-SO-session' PIN unblock style, try to set PIN when PUK value is not available
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5539 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 18:05:02 +00:00
vtarasov 36a85ffe5b iso7816: resolve problem 'r5237 breaks support for Belgian eID', thanks to Jean-Pierre.
http://www.opensc-project.org/pipermail/opensc-devel/2011-May/016703.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5538 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 17:28:37 +00:00
vtarasov b3cbf5453e pkcs11: resolve problem 'change 5421 breaks MIT Kerberos login', thanks to Douglas.
http://www.opensc-project.org/pipermail/opensc-devel/2011-June/016734.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5537 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 17:20:10 +00:00
vtarasov 3095f5479f pkcs11-tool: resolve compiler warning '"OPENSSL_VERSION_NUMBER" is not defined', thanks to Ludovic
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5536 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 17:12:12 +00:00
vtarasov d5679f58af warning: resolve 'suggest parentheses around operand' compiler warning
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5535 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 17:00:36 +00:00
vtarasov f026db6f84 compile warnings: resolve 'comparison between signed and unsigned' compiler warnings
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5534 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 16:59:39 +00:00
andre 31a56bb374 pkcs11-tool.c: Remove useless parameter 'slot' from a lot of function prototypes.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5533 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-01 18:51:26 +00:00
vtarasov 9ac55871fb pkcs15init: oberthur: cleanup compiler warnings
http://www.opensc-project.org/pipermail/opensc-devel/2011-May/016724.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5532 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-01 17:15:31 +00:00
andre e966cc1e6e dir.c: In function ‘update_single_record’:
dir.c:318: warning: unused parameter ‘file’


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5531 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-01 16:54:40 +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
andre 7dff44ae53 framework-pkcs15.c: In function ‘set_gost_params’:
framework-pkcs15.c:1892: warning: comparison between signed and unsigned
framework-pkcs15.c:1902: warning: comparison between signed and unsigned


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5529 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-31 15:09:01 +00:00
vtarasov 185e3f8259 pkcs11-tool: replace 'slot-label' argument with the two new ones -- 'slot-description' and 'token-label'...
the main difference between 'slot-description' and 'token-label' is that 
the first one is unique in any case, 
the second one can be the same for more then one slots.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5528 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-30 14:47:50 +00:00
vtarasov 8931231396 pkcs11-tool: show CKA_VALUE of the GOST public key object
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5527 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-30 13:28:16 +00:00
vtarasov 40cf9a5cca libopensc: reverse data to sign when signing with the GOST key
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5526 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 19:23:18 +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 b21e04f42a libopensc: avoid warning "missing braces around initializer"
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5524 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 18:47:44 +00:00
vtarasov bf830d63da gost: when decoding public key, add explicit key params
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5523 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 18:45:00 +00:00
vtarasov a41a9c3f82 pkcs11: pkcs15 framework support for the import of the GOST key
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5522 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 18:35:34 +00:00
vtarasov e81c174372 pkcs15-tool: encode GOST public key with the key parameters ...
.. so that it can be used with the OpenSSL tools


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5521 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 18:25:04 +00:00
vtarasov a9e9aaee78 gost: GOST key parameters data type, encode gost parameters procedure
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5520 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 18:18:43 +00:00
vtarasov 1dd7d1fdeb pkcs11: debug title for GOSTRPARAMS
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5519 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 18:07:18 +00:00
vtarasov 4d2428378d pkcs11-tool: CKA_VALUE of imported GOST key has to be presented in the little endian order
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5518 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 17:55:26 +00:00
vtarasov 71b1f55f7c pkcs15-init: use general function to reverse memory buffer
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5517 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 17:49:00 +00:00
vtarasov dce63c8bfc libopensc: new exported function to reverse memory buffer
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5516 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 17:47:54 +00:00
vtarasov a045543cc1 minidriver: unused variable
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5514 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 11:50:13 +00:00
vtarasov 319cb6f071 minidriver: when reading 'cardid' file return the content of 'cardid' file ...
'cardid' size is 16 bytes.
It's initialized by the 'empty-cardid' value (00-0F) overwritten (from left) by the last 16 (or less) bytes
of the card's serial.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5513 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 11:48:50 +00:00
vtarasov ee4f346b07 pkcs15init oberthur: avoid warnings 'signed/unsigned mismatch'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5512 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-28 22:47:05 +00:00
martin 2d43c601e9 Remove unused code: sc_pkcs15init_get_label()
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5511 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-28 22:14:14 +00:00
martin 215c133ba0 libopensc: remove more traces of software token/non-native private key related code.
pkcs15-wrap.c can be removed. Clarified/changed the meaning of "insecure" flag to pkcs15-init tool,
which will be needed to explicitly enforce the creation of a key which does not require a PIN.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5510 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-28 22:14:07 +00:00
vtarasov 7179778e22 authentic: avoid warning C4018: signed/unsigned mismatch
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5509 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-28 19:30:26 +00:00
pk c97fc2e719 support for TCOS3 IdKey cards and fix for bug #256
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5508 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-28 14:24:27 +00:00
andre 661cc0dd47 libopensc: Remove the somewhat mysterious flag SC_CARD_CAP_NO_FCI.
It's solely purpose was to get opensc-explorer to work with card-belpic (r2118, r2119).

Relates to #296.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5507 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-27 12:33:52 +00:00
andre 487a7ab372 sc-test.c: In function ‘sc_test_init’:
sc-test.c:80: warning: comparison between signed and unsigned
sc-test.c:94: warning: comparison between signed and unsigned


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5506 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-27 09:29:01 +00:00
andre 4a2dfa6822 pkcs11-tool.c: In function ‘sign_data’:
pkcs11-tool.c:1253: warning: comparison between signed and unsigned
pkcs11-tool.c: In function ‘write_object’:
pkcs11-tool.c:1777: warning: unused variable ‘type’


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5505 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-27 09:24:09 +00:00
andre bbcb867a8f card-openpgp.c: In function ‘pgp_enumerate_blob’:
card-openpgp.c:584: warning: comparison between signed and unsigned
card-openpgp.c: In function ‘pgp_card_ctl’:
card-openpgp.c:1036: warning: unused variable ‘priv’
card-openpgp.c: In function ‘pgp_init’:
card-openpgp.c:272: warning: ‘child’ may be used uninitialized in this function


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5504 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-27 08:49:43 +00:00
martin dffe79d559 SetCOS/FinEID: add support for cards issued after 01.03.2011
Thanks to Juha Tuomala & Tero Kivinen <kivinen@iki.fi> for the patch.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5502 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-24 19:08:55 +00:00
martin 1bb6c706b9 pkcs15-crypt: remove extractable key support. Only native keys (operations on the card) are supported.
This amends r4646 and related commits.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5501 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-24 19:08:43 +00:00
martin 3655d1a1e4 pkcs15-tool: align access flags with the rest of output.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5500 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-24 19:08:05 +00:00
martin 4899f70b4e OpenPGP: use updated ushort2bebytes() in pgp_get_pubkey()
Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5499 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:33:50 +00:00
martin 15cdf5367d rewrite bebyte conversion functions: NULL check, return buffer
Rewrite bebyte conversion functions:
* check whether the buffer passed is non-NULL
* for conversions to bebytes, return the buffer passed

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5498 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:33:45 +00:00
martin fa259c63d5 OpenPGP: re-factor pgp_list_files()
Use ushort2bebytes instead of calculating the mapping to IDs ourselves.

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5497 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:33:38 +00:00
martin e422a57449 OpenPGP: re-factor pgp_get_blob()
Instead of jumping out of the loop when the correct child is found,
and checking afterwards again if we found the correct object,
do everything directly in the loop and return from there.

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5496 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:33:33 +00:00
martin 782b4efa73 OpenPGP: get flags & algorithms in pgp_get_card_features()
Extend pgp_get_card_features() to get card's flags & supported algorithms
from the card:
* get algorith values from "algorithm attributes" DOs 0x00c1 - 0x00c3

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5495 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:33:27 +00:00
martin c46152d89b OpenPGP: extend pgp_get_card_features()
Extend pgp_get_card_features() with these features:
* get SC_CARD_CAP_RNG capability from "extended capabilities" DO 0x00c0
* for OpenPGP 2.0 cards get max_send_size / max_recv_size values
  from "extended capabilities" DI 0x00c0
* get max_pin_len from "CHV status bytes" DO 0x00c4

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5494 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:33:15 +00:00
martin 1342648a89 OpenPGP: new function to get card's features
Add a new function pgp_get_card_features() to get the card's capabilities,
algorithms, features, ... instead of doing it all in pgp_init():
* get SC_CARD_CAP_APDU_EXT capability from ATR
* for openPGP 2.0 cards, if not found in ATR,
  get SC_CARD_CAP_APDU_EXT capability from "historical bytes" DO 0x5f52

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5493 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:33:04 +00:00
martin ee446adf09 OpenPGP: check for get_fn != NULL in pgp_read_blob()
In pgp_read_blob(), check if the pointer to the function we want to call
is defined.

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5492 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:32:59 +00:00
martin 19142ee9af OpenPGP: deal with DOs depending on card version
Have separate copies of pgp_objects[] data elements specific to the card's
version, and extend these structures with additional information:
* Some spec changes cannot be compatibly expressed in one common
  simple data structure without making it too complex.
* depending on specification version, only deal with those DOs
  that are legal within that version
* add information or read & write access conditions
* add information for non-toplevel and/or write-only DOs
* use symbolic names for constants

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5491 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:32:54 +00:00
martin 88e88d9317 OpenPGP: read BCD version from card
Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5490 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:32:49 +00:00
martin cf3a34cbef OpenPGP: re-factor pgp_select_file()
* remove unnecessary copy operations with a temporary path object,
  instead increase the start index.
* addd comments

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5489 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:32:43 +00:00
martin 4a3df98450 OpenPGP: comment use of "current"
Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5488 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:32:36 +00:00
martin 101cf28766 OpenPGP: clean up with pgp_finish()
Use pgp_finish() wherever possible to clean up.

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5487 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:32:31 +00:00
martin 9aa7342000 OpenPGP: re-factor pgp_finish()
Re-structure pgp_finish() for easier reading.
While at it, check for priv != NULL before free()ing it.

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5486 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:32:26 +00:00
martin ec1f1bd812 OpenPGP: sprinkle with LOG_... macros
Instrument functions used in the card operations table pgp_ops[]
with log macros to ease debugging.

Signed-off-by: Peter Marschall <peter@adpm.de>

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5485 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-23 17:32:21 +00:00