Commit Graph

3335 Commits

Author SHA1 Message Date
s 2885691a10 fix potential memory leak
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3800 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-01 14:11:41 +00:00
s f8c6e28bac fix memory leak and read after free
Example code:
int main()
{
	...
	r = C_Initialize(NULL);
	assert(r == CKR_OK);
	r = C_GetSlotList(CK_TRUE, NULL_PTR, &slot_cnt);
	assert(r == CKR_OK);
	assert(slot_cnt >= 1);
	r = C_GetSlotList(TRUE, &slot, &slot_cnt);
	assert(r == CKR_OK);
	r = C_OpenSession(slot, CKF_SERIAL_SESSION | CKF_RW_SESSION, 0, 0, &hndl_session);
	assert(r == CKR_OK);
	assert(hndl_session != CK_INVALID_HANDLE);
	r = C_Login(hndl_session, CKU_USER, pin, sizeof(pin));
	assert(r == CKR_OK);
	r = C_CreateObject(hndl_session, data_tmpl,
			sizeof(data_tmpl)/sizeof(data_tmpl[0]), &hndl);
	assert(r == CKR_OK);
	r = C_DestroyObject(hndl_session, hndl);
	assert(r == CKR_OK);

	r = C_GenerateKeyPair(hndl_session, &rsa_genkp_mech, rsa_pbkey_tmpl,
			sizeof(rsa_pbkey_tmpl)/sizeof(rsa_pbkey_tmpl[0]), rsa_prkey_tmpl,
			sizeof(rsa_prkey_tmpl)/sizeof(rsa_prkey_tmpl[0]),
			&hndl_pb, &hndl_pr);
	assert(r == CKR_OK);

	r = C_Finalize(NULL);
	assert(r == CKR_OK);
	return 0;
}

==20626== Invalid read of size 4
==20626==    at 0x41036B: pkcs15_add_object (framework-pkcs15.c:679)
==20626==    by 0x410B27: pkcs15_gen_keypair (framework-pkcs15.c:1761)
==20626==    by 0x40980D: C_GenerateKeyPair (pkcs11-object.c:869)
==20626==    by 0x4078CD: main (pkcs11_1.c:71)
==20626==  Address 0x632d3e0 is 0 bytes inside a block of size 584 free'd
==20626==    at 0x4C24A28: free (vg_replace_malloc.c:325)
==20626==    by 0x4E5452B: sc_pkcs15init_delete_object (pkcs15-lib.c:2903)
==20626==    by 0x41243B: pkcs15_dobj_destroy (framework-pkcs15.c:2721)
==20626==    by 0x40AD91: C_DestroyObject (pkcs11-object.c:96)
==20626==    by 0x407871: main (pkcs11_1.c:68)
==20626== 
==20626== 80 bytes in 1 blocks are definitely lost in loss record 76 of 148
==20626==    at 0x4C24137: calloc (vg_replace_malloc.c:418)
==20626==    by 0x40E383: __pkcs15_create_object (framework-pkcs15.c:250)
==20626==    by 0x40E45C: __pkcs15_create_data_object (framework-pkcs15.c:439)
==20626==    by 0x41164C: pkcs15_create_data (framework-pkcs15.c:1441)
==20626==    by 0x411760: pkcs15_create_object (framework-pkcs15.c:1490)
==20626==    by 0x409A35: C_CreateObject (pkcs11-object.c:53)
==20626==    by 0x40783A: main (pkcs11_1.c:65)
==20626== 
==20626== LEAK SUMMARY:
==20626==    definitely lost: 80 bytes in 1 blocks



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3799 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-01 13:55:52 +00:00
s 3a5db68158 fix memory leak
Example code:
int main() {
	...
	C_Initialize(NULL);
        C_Finalize(NULL);
	return 0;
}

