Commit Graph

5447 Commits

Author SHA1 Message Date
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 d7285843f6 pkcs11 framework: more debug logs in 'login' handler 2013-12-29 19:46:56 +01:00
Viktor Tarasov 95b6b4ccd3 pkcs11: changes in framework API
to prepare future enhancements and in the sake of uniformity
in 'struct sc_pkcs11_framework_ops'
the 'struct sc_pkcs11_card' argument of 'init_token' handler is changed for 'struct sc_pkcs11_slot'

coding style issues
2013-12-29 19:46:56 +01:00
Viktor Tarasov f43a9fa41c pkcs11: fix translation of SC error to PKCS11
SC error SC_ERROR_WRONG_CARD and SC_ERROR_NO_CARD_SUPPORT are translated as CKR_TOKEN_NOT_RECOGNIZED
2013-12-29 19:46:56 +01:00
Viktor Tarasov 9fdd9ecaeb pkcs11: PIN-NOT-INITIALIZED error concerns only User PIN
C_Login returns CKR_USER_PIN_NOT_INITIALIZED error when token info flags do not
contains CKF_USER_PIN_INITIALIZED and CKU_USER login type is asked.

This flag is not consulted when CKU_SO or CKU_CONTEXT_SPECIFIC login type is needed
2013-12-29 19:46:56 +01:00
Viktor Tarasov efdab893a7 pkcs15init: NULL pointer dereference error 2013-12-29 19:46:56 +01:00
Viktor Tarasov 7a03f1883b libopensc: create and export 'sc_match_atr_block' 2013-12-29 19:46:56 +01:00
Viktor Tarasov 1fe9ba1b2f opensc-explorer: if available, print DF name 2013-12-29 19:46:56 +01:00
Viktor Tarasov 3140c6c43b md: use, if available, internal cardcf data 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 411cbfb403 md: use if available the GUID from the prkey info ...
the proprietary on-card data can contain the GUIDs created by proprietary MW,
these data are parsed by card driver and put into the internal pkcs15 private key data
to be accesible in the different OpenSC frameworks
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 7948a5c83e pkcs15: remove unused macros "SC_PKCS15_KEY_USAGE_*" 2013-12-29 17:38:52 +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 db9e4c9039 build: suppress warning 'unused-parameter' 2013-12-29 17:38:44 +01:00
Viktor Tarasov 04fbf6ad08 pkcs15init: externalize and change name of select_intrinsic_id() 2013-12-29 17:33:36 +01:00
Viktor Tarasov 6a389f3c4b pkcs15init: reselect file to delete 2013-12-29 14:05:23 +01:00
Viktor Tarasov cb6955c0a7 pkcs15init: keep certificate's blob in cert. info data
always do it, not only when creating a new 'direct' certificate
2013-12-29 14:05:23 +01:00
Martin Paljak 91e3988ef0 macosx: fix typo in distribution descriptor 2013-12-18 10:40:59 +00:00
Martin Paljak d4a3edac08 macosx: update package building to modern tools
PackageMaker has been deprecated since Xcode 4.6.
pkgbuild and productbuild have been available since 10.6.6
2013-12-18 09:49:44 +00:00
Martin Paljak cfe0e7368d macosx: silence the deprecation warnings about OpenSSL 2013-12-11 10:41:19 +00:00
Doug Engert dff25190d2 Merge pull request #197 from CardContact/master
Changing EC Public Key format in PuKDF from raw to spki
2013-12-09 13:15:51 -08:00
Andreas Schwier d4be8ec747 sc_pkcs15_encode_pubkey_as_spki replaces sc_pkcs15_encode_pubkey_with_param.
The name implies what the format of the returned value, a SPKI.

The support for spki as a pkcs15 format of a pubkey, is extended to
work for any algorithm not just EC pubkeys. PKCS#15 appears to allow this.

sc_pkcs15_decode_pubkey_with_param will look for a SPKI
and attempt to use it for any algorithm, including RSA.
(RSA is the null case, as there are no algorithm parameters.)

