Commit Graph

86 Commits

Author SHA1 Message Date
German Blanco 4a674b4dfc Improving logging of certificate handling. 2013-05-07 09:43:47 +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
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 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 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
andre a9eba2b205 libopensc: Remove unused parameter 'file_out' in function 'sc_pkcs15_read_file'.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5546 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 11:08:36 +00:00
vtarasov e7790508f6 pkcs15: when setting object data's path, use, if available, the AID from 'DiscretionaryDataObject'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5111 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-18 16:31:41 +00:00
martin acb54b965f typo: remove double semicolon which prevents compilation with Visual Studio.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4888 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-29 08:51:25 +00:00
dengert d1aa716bec Move decoding of subjectPubkeyInfo from pkcs15-cert.c
to pkcs15-pubkey.c and call the new sc_pkcs15_pubkey_from_spki.
Add sc_pkcs15_pubkey_from_spki_filename to allow a file to 
contain the subjectPubkeyInfo, which will be used the the PIV 
driver when EC is implemented. The format of the file, is the
same as an X509 certificate subjectPublicKeyInfo and what 
OpenSSL calls an EVP_PKEY, which includes the algorithm,
any parameters and the public key. 
 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4874 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-08 17:05:40 +00:00
dengert 0f2a44b33e sc_pkcs15_pubkey_from_cert now uses parse_x509_cert without OpenSSL.
sc_pkcs15_cert now has pointer to sc_pkcs15_pubkey, allowing it to 
be removed and used separatly.  
sc_pkcs15_pubkey now has pointer to sc_algorithm_id to faclitate
addition of other key algorithms and their parameters. 
Various code changes to free these structures and references
to the structures have been changed. 



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4805 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-12 15:26:45 +00:00
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