Commit Graph

74 Commits

Author SHA1 Message Date
Frank Morgner a899a46b09 replaced SC_TEST_RET with LOG_TEST_RET 2018-12-06 09:26:42 +01:00
Frank Morgner 24b50a4277 replace sc_debug with sc_log 2018-12-06 09:26:42 +01:00
Frank Morgner cf55cdc637 replace SC_FUNC_CALLED with LOG_FUNC_CALLED 2018-12-06 09:26:42 +01:00
Jakub Jelen e2fe24d56a clang static analyzer reports
tools/pkcs15-tool.c:
	Dead assignment: Value stored to 'c' is never read
tools/pkcs11-tool.c:
	Dead assignment: Value stored to 'n' is never read
	Dead assignment: Value stored to 'rv' is never read
libopensc/card-cac.c:
	Dead assignemnt: Value stored to 'tl_head_len' is never read
	Dead increment: Value stored to 'outp' is never read
common/libpkcs11.c:
	Memory leak in case of C_UnloadModule() fails
libopensc/pkcs15-pubkey.c:
	Potential memory leaks
pkcs11/mechanism.c:
	Potential memory leak
pkcs11/framework-pkcs15.c:
	Potential memory leaks
	Dereference of null pointer
	Dead assignments
tools/sc-hsm-tool.c:
	Function call argument is an uninitialized value
	Dead assignment: Value stored to 'r' is never read
libopensc/card-openpgp.c:
	Dead assignment: ignoring the errors in case of sc_pkcs15_encode_pubkey() failed
libopensc/pkcs15-cac.c:
	Dead assignments: ignoring return values
libopensc/pkcs15-coolkey.c:
	Dead assignments: ignoring return values
libopensc/card-sc-hsm.c:
	Dereference of undefined pointer value: Properly check the file allocation
pkcs11/slot.c:
	Dead assignment
pkcs15init/pkcs15-cflex.c:
	Dereference of null pointer
	Uninitialized argument values
2017-07-18 22:40:20 +02:00
Maciej S. Szmigiero 62cbda6cd9 Fix log messages format and parameter issues flagged by GCC
Since "Add GCC format checking attributes to log functions" commit GCC
warns us about problems with format strings and their arguments provided
to OpenSC message logging functions.

This commit fixes all cases where GCC warned about incorrect format on
64-bit Linux, 32-bit and 64-bit mingw builds (with SM and OpenSSL enabled).
Well, almost all since on mingw GCC does not recognize "ll" size specifier
(present at least since Visual Studio 2005, also in mingw own CRT) so these
(few) warnings about it remain.

In most cases format size specifier for size_t type was missing (usually
size was left at default int level, with is different on 64-bit x86).
Some formats had too few / too many arguments.
In some cases pointers were printed as integers.
Some long variables were missing "l" prefix (especially with regard to %x
format).

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2017-03-27 11:05:16 +02:00
Michał Trojnara 645780e6d4 NULL parameter check moved to sc_file_free()
This fixes numerous issues where the check is *not* performed,
and also simplifies the code.
2017-01-10 12:46:44 +01:00
Frank Morgner d4fd135e20 pkcs15-cflex: fixed resource leak 2015-05-08 09:11:19 +02:00
Viktor Tarasov e57d443e86 pkcd15init: remove trailing whitespaces
inspired by
http://www.opensc-project.org/pipermail/opensc-devel/2012-March/017883.html

Change-Id: I817f903e67965942d9cc0c30931dbaea0c5f736e
2012-04-02 23:40:05 +02:00
vtarasov d888b3fd55 pkcs15: use general 'AuthenticationObject' instead of 'PinObject'
now the attributes of the previous 'pin-info' data type are included
as the sub-type attributes of the general 'auth-info' data .
It will allow to include support of the 'biometricTemplate' and 'authKey' authentication types.

