Commit Graph

3630 Commits

Author SHA1 Message Date
viktor.tarasov 167aed7c1f pkcs15init: migrate setcos to the New API
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3968 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-31 20:29:58 +00:00
viktor.tarasov 7f52a0267f pkcs15init cardos: fix update keys
When creating application DF ('PKCS15-AppDF'), User PIN is not yet created, and AC type 'SC_AC_SYMBOLIC' cannot be resolved.
So, in the card profile, the macro '$PIN' cannot be used to define the ACLs of the application DF.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3967 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-31 20:26:45 +00:00
aj 72d5ebb79c make erase incompatible with all other actions.
thus we don't need to worry about if the pin/so-pin was passed
for the old structures (before erase) or the new ones (if used
with create).


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3966 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-30 19:25:22 +00:00
viktor.tarasov b83ed7ed71 sertcos: both PINs are globals
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3965 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-29 17:41:05 +00:00
viktor.tarasov 19e9aaf635 pkcs15init: fix putting xPINs in cache
;when putting SOPIN into the global cache, use the path from the object info;
;sc_pkcs15init_create_pin() can be called to create PUK object;




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3964 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-29 17:40:03 +00:00
viktor.tarasov 742b0ea341 pkcs15init: one more fix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3963 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-29 17:12:53 +00:00
viktor.tarasov 2bcd535284 pkcs15init: fix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3962 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-29 17:08:26 +00:00
viktor.tarasov 5e805ecf2d libopensc: in iso7816 process_fci() decode Life Cycle Status byte (ISO 7816-4 2005, 5.3.3, tag '8A')
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3961 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-29 10:54:51 +00:00
viktor.tarasov 90ba3c769d pkcs15init: card specific pkcs15init has to be ready for pin_reference = -1
Starting from r3946, the reference of PIN, instantiated from profile, is not overwritten by 0 in sc_pkcs15init_create_pin().
http://www.opensc-project.org/opensc/browser/trunk/src/pkcs15init/pkcs15-lib.c?rev=3946#L1064

So, card specific pkcs15init has to be ready for the pin_reference = -1. 




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3960 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 16:44:02 +00:00
aj 32f7a4eed3 fix text a bit.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3959 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 14:53:36 +00:00
martin c23f07764d Add more event type defines, add declaration of sc_ctx_get_reader_by_id().
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3958 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 14:29:30 +00:00
viktor.tarasov 9eebe0e1a5 pkcs11: by default do not create slot for the User PUK (thanks to Andreas)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3957 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 14:15:13 +00:00
viktor.tarasov 630eb213f4 miocos: migration to New API
Miocos card owners are heartly invited to test this revision.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3956 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 12:46:36 +00:00
viktor.tarasov 55f7f02e18 remove debug message
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3955 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 12:42:19 +00:00
viktor.tarasov 67b1ba0562 opensc.conf: in pkcs11 section a new option to disable slot for User PUK
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3954 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 12:17:05 +00:00
viktor.tarasov 031bfc7a07 pkcs11: parametrize disabling of the slot for PUK
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3953 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 12:14:48 +00:00
viktor.tarasov ae046cc460 pkcs11: do not create slot for PUK
Ignore PUK for the 'normal' pkcs11 also, not only for 'one-pin-pkcs11'.




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3952 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 08:28:25 +00:00
viktor.tarasov 660fdea68a profile: for PIN flags use rather 'define' macro
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3951 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 18:18:10 +00:00
viktor.tarasov f2d3618ff6 oberthur: finalize migration to the NEW API
no more 'init_app'.

- Oberthur unblock style is the only one (local SOPIN is used as PUK);
- user PIN and PUK should be everywhere defined as local;
- SOPIN is always global.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3950 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 18:07:14 +00:00
viktor.tarasov 38e1144c1e pkcs15init: pkcs15 PinObject for PUK
When creating PIN, if 'puk_id' is defined in 'struct sc_pkcs15init_pinargs', 
the pkcs15 PinObject for PUK will be created. 

For a moment, PinObject is not created for SO PUK.







git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3949 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 17:53:51 +00:00
viktor.tarasov 8aa2128423 pkcs15-init tool: don't ask for PUK value when creating PIN with 'unblock-disabled' in flags
- prepare pkcs15-init tool for creating a pkcs15 PinObject for PUK.




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3948 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 17:38:43 +00:00
viktor.tarasov 42ad65e8d2 sorry, fix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3947 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 17:08:04 +00:00
viktor.tarasov 7f0abe80bb libopensc pkcs15: path is optional for PinAttributes of PinObject
- for 'global' PINs path in not encoded into the AODF;
- when selecting pin_reference, start from value defined in profile.




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3946 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 17:03:04 +00:00
s 33228c7cbc cleanup and correct style
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3945 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 16:04:19 +00:00
s 723bcc41ff fix: use of uninitialised value - return parameter (phObject) from C_CreateObject and C_GenerateKeyPair
(In function 'pkcs15_add_object': warning: unused parameter 'pHandle')

