Commit Graph

76 Commits

Author SHA1 Message Date
viktor.tarasov 58c1c88efa libopensc: homogenise line ending in the debug messages
continuating r4759


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4774 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-25 20:35:59 +00:00
ludovic.rousseau f47416d60e Do not cast the return value of malloc(3) and calloc(3)
From http://en.wikipedia.org/wiki/Malloc#Casting_and_type_safety
" Casting and type safety

malloc returns a void pointer (void *), which indicates that it is a
pointer to a region of unknown data type. One may "cast" (see type
conversion) this pointer to a specific type, as in

int *ptr = (int*)malloc(10 * sizeof (int));

When using C, this is considered bad practice; it is redundant under the
C standard. Moreover, putting in a cast may mask failure to include the
header stdlib.h, in which the prototype for malloc is found. In the
absence of a prototype for malloc, the C compiler will assume that
malloc returns an int, and will issue a warning in a context such as the
above, provided the error is not masked by a cast. On certain
architectures and data models (such as LP64 on 64 bit systems, where
long and pointers are 64 bit and int is 32 bit), this error can actually
result in undefined behavior, as the implicitly declared malloc returns
a 32 bit value whereas the actually defined function returns a 64 bit
value. Depending on calling conventions and memory layout, this may
result in stack smashing.

The returned pointer need not be explicitly cast to a more specific
pointer type, since ANSI C defines an implicit conversion between the
void pointer type and other pointers to objects. An explicit cast of
malloc's return value is sometimes performed because malloc originally
returned a char *, but this cast is unnecessary in standard C
code.[4][5] Omitting the cast, however, creates an incompatibility with
C++, which does require it.

The lack of a specific pointer type returned from malloc is type-unsafe
behaviour: malloc allocates based on byte count but not on type. This
distinguishes it from the C++ new operator that returns a pointer whose
type relies on the operand. (see C Type Safety). "

See also
http://www.opensc-project.org/pipermail/opensc-devel/2010-August/014586.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4636 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-18 15:08:51 +00:00
viktor.tarasov bd5c186767 pkcs15/pkcs11: encoding of certificate's attribute 'serialNumber'
Applying patch of Andre Zepezauer. Thanks.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4451 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-21 10:49:58 +00:00
viktor.tarasov fec213ad2e pkcs11: DER encoded value for CKA_SERIAL_NUMBER
discussed in http://www.opensc-project.org/pipermail/opensc-devel/2010-May/014264.html



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4375 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-25 08:06:28 +00:00
aj 6545b42c02 cleanup of the debug code:
* reduce to a few, supported functions.
* change all functions to take the debug level as parameter.
* use symbolic names for the debug levels.
* fix tools to pass "verbose"/"opt_debug" as ctx->debug.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4118 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-15 12:17:13 +00:00
aj d22a2483c0 Header file cleanup.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4081 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-04 08:14:36 +00:00
martin d672fde449 Remove sc_error and sc_ctx_suppress_errors_* in favor of sc_debug/fprintf
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3721 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-14 08:46:59 +00:00
aj b3ad2f9dd2 convert to utf-8.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3084 c6295689-39f2-0310-b995-f0e70906c6a9
2006-12-19 21:31:17 +00:00
henryk b45617c451 Make absolute paths from all paths read from the PKCS#15 directories by prepending the DF(PKCS#15) path if necessary.
Fixes compatibility with Siemens HiPath SIcurity formatted cards which use relative paths.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3028 c6295689-39f2-0310-b995-f0e70906c6a9
2006-09-26 10:55:02 +00:00
nils e8c05ca648 use more opensc specific names for ASN.1 tags to avoid name conflicts
with other ASN.1 libraries


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2815 c6295689-39f2-0310-b995-f0e70906c6a9
2006-01-20 20:52:36 +00:00
nils 23802d825e properly initialize sc_asn1_entry elements + some cleanup
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2463 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-05 07:24:43 +00:00
sth 41889b27a1 Export function parse_x509_cert()
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2458 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-03 09:07:09 +00:00
bert 2d97002824 API fixup: use defined type instead of struct for exposed structs
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2232 c6295689-39f2-0310-b995-f0e70906c6a9
2005-03-08 20:59:35 +00:00
nils 8673508a43 fix memory leak, cleanup: use object specific release method
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2024 c6295689-39f2-0310-b995-f0e70906c6a9
2004-12-18 14:14:57 +00:00
nils 75b9f0b5de fix (potential) memory leak
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1998 c6295689-39f2-0310-b995-f0e70906c6a9
2004-12-12 17:17:07 +00:00
nils 6281259f04 fix usage of asn1 flags
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1797 c6295689-39f2-0310-b995-f0e70906c6a9
2004-06-18 20:49:54 +00:00
okir ed5d12800d - Read and write CDF entries with directly encoded certificates
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1610 c6295689-39f2-0310-b995-f0e70906c6a9
2003-11-19 20:28:02 +00:00
aet 5616dba08e - Stop using unflexible automake conditionals when
building PC/SC, OpenCT or USBToken support,
  use ifdef's directly in source.
