Commit Graph

46 Commits

Author SHA1 Message Date
vtarasov 971d643a0a libopensc: encode/decode 'direct' public key value
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5024 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-02 14:25:48 +00:00
andre 1b030f5d73 pkcs11-pubkey.c: Minor corrections related to r4874 and r4902.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4946 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-14 01:19:46 +00:00
vtarasov 2aa034d467 libopensc: avoid warning 'not all control paths return a value'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4933 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-09 09:17:08 +00:00
dengert c34caeb662 Support for ECC keys (part 1) header files and
support routines. Add definitions for EC keys,
parameters and extensions to structures. 
Add the sc_card_find_ec_alg, sc_pkcs15_decode_pubkey_ec,
sc_pkcs15_encode_pubkey_ec, sc_pkcs15emu_add_ec_prkey,
sc_pkcs15emu_add_ec_pubkey routines. 
Only EC named curves are currently supported. 



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4902 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-30 19:13:48 +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 bd93b97674 Additianl changes to r4805 which made cert->pubkey a pointer to sc_pkcs15_pubkey_t
Thanks to Andre Zepezauer for pointing out most of these. 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4828 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-25 20:58:02 +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
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 b78d7630e7 pkcs15: encode/decode 'subjectName' in 'CommonPrivateKeyAttributes'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4512 c6295689-39f2-0310-b995-f0e70906c6a9
2010-07-05 13:29:10 +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
aj f0484968a9 merge changes 0.11.11 -> 0.11.12
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3899 c6295689-39f2-0310-b995-f0e70906c6a9
2009-12-18 13:33:03 +00:00
s 5320ca6fd1 Corrected GOSTR3410 public key structure
Working now with GOST R 34.10:
$ pkcs15-init --store-private-key key --key-usage sign,decrypt --auth-id 2 --id 1 --pin "12345678"
$ pkcs15-init --store-certificate my_cert --id 1 --pin "12345678"

But have problem: no CKA_GOSTR3410_PARAMS by retrieve pub_key from certificate, if pub_key object was removed (see parse_x509_cert, asn1_decode_gostr3410_params)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3859 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-19 15:41:03 +00:00
martin 3ea5bb7987 Merge [3804:3822/trunk]
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3824 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-13 09:45:21 +00:00
martin ea37069272 Merged r3749:3758 from trunk
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3759 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-05 20:10:07 +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 a577a25813 silence a warning we get with siemens cards.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3226 c6295689-39f2-0310-b995-f0e70906c6a9
2007-07-20 13:47:17 +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 6abeaf1f1c add a new function
void sc_mem_clear(void *ptr, size_t len);
to clear a memory buffer. If OpenSSL is used this function
is a wrapper for OPENSSL_cleanse, otherwise memset is currenlty used.

Use this function to clear memory buffers with sensitive content.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2601 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-17 10:44:45 +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
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 bd02c1a6be add data field for subject Common{Private|Public}KeyAttributes
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2046 c6295689-39f2-0310-b995-f0e70906c6a9
2004-12-27 13:22:06 +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 71441cd6a5 fix memory leak
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2003 c6295689-39f2-0310-b995-f0e70906c6a9
2004-12-12 21:51:51 +00:00
okir a2c9afec7f - fixed problem with pubkey encoding/decoding
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1643 c6295689-39f2-0310-b995-f0e70906c6a9
2003-11-26 15:37:29 +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
okir 98907b68f1 - fixed endianness problem with encoding/deconding of bit fields
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1034 c6295689-39f2-0310-b995-f0e70906c6a9
2003-04-16 20:52:26 +00:00
okir 542e12deb3 - pubkey asn.1 encoding fix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@893 c6295689-39f2-0310-b995-f0e70906c6a9
2003-02-03 12:17:12 +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
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 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
jey 546f920fc1 - PKCS #15 objects and DFs are now stored with linked lists
in struct sc_pkcs15_card; this way we can have 'floating'
  objects that don't belong in any DF, for e.g. generating
  public key objects from certificates
- Removed some unused function prototypes


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@572 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-19 09:22:44 +00:00
jey b4af9ab16e - Added a missing SC_ASN1_CTX flag to DSA key ASN.1 entries
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@570 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-18 14:59:12 +00:00
okir c9aba0d1ca - fixed bug with DSA pubkey de/encoding
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@565 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-18 10:58:48 +00:00
okir 6d8fe463a4 - properly encode/decode DSA public keys
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@559 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-18 09:10:54 +00:00
okir fcbbb6c3e5 - eliminated RSA specific code to support generic pubkeys instead
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@548 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-17 18:33:27 +00:00
okir 996f5b7f2e - renamed sc_pkcs15_parse_pubkey_rsa -> sc_pkcs15_decode_pubkey_rsa
- added sc_pkcs15_decode_pubkey_dsa
- sc_pkcs15_read_pubkey now uses sc_pkcs15_read_file


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@532 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-17 08:59:52 +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
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
okir 41cd4c4d2c - implemented sc_pkcs15_free_pubkey
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@330 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-15 10:01:25 +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
okir 9f43b3b0f3 - small typo
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@259 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-05 09:30:01 +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