==3312== 176 bytes in 1 blocks are definitely lost in loss record 109 of 146
==3312==    at 0x4C24137: calloc (vg_replace_malloc.c:418)
==3312==    by 0x4117B8: pkcs15_init_slot (framework-pkcs15.c:716)
==3312==    by 0x41307F: pkcs15_create_slot (framework-pkcs15.c:761)
==3312==    by 0x413263: pkcs15_create_tokens (framework-pkcs15.c:849)
==3312==    by 0x40BB9B: card_detect (slot.c:149)
==3312==    by 0x40BCF9: __card_detect_all (slot.c:167)
==3312==    by 0x4083F7: C_Initialize (pkcs11-global.c:229)
==3312==    by 0x4076BD: main (pkcs11_1.c:27)
==3312==
==3312== 528 bytes in 1 blocks are definitely lost in loss record 139 of 146
==3312==    at 0x4C24137: calloc (vg_replace_malloc.c:418)
==3312==    by 0x41365B: pkcs15_bind (framework-pkcs15.c:167)
==3312==    by 0x40BB43: card_detect (slot.c:139)
==3312==    by 0x40BCF9: __card_detect_all (slot.c:167)
==3312==    by 0x4083F7: C_Initialize (pkcs11-global.c:229)
==3312==    by 0x4076BD: main (pkcs11_1.c:27)
==3312==
==3312== LEAK SUMMARY:
==3312==    definitely lost: 704 bytes in 2 blocks


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3798 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-01 13:50:45 +00:00
s 83b7a9788d trunk is now post release
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3797 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-01 13:45:56 +00:00
aj a8d8262d6d we created a -rc2 for openssl 1.0.0 support too.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3794 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-24 06:38:06 +00:00
s 1ecd64ed93 fix: compile with openssl-1.0 beta3
http://www.opensc-project.org/pipermail/opensc-devel/2009-October/012702.html
Thanks to Kalev Lember


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3791 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-23 18:16:59 +00:00
aj 425c0ccb69 Prepare release candidate.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3789 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-23 13:09:48 +00:00
aj 12213dee5c Improved myeid driver (by Aventra)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3788 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-23 13:08:32 +00:00
ludovic.rousseau 6cd345d316 Default PCSC provider is libpcsclite.so.1 instead of libpcsclite.so
See Debian bug #511344


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3787 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-23 12:12:40 +00:00
aj 5926c08c91 Cleanup westcos driver to remove warnings - by François Leblanc.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3786 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-22 18:28:25 +00:00
aj 268755c4d6 latest changes.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3783 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-21 09:23:26 +00:00
aj 8746d02329 rewrite code to support openssl 0.9.7 so rsa variable is properly set.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3782 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-21 09:08:22 +00:00
aj e2848c7094 Make opensc / westcos driver compile with openssl 0.9.7:
It tests the version of openssl and uses the old RSA_gererate_key
if older the 0.9.8. By Douglas E. Engert.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3781 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-21 07:27:19 +00:00
aj 59c9a8eae0 remove the variable not initialized error for "tag",
and to fix another error when loading a 3des key when
the string passed to sc_hex_to_bin is not terminated.
By Douglas E. Engert


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3780 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-21 07:24:58 +00:00
aj b2df781e8d Fix warnings in muscle code - by João Poupino.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3779 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-21 07:22:56 +00:00
aj 2446c46459 next release could be 0.11.11, trunk is "-svn" preview.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3778 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-20 12:27:26 +00:00
aj 03bc256594 Create new release 0.11.10
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3776 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-20 12:25:16 +00:00
s 7fa19788e2 fix misprint
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3775 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-13 14:20:03 +00:00
martin 02ea9d7388 Fix windows/nmake build
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3772 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-09 13:03:23 +00:00
s 82ab3bfc22 rollback: "fix pkcs11 access with multiple PINs"
http://www.opensc-project.org/pipermail/opensc-devel/2009-October/012607.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3771 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-09 05:46:20 +00:00
s b7845debb0 framework-pkcs15.c:683: warning: comparison of distinct pointer types lacks a cast
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3770 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-06 13:46:41 +00:00
s d9c52b85a4 fix OpenSC PKCS#11 object grouping
Thanks to Pierre Ossman