- Because of above, add HAVE_PCSCLITE for winconfig.h
- Remove unnecessary includes for log.h, opensc.h and
  errors.h in libopensc sources, they're already taken
  care by internal.h.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1406 c6295689-39f2-0310-b995-f0e70906c6a9
2003-09-03 09:28:55 +00:00
aet 763fc16704 Rename libopensc specific error/debug to sc_error/sc_debug
We should have done this ages ago.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1392 c6295689-39f2-0310-b995-f0e70906c6a9
2003-08-25 14:21:18 +00:00
sth 55e8c31b12 Fixed: support for X.509 V1 certs
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1094 c6295689-39f2-0310-b995-f0e70906c6a9
2003-05-11 07:22:27 +00:00
okir a5492a32a8 - slightly more verbose error messages when ASN.1 parsing fails
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@871 c6295689-39f2-0310-b995-f0e70906c6a9
2003-01-20 09:56:27 +00:00
okir 3f16e04a8f - sc_pkcs15_read_certificate now uses sc_pkcs15_read_file
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@733 c6295689-39f2-0310-b995-f0e70906c6a9
2002-12-02 13:39:36 +00:00
aet 1d2c9e4c48 Cleanups for initial win32 port, untested.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@696 c6295689-39f2-0310-b995-f0e70906c6a9
2002-10-19 14:04:52 +00:00
jey 4c36cb9641 - Used cert->key instead of key in parse_x509_cert()
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@686 c6295689-39f2-0310-b995-f0e70906c6a9
2002-08-21 10:22:13 +00:00
okir b18d893764 - certificate version is optional (v1)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@673 c6295689-39f2-0310-b995-f0e70906c6a9
2002-08-06 13:51:08 +00:00
fabled 7635468ed9 - Initial support for win32
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@654 c6295689-39f2-0310-b995-f0e70906c6a9
2002-06-14 12:52:56 +00:00
jey 7c94d7d8d3 - Several patches to fix behaviour on 64-bit architectures (by
Jochen Friedrich)
- Fixed one bug in sc_copy_asn1_entry(), one in
  sc_pkcs15init_add_object() and one in pkcs15-crypt
  (patches also by Jochen)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@609 c6295689-39f2-0310-b995-f0e70906c6a9