sc_pkcs15_encode_pubkey_as_spki is exported from libopensc.

pkcs15-piv.c will use sc_pkcs15_encode_pubkey_as_spki to load public keys
as SPKI for RSA and EC.

The pubkey->data is never a SPKI, it is the DER encoding of the
pubkey without the parameters.  If an spki is needed, use the
sc_pkcs15_encode_pubkey_as_spki to get the DER encoding of the spki.

As in the previous set of patches, pkcs15-tool.c will output both
sc_pkcs15_decode_pubkey_with_param and its internal.
This was left for testing, and the pubkey_pem_encode should be deleted
2013-12-06 09:23:57 +01:00
Andreas Schwier 09e5a9fa7f pkcs11: Fixed typo 2013-12-05 14:26:49 +01:00
Martin Paljak 1acb4adc3e Check for NULL before dereferencing.
Reported by STACK

http://css.csail.mit.edu/stack/

Change-Id: Id7959c8217f46313ecf35a271efaf5f703fde2dc
2013-11-25 19:25:43 +02:00
Andreas Schwier 3a6e7ba959 pkcs15: Changed encoding for EC public keys in PuKDF to SPKI rather than ECPoint, preserving domain parameter 2013-11-15 11:41:10 +01:00
Andreas Schwier 633c98e9ee sc-hsm: Removed compiler warning 2013-11-15 11:41:10 +01:00
Andreas Schwier 4604dac3a7 sc-hsm: Fixed memory checking and removed warning 2013-11-15 11:41:10 +01:00
Doug Engert f09dae493c Merge pull request #196 from dengert/master
EC parameters not copied correctly
2013-11-14 08:17:05 -08:00
Doug Engert 9ff8bd1c61 EC parameters not copied correctly
As reported in Github, the memcpy was not valid.

	pkcs15-pubkey.c-20131106-09007
2013-11-14 09:38:49 -06:00
Doug Engert 5dd5994492 Merge pull request #194 from dengert/ecpointQ
EcpointQ
2013-11-12 06:56:10 -08:00
Doug Engert 86d5941e4c Merge branch 'ecpointQ' of https://github.com/dengert/OpenSC into ecpointQ 2013-11-06 16:35:09 -06:00
Doug Engert 03c196eeaf ECC ecpointQ Fixes
The original ECC code in OpenSC stored the ecpointQ as a DER encoded OCTET STRING.
Shortly before 0.13.0, code changes where made to store the ecpointQ as raw data
without the DER encoding.

Only some of the code was changed to support this but not all, and the comments
that said the ecpointQ was in DER where not changed either.

Some card drivers continued to work, using the original code in all place,
while some cards failed, as they where using a mixture of original code and
0.13.0 code.

This commit fixes these problems.

The ecpointQ is stored in raw format

A new structure type sc_pkcs15_u8 is defined.

The ecpointQ are changed to use the struct sc_pkcs15_u8. This was done to avoid
 the confusion of using struct sc_pkcs15_der to hold non-DER encoded data.
(There may be other uses for this too...)

Comments are change is many places.

sc_pkcs15_decode_pubkey_ec was fixed to store the raw ecpointQ correctly.

sc_pkcs15_pubkey_from_spki was change to get the sc_ec_params from the alg_id
and fix up u.ec.params. Unfortunately the OpenSC code has two places EC parameters
are stored. They can get out of sync, or there may still be code
that looks in the wrng oplace. o(TODO get it to only only place.)

The u.ec.params.field_length is now set in a number of places, as this is need
in many of the PKCS#11 routines.

framework-pkcs15.c will now correctly return the DER encode ecpointQ,
for the CKA_EC_POINT attribute using pubkey->data which has the DER encoding
for the ecpointQ.

framework-pkcs15.c will look for the EC parameters in either the u.ec.params.der,
or in the alg_id->params. (TODO get it to only only place.)

pkcs15-myeid.c has some comments, as it looks like the code is storing a TLV
rather then a DER encoding of the ecpointQ. With the wrong encoding PKCS#11 will
return the wrong attribute for CKA_ECDSA_PARAMS.