http://www.opensc-project.org/pipermail/opensc-devel/2011-May/016655.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5550 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 15:46:25 +00:00
ludovic.rousseau 18c144603a Remove dead code
pkcs15-cflex.c:747:3: warning: Value stored to 'key' is never read
        *key++ = 0;
         ^~~~~


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5143 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-05 20:42:50 +00:00
vtarasov 891f98363b pkcs15init: new 'emulation-store-data' operation ...
the first usage is to update the public key PKCS#15 object attributes 
and to encode it's direct value.
(support of the Oberthur's AuthentIC V3.2 card)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5001 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-30 12:50:35 +00:00
andre 5c6afb6bed Add missing initializers. Left over from r4508.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4952 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-16 01:47:03 +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 83ca335da7 cflex pkcs15init: use temporary PINs that satisfy default pin policy
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4257 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-19 12:10:56 +00:00
ludovic.rousseau ecae106253 Fix warning: missing initializer
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4156 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-28 11:37:13 +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
viktor.tarasov 052881c38f libopensc: in pkcs15 PIN commands 'pin_info' parameter replaced by 'pin_object'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4103 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-10 09:23:01 +00:00
viktor.tarasov 0e8e1a1bf0 pkcs15init cflex: fix protected initialisation
In the 'flex' card profile the ACLs of the public objects are set to 'NONE'.

As the pkcs15init core currently implemented, the AuthID attribute is not used for the public objects. 
Without AuthID the destination 'pin-domain' DF cannot be determined in a simple and sure manner.
That's why 'pin-domain' works only for private key, private data
and the public objects are placed into the application DF. 


; take 'flex' CHV files settings from the card profile;






git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4085 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-04 13:37:11 +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
viktor.tarasov 535131adda pkcs15init: instead of static keycache use the pincache as a content of the pkcs15 AUTH object
Tested with cards:
CardOS v4.3B;
SetCOS 4.4.1B;
Oberthur;
Cryptoflex 16k, 32k e-gate, 32k e-gate token;
GPK 8K;
Athena;
Aventra;
Fetian;
Rainbow 3000 (STARCOS SPK 2.3)




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4058 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-21 18:24:41 +00:00
viktor.tarasov 4dd6abf41b pkcs15init: in the prototypes of the internal procedures the 'struct sc_card' argument replaced with the 'struct sc_pkcs15_card' one
This patch is not largely tested and it will be followed (hope in a few hours) with another one 
that will replace the using of the static pincache 
with the pincache as the content of the AUTH pkcs15 object.

In the intervention into the card specific part I tried to respect its creator's coding style.
Sorry, if it's not always the case.




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4057 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-21 16:21:57 +00:00
viktor.tarasov b065c70695 pkcs15init: abandon Old API
tested with Oberthur, CardOS and SetCOS.




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3981 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-02 14:50:56 +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 d7bde1e9e0 inline is something the compiler can decide on his own.
static is a good hint to the compiler for that - the function isn't used
outside of this file. 
"static inline" is not valid, visual studio doesn't compile that.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3209 c6295689-39f2-0310-b995-f0e70906c6a9
2007-07-09 14:17:43 +00:00
aj 047ee1d73e fix more warnings found by gcc/sparse.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3178 c6295689-39f2-0310-b995-f0e70906c6a9
2007-06-21 11:07:00 +00:00
aj 9287da54da convert to utf-8.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3088 c6295689-39f2-0310-b995-f0e70906c6a9
2006-12-19 21:34:00 +00:00
aj 3066830238 close memory leaks.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2899 c6295689-39f2-0310-b995-f0e70906c6a9
2006-04-26 10:01:06 +00:00
nils de4b5c280f - implement thread-safe path printing function sc_path_print() and use
it src/libopensc/ and src/pkcs15init/
- use size_t for the certlen parameter of sc_pkcs15init_update_certificate()


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2811 c6295689-39f2-0310-b995-f0e70906c6a9
2006-01-11 23:41:17 +00:00
aj 71c91425c7 check prkf != NULL.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2727 c6295689-39f2-0310-b995-f0e70906c6a9
2005-12-05 21:58:04 +00:00
nils 47ee84e72d add functions
void sc_ctx_suppress_errors_on(sc_context_t *ctx);
	void sc_ctx_suppress_errors_off(sc_context_t *ctx);
to turn on/off error suppression (to avoid accessing
sc_context_t directly) and use it.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2671 c6295689-39f2-0310-b995-f0e70906c6a9
2005-10-30 19:08:06 +00:00
nils d37315ec35 cleanup key usage handling, cleanup
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2550 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-07 09:32:52 +00:00
sth b5e2a2afff Added support for deleting pkcs15 objects, each card driver should implement its delete_object() operation in order to support it
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2506 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-22 09:20:13 +00:00
nils d6e5facb0d make old compilers happy
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2487 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-14 22:33:43 +00:00
nils 4d48735d10 initialize sc_pkcs15init_operations at compile time
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2480 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-10 21:31:18 +00:00
nils e16485826e fix memory leak; patch supplied by Imanishi Masayuki <Masayuki.Imanishi@jp.sony.com>
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2446 c6295689-39f2-0310-b995-f0e70906c6a9
2005-07-20 18:19:40 +00:00
bert eb4717ea17 API fixup: use defined type instead of struct for exposed structs (part 2)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2233 c6295689-39f2-0310-b995-f0e70906c6a9
2005-03-09 00:04:44 +00:00
aet 85d6bc7922 - Warning fixes
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1731 c6295689-39f2-0310-b995-f0e70906c6a9
2004-01-08 15:23:11 +00:00
aet e18b7117cd - Warning fix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1690 c6295689-39f2-0310-b995-f0e70906c6a9
2003-12-20 14:41:05 +00:00
okir ae5dcea891 - created new function profile->ops->init_card for card-specific
initialization at the pkcs15 creation stage
- Added cryptoflex init_card from Stef. This function reads the card's
  serial number from 3F000002 and puts it into the pkcs15 serial number


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1688 c6295689-39f2-0310-b995-f0e70906c6a9
2003-12-19 09:29:56 +00:00
aet 7d3fc55736 - Minor build and C++ warning fixes
- pkcs15init: Use u8 for pin variable
  declarations like libopensc does


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1686 c6295689-39f2-0310-b995-f0e70906c6a9
2003-12-18 21:37:34 +00:00
okir cec660fda1 - More cyberflex fixes from Martin Buechler
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1665 c6295689-39f2-0310-b995-f0e70906c6a9
2003-12-09 13:57:20 +00:00
okir b15bd6c453 - Added support for Cyberflex Access 16K, based on a patch by
Martin Buechler


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1662 c6295689-39f2-0310-b995-f0e70906c6a9
2003-12-08 11:43:21 +00:00
okir 7ea930a030 - return error if cflex_create_dummy_chvs fails
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1575 c6295689-39f2-0310-b995-f0e70906c6a9
2003-10-30 12:03:31 +00:00
okir 927ae344cc - fix cflex key generation
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1536 c6295689-39f2-0310-b995-f0e70906c6a9
2003-10-18 08:39:40 +00:00
okir 937e6c711d - fix for cryptoflex key download
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1535 c6295689-39f2-0310-b995-f0e70906c6a9
2003-10-18 08:08:07 +00:00
okir 2a12ed3108 - Prepare for userConsent support: changed ops->create_pin to take
a sc_pkcs15_object_t instead of sc_pkcs15_pin_info_t argument.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1534 c6295689-39f2-0310-b995-f0e70906c6a9
2003-10-17 11:21:48 +00:00
okir f552395705 - Error logging changes: replace ctx->log_errors with ctx->suppress_errors
- remove error/debug callbacks; always use sc_error/sc_debug


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1519 c6295689-39f2-0310-b995-f0e70906c6a9
2003-10-14 09:57:29 +00:00
okir aad883149e - removed some dead code inside #if 0/#endif
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1514 c6295689-39f2-0310-b995-f0e70906c6a9
2003-10-14 08:17:59 +00:00
aet 936ad78b02 - Some build/portability fixes for the pkcs15init rewrite
- Add sc_pkcs15_get_<drv>_ops(), yet untested


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1512 c6295689-39f2-0310-b995-f0e70906c6a9
2003-10-13 20:41:00 +00:00
aet 1bdcd2184c - Revert previous patch, an alternative patch to
work around non-C99 and/or gcc issues coming up
  soon.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1511 c6295689-39f2-0310-b995-f0e70906c6a9
2003-10-13 20:28:18 +00:00