2002-05-26 12:31:23 +00:00
aet f7fcaee513 Extract certificate crlDistributionPoints and store it in sc_pkcs15_cert
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@580 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-21 18:54:10 +00:00
aet 3dccd63989 - C++ support. Compiles with gcc/g++ for Linux, otherwise
completely untested.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@574 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-19 14:23:31 +00:00
okir 95a7fafe31 - use SC_ASN1_ALGORITHM_ID when decoding x509 certs
- handle certificates with non-RSA keys as well


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@547 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-17 18:32:06 +00:00
okir b63cfcf70d - renamed sc_pkcs15_parse_pubkey_rsa -> sc_pkcs15_decode_pubkey_rsa
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@530 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-17 08:57:29 +00:00
okir 596220e821 - pkcs15-init does not require openssl anymore
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@523 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-15 13:42:10 +00:00
jey 22636c2df9 - Added SC_ERROR_FILE_ALREADY_EXISTS
- Changed call convention for reader finish()
- CT-API driver now frees its resources correctly
- Added year 2002 to some of the copyright statements
- sc_pkcs15_decipher() and sc_pkcs15_compute_signature()
  now select only the parent DF of the private key file


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@463 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-05 14:46:44 +00:00
aet d81d10ba90 Upgrade sources to use new headers, part #1
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@458 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-05 10:44:51 +00:00
aet 1ef47d245b Workaround for a compiler problem (Sun WorkShop 6 update 2 C 5.3 Patch 111679-05 2002/02/07)
Still lots of bogus warnings, but at least everything compiles


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@444 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-04 15:02:08 +00:00
aet 6e3a09fa7b Remove bogus "len = len;" statement from pkcs15-cert
Other minor cleanups


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@368 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-21 23:45:03 +00:00
okir 8f07d6706d - now extracting issuer from certificate
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@346 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-20 13:08:09 +00:00
jey 3fa7a056f1 - Fixed a couple of memory leaks
- Fixed a bug in decoding EF(TokenInfo)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@344 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-19 10:04:11 +00:00
okir 7d6cf8fa81 - extract certificate issuer and store it in sc_pkcs15_cert
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@338 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-15 15:19:34 +00:00
jey 67ffdfa213 - Added support for big serial numbers in certificates
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@332 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-15 10:10:33 +00:00
okir c94fb9a1d5 - added sc_pkcs15_read_pubkey to retrieve public key from a public key file
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@281 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-08 19:47:26 +00:00
jey 6b07ff64f6 - Reworked PKCS #15 structure a bit (MANY THINGS
WILL BREAK)
- Added support for public key DFs (not tested yet)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@251 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-03 00:32:28 +00:00
jey 61fc1f9327 - all instances struct sc_file should now be
dynamically allocated with sc_file_new() and released
  with sc_file_free()
- improved ACL's
- moved struct sc_card_error to opensc.h
- moved EF(DIR) parsing and encoding to dir.c
  (encoding is not working yet)
- removed hst-test.c and filetest.c


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@213 c6295689-39f2-0310-b995-f0e70906c6a9
2002-02-20 09:56:47 +00:00
jey c1cac5f311 - bumped up version number in preparation of the new release
- unified PKCS #15 DF decoding
- added PKCS #15 file caching


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@191 c6295689-39f2-0310-b995-f0e70906c6a9
2002-01-24 16:02:54 +00:00
jey e7c65bf669 - PKCS #15 generation is now in a semi-working state
- started coding crypto support for Cryptoflexes


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@175 c6295689-39f2-0310-b995-f0e70906c6a9
2002-01-17 23:47:03 +00:00
jey 54e5d23e93 - improved PKCS #15 generation
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@170 c6295689-39f2-0310-b995-f0e70906c6a9
2002-01-17 11:44:27 +00:00
jey 20adb4b39c - continued to improve PKCS #15 generation
- fixed a few problems in sc_set_security_env
- started to implement Better (tm) object handling for
  PKCS #15 objects


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@167 c6295689-39f2-0310-b995-f0e70906c6a9
2002-01-16 23:59:18 +00:00
jey 452b9d4193 - pretty much finished the DER encoder
- added delete and create file support for 'flex cards
- PKCS #15 DF's are now stored more flexibly; this makes
  adding new types of DF's (such as PuKDF's) easier
- added 'get' and 'put' commands to opensc-explorer


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@160 c6295689-39f2-0310-b995-f0e70906c6a9
2002-01-13 23:56:13 +00:00
aet b75b88a8b8 Fix compiler warnings
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@157 c6295689-39f2-0310-b995-f0e70906c6a9
2002-01-10 13:49:54 +00:00
jey 9dc7054919 - added preliminary ASN.1 encoding support
- modified ASN.1 decoding to make it easier to
  port decoder structures to the encoder
- fixed a recently introduced bug in card driver handling
- opensc-explorer will now allow only DF's to be cd'd into


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@156 c6295689-39f2-0310-b995-f0e70906c6a9
2002-01-10 12:33:56 +00:00