Commit Graph

5143 Commits

Author SHA1 Message Date
Viktor Tarasov 2a88453aaa build: Illegal char '-' in: 'Version: 0.13.0-pre1' 2012-09-16 22:39:12 +02:00
Viktor Tarasov 961059a052 build: include to 'dist' the files used by Windows build 2012-09-12 10:50:51 +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
Andreas Schwier d5ee8a80b5 sc-hsm: Added fallback for readers that do not support extended length. Without extended length, RSA 2048 bit operations will not work. 2012-09-01 21:25:58 +02:00
Andreas Schwier ee94020919 pkcs15-init: Fixed bugs and improved isolation between framework and emulation layer
select_object_path: Fixed misplaced return and wrong return code. This bug is the cause why a profile
must include a template even for fully emulated cards.

sc_pkcs15init_store_certificate: Added a call to the emulation layer when the private key
description requires an update after storing a certificate. Should not break existing code.

sc_pkcs15init_delete_object: Now calling the emulation layer before the frameworks tries to delete
files itself. An emulation that deletes object explicitly and leaves the deletion of some objects
to the framework will now need to completely handle deleting objects (by calling the methods of the
framework).

sc_pkcs15init_update_certificate: Missing call to the emulation layer added.
2012-09-01 21:01:51 +02:00
Viktor Tarasov ed18b789d7 win32: add windows version of opensc.conf.in
it do not contains macros that have to be resolved by 'configure'.
2012-09-01 19:51:43 +02:00
Viktor Tarasov 8c342ec772 tools: t404: redesign treatment of 'reader' option
in previous version
first of all the 'reader' option's value was converted to hexadecimal form,
used as ATR value
and all present readers where scanned to find the inserted card with such ATR.
Only after this the 'reader' option was used as reader's number or reader's name.

Currently in use the 'hex-to-bin' procedure accepts for conversion one digit,
and so even if the 'reader' option value is one digit,
the useless search over all present readers take place.

In the current version the order of checks if kept (ATR, reader's number, reader's name),
but enforced the validity check of ATR, presented by 'reader' option.
Also the option is accepted as reader's number only if the 'entire' option's string can be converted to integer.

