Commit Graph

4716 Commits

Author SHA1 Message Date
Rainer Metsvahi a0ceaeecab Add AzeDIT 3.5 card support
AzeDIT cards are similar to EstEID 3.5 cards but have their own
cold ATR and AID
2013-11-07 17:48:16 +02: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
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
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
Ludovic Rousseau 3afe644c0d Fix integration problem with DNIe
card-dnie.c:1481:2: error: too few arguments to function `sc_pkcs1_strip_01_padding'

The prototype of sc_pkcs1_strip_01_padding() changed between the patch
submission and its integration.
2013-08-27 10:58:20 +02:00
Ludovic Rousseau 02727a1406 Merge pull request #168 from germanblanco/opendnie
Adding support for DNIe.
2013-08-27 01:52:55 -07:00
Charles Bancroft 865900e210 Updated load_cert to use the proper key identifier 2013-08-10 22:30:59 +02:00
Viktor Tarasov 12e0ac1aa6 minidriver: add registers file for feitian cards 2013-08-10 22:25:30 +02:00
Viktor Tarasov bdd264936c pkcs15: add 'context' parameter to the strip padding procedures
and add debug messages
2013-08-03 21:53:01 +02:00
Viktor Tarasov daa79054c0 CardOS: more debug messages in 'pin-cmd' handler 2013-08-03 21:46:44 +02:00
Frank Morgner d21830344f fixed a ton of compiler warnings 2013-08-03 19:15:55 +02:00
Frank Morgner 07818329ab made sc_apdu_t.data 'const' (which it used to be)
fixes a lot of warnings which pass a const buffer to the APDU's data

Note that a non-const data member is only required for sc_allocate_apdu
sc_free_apdu. They are currently used with an explicit typecast.
However, sc_allocate_apdu and sc_free_apdu both are not used once in the
entire project. One might also simply throw both functions away.
-- Both are thrown away. (VT)
2013-08-03 18:26:04 +02:00
Viktor Tarasov 2c019485e8 Merge branch 'master' of github.com:szikora/OpenSC 2013-08-03 17:56:45 +02:00
Viktor Tarasov 1a972920f0 By default 'default' card driver is disabled ...
'Default' card driver is explicitely enabled for 'opensc-explorer' and 'opensc-tool' tools.
https://github.com/OpenSC/OpenSC/pull/175
2013-08-02 22:01:51 +02:00
Jean-Pierre Szikora de4dd056bf Onepin profile stopped to work after commit 10e1ad001d
Cards formatted with one-pin profile can not be used (for modification
of the data on the card with pkcs15-init -X for example) after this
commit, which prevent the reading of 5015/4946 (containing the
profile).

The part of the code was simply commented out without comment.
Maybe it was used for testing purposes, and not removed for
the commit ?
2013-08-02 16:06:52 +02:00
Frank Morgner e3649fb7de fixed even more compiler warnings 2013-08-02 15:43:25 +02:00
Frank Morgner a7564d6f1e Use C99 flexible array member
The structures PIN_MODIFY_STRUCTURE and PIN_VERIFY_STRUCTURE now use a
C99 flexible array member when available for abData field.

uint8_t abData[];

See http://lists.alioth.debian.org/pipermail/pcsclite-cvs-commit/2013-May/006191.html
2013-08-02 15:18:07 +02:00
Frank Morgner 32c470469d use enough memory for pin verification/modification structure 2013-08-02 15:00:09 +02:00
Viktor Tarasov 407ffa3388 libopensc: for hex dump in debug messages ...
use dedicated log procedure that uses a static dump buffer

inspired by pull request #164 of Frank Morgner
https://github.com/OpenSC/OpenSC/pull/164
2013-08-02 14:21:02 +02:00
Viktor Tarasov c4c189fec3 make: change make order of SM components
to respect dependencies
2013-08-02 12:29:55 +02:00
Viktor Tarasov f053070e14 libopensc: assertion fails on calling fclose() on a NULL filehandle
From @geoffbeier:
(https://github.com/OpenSC/OpenSC/pull/171#issuecomment-20407132)

So it sounds like the right fix is to:

 * check the return value of sc_ctx_log_to_file() and have sc_do_log_va()
   return if it's anything other than SC_SUCCESS.
 * Inside sc_ctx_log_to_file() make sure to set ctx->debug_file to NULL
   whenever it does call fclose() on it.
 * Inside sc_do_log_va() where it currently calls fclose() check
   if(ctx->debug_file && ctx->debug_file != stdout &&ctx->debug_file != stderr)
2013-08-02 12:22:42 +02:00
Frank Morgner 3567660a1c reader-pcsc.c: fixed implicit pin modification
Allows the application to only initialize pin2 for implicit pin
modification and to leave pin1 untouched.
2013-08-02 11:41:30 +02:00
Frank Morgner eb281b1ada reader-pcsc.c: fixed pin checking when implicitly given 2013-08-02 11:41:29 +02:00
Frank Morgner ff637bd02a initialize sm_ctx with 0s for iso7816 driver 2013-08-02 11:41:29 +02:00
Frank Morgner 6707f92b38 fixed PACE reader capability flag 2013-08-02 11:41:29 +02:00
Jean-Pierre Szikora b1a2c26235 Onepin profile stopped to work after commit 10e1ad001d
Cards formatted with one-pin profile can not be used (for modification
of the data on the card with pkcs15-init -X for example) after this
commit, which prevent the reading of 5015/4946 (containing the
profile).

The part of the code was simply commented out without comment.
Maybe it was used for testing purposes, and not removed for
the commit ?
2013-07-29 11:53:18 +02:00
JP Szikora 3f8f6facf5 Merge branch 'master' of https://github.com/OpenSC/OpenSC 2013-07-29 11:37:03 +02:00
entersafe c02f30a2da Fix a bug when writing public key 2013-07-29 10:13:39 +02:00
German Blanco 140ec71d73 Formatting with spaces and returns in hex dump. 2013-07-28 23:49:41 +02:00
Frank Morgner 1a65ed1ecf use _setmode instead of _set_fmode in windows
now compiles with MinGW-w64
2013-07-10 17:05:17 +02:00
Frank Morgner 9a05414f9a let OpenSC compile without OpenSSL and without SM 2013-07-10 16:22:33 +02:00
Jean-Pierre Szikora ad91449c87 Gives the "Current Maximum Data Field Length" for CardOS card in cardos-tool -i. 2013-06-21 10:46:35 +02:00
Jean-Pierre Szikora ac96e73c8c Merge remote branch 'upstream/master' into cardos5 2013-06-21 10:35:21 +02:00
German Blanco 63ce563d76 Adding support for DNIe. 2013-06-13 17:31:56 +02:00
Andreas Schwier 962cba98db sc-hsm: Fixed bug when changing SO-PIN with opensc-explorer
sc-hsm-tool: Fixed some warnings
2013-06-11 16:55:47 +02:00
Andreas Schwier ae1b96e5b2 sc-hsm-tool: Fixed a crash on Windows when --wrap-key frees memory allocated in opensc.dll 2013-06-11 16:55:47 +02:00
Viktor Tarasov e1da77e253 md: fix length of stripped data in RSADecrypt 2013-05-27 16:25:25 +02:00
viktorTarasov 584e47a9b8 Merge pull request #158 from cbancroft/fix-piv-tool-gen_key
Fixed gen_key to expect the proper PIV Key references.
2013-05-14 00:22:22 -07:00
Martin Paljak f6b0e893b9 card-ias: fix code style to be MS C89 compliant. 2013-05-11 18:39:55 +03:00
Martin Paljak 1b265690e8 Merge pull request #156 from poupas/master
Fixes for the PTEID card
2013-05-11 08:39:26 -07:00
Charles Bancroft 62dbdfff3a Fixed gen_key to expect the proper PIV Key references.
0x9B is defined as the Card Management Key, and probably shouldn't be
regenerated.  0x9E is the Card Authentication key which is what you
should be generating keys for.  This also brings piv-tool in line with
the documentation that states 0x9A, 0x9C, 0x9D and 0x9E are the proper
keyIds to use.
2013-05-10 09:14:20 -04:00
German Blanco 4a674b4dfc Improving logging of certificate handling. 2013-05-07 09:43:47 +02:00
João Poupino aec1cd9639 Remove redudant check 2013-05-06 21:46:15 +01:00
João Poupino 4ecbfabffe Fix for PTEID's PKCS#15 emulation breakage 2013-05-05 18:15:41 +01:00
João Poupino 9f57dd3c53 Simplify the compute signature operation and add warning 2013-05-05 18:14:39 +01:00
Dirk-Willem van Gulik b23060526c Allow for the pin to be entered on the keypad during issuing. For compliance reasons. 2013-04-28 18:56:51 +02:00
Ondrej Mikle 4c1cafed7c epass2003: key generation allows stricter privkey/pubkey ACLs 2013-04-28 18:37:29 +02:00
João Poupino 338fc3ed5f pteid: do not call the iso7816 driver get_response operation 2013-04-10 01:13:34 +01:00
Viktor Tarasov e8eb4cd7ed pkcs11-framework: do not wrap subject in a second ASN1 sequence
In a supplement to f5d53ab01783b0c37802e35f063fdbe5814bdbc7.

Subject and Issuer, returned by pkcs#15 framework, are already encoded as ASN1 sequence.
No need to wrap them in a second ASN1 sequence frame.
2013-04-07 17:09:15 +02:00
Viktor Tarasov c66278098b tools: missing names for ACL methods
thanks to fdeybach@gmail.com
https://sourceforge.net/mailarchive/message.php?msg_id=30684430
2013-04-06 22:06:52 +02:00
Viktor Tarasov 98db49936a pkcs15: 'issuer' and 'subject' have to be DER encoded sequence
'issuer' and 'subject' data have been the non-encoded sequence of rDNs
2013-03-17 13:56:26 +01:00
Martin Paljak 32ed309037 pkcs11: use calloc instead of malloc; remove obsolete malloc.h references. 2013-03-15 23:02:02 +02:00
Martin Paljak 3b4f7b9ff7 pkcs11: Don't touch readers or inserted cards in C_Initialize in 2.20 mode
This significantly speeds up calling C_Initialize.
Thanks to Nikos Mavrogiannopoulos for the tip.
2013-03-15 23:01:16 +02:00
Martin Paljak c2b6a0d500 pkcs11: report the library version based on plug-n-play feature. 2013-03-15 21:28:29 +02:00
Martin Paljak 9901682288 Normalize SC_ERROR_* API and clean up ISO7816-4 errors.
* iso7816_check_sw() emits a "informational message" (from ISO7816-4 table 6)
 * SW-s which are not known or not meaningful for internal API get translated
   to SC_ERROR_CARD_CMD_FAILED by default, so use it also in the SW table
 * Remove undefined SW-s and move generic SW-s to their sequential location.

This commit improves 8fc679bf40
2013-03-15 12:30:38 +02:00
Viktor Tarasov 6f1ae23b1e pkcs11: segfault if 'application-file' not defined
for some cards with emulated PKCS#15 'file_app' from 'application-info' is not defined
2013-03-12 10:23:35 +01:00
Viktor Tarasov 3b0ac5f8e7 pkcs15init: copy DATA object value to 'pkcs15-data-info'
When creating new DATA object, keep it's value in 'data' member of
'sc-pkcs15-data-info' data.
Used by pkcs15init emulation layer to store DATA value into a proprietary placement.
2013-03-11 18:25:22 +01:00
Viktor Tarasov c1b6575204 pkcs15init tool: throw error when invalid appliaction-id supplied
fix action labels
2013-03-11 18:25:05 +01:00
Viktor Tarasov 743ca1cedc pkcs15: new 'data' member in 'sc_pkcs15_data_info'
New member keeps the value of the PKCS#15 DATA object.

Internal pkcs15 procedure that reads DATA object is modified
to check if requested data are already vailable in 'data-info',
an only then try to read the content of dedicated on-card file.

For some emulated PKCS#15 systems value of DATA object is kept as 'direct' value
in a proprietary attribute files and so the common read procedure could not be used.

; some efforts to unify layout of code source.
2013-03-11 13:04:10 +01:00
Viktor Tarasov a24ecd0733 pkcs11-tool: ignore CRYPTOKI_ALREADY_INITIALIZED error
https://github.com/OpenSC/OpenSC/pull/118
Print warning and ignore 'Cryptoki library has already been initialized'  error
returned by C_Initialize().
2013-03-10 13:45:32 +01:00
Viktor Tarasov 8fc679bf40 libopensc: invalid usage of SC_ERROR_MEMORY_FAILURE
Initiated by discussion in https://github.com/OpenSC/OpenSC/pull/134 .

SC_ERROR_MEMORY_FAILURE has to be used as a resulting code of the card related operations,
and not as result of the memory allocation problems.

New 'warning' category of SC_ERRORs introduced -- SC_WARNING_xx .
Error text and SC_ERROR associated with return codes 6300 and 6200 has been changed.
2013-03-02 19:29:14 +01:00
Zbigniew Halas b1a4775310 epass2003: properly disable padding
EVP_CIPHER_CTX_set_padding needs to be called after EVP_EncryptInit_ex
and EVP_DecryptInit_ex, otherwise padding is re-enabled, which in turn
causes buffer overruns
2013-02-27 23:44:02 +00:00
Ondrej Mikle 83dc469f07 epass2003: list_files implemented 2013-02-25 19:21:52 +01:00
Viktor Tarasov 7a57fa8689 win32: build and include to MSI package 'openpgp-tool.exe' 2013-02-25 19:12:06 +01:00
Martin Paljak 16ee818440 Update domain name. paljak.pri.ee is gone since 2011. 2013-02-25 11:58:25 +02:00
Viktor Tarasov 3c804ff382 libopensc: more comments about FCP data 2013-02-25 10:20:31 +01:00
Viktor Tarasov 4b30292585 more macros for the values from ISO specification 2013-02-24 19:37:35 +01:00
Viktor Tarasov 326232de90 libopensc: introduce 'encoded-content' to the sc_file data
it's the hold place for the file's initial encoded content.
For some cards such data can be included into the file creation command.
2013-02-24 19:37:35 +01:00
Viktor Tarasov 5140c4a1f1 libopensc: use short form of the debug message calls 2013-02-24 19:37:35 +01:00
Ondrej Mikle ee48ea187a Fix to allow exponents other than 65537 for Feitian ePass 2003 2013-02-16 21:13:17 +01:00
Andreas Schwier b34d916e60 sc-hsm: Fixed problem deleting CA certificates
sc-hsm: Fixed public key format returned when generating ECC keys
2013-02-15 15:02:28 +01:00
Frank Thater 0577f7d4f5 sc-hsm-tool: Added support for DKEK password sharing scheme 2013-02-07 15:07:42 +01:00
Andreas Schwier 99af6cd8ee sc-hsm: Fixed a bug that prevents a newly generated 2048 key to show up at the PKCS#11 interface 2013-01-27 18:42:33 +01:00
Andreas Schwier 6d51b320f3 sc-hsm-tool: Added better error handling for non-SmartCard-HSM cards 2013-01-27 18:42:33 +01:00
mescheryakov1 f55bb019d9 Update src/tools/pkcs11-tool.c
fixed filling key type attr on writing object

pointer refers to local variable from destroyed stack frame
2013-01-27 18:37:45 +01:00
Toni Sjöblom 58679a5df1 Fixed file-id in myeid.profile 2013-01-27 18:34:07 +01:00
Viktor Tarasov d30cd83ad4 SM: common SM 'increase-sequence-counter' procedure 2013-01-06 17:34:35 +01:00
Viktor Tarasov 6a4de6d551 libopensc: APDU 'allocate & copy'and 'free' procedures 2013-01-06 17:30:41 +01:00
Viktor Tarasov 8d7c773561 SM: move SM APDU procedures to dedicated source file
new SM errors: 'session-already-opened' and 'invalid-checksum'
declare typed data for DH SM session
2013-01-06 16:40:17 +01:00
Viktor Tarasov 4c1c39f3e4 opensc-tool: add 'call-SM-handler' command
'open' and 'close' handlers of the card's SM driver can be called
2013-01-06 13:13:08 +01:00
Viktor Tarasov 3f30e14087 sm: move SM common crypto procedures to the dedicated library
rename 'sm' source directory
2013-01-04 22:29:59 +01:00
Viktor Tarasov 250364c060 pkcs15init: fix spurious gcc overflow warning,
thanks to Milan Broz (mbroz@redhat.com)
As discussed in pull request #115 (https://github.com/OpenSC/OpenSC/pull/115),
'if' test of impossible condition is removed in 'cardos' and 'incypto34' card drivers.
2013-01-04 19:03:46 +01:00
Viktor Tarasov cc5a171ddc pkcs15: regression in e35febe: compute cert length
parse_x509_cert() reviewed.
Now certificate's DER data are allocated and the DER data length is determined in one place.

https://github.com/OpenSC/OpenSC/pull/114
https://github.com/OpenSC/OpenSC/commit/e35febe
2012-12-25 20:05:45 +01:00
Viktor Tarasov 3aaf95c21b cardOS: compile on Windows
few coding style remarks
2012-12-16 11:50:08 +01:00
mtausig 1d75427f55 cardOS: Use information from AlgorithmInfo
In set_security_env, the algorithmInfo structure (from the TokenInfo file of
PKCS#15) is parsed to see, what algorithm IDs are supported for signature
operations.

Using the information from AlgorithmInfo set in set_security_env when
computing signatures.

Fixed incorrect order of code blocks. If neither a reference to rsa_sig nor to
rsa_pure_sig is found in AlogirthmInfo, boths methods are enabled before (and
not after) trying pure_sig
2012-12-16 11:23:35 +01:00
blumentopf d5c2401e19 pkcs15-gemsafeV1.c: Multiple key containers and ATR-specific PIN policies
pkcs15-gemsafeV1.c: Change PIN data structure to make MSVC compiler happy
pkcs15-gemsafeV1.c: Turn constants into macros to make MSVC compiler happy
2012-12-16 10:09:44 +01:00
Anthony Foiani f7c12574ee pkcs15-tool: initialize 'opt_auth_id' consistently.
All the other option values are initialized to NULL, so do the same to
opt_auth_id.

(Although, as they're all static globals, they should be set to 0 at
runtime anyway, I think...)

Signed-Off-By: Anthony Foiani <anthony.foiani@gmail.com>
2012-12-10 00:54:26 -07:00
Jean-Pierre Szikora f6b1b0c873 ATR status in GET DATA is 0x80 with a custom ATR 2012-12-05 10:03:52 +01:00
Jean-Pierre Szikora 9ad8cd96ac CardOS V5.0 is recognized now. Some useful infos are given with cardostool -i,
but the card is still not supported by other tools.
2012-12-05 10:03:52 +01:00
Viktor Tarasov 8b07b9c5a7 compile on Windows, minor codding style issues 2012-12-03 15:21:22 +01:00
sjoblomt 457426543d MyEID ECDSA support 2012-12-03 14:37:13 +01:00
Viktor Tarasov 9e9b3d0bd8 tool: in 'do_apdu' increase size of send/receive buffers 2012-11-28 11:09:36 +01:00
Viktor Tarasov 60b7e52e06 pkcs15: mandatory 'publicKeyCoefficients' in encode/decode public key procedures
http://www.opensc-project.org/pipermail/opensc-devel/2012-November/018586.html
2012-11-20 22:58:37 +01:00
Ludovic Rousseau 81bbddfc24 card-gemsafeV1: Add a GemSafe V1 ATR
Thanks to Lukas Wunner for the patch
2012-11-20 19:11:23 +01:00
Anthony Foiani 27c677188e pcks11: trivial: fix debug output for CKA_PRIME_1 and CKA_PRIME_2
Without this patch, debugging output issues these as unknown
attributes:

  ... C_CreateObject(): CKA_PRIVATE_EXPONENT = 97F798...
  ... C_CreateObject(): Attribute 0x124 = EFE5AD...
  ... C_CreateObject(): Attribute 0x125 = D4D3F6...
  ... C_CreateObject(): CKA_EXPONENT_1 = 5815FD...

With this patch, we see:

  ... C_CreateObject(): CKA_PRIVATE_EXPONENT = 97F798...
  ... C_CreateObject(): CKA_PRIME_1 = EFE5AD...
  ... C_CreateObject(): CKA_PRIME_2 = D4D3F6...
  ... C_CreateObject(): CKA_EXPONENT_1 = 5815FD...

Signed-Off-By: Anthony Foiani <anthony.foiani@gmail.com>
2012-11-20 08:46:27 +01:00
Anthony Foiani f63135afab tools: check return value after each call.
It seems that this suffered some copy and paste damage at some point.
Change so that we check each return value immediately after the API
call.

Signed-Off-By: Anthony Foiani <anthony.foiani@gmail.com>
2012-11-20 08:46:27 +01:00
Andreas Schwier fb8e0cc3b2 sc-hsm: Improved checking in sc-hsm-tool 2012-11-20 08:46:27 +01:00
Andreas Schwier 0adec1bddd sc-hsm: Fixed bug with memory released to early 2012-11-20 08:46:27 +01:00
Andreas Schwier bbbfae4bf0 sc-hsm: Now saving the internal CSR in place of the certificate and decoding the public key at initialization (RSA only) 2012-11-20 08:46:27 +01:00
Viktor Tarasov 6c051f8490 pkcs11: check arguments in get_bignum_bits() procedure
t451: segmentation fault when getting public key bits number
2012-11-12 16:46:25 +01:00
Viktor Tarasov bd86063835 t455: check validity of RSA/DSA public key components
Segmentation fault happened when reading SSH key with the non-initilized public key components.
2012-11-12 10:13:57 +01:00
Viktor Tarasov 68ee0e76e0 t447: return value from init() in reader driver not checked 2012-11-11 22:17:17 +01:00
Viktor Tarasov f7771c9b08 libopensc: check data returned by 'read-public-key'
fix error message
2012-11-11 21:47:10 +01:00
Viktor Tarasov da5934a6ff libopensc iso7816: retry SELECT with FCI if SELECT without FCI fails
t457 (https://www.opensc-project.org/opensc/ticket/457)
For some cards that currently use the common iso-7816 operations
only SELECT with return of FCI/FCP can be applied.

In iso-7816 'select-file' handle, if 'SELECT without FCI' fails with error code 6A86,
then retry 'SELECT with FCI'. Other error code can be added.

Sorry for the 'coding style' noise.
2012-11-11 20:38:30 +01:00
Viktor Tarasov a4ac33f32a build sc-hsm-tool: link with OpenSSL libs 2012-11-11 20:36:57 +01:00
Andreas Schwier 7c714860a2 sc-hsm: Fixed bug decoding CVCs without domain parameter 2012-11-11 12:53:03 +01:00
Andreas Schwier 33da14c459 sc-hsm: Added code to prevent CV certificates being listed as X.509 certificates 2012-11-11 12:53:03 +01:00
Andreas Schwier ffb20e5916 sc-hsm: Added sc-hsm-tool with DKEK support and key wrap / unwrap 2012-11-11 12:53:03 +01:00
Viktor Tarasov 1d1abe4c21 pkcs15-crypt tool: set HASH_NONE crypto flags when the hash do not asked
without this for the cards that have only RAW mechanism
it's not possible to compute signature with PKCS1 padding and without hash.
2012-11-11 00:42:52 +01:00
Viktor Tarasov 7fbca94698 opensc: new card operation 'read-public-key'
In PukDF of PKCS#15 the public key value can be presented by 'direct value', by path or by path and reference.
For the different cards the public key can be stored in EF, internal EF or in card specific SDO (security data objects).
A new card handle allows to read out the public key from the card specific SDOs.
2012-11-09 14:36:14 +01:00
Viktor Tarasov 6819b32e18 pkcs15-tool: for public key show the presence of 'direct' value 2012-11-09 14:34:46 +01:00
Viktor Tarasov 62fd67f6a8 gemsafeV1: set 'auth-method' for the emulated PIN PKCS#15 object 2012-11-09 14:33:23 +01:00
Viktor Tarasov 0166321835 libopensc: increase maximum number of card drivers
http://www.opensc-project.org/pipermail/opensc-devel/2012-October/018552.html
Default driver is disabled on 0.13 because there are more drivers listed in ctx.c. (leonardo.schenkel@gmail.com)

SC_MAX_CARD_DRIVERS is increases from 32 to 48. It's not the best solution, but the most rapid.
Will be waiting for the better proposals.
2012-11-04 16:44:34 +01:00
Viktor Tarasov e35febed5b pkcs15: use whe available the pkcs15 object content
when reading certificate, try to get the pkcs15 object's content
before reading the certificate file.
2012-10-21 16:30:06 +02:00
Viktor Tarasov 4cf3a3b204 move CK_VERSION data from 'pkcs15' to 'sc-card'
CK_VERSION is included into PKCS#11 data but is not specified by PKCS#15.

CK_VERSION can be provided by card's pkcs15 emulator or by the card's driver,
including the cards with the native support of pkcs#15 (and thus without pkcs15 emulator).

That's why the more general solution is to have these data included into 'sc-card' data type.
2012-10-21 16:24:11 +02:00
Andreas Schwier aaedef70b5 sc-hsm: Added ability to initialize SmartCard-HSM using C_Initialize and C_InitPIN on PKCS#11 interface 2012-10-21 15:51:55 +02:00
Andreas Schwier fba298c6f4 pksc11: Added ability to indicate hardware and firmware version information at PKCS#11 interface 2012-10-21 15:51:55 +02:00
Viktor Tarasov 40ff0e4ede pkcs11: Fixed SIGV when deleting public key objects via PKCS#11
Thanks to Andreas Schwier.
2012-10-02 09:26:35 +02:00
riham c91f0e84cb entersafe: Disable RSA:512bits that modified in entersafe_generate_key and entersafe_store_key function
1.Added a prompt while initializing ePass2003 \n 2.Modify code to disable 512bit key
2012-10-01 18:52:19 +02:00
Andreas Schwier 72786abe1f sc-hsm: Added write support for RSA and ECC keys, certificates and data objects 2012-10-01 13:09:02 +02:00
Andreas Schwier a9393aa983 framework-pkcs15: Fixed a SIGV when key generation returned ERROR_NOT_SUPPORTED 2012-10-01 13:04:02 +02:00
Andreas Schwier 1619a42375 ecc: Adding more curves 2012-10-01 13:04:02 +02:00
Andreas Schwier db3f5f5f17 framework-pkcs15: Fixed issued with uninitialized variable keysize 2012-10-01 13:04:02 +02:00
Andreas Schwier f508b21253 pkcs15: Add support to encode EC private key description 2012-10-01 13:04:02 +02:00
Andreas Schwier 7b943b934b pkcs15: Fixed typo 2012-10-01 13:04:01 +02:00
Andreas Schwier 02fe6d474b pkcs11-tool: Fixed issue with ID increment failing on constant data 2012-10-01 13:04:01 +02:00
Viktor Tarasov 249b769a4b pkcs11: unlink 'pubkey' FW object when deleting related certificate
Thanks to Andreas Schwier.
http://www.opensc-project.org/pipermail/opensc-devel/2012-September/018455.html

In PKCS#11 FW, the 'certificate' FW object is used to create corresponding 'public'key' FW object
or to get some of its attributes.
Seg.fault occured when, in the same session, the related certificate was destroyed and after that
there was the attempt to get such public key attributes.
2012-10-01 10:47:52 +02:00
Viktor Tarasov df9a4d0b2c pkcs15: for 'sc_pkcs15_cer's data use the 'der' object type
To hold the raw certificate blob in 'sc_pkcs15_cert' data use the 'sc_pkcs15_der' data type.
also:
; in 'pkcs15-cert.c' use short call of the debug messages;
; in 'destroy-object' pkcs15 framework handler take into account the multi-application cards:
-- when binding card use the application info;
-- when finalizing profile use the application ID.
2012-09-30 22:54:52 +02:00
Ludovic Rousseau ea40e7fe24 Use AM_CPPFLAGS instead of INCLUDES
Fix autoreconf warnings:

$ autoreconf -vis -Wall
[...]
src/common/Makefile.am:12: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/libopensc/Makefile.am:19: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/minidriver/Makefile.am:15: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/pkcs11/Makefile.am:10: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/pkcs15init/Makefile.am:36: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/scconf/Makefile.am:12: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/sm/Makefile.am:8: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/tests/Makefile.am:9: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/tools/Makefile.am:15: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
2012-09-25 23:03:38 +02:00
Viktor Tarasov 628ead7e41 pkcs11-tool: suppress warnings about the missing attributes
when showing an object  do not print warnings about missing 'uncommon' attributes
2012-09-24 11:51:04 +02:00
Viktor Tarasov ceef4c0be3 iasecc: remove ostentatious TODO messages 2012-09-24 11:50:56 +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 760cd1cfbd pkcs15-tool: non-initialised OID 2012-09-23 16:51:25 +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 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 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
Peter Marschall 322e3cf403 opensc-explorer: convert CHANGE & UNBLOCK to sc_pin_cmd 2012-08-11 20:48:58 +02:00
Peter Marschall 81695df211 opensc-explorer: use standard usage() everywhere
With the improvements of the man page, there is no need any more to have
local help texts for functions.
2012-08-11 20:48:58 +02:00
Ludovic Rousseau 72c4060f1d Fix compilation error on Mac OS X
In file included from pkcs15.c:30:
cardctl.h:870: error: expected specifier-qualifier-list before 'time_t'

Change-Id: I5faad5462ba6268fd7cf48a04f41e1755597ad0c
2012-08-07 00:34:15 +02:00
Viktor Tarasov c7827e5e4b sm: change SM data types, thanks to Frank Morgner for revision
http://www.opensc-project.org/pipermail/opensc-devel/2012-July/018232.html
2012-07-29 21:41:44 +02:00
Viktor Tarasov 7301715624 sm: link 'local' SM module with OpenSSL's crypto library 2012-07-29 21:40:47 +02:00
Viktor Tarasov 49e7f529b2 sm: misplaced check of the 'get-sm-apdus' return code 2012-07-29 21:38:39 +02:00
Nguyễn Hồng Quân e34866f188 OpenPGP: Accept authentication key for S/MIME decrypting.
The card contains only 1 certificate, which can be used for encrypting.
But this certificate is bound with authentication key, so when decrypting,
the authentication key will be presented to check.
This commit allows to bypass the check in driver. However, it is not enough.
The users have to import the same key to "Encryption key" to help the card find
right key to work.

OpenPGP: Add log and comments.

OpenPGP: Pretend to select dummy files.
Some files are needed by pkcs15init, but not exist in OpenPGP card.
We pretend to know these dummy files to make pkcs15init successful.

Compilation error on windows:
when declaring array use explicit size, add pkcs15-openpgp.obj in Makefile.mak
2012-07-29 14:04:08 +02:00
Nguyễn Hồng Quân 241bfded4d OpenPGP-pkcs15init: Support generating key via pkcs15-init tool.
OpenPGP-pkcs15int: Add more debug log.

OpenPGP-pkcs15init: Add more checks in key generation.
Check for key ID. Set default key.
Check for result of key generation from driver.
2012-07-29 13:09:08 +02:00
Nguyễn Hồng Quân 30e61d9fbf OpenPGP: Handle access on dummy files, which is assumed to exist by pkcs15init.
OpenPGP: Update card algorithms after importing key.

OpenPGP: Add SC_ALGORITHM_ONBOARD_KEY_GEN flag to card algorithms.
2012-07-29 13:09:08 +02:00
Nguyễn Hồng Quân b67063dcd8 pkcs15init-openpgp: Support for private key import in pkcs15init.
Example command:
pkcs15-init --delete-objects privkey,pubkey --id 3 --store-private-key quan-key.pem  --auth-id 3 --verify-pin --extractable --id 3

pkcs15init-OpenPGP: Some parts in openpgp.profile are not used.
2012-07-29 13:09:08 +02:00
Nguyễn Hồng Quân 7123638454 OpenPGP: Correct access condition for some pubkey blobs.
OpenPGP: Don't really delete pubkeys blobs.
2012-07-29 13:09:08 +02:00
Nguyễn Hồng Quân affb38304e pkcs15-init tool: Change the order of action.
DELETE_OBJECT will be done before STORE_XXX.
2012-07-29 13:09:08 +02:00
Nguyễn Hồng Quân 70b7b4aa54 pkcs15init-OpenPGP: Add store_data functions.
We need this function to use OpenPGP's specific action flow instead pkcs15init's default.
This will help to avoid redundant steps which may make the overall process fail.
2012-07-29 13:09:08 +02:00
Viktor Tarasov 0518ced8e0 asn1: export 'asn1-write-element' function
... used by OpenPGP driver
2012-07-29 13:09:00 +02:00
Nguyễn Hồng Quân 42ad3c1dff OpenPGP: Add support for key import at driver level.
OpenPGP: Some indentations need to be tab-size-independent.

OpenPGP: Check for null data when storing fingerprints.

OpenPGP: Allow to provide creation time to store (when gen/import key).
Old: Only store current time.
New: Can provide time to store, not only calculate current time.

OpenPGP: Correct setting content of pubkey blobs after key generation.

cardctl: Add definitions to support key import in OpenPGP.

OpenPGP: Add support for key import at driver level.
2012-07-29 12:48:59 +02:00
Nguyễn Hồng Quân 69e30ead89 openpgp-tool: Key generation support.
openpgp-tool: PIN verfication support.
openpgp-tool: Add notification in case of error.
openpgp-tool: Add manual for key generation and PIN verification.
2012-07-29 12:48:45 +02:00
Nguyễn Hồng Quân 50e37aa849 OpenPGP: Correct the way to set output after generating key.
Correct the way to parse response data.
Updated wrong blob for pubkey info <~~ Fix.

OpenPGP: Store creation time after generating keys.

OpenPGP: Put_data: Handle the case that DO exists but its blob does not.
When checking DO before writing, relying on blobs only will miss the case that DO exists but its blob does not, when DO is non-readable.

OpenPGP: Set algorithm attributes before generating key.

OpenPGP: Add dependency of OpenSSL.

OpenPGP: Calculate and store fingerprint.
Calculate and store fingerprint after generating key.

OpenPGP: Update blob of pubkey info.
Update blob holding pubkey info after generating key.

OpenPGP: Add step to update card algorithms.
Update card algorithms after generating key. However, this step is not implemented yet, because of suspection about wrong data (see code comment).
2012-07-29 12:48:21 +02:00
Nguyễn Hồng Quân 8261490ec1 PKCS15-OpenPGP: Change the way emu_init return in error case. 2012-07-29 12:09:56 +02:00
Nguyễn Hồng Quân ed0e2be305 Add pkcs15init-binding for OpenPGP 2012-07-29 12:09:56 +02:00
Doug Engert 58a4821689 piv-tool -s not sending APDU - missing code
The code to send the APDU to the piv card when using
piv-tool -s xx:xx:xx... was inadvertently removed
on 2011-04-26 02:29:53 by: 1cdb3fa971
APDU parsing: switch to Frank Morgner's implementation

The missing code is replaced.

The -s option is infrequently used, so the problem
was not spotted earlier.
2012-07-29 11:29:14 +02:00
Kalev Lember 124d6e3a40 esteid: Do not set CKA_ALWAYS_AUTHENTICATE for the "Allkirjastamine" key
CKA_ALWAYS_AUTHENTICATE implies CKU_CONTEXT_SPECIFIC login, but all this
key really should need is a C_Login with CKU_USER.

The historical reason for having CKA_ALWAYS_AUTHENTICATE set was to keep
Firefox/NSS from using that particular key for SSL connections. However,
starting with Firefox 8, NSS ignores Non Repudiation certificates for
SSL and that makes the CKA_ALWAYS_AUTHENTICATE workaround unnecessary.

Now that Firefox is fixed, drop the workaround in OpenSC so that
applications that follow the pkcs11 spec wouldn't have to login twice to
access the key.
2012-07-22 20:02:24 +03:00
Nguyễn Hồng Quân 4e5ef8f1c9 PKCS15 - OpenPGP: Add more comments. 2012-07-07 19:00:36 +02:00
Nguyễn Hồng Quân 0b469ed31e OpenPGP: Add an explanation when building APDU. 2012-07-07 19:00:35 +02:00
Nguyễn Hồng Quân cf6b5e7903 pkcs15init: Add more debug log. 2012-07-07 18:42:36 +02:00
Frank Morgner 31bdbd6b6a use error code if no SM was applied 2012-07-05 10:12:34 +02:00
Diego Elio Pettenò 1d6fae2241 build: use autoconf's MKDIR_P not automake's (deprecated) mkdir_p. 2012-07-01 17:03:27 +02:00
Mathias Brossard e423bac474 Move case block so that fall-through works as intended 2012-06-28 16:59:40 +02:00
Mathias Brossard bfbef6fe2b Support key type inference for CKM_GOSTR3410_KEY_PAIR_GEN 2012-06-28 16:56:59 +02:00
Mathias Brossard 3fc4547e45 Add CKM_GOSTR3410_KEY_PAIR_GEN if card supports onboard generation 2012-06-26 10:48:49 +02:00
Viktor Tarasov 0914b1eca7 libopensc: SM: not all the APDUs need to be wrapped
For some cards some APDUs are always transmitted in a plain mode,
even if SM session is opened.
For these APDUs the 'get_sm_apdu' card's handler returns SUCCESS without wrapped APDU version.
In such cases 'transmit' is called for the plain APDU.
2012-06-19 18:04:37 +02:00
Viktor Tarasov 68e217ceee pkcs15: free NULL key is not error
when freeing key object, do not throw an error if supplied key pointer is NULL;

sc_pkcs15_free_prkey() procedure should not free the supplied key pointer,
the body of this procedure is replaced by body of sc_pkcs15_erase_prkey().
staitc sc_pkcs15_erase_prkey() is not more used.
2012-06-19 17:58:12 +02:00
Viktor Tarasov f9a13179d8 AuthentIC: when using SM decrease max-send-size value
update list of APDUs that always sent in plain (non SM wrapped) mode
2012-06-19 17:37:51 +02:00
Peter Marschall 34541e95c4 OpenPGP: add LOG_FUNC_CALLED() for "symmetric" logging 2012-06-17 10:49:00 +02:00
Nguyễn Hồng Quân 8db8f76bad OpenPGP: Change whitespace. 2012-06-16 15:43:51 +02:00
Nguyễn Hồng Quân ccb1067d75 OpenPGP: Correct the APDU preparation step for key generation. 2012-06-16 15:43:09 +02:00
Peter Marschall db06b043ca PKCS15 - OpenPGP: re-factor certificate object init
restrict scope of some variables.
2012-06-15 14:56:46 +02:00
Nguyễn Hồng Quân 735883d8f6 PKCS15 - OpenPGP: Change way to check certificate object.
Old: If cert is missing, raise error.
New: If cert have data, declare object, otherwise, just ignore it.
2012-06-15 14:45:44 +02:00
Nguyễn Hồng Quân 5e295ba08d OpenPGP: Remove unused constants. 2012-06-15 14:40:14 +02:00
Viktor Tarasov c64a5f34d3 pkcs15init: application path selection in bind procedure
Application path can contain non-zero length path value and AID.
In this case select AID as DF_NAME only if length of path value is zero.

Segfault: dereferencing NULL pointer, thanks to Magosányi Árpád
2012-06-13 08:31:46 +02:00
Viktor Tarasov d3dbe444e1 pkcs15-init: coverity scan warning NEGATIVE-RETURNS
CID 402540: Argument cannot be negative (NEGATIVE_RETURNS)
2012-06-11 21:28:37 +02:00
Viktor Tarasov 61254f8651 muscle: coverity scan warning OVERRUN-STATIC
CID 402559: Out-of-bounds access (OVERRUN_STATIC)
CID 402558: Out-of-bounds access (OVERRUN_STATIC)
2012-06-11 21:18:51 +02:00
Viktor Tarasov ce23bba622 gemsafeV1: coverity scan warning OVERRUN-STATIC
CID 402560: Out-of-bounds read (OVERRUN_STATIC)
2012-06-11 21:08:21 +02:00
Viktor Tarasov aa46a210fc iasecc: coverity scan warning OVERRUN-STATIC
CID 402562: Out-of-bounds read (OVERRUN_STATIC)
2012-06-11 20:59:45 +02:00
Viktor Tarasov 12dcf13236 pkcs15-init: coverity scan warning RESOURCE-LEAK
CID 402619: Resource leak (RESOURCE_LEAK)
2012-06-11 20:10:42 +02:00
Viktor Tarasov c6f4e09477 pkcs15-tool: coverity scan warning RESOURCE-LEAK
Coverity scan CID 402622: Resource leak (RESOURCE_LEAK)
2012-06-11 20:04:08 +02:00
Viktor Tarasov 62eb0d05d7 jcop: coverity scan warning RETURN_LOCAL
CID 402623: Pointer to local outside scope (RETURN_LOCAL)
2012-06-11 19:59:36 +02:00
Viktor Tarasov 629c0e8df4 libopensc: resource leak coverity scan warning
Coverity warning CID: 203380: RESOURCE_LEAK;
use short call form of the debug messages;
code layout.
2012-06-11 19:45:26 +02:00
Viktor Tarasov 9466891752 openpgp: coverity scan warning MISSING_RETURN
Coverity Scan CID: 709045
2012-06-11 18:51:06 +02:00
Peter Marschall a09f304817 OpenPGP: clean up & fix pgp_delete_file()
* use LOG_FUNC_CALLED() .. LOG_FUNC_RETURN for "symmetric" logging
* don't zero-fill the DO's contents but empty it
* get rid of unnecessary variables
* select parent DF after deletion (required by to ISO 7816-9)
* don't try to delete MF
2012-06-09 13:48:09 +02:00
Peter Marschall 2aa4cf57ed OpenPGP: simplify pgp_update_binary() even more
Fail on idx > 0 in order to avoid the requirement to read from the DO.
The DO may be read-protected, and this might either fail or produce
wrong results.
2012-06-09 13:48:09 +02:00
Peter Marschall d7f58f7ea7 OpenPGP: cleanup & fix pgp_update_binary()
* use LOG_FUNC_CALLED() .. LOG_FUNC_RETURN for "symmetric" logging
* update comment
* check that blob->data is defined
* fix writing new data to the correct offset
* use calloc() instead of malloc() & memset()
* align pgp_ops function pointer list
2012-06-09 13:48:09 +02:00
Peter Marschall c8e802eab6 OpenPGP: simplify & clean up pgp_put_data()
* make sure variables of type u8 do only get passed fitting data
* use LOG_FUNC_CALLED() .. LOG_FUNC_RETURN for "symmetric" logging
* leave most of the spcial casing in ADPU handling to sc_adpu_transmit()
* use SC_ADPU_CASE_1 for empty buffer (avoids special casing Lc=0)
* clean up log strings & comments
2012-06-09 13:48:09 +02:00
Peter Marschall 0010fcbe6b OpenPGP: make pgp_set_blob() a bit more resilient
* use calloc() instead of malloc() to have defined contents
* only copy from passed data when it is not NULL
2012-06-09 13:48:09 +02:00
Nguyễn Hồng Quân 73387d4b84 OpenPGP: Correct ACL key_ref
Correct ACL key_ref after redefining conventional OpenPGP key-ref (0x81-0x83 -> 1-3).
2012-06-09 08:04:19 +02:00
Peter Marschall 825c8578a9 tools: fix typo/thinko in util_print_usage_and_die()
Fix a typo/thinko in util_print_usage_and_die() that led to the short option
names not to be shown at all.
2012-06-08 20:32:33 +02:00
Peter Marschall a56bebd952 opensc-explorer: clean-up help text
"asn1 file" -> "ASN.1 file"
2012-06-08 20:32:33 +02:00
Peter Marschall 56affa612f pkcs15-tool: help text clean-up
"to be binded to " -> "to bind to"
2012-06-08 20:32:33 +02:00
Viktor Tarasov 67136befe8 pkcs15-tool: print content of DATA object ...
list the 'Authentication' objects instead of 'PIN' objects.
2012-06-08 20:17:36 +02:00
Viktor Tarasov 73f324010e config: ignore non 'auto-configurated' values
When getting string configuration parameter,
ignore non 'auto-configurated' in configuration file value
(ex. @SOME_VALUE_IN_OPENSC_CONF@) and return it's default value.
2012-06-08 20:17:36 +02:00
Viktor Tarasov da894500c9 minidriver: build dependence on opensc_a.lib and pkcs15init.lib
spelling of comments and debug messages
2012-06-08 20:17:36 +02:00
Viktor Tarasov 667949019a coverity scan: warning use non-initialized data 2012-06-08 20:17:36 +02:00