Example (C_CreateObject):
Breakpoint 3, C_CreateObject (hSession=134587040, pTemplate=0x8049160, ulCount=5, phObject=0xbff55560)
    at pkcs11-object.c:57
57              rv = sc_pkcs11_lock();
(gdb) x/x phObject
0xbff55560:     0xffffffff
(gdb) finish
0xb7f5c6c0 17:15:09.969 [opensc-pkcs11] framework-pkcs15.c:657:pkcs15_add_object: Setting object handle of 0x0 to 0x805ab80
Run till exit from #0  C_CreateObject (hSession=134587040, pTemplate=0x8049160, ulCount=5,
    phObject=0xbff55560) at pkcs11-object.c:57
0x080487a4 in main ()
Value returned is $1 = 0
(gdb) x/x 0xbff55560
0xbff55560:     0xffffffff
(gdb) c
Continuing.

Breakpoint 4, C_DestroyObject (hSession=134587040, hObject=4294967295) at pkcs11-object.c:106
106             rv = sc_pkcs11_lock();
(gdb) p/x hObject
$2 = 0xffffffff
(gdb) finish
Run till exit from #0  C_DestroyObject (hSession=134587040, hObject=4294967295) at pkcs11-object.c:106
0xb7f5c6c0 17:15:56.581 [opensc-pkcs11] pkcs11-object.c:110:C_DestroyObject: C_DestroyObject(hSession=0x805a2a0, hObject=0xffffffff)
0x080487cb in main ()
Value returned is $3 = 130



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3944 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 14:50:35 +00:00
s 66f9ccaa94 fix SIGSEGV:
$ pkcs11-tool --slot 5 --login --pin "12345678" --label 1 --type data --private --write-object tmp.txt
Generated Data Object:
Data object 0
...
$ pkcs11-tool --slot 5 -O --login --pin "12345678"
Data object 135436368
  label:          '1'
  application:    '1'
  app_id:         -1
  flags:           modifiable private
...
(gdb) run
Starting program: /usr/local/bin/pkcs11-tool --slot 5 --login --pin "12345678" --label 1 --type data --delete-object

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1210333504 (LWP 7193)]
0xb7cc8181 in slot_token_removed (id=5) at slot.c:319
319                     if (object->ops->release)
(gdb) bt
#0  0xb7cc8181 in slot_token_removed (id=5) at slot.c:319
#1  0xb7cc82dd in card_removed (reader=0x811bdf0) at slot.c:132
#2  0xb7cc43e7 in C_Finalize (pReserved=0x0) at pkcs11-global.c:298
#3  0x08050fc0 in main (argc=11, argv=0xbf98d6f4) at pkcs11-tool.c:677


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3943 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 12:22:50 +00:00
viktor.tarasov 5cd5728c0e libopensc: search pkcs15 objects: accept NULL value for the output argument
So that, the dummy object for the 'search pkcs15 object' calls is not neccessary. 



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3942 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-26 12:59:08 +00:00
s 2ec8932c93 fix:
reader-openct.c: In function 'openct_reader_connect':
reader-openct.c:204: error: 'reder' undeclared (first use in this function)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3941 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-26 10:40:47 +00:00
viktor.tarasov bc140126e9 pkcs15init: in select_object_path() look for the template also outside the 'key-domain'.
To use New API with the cards that do not have 'key-domain' in their profile,
when setting object data path,
the object template has to be also looked for outside the 'key-domain'.

;migrate Oberthur to the New API;
;use macros SC_CALLED, SC_TEST_.., SC_RETURN in pkcs15-lib.c




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3940 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-25 16:42:22 +00:00
viktor.tarasov 986309db79 libopensc: new operations for access control
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3939 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-25 16:10:54 +00:00
viktor.tarasov 4662812e93 pkcs15-init tool: when importing bunch of certificates, break after the first error
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3938 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-25 15:53:29 +00:00
viktor.tarasov 97d5b3e6e7 sorry, commit by error; reverting back to r3935
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3937 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-25 15:30:33 +00:00
viktor.tarasov 6e9c7e5619 pkcs15-init tool: when importing bunch of certificate, break after the first errorsrc/tools/pkcs15-init.c
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3936 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-25 15:11:35 +00:00
martin 0244baa494 pkcs11:
- slots, sessions and objects are kept as lists.
  - change the way slots, cards and readers are managed.
  - re-implement C_WaitForSlotEvent(/C_Finalize) as written in PCKS#11 v2.20, canceling pending blocking calls.
  - implement a "virtual hotplug slot" with a floating slot id to keep NSS working with C_WaitForSlotEvent with a new reader.
    NSS does not call C_GetSlotList(NULL) to re-fetch the list of available slots if C_WaitForSlotEvent returns an event in an already known slot ID.
    By changing the ID of a slot whenever a reader attached  NSS/Firefox can be tricked into recognizing new readers when waiting for events with C_WaitForSlotEvent.
  - change (possibly break something) sc_to_cryptoki_error() to not have side-effects
  - Implement CKU_CONTEXT_SPECIFIC in C_Login to implement CKA_ALWAYS_AUTHENTICATE (keys with user consent) 
 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3935 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 20:45:02 +00:00