http://www.opensc-project.org/pipermail/opensc-devel/2009-October/012553.html
http://www.opensc-project.org/pipermail/opensc-devel/2009-October/012580.html
http://www.opensc-project.org/pipermail/opensc-devel/2009-October/012582.html



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3769 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-06 13:32:27 +00:00
s c36bd197e3 fix: key id for automatic selection of the predefined directory (for rutoken-tool)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3768 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-06 11:17:41 +00:00
s dd045ff638 remove dead code
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3767 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-06 10:59:00 +00:00
s 616c7fea75 correct options "small" and "default" in rutoken.profile
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3766 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-06 08:22:47 +00:00
aj ff9951d94d kill lots of warnings (unused variables, unsigned/signed comparison etc.)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3765 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-06 07:36:51 +00:00
aj 80f16d4f4e remove gemsafeV2 code - not working properly, not maintained.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3764 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-06 07:25:35 +00:00
aj 1719567840 Add more NEWS entries.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3763 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-06 06:40:18 +00:00
aj b7de6380e8 westcos: use generic select_file function (Aleksey Samsonov).
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3762 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-06 06:36:21 +00:00
aj 46b55bb870 Allow building westcos without openssl. (François Leblanc)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3761 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-06 06:34:05 +00:00
aj 8402c6248a New GemsafeV2 Emulation code by Georges Bart
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3760 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-06 06:32:26 +00:00
s 97a8f73b9c add GOST R 34.10-2001 algorithm (only PKCS#11) by Aktiv Co.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3757 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-05 18:40:51 +00:00
ludovic.rousseau 45e12e6ff5 Move the declaration of sbuff[] to avoid a compiler warning
card-entersafe.c: In function ‘entersafe_write_rsa_key_factor’:
card-entersafe.c:1131: warning: declaration of ‘sbuff’ shadows a previous local
card-entersafe.c:1126: warning: shadowed declaration is here 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3749 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-02 10:56:58 +00:00
ludovic.rousseau bceeb38977 comment out 2 unused static functions
card-entersafe.c:1591: warning: ‘entersafe_card_ctl_1024’ defined but not used
card-entersafe.c:1378: warning: ‘entersafe_preinstall_rsa_1024’ defined but not used 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3748 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-02 10:54:38 +00:00
ludovic.rousseau 2e1b4dbade remove unused variables
card-entersafe.c: In function ‘entersafe_cipher_apdu’:
card-entersafe.c:172: warning: unused variable ‘r’
card-entersafe.c:172: warning: unused variable ‘i’

card-entersafe.c: In function ‘entersafe_process_fci’:
card-entersafe.c:434: warning: unused variable ‘len’
card-entersafe.c:434: warning: unused variable ‘taglen’
card-entersafe.c:433: warning: unused variable ‘p’
card-entersafe.c:433: warning: unused variable ‘tag’

card-entersafe.c: In function ‘entersafe_create_file’:
card-entersafe.c:775: warning: unused variable ‘r’


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3747 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-02 10:52:32 +00:00
ludovic.rousseau d2d59cf3eb card-entersafe.c:226: warning: ‘tmp_rounded’ may be used uninitialized in this function
card-entersafe.c:226: note: ‘tmp_rounded’ was declared here


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3746 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-02 10:49:28 +00:00
ludovic.rousseau 10547c9c8d card-entersafe.c:496: warning: ‘r’ may be used uninitialized in this function
card-entersafe.c:496: note: ‘r’ was declared here 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3745 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-02 10:48:20 +00:00
ludovic.rousseau 8874c50e86 remove spaces at end of line
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3743 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-21 11:59:17 +00:00
ludovic.rousseau 4439f4d3a2 fix pkcs11 access with multiple PINs
Thanks to Roman Himmes for the patch
http://www.opensc-project.org/pipermail/opensc-devel/2009-September/012426.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3741 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-18 11:54:52 +00:00
aj 2763c08d09 Add myeid driver by Aventra.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3740 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-17 07:50:28 +00:00
martin 2a6c41be27 Fix "serial->len is used uninitialized", By Aleksey Samsonov
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3739 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-16 11:29:54 +00:00
aj 3dbc0a7143 More Westcos cleanups by Aleksey Samsonov
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3719 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-12 07:04:48 +00:00
aj e31d2ff966 New westcos driver by François Leblanc.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3718 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-11 09:48:51 +00:00
aj 886fa8931f trunk is now post release.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3716 c6295689-39f2-0310-b995-f0e70906c6a9
2009-07-29 07:03:59 +00:00
aj a495162259 Prepare for new release
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3714 c6295689-39f2-0310-b995-f0e70906c6a9
2009-07-29 07:02:37 +00:00
aj 5f185e3079 Weitao Sun: no one can create more than 15 files
under 5015 df. I increase it from 15 to 48, and all are OK.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3713 c6295689-39f2-0310-b995-f0e70906c6a9
2009-07-23 08:56:41 +00:00
aj 61b8f0a35d Latest version from scute svn with this change:
Stef Walter: Make all constants UL that should be.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3712 c6295689-39f2-0310-b995-f0e70906c6a9
2009-07-23 08:30:43 +00:00
aj 0c2fe83c3b Aktiv Co./Aleksey Samsonov:
fix a bug in rutoken driver.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3711 c6295689-39f2-0310-b995-f0e70906c6a9
2009-07-22 12:24:33 +00:00
aj 16f045bf0c Douglas E. Engert: major update for the PIV smartcard.
The major issue is with getting the length of an object or the cert
contained in an object. The PIV card does not have a directory on the card,
So the previous version tried to put off as long as possible the reading
of objects for performance so as to avoid having to read objects that would
not be used. The first standard, NIST 800-73, set maximum sizes for objects.
800-73-2 removed this for certificates.

A certificate object can contain a certificate which might be compressed.
The only way to get the length of the compressed certificate is to decompress
it. Thus the decompressed certificate could be larger then the container object,
so even if the PIV card had a directory, one would still need to decompress
the certificate to find its length.

OpenSC sc_read_binary will use the length obtained by using
sc_select_file(...,&file_out), and thus the lengths must be determined
in sc_select_file.

Change are to card-piv.c and pkcs15-piv.c and include:
  * The old cache code which was not working was removed.
  * New cache code was added which caches all object read from the card
  * If an object has a cert, the cert is decompressed and also cached.
  * As part of reading an object the first 8 bytes are read
    and this is then used to allocate a large buffer to read in the
    object.
  * If pkcs15 or pkcs11 asks about a certificate, the cert object
    will be read, and the cert decompressed, to get the actual length.
  * If piv_select_file is called with the file_out != NULL the object
    will be read to get the length If called with NULL it will not be read.
  * The enumeration of the objects now starts with 0.
  * sc_ctx_suppress_errors_on and off are used to avoid file not found
    messages which are are a by product of not having a directory.
  * "Unsigned Card Holder Unique Identifier" object in card-piv and pkcs15-piv.c
     had conflicting paths, as NIST 800-72-1 had two tables with different
     paths. The enumtag for it in card-piv.c was also wrong.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3710 c6295689-39f2-0310-b995-f0e70906c6a9
2009-07-22 10:09:21 +00:00
aj d9cd831b4f Douglas E. Engert: The pkcs15-gemsafeV1.c does not detect of the
card present is in fact a gemsafeV1 card, and thus it can end up
issuing commands to the wrong cards.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3709 c6295689-39f2-0310-b995-f0e70906c6a9
2009-07-22 10:06:32 +00:00