pkcs15-piv.c is changed so emulation of a pubkey taken from a certificate will
work correctly.
2013-11-06 16:31:34 -06:00
Doug Engert bec6d143f3 ECC ecpointQ Fixes
The original ECC code in OpenSC stored the ecpointQ as a DER encoded OCTET STRING.
Shortly before 0.13.0, code changes where made to store the ecpointQ as raw data
without the DER encoding.

Only some of the code was changed to support this but not all, and the comments
that said the ecpointQ was in DER where not changed either.

Some card drivers continued to work, using the original code in all place,
while some cards failed, as they where using a mixture of original code and
0.13.0 code.

This commit fixes these problems.

The ecpointQ is stored in raw format

A new structure type sc_pkcs15_u8 is defined.

The ecpointQ are changed to use the struct sc_pkcs15_u8. This was done to avoid
 the confusion of using struct sc_pkcs15_der to hold non-DER encoded data.
(There may be other uses for this too...)

Comments are change is many places.

sc_pkcs15_decode_pubkey_ec was fixed to store the raw ecpointQ correctly.

sc_pkcs15_pubkey_from_spki was change to get the sc_ec_params from the alg_id
and fix up u.ec.params. Unfortunately the OpenSC code has two places EC parameters
are stored. They can get out of sync, or there may still be code
that looks in the wrng oplace. o(TODO get it to only only place.)

The u.ec.params.field_length is now set in a number of places, as this is need
in many of the PKCS#11 routines.

framework-pkcs15.c will now correctly return the DER encode ecpointQ,
for the CKA_EC_POINT attribute using pubkey->data which has the DER encoding
for the ecpointQ.

framework-pkcs15.c will look for the EC parameters in either the u.ec.params.der,
or in the alg_id->params. (TODO get it to only only place.)

pkcs15-myeid.c has some comments, as it looks like the code is storing a TLV
rather then a DER encoding of the ecpointQ. With the wrong encoding PKCS#11 will
return the wrong attribute for CKA_ECDSA_PARAMS.

pkcs15-piv.c is changed so emulation of a pubkey taken from a certificate will
work correctly.
2013-11-06 16:09:29 -06:00
Ludovic Rousseau a18a7d8ecf Fix typo 2013-11-01 18:00:49 +01:00
Martin Paljak 6e255a9503 osx: target 10.9 (a free upgrade to anyone using 10.6+) from now on. 2013-10-24 13:29:34 +03:00
Raul Metsma 2b45194f4b Add EstEID 3.5 card support
EstEID card has new cold ATR and AID
2013-10-20 20:17:57 +02:00
Ludovic Rousseau 5979e2fed8 Add documentation for --list-token-slots, -T 2013-10-20 13:32:45 +02:00
Viktor Tarasov 80788dfcb2 fix LGPL version
f5814595db (commitcomment-3971686)
2013-09-29 20:55:41 +02: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
Tim Taylor 2dee7baae0 Extract public key from cert if no object on card 2013-09-29 19:32:25 +02:00
Frank Morgner a635d44336 fixed initialization of structure 2013-09-29 19:19:17 +02:00
Frank Morgner 7a87d947e7 don't require ushort to be present 2013-09-29 19:19:17 +02:00
Frank Morgner d5e86752de added getpass implementation for non windows
modifies terminal attributes to emulate _getch
2013-09-29 19:19:17 +02:00
Tim Taylor 2741f23641 Set output buffer len variable if padding removed. 2013-09-29 19:14:01 +02:00
Tim Taylor cd1116ac7c Use reader pin pad if available and allowed 2013-09-29 19:08:51 +02:00
Frank Morgner 6e728a89ee verifying the pin is a valid action 2013-09-29 18:53:04 +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 c023d20e14 removed unused reference to sm_iasecc_rsa_generate 2013-09-29 18:52:38 +02:00
Tim Taylor b731dac518 Reset return code to success if pubkey read from cert. 2013-09-29 18:31:33 +02:00