martin 0595eb7d1e tests: remove slots and sc_disconnect_card API as in r3931
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3934 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 15:40:02 +00:00
martin 5a0cc50123 tools: remove slots; implement change in sc_disconnect_card(); convert util_connect_card()/--wait to support the changes in r3931
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3933 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 15:29:47 +00:00
martin e191142d04 pkcs15init: remove slots, according to r3931
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3932 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 15:26:14 +00:00
martin d006b1845e libopensc:
- Remove slot abstraction from internal API and all reader drivers. CT-API (from where it all comes from) readers with multiple slots (if still found) can be presented as separate readers, OpenCT should remove the slot abstraction, PC/SC never knew about it. None of the tools knew how to use slots.
 - Add sc_cancel (translates to SCardCancel)
 - Re-implement sc_wait_for_event; support a blocking call.
 - Replace the "int reader" API with "* sc_reader_t" style; add "Get reader by name" functionality.
 - Remove "action" parameter from sc_disconnect_card() (was not used)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3931 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 15:25:08 +00:00
martin 0c7d6587be Use a constant buffer instead of malloc.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3930 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 15:14:55 +00:00
martin 101df10ae5 Add simclist, also used by pcsc-lite, for list operations.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3929 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 15:05:14 +00:00
martin cbfa2dd939 Missing piece from r3912
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3928 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 12:50:37 +00:00
martin cd9e666926 SC_ERROR_MEMORY_FAILURE signals EEPROM failures on card. Failures to allocate memory on host result in SC_ERROR_OUT_OF_MEMORY.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3927 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 12:38:34 +00:00
martin 612d66655d Introduce SC_ERROR_NOT_ENOUGH_MEMORY <=> CKR_DEVICE_MEMORY.
When trying to import a too large keyfile as a data object, TrueCrypt received a CKR_GENERAL_ERROR before this.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3926 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-23 19:12:52 +00:00
martin f48ec9528e OpenSSL 1.0.0-beta series crash when assembler implementations underflow with 0 byte length call to OPENSSL_cleanse() and overwrite memory.
Avoid it by nut trying to eraze zero memory.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3925 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-23 06:28:35 +00:00
martin 561507769a tools: cardos-tool uses OpenSSL, link against it.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3924 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-22 12:11:41 +00:00
s f2bc83b138 fix:
CK_MECHANISM rsa_mech = { CKM_RSA_PKCS_KEY_PAIR_GEN, NULL, 0 };
C_GenerateKeyPair(..., &rsa_mech, ..., ..., ..., ..., ..., ...); -> ... -> sc_pkcs15init_store_public_key -> sc_pkcs15init_store_data -> select_object_path -> sc_pkcs15_get_objects: return 0 -> CKR_OK
($ pkcs15-tool --list-public-keys:
Public RSA Key [Public Key]
        ...
        Path        : 3f0050000200
)

CK_MECHANISM gost_mech = { CKM_GOSTR3410_KEY_PAIR_GEN, NULL, 0 };
C_GenerateKeyPair(..., &gost_mech, ..., ..., ..., ..., ..., ...); -> ... -> sc_pkcs15init_store_public_key -> sc_pkcs15init_store_data -> select_object_path -> sc_pkcs15_get_objects: return 0 -> CKR_OK
($ pkcs15-tool --list-public-keys:
Public RSA Key [Public Key]
        ...
        Path        : 3f0050000200

Public GOSTR3410 Key [Public Key]
        ...
        Path        : 3f0050000200
)



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3923 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-22 12:01:17 +00:00
martin 7d935df1bc Fix #193: cryptoflex driver did not set minimum PIN length.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3922 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-21 19:58:49 +00:00
s a6dd95cd03 update on NEWS
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3921 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-21 10:58:10 +00:00
viktor.tarasov 39a70345b9 pkcs15init profile: 'private key' as BSO is differenciated from the one as EF
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3920 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-21 10:07:40 +00:00
viktor.tarasov 6fc954cbc6 pkcs15init: new profile type BSO
at the profile level the difference between EF and BSO is:
- BSO path is always the path of the host DF and do not indexated when template is instanciated;
- EF path is always ending with file-id that is always indexated  when template is instanciated.

New non-static 'sc_profile_get_file_instance' procedure to instanciate non-template entries.
In profile.c get_uint() accepts hexadecimals.
In CardOS profile (I venture to) increase the xDF sizes 
	and change ACL to permit the key re-importing.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3919 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-21 09:41:40 +00:00