Commit Graph

43 Commits

Author SHA1 Message Date
Jakub Jelen 9c91a4327e oberthur: Free another read data on failure paths 2021-02-25 09:08:52 +01:00
Jakub Jelen 251c4f6b76 oberthur: Avoid memory leaks
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29998
2021-02-25 09:08:52 +01:00
Jakub Jelen 1db88374bb oberthur: Correctly check for return values
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28843
2021-01-22 19:07:05 +01:00
Jakub Jelen c8b2e82713 oberthur: Once again, fix the error check
The shared codition was executed but the condition in LOG_TEST_RET
was not met in case of the acl was null.

Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25962
2020-11-18 23:02:34 +01:00
w00475903 26a404d6a5 pkcs15-oberthur.c:remove redundant code
Signed-off-by: whzhe <wanghongzhe@huawei.com>
2020-10-16 14:02:56 +02:00
Frank Morgner d0c44b9ddc oberthur: fixed missing error handling
fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25962
2020-10-05 23:18:27 +02:00
Frank Morgner fca2ba9474 oberthur: fixed length checking
fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26116
2020-10-05 08:49:27 +02:00
Frank Morgner 3ff059a74b fixed length checking in oberthur profile
fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25943
2020-10-02 13:23:11 +02:00
Jakub Jelen 56acf7b445 oberthur: Do not leak memory on repeated init
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24518
2020-09-22 23:08:27 +02:00
Jakub Jelen 71876042bd oberthur: Do not leak memory on error
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24518
2020-09-15 12:41:37 +02:00
Frank Morgner 6903aebfdd Heap-buffer-overflow WRITE
fixes https://oss-fuzz.com/testcase-detail/5088104168554496
2020-07-30 02:27:02 +02:00
Jakub Jelen 0a34d11cb7 oberthur: Avoid memory leaks on error paths 2020-06-09 13:02:27 +02:00
Jakub Jelen f49162af04 Avoid memory leaks when initializing tokeninfo in various drivers
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22578
2020-06-09 13:02:27 +02:00
Raul Metsma 63fd71c245 Remove unused sc_pkcs15emu_opt_t structure
Only usage was removed SC_PKCS15EMU_FLAGS_NO_CHECK flag

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-05-02 10:08:46 +02:00
Raul Metsma bbec50bfdb Remove unused SC_PKCS15EMU_FLAGS_NO_CHECK flag
Fixes #1634

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-25 14:53:25 +02:00
Frank Morgner 00a150f74c replaced SC_FUNC_RETURN with LOG_FUNC_RETURN 2018-12-06 09:26:42 +01:00
Jakub Jelen 52959df9f6 pkcs15-oberthur: Avoid memory leaks on failures 2018-10-01 23:07:34 +02:00
Florian Bezdeka af72682072 Fixed gcc 8 compilation errors (#1353)
The following errors occured during a compilation using gcc 8:

In function »gids_create_file.constprop«,
    inserted by »gids_save_certificate.isra.8« beicard-gids.c:1548:7:
card-gids.c:465:2: Error: »strncpy« output may be truncated copying 8 bytes from a string of length 8 [-Werror=stringop-truncation]
  strncpy(record->filename, filename, 8);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pkcs15-oberthur.c: In function »sc_pkcs15emu_oberthur_add_prvkey«:
pkcs15-oberthur.c:741:5: Error: »strncpy« output may be truncated copying 254 bytes from a string of length 254 [-Werror=stringop-truncation]
     strncpy(kobj.label, objs[ii]->label, sizeof(kobj.label) - 1);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2018-05-18 18:54:56 +02:00
Peter Marschall 5abe99d228 fix typos
Mass-typo fixing, almost exclusively in comments and text strings.

While at it also fixed a few (very few) grammar errors.
2018-04-15 09:34:45 +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
Maciej S. Szmigiero 1168ca00f3 Set PIN-PUK association for cards that don't have it set
sc_pkcs15_unblock_pin() in libopensc/pkcs15-pin.c wants to associate PIN
to be unblocked with its PUK to check, for example, whether provided PUK
conforms to its policy.

When this function is not able to find a relevant PUK is uses policy for
PIN to be unblocked instead to check provided PUK which causes problems if
PIN and PUK policies differ.

Set PIN-PUK association for cards where it was unset and where this
association was either obvious, described in code or specs or provided
by the community.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2017-03-27 10:57:21 +02:00
Maciej S. Szmigiero d84ee6c96a Initialize PIN logged_in field for cards that do not support PIN info
Commit 2f10de4f5c ("use sc_pkcs15_get_pin_info in C_GetTokenInfo")
introduced dependency of logged in state returned for session
by C_GetTokenInfo() on logged_in field of that session slot PIN.

This field is updated by sending pin_cmd of type SC_PIN_CMD_GET_INFO to
card.
However, not all cards support such pin_cmd type (in fact, majority of
them don't). In this case logged_in field is usually left zero-initialized
which means SC_PIN_STATE_LOGGED_OUT.

With such logged_in field value C_GetTokenInfo() always returns
CKS_R{O,W}_PUBLIC_SESSION, instead of CKS_R{O,W}_USER_FUNCTIONS when
logged in.

At least Firefox (and probably other NSS-based software, too) is confused
by such value and keeps repeating PIN prompts a few times until it
ultimately considers that logging in to this slot has failed.

Fix this by initializing PIN logged_in field to SC_PIN_STATE_UNKNOWN for
cards that do not support SC_PIN_CMD_GET_INFO pin_cmd.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-09-01 02:03:42 +02:00
Viktor Tarasov 9ac4120594 pkcs15: 'aid' argument for emulator init
Allows to PKCS#15 emulator to bind more then one application
2016-04-08 10:48:58 +02:00
Thomas Calderon 91ddcfb514 PKCS15: remove redundant code for access_flags.
* With commit facaf59, access_flags were set for most cards. A closer look
    revealed that this is already done in `sc_pkcs15emu_add_rsa_prkey`.
    Therefore, this removes the duplicated code for cards calling this function.
2015-01-16 10:03:13 +01:00
Viktor Tarasov 8fc679bf40 libopensc: invalid usage of SC_ERROR_MEMORY_FAILURE
Initiated by discussion in https://github.com/OpenSC/OpenSC/pull/134 .

SC_ERROR_MEMORY_FAILURE has to be used as a resulting code of the card related operations,
and not as result of the memory allocation problems.

New 'warning' category of SC_ERRORs introduced -- SC_WARNING_xx .
Error text and SC_ERROR associated with return codes 6300 and 6200 has been changed.
2013-03-02 19:29:14 +01: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
vtarasov f026db6f84 compile warnings: resolve 'comparison between signed and unsigned' compiler warnings
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5534 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 16:59:39 +00:00
andre 3169f14b32 libopensc: Removes useless attribute 'file' in 'struct sc_pkcs15_df'
There is no need to carry around that attribute, because it's easy to look up the 'file' as needed. This is done by issuing a single sc_select_file command in sc_pkcs15init_update_any_df (pkcs15-lib.c).

The parameter 'file' of sc_pkcs15_add_df (pkcs15.c) became useless too and was removed in turn.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5316 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-10 04:09:33 +00:00
ludovic.rousseau fe630c884f Fix a real bug (and a compiler warning)
pkcs15-oberthur.c: In function 'sc_pkcs15emu_oberthur_add_pubkey':
pkcs15-oberthur.c:585: warning: statement with no effect
pkcs15-oberthur.c: In function 'sc_pkcs15emu_oberthur_add_cert':
pkcs15-oberthur.c:654: warning: statement with no effect


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5269 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-23 17:17:07 +00:00
ludovic.rousseau fc40ad754c Remove dead code
pkcs15-oberthur.c:353:3: warning: Value stored to 'len' is never read
                len = sizeof(label) - 1;
                ^     ~~~~~~~~~~~~~~~~~
pkcs15-oberthur.c:587:3: warning: Value stored to 'sz' is never read
  ...sz = len > sizeof(key_obj.label) - 1 ? sizeof(key_obj.label) - 1 : len;
     ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkcs15-oberthur.c:669:2: warning: Value stored to 'offs' is never read
        offs += 2 + len;
        ^       ~~~~~~~
pkcs15-oberthur.c:656:3: warning: Value stored to 'sz' is never read
  ...sz = len > sizeof(cobj.label) - 1 ? sizeof(cobj.label) - 1 : len;
     ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5181 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-05 22:14:19 +00:00
vtarasov 0d96b3c9c3 oberthur: from the common part remove the Oberthur specific tokenInfo flags
Thanks to Andre Zepezauer for the patch.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4800 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-07 15:12:12 +00:00
martin 50f99a20f8 libopensc: move TokenInfo fields from sc_pkcs15_card_t to a separate structure.
Thanks to Andre Zepezauer for the patch.

See http://www.opensc-project.org/pipermail/opensc-devel/2010-September/015076.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4788 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-05 15:44:58 +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
viktor.tarasov be3670600b emulator fix #125: thanks to Thomas Harning: emulator specific 'clear' handler
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4255 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-18 16:38:49 +00:00
viktor.tarasov 0004461734 oberthur: add in emulator and create in pkcs15init the private data object
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4253 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-18 14:51:44 +00:00
viktor.tarasov f75f539a6f libopensc: export 'sc_asn1_encode_object_id'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4142 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-22 14:14:51 +00:00
viktor.tarasov 0f82c7c1d4 oberthur: pkcs15init emulator
Now the native Oberthur card format is supported for emulation of pkcs15 and pkcs15init.

It means that card personalized with OpenSC and the obejcts created with OpenSC 
will be usable with the native Oberthur's middleware 
and vice-versa.





git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4137 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-18 12:30:39 +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 22f067863a libopensc emu: more general implementation of the postponed DF parsing
In previous version the card specific 'parse_df' handler was a part of 'sc_pkcs15_df'.

Now the placehold ('sc_pkcs15_operations') created for the all card emulator specific operations .


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4109 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-13 19:48:09 +00:00
viktor.tarasov 172d710a35 oberthur emu: create pkcs15 object for SOPIN; accept non-initialized token; use 'define' macros for the native file paths
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4108 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-11 13:29:10 +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
martin 91230bdbc9 there is no ui.h any more.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4102 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-10 07:07:13 +00:00
viktor.tarasov ffab538bcc oberthur: pkcs15 emulator for the native cards
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4100 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-09 17:40:22 +00:00