Thanks to 'jbwisemo' for cooperation.
https://www.opensc-project.org/opensc/ticket/404
2012-08-30 18:51:54 +02:00
Viktor Tarasov 41861e42b0 no 'pace' in common part
'PACE' is extremely card specific protocol and has not to be ostensibly
present in the common part of OpenSC:
 * currently in OpenSC there is no card driver that supports or uses this protocol;
 * amazing content of the common 'sc_perform_pace' -- beside the verbose logs
   the only substantial action is to call the card/reader specific handler.
   According to the current sources and the pull request 83
   this 'common' procedure is called by the card driver or
   card specific tool/operation.
 * currently the 'PACE' can be thouroghly tested only by one person (Frank Morgner),
   and only using the OpenSSL patched with the PACE specific patch.
   So, at least a dedicated configuration option could be introduced when comiting PACE to the common part.
 * common 'sc_perfom_pace' has the same role as the 'initialize-SM' handler of the existing SM framework
   and can be implemented as card specific SM, as the others cards do.
   This confirmed by Frank Morgner, the author of PACE commits and nPA card driver, himself.
   (https://github.com/OpenSC/OpenSC/pull/83)
2012-08-30 18:51:42 +02:00
Ludovic Rousseau 7c39aeefb9 Fix potential NULL pointer dereference
Coverity: Dereference before null check (REVERSE_INULL)
Directly dereferencing pointer "pin_obj".
2012-08-25 19:15:27 +02:00
Ludovic Rousseau 9ca47cded6 Fix a memory leak
Do not forget to also free data in case of error.

Coverity: Resource leak (RESOURCE_LEAK)
Calling allocation function "calloc".
2012-08-25 19:15:27 +02:00
Ludovic Rousseau ed959004dd Fix a potential memory leak
If tlvblock is not stored then the value is lost and the allocated
mempry is leaked.

Coverity: Resource leak (RESOURCE_LEAK)
Calling allocation function "pgp_build_tlv" on "tlvblock".
2012-08-25 19:15:27 +02:00
Ludovic Rousseau b90a557237 Fix SC_PKCS15_TYPE_PRKEY_EC case
Coverity: Missing break in switch (MISSING_BREAK)

"A break statement was missing. The case SC_PKCS15_TYPE_PRKEY_EC was then
managed as a SC_PKCS15_TYPE_PRKEY_DSA" (Ludovic Rousseau)

"the break here has no sense, because LOG_TEST_RET will always return SC_ERROR_NOT_SUPPORTED before"
(Frank Morgner https://github.com/OpenSC/OpenSC/pull/85)

'break' is kept to satisfy coverity.
2012-08-25 19:09:05 +02:00
Andreas Schwier 68c87fd88e pkcs15-tool: Fix display error for fieldLength of ECC private keys 2012-08-24 13:15:39 +02:00
Andreas Schwier cdfc22be73 sc-hsm: Removed dead code and memory leak if serial number is set more than once 2012-08-24 09:39:45 +02:00
Andreas Schwier deeb1cde96 sc-hsm: Added registry key file to makefile.am 2012-08-24 09:25:45 +02:00
Andreas Schwier 30e6504720 sc-hsm: Add registry key to enable SmartCard-HSM for use with minidriver 2012-08-23 22:06:01 +02:00
Andreas Schwier cb46192d89 minidriver: Added support for ASCII encoded serial numbers 2012-08-23 22:06:01 +02:00
Andreas Schwier d180fc324c sc-hsm: Added basic cvc support to read device identity. Used for token serial number and GUID generation 2012-08-23 22:06:01 +02:00
Viktor Tarasov f8cdb0856f asn1: 'asn1_prkey' members order
Unwary rebase of Frank Tater's proposal introduced the bug of invalid
order of the sub-key types in the 'asn1_prkey' array in 1a7ca32865 .
2012-08-23 09:23:23 +02:00
Andreas Schwier 2e0ef7a0ab sc-hsm: Improved usablity in opensc-explorer 2012-08-20 11:22:02 +02:00
Andreas Schwier 46efb61a2b sc-hsm: Fixed field size constants for 320 bit curve 2012-08-20 11:22:02 +02:00
Andreas Schwier 0fa6e7f977 pkcs11-tool: Added CKM_SHA256_RSA_PKCS to tests in test_signatures 2012-08-20 11:22:02 +02:00
Andreas Schwier efb4673ec8 Revert change to pkcs11-tool because of upstream changes in RSA signature tests
Fixed a typo that went undetected
2012-08-20 11:22:02 +02:00
Viktor Tarasov 8e8acf1ff6 pkcs11-tool: implement 'find mechanism from the given list'
and use it when testing signature
2012-08-20 11:22:02 +02:00
Andreas Schwier dc927fbe3c sc-hsm: Undo the change to mechanism.c in commit f24bcd346340d80b552c0859942a49fd5e8feeff
sc-hsm: Change ECDSA signature format from DER to r/s format
2012-08-20 11:22:02 +02:00
Andreas Schwier 03632f336e sc-hsm: Added support for ECDH 2012-08-20 11:22:02 +02:00
Andreas Schwier e0f9edb121 sc-hsm: fixed to be compiled with Microsoft VC 2012-08-20 11:22:02 +02:00
Andreas Schwier f678b68650 Activated ECDSA for SmartCard-HSM
Fixed issues in pkcs11-tool/test_signature is card has RSA and ECDSA keys
Fixed bug in sc_pkcs11_signature_size that returns the wrong ECDSA signature size
2012-08-20 11:22:02 +02:00
Frank Thater 4ff917bd25 Added obj files to Makefile.mak for windows build
Fixed WIN32 compiler errors
Adjusted log message calls to short form

modified:   src/libopensc/Makefile.mak
modified:   src/libopensc/card-sc-hsm.c
modified:   src/libopensc/pkcs15-sc-hsm.c
2012-08-20 11:22:02 +02:00
Frank Thater 1a7ca32865 Added support for SmartCard-HSM and ECC keys
modified:   src/libopensc/Makefile.am
new file:   src/libopensc/card-sc-hsm.c
new file:   src/libopensc/card-sc-hsm.h
modified:   src/libopensc/cards.h
modified:   src/libopensc/ctx.c
modified:   src/libopensc/pkcs15-prkey.c
new file:   src/libopensc/pkcs15-sc-hsm.c
modified:   src/libopensc/pkcs15-syn.c
2012-08-20 11:22:01 +02:00
Peter Marschall feb2b96127 opensc-explorer: allow filename-pattern as argument to 'ls'
Make ls more flexible and more similar to the UNIX ls.
2012-08-19 21:31:32 +02:00
Viktor Tarasov 2f3ace06ec doc: #329: explicit usage of --id for a new keys is deprecated
'Id' option in the pkcs15-init commands to import/generate a new key
is deprecated. Better s to let the MW to derive an identifier from
the key material.
2012-08-19 20:30:00 +02:00
Viktor Tarasov ca08e97ab7 pkcs11: #162,#370,#115,#413: reselect application DF issue
Limit the number of cases when applicated re-selection of application DF to strict minimum.
I.e. only when pkcs11 login session is not locked and private key PKCS#15 object do not
contain the 'path' attribute.
2012-08-19 18:18:59 +02:00
Viktor Tarasov cb54ebf747 pkcs11: #371: Public key create template should not include CKA_MODULUS_BITS
Thanks to 'z22' and Martin.
2012-08-16 16:00:35 +02:00
Viktor Tarasov 080010d211 pkcs15: #268: Wrong ASN1 tagging of GOSTR3401Key
"The encoding of {public,private}GOSTR3410Key uses tag [CONTEXT 3] which is reserved for KEAKey.
Caused by the fact, that the specifications (pkcs15,iso) don't define a encoding for GOST,
the genericKey encoding [CONTEXT 4] from iso-7816 should be used." (Andre)
2012-08-16 15:04:14 +02:00
Viktor Tarasov 5a0cd4139f libopensc: #311: possible memory corruption
Thanks to 'frankmpunkt'.
2012-08-16 14:18:08 +02:00
Viktor Tarasov c6065fcfe2 doc: #377: no optional parameters for sc_context_create()
thanks to 'TimBarton'.
2012-08-16 10:59:03 +02:00
Stef Walter 12ec13d43c libopensc: Make OPENSC_DEBUG environment variable without conf file
* Make the OPENSC_DEBUG environment variable work even when no
   conf file is available.

https://www.opensc-project.org/opensc/ticket/388

Signed-off-by: Viktor Tarasov <viktor.tarasov@gmail.com>
2012-08-16 10:24:44 +02:00
Viktor Tarasov 7e42c6d97d pkcs11-tool: #407: on Windows use O_BINARY open file mode
https://www.opensc-project.org/opensc/ticket/407
http://msdn.microsoft.com/en-us/library/ee2849wt%28v=VS.71%29.aspx
2012-08-15 23:15:06 +02:00
Viktor Tarasov dfbc3996bf pkcs11: #439: 'SEQUENCE' of 'SET' issue when comparing cert attributes
Thanks to 'crank'.
https://www.opensc-project.org/opensc/ticket/439

Some pkcs11 callers (i.e. netscape) will pass in the ASN.1 encoded SEQUENCE OF SET,
while OpenSC just keeps the SET in the issuer/subject field.
2012-08-15 19:59:09 +02:00
Viktor Tarasov 16b4cb6a3f MyEID: always select in mode 'return FCI template'
According to ch.4.2 of MyEID reference manual v1.7.6 the only possible value of P2 of 'SELECT' APDU is '00'.
For this reason, when caller do not request to return 'sc_file' data,
use the non-null dummy 'sc_file' pointer in the call of iso->select_file,
and thus avoid the P2 different from '00'.

Also log calls are replaced by its short forms,
and resolved the 'trailing spaces' issues.
2012-08-14 15:52:39 +02:00
Viktor Tarasov 25f7bc5ac5 pkcs11-tool: implement 'find mechanism from the given list'
and use it when testing signature
2012-08-13 11:34:01 +02:00
Nguyễn Hồng Quân 1adbb3fae7 OpenPGP: Set write access more restrictive for pubkey blobs.
marschap: "The WRITE_ALWAYS ACL tells anyone can write to this file at any time."
2012-08-12 15:57:03 +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
Doug Engert 4e44cabcf0 Only 9C key needs "Pin Always" i.e. user_consent
The 9D key does not nee the user_consent flag, as the PIV card only
enforces the "PIN Always" for the 9C signing key.

Various comments cleaned up.
2012-08-12 00:11:03 +02:00
Peter Marschall 4035245649 opensc-explorer: allow longer PINs in CHANGE & UNBLOCK
Harmonize the allowed PIN length in CHANGE & UNBLOCK with the one in VERIFY,
making sure they are large enough for OpenPGP, which allows up ro 32 characters,
and giving additional security margin for other cards.
2012-08-11 21:33:36 +02:00
Viktor Tarasov 71ec763604 opensc-explorer: warnings when compiling with Windows VC
opensc-explorer.c(447) : warning C4101: 'count' : unreferenced local variable
opensc-explorer.c(940) : warning C4013: 'strlcpy' undefined; assuming extern returning int
opensc-explorer.c(1683) : warning C4013: '_isatty' undefined; assuming extern returning int
opensc-explorer.c(1726) : warning C4090: 'function' : different 'const' qualifiers
2012-08-11 20:48:58 +02:00
Peter Marschall 7f22ede919 opensc-explorer: show text message for APDU result 2012-08-11 20:48:58 +02:00
Peter Marschall 95cbfbb799 opensc-explorer: increase allowed bytes in RANDOM
Allow to fetch up to 256 random bytes from the card -
236 being the maximal value for Le in short APDUs.
2012-08-11 20:48:58 +02:00
Peter Marschall ea8a64d95a opensc-explorer: allow entering the PIN interactively
In VERIFY, allow the user to enter the PIN unteractively if it was not given
on the command line, and if the card reader does not support PIN input.

If it was not given on the command line and the card reader supports PIN input,
then the bahaviour is unchanged: enter PIN via card reader.
2012-08-11 20:48:58 +02:00