Commit Graph

8626 Commits

Author SHA1 Message Date
Jakub Jelen d224b2612d pkcs11-spy: Implement new functions and interfaces to intercept PKCS #11 3.0 calls 2021-01-11 14:49:22 +01:00
Jakub Jelen 03079a9413 pkcs11: Add missing flag for new PKCS #11 3.0 functions 2021-01-11 14:49:22 +01:00
Jakub Jelen 6e25924eb0 common, pkcs11-tool: Use new PKCS #11 API with fallback to old one 2021-01-11 14:49:22 +01:00
Jakub Jelen 224e265266 Implement C_SessionCancel from PKCS #11 3.0 2021-01-11 14:49:22 +01:00
Jakub Jelen 8e71118cd4 Ignore build artifacts 2021-01-11 14:49:22 +01:00
Jakub Jelen 7f0166ab12 p11test: Basic test for C_GetInterface API from PKCS#11 3.0 2021-01-11 14:49:22 +01:00
Jakub Jelen 95122abe2e pkcs11: Implement PKCS#11 3.0 stubs for required functions 2021-01-11 14:49:22 +01:00
Jakub Jelen 47151e9335 pkcs11: Implement getInterface() for accessing PKCS #11 3.0 functions 2021-01-11 14:49:22 +01:00
Jakub Jelen e58e7e1428 Standardize PKCS #11 version to 2.20 systematically 2021-01-11 14:49:22 +01:00
Jakub Jelen 23eb606d86 Print testsuite logs on error 2021-01-06 14:15:06 +01:00
Jakub Jelen c7c689c74d .travis.yml: Install clang-tidy to run some static code analysis early 2021-01-06 14:15:06 +01:00
Jakub Jelen 910020aeec Ignore non-useful check in clang-tidy as we have ton of memset/memcpy 2021-01-06 14:15:06 +01:00
Jakub Jelen 9cda87e200 authentic: Initialize structure to avoid comparison against garbage
Thanks clang:

/src/libopensc/card-authentic.c:1564:47: warning: The left operand of '==' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
        if (acls[AUTHENTIC_ACL_NUM_PIN_RESET].method == SC_AC_CHV)   {
                                                     ^
2021-01-06 14:15:06 +01:00
Jakub Jelen d25009cde6 belpic: Remove unused variable
Thanks clang

/src/libopensc/card-belpic.c:230:7: warning: Although the value stored to 'r' is used in the enclosing expression, the value is never actually read from 'r' [clang-analyzer-deadcode.DeadStores]
                if((r = get_carddata(card, carddata, sizeof(carddata))) < 0) {
                    ^
/src/libopensc/card-belpic.c:230:7: note: Although the value stored to 'r' is used in the enclosing expression, the value is never actually read from 'r'
2021-01-06 14:15:06 +01:00
Jakub Jelen 3135fccdca itacns: Correctly free allocated memory
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28510
2021-01-06 14:15:06 +01:00
Jakub Jelen 049b2a8754 pkcs15: Do not override tokeninfo in bind_internal
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28550
2021-01-06 14:15:06 +01:00
Jakub Jelen 66f274dcaf authentic: Fix copy&paste error in log message 2021-01-06 14:15:06 +01:00
Jakub Jelen b48696539d tests: Verify there are no duplicate symbols exported 2021-01-06 14:15:06 +01:00
Jakub Jelen 88543529a2 pkcs11.exports: Remove duplicate symbols 2021-01-06 14:15:06 +01:00
Jakub Jelen f7b0ce3dac Remove duplicate symbols from libopensc.exports 2021-01-06 14:15:06 +01:00
Doug Engert f443c391b0 PIV whitespace cleanup and addtion of // clang-format off|on
Cleanup trailing whitespaces and protect hand formated structures
in card-piv.c and pkcs15-piv.c

 On branch PIV-whitespace
 Changes to be committed:
	modified:   card-piv.c
	modified:   pkcs15-piv.c
2020-12-15 11:14:15 +01:00
Carsten Blüggel f8af905574 Fixes #2175, C_GetAttributeValue for CKA_EXTRACTABLE, CKA_MODIFIABLE 2020-12-10 13:04:11 +01:00
Jakub Jelen 1ae8b60425 mcrd: Do not leak memory
Similar as in 62049ea18c

Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28405
2020-12-09 15:50:54 +01:00
Jakub Jelen 5df913b7f5 tcos: Check bounds in insert_pin()
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28383
2020-12-09 15:50:54 +01:00
Jakub Jelen 69544553c3 tcos: Reformat insert_pin() for readability 2020-12-09 15:50:54 +01:00
Jakub Jelen 196bf9e574 gpk: Replace assert with error
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28306
2020-12-09 15:50:54 +01:00
Peter Popovec a089353e1f MyEID: enable more PKCS11 mechanisms
This patch enables using of: SHA224-RSA-PKCS, SHA256-RSA-PKCS,
SHA384-RSA-PKCS, SHA512-RSA-PKCS and PSS variants of these mechanism for
MyEID users. (This patch is related to issue #2173.)

CI tests for these mechanisms are also enabled (using OsEID emulation).
2020-12-09 04:29:46 +01:00
Jakub Jelen f015746d22 idprime: Use temporary variable instead of messing up the passed one
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28185
2020-12-04 09:30:10 +01:00
Jakub Jelen 78cdab949f tcos: prevent out of bounds read
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27719
2020-12-04 09:30:10 +01:00
Jakub Jelen 3ffe24cfb6 pkcs15: Clean tokeninfo on parse errors to avoid memory leaks
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27779
2020-12-04 09:30:10 +01:00
Jakub Jelen fb83cd0439 asn1: Improve logging 2020-12-04 09:30:10 +01:00
Jakub Jelen 61eb4e487e card: Correctly free pointers durint cache invalidation
As the whole structure is memset(0) on the following line,
we need to clean the pointers before doing so.

Thanks oss-fuzz

Related to:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27797
2020-12-04 09:30:10 +01:00
Frank Morgner 175c357c37 opensctoken: avoid component spec when it's not built 2020-12-01 15:54:27 +01:00
Jakub Jelen 85e08ae675 pkcs11-tool: Avoid calloc with 0 argument 2020-11-25 14:38:23 +01:00
rickyepoderi 3ce249f365 Issue 2153: organizationIdentifier is not translated by openssl 1.1.0/1.0.x 2020-11-25 09:33:20 +01:00
Frank Morgner 98beb86a38 fixed atrmask for gnuk
fixes https://github.com/OpenSC/OpenSC/issues/2155
2020-11-25 09:28:00 +01:00
Frank Morgner 480da424a5
fix possible infinite recursion (#2151)
fixes https://github.com/OpenSC/OpenSC/issues/2149
2020-11-25 09:27:28 +01:00
Jakub Jelen 0365c3ce6c westcos: Avoid assigning local variable to function arguments 2020-11-25 09:26:42 +01:00
Jakub Jelen 3d257410b2 sc-hsm: Avoid assigning local variable to function arguments 2020-11-25 09:26:42 +01:00
Jakub Jelen 63bb85b050 gpk: Avoid assigning local variable to function arguments 2020-11-25 09:26:42 +01:00
Jakub Jelen 871e4f2ac6 flex: Avoid assigning local variable to function arguments 2020-11-25 09:26:42 +01:00
Jakub Jelen 55a5556949 dnie: Remove unused assignment leaking local variable through parameters 2020-11-25 09:26:42 +01:00
Jakub Jelen af2fb6938c cac: Avoid assigning local variable to function arguments
Reported by cppcheck. The argument is not used after
returning from this function, but better make it explicit.
2020-11-25 09:26:42 +01:00
Jakub Jelen 8a6708c163 doc: Update documentation about the cache location 2020-11-25 09:26:18 +01:00
Jakub Jelen d0e5d62bf5 Verify the cache dir is correctly set with different combination of variables 2020-11-25 09:26:18 +01:00
Jakub Jelen 3eae6a031c ctx: Use more standard cache directory
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
2020-11-25 09:26:18 +01:00
Jakub Jelen 00ad8644e6 Enable CIFuzz to run fuzzers even before merging changes 2020-11-25 08:54:54 +01:00
Doug Engert 483e153182 ASN1 cleanup part 1
ASN1 tags are represented in two many ways within OpenSC.
This is a trivial change to simplify one aspect of this.
It also makes the code more readable.

SC_ASN1_CLASS_MASK, SC_ASN1_APP, SC_ASN1_CTX, SC_ASN1_PRV,
SC_ASN1_CONS are changed, and SC_ASN1_CLASS_MASK is added.

These then align with the bits defined by SC_ASN1_TAG_CLASS,
SC_ASN1_TAG_APPLICATION, SC_ASN1_TAG_CONTEXT, SC_ASN1_TAG_PRIVATE,
and SC_ASN1_TAG_CONSTRUCTED.

(SC_ASN1_UNI and SC_ASN1_TAG_UNIVERSAL are both 0x00 thus no change
is needed).

(No sign of a right shift of SC_ASN1_CTX or SC_ASN1_PRV causeing
problems has been seen in the code.) If found, can be solved.)

Close examination of the OpenSC code base shows all uses of tags
used by routines and sc_asn1_entry use the defines.

This could allows 26 lines of code in sc_asn1_skip_tag used to test
the 3 CLASS and CONSTRUCTED bits to be replaced by:

	if (((cla << 24) | tag) != tag_in)
		return NULL;

The 26 lines still work as will any other code in OpenSC
that tests the bits using the defines. It also allows new code
to be simplified.

Problem identified while looking at better way to check response
on GET_DATA (0xCB) that returns TLV as used in card-piv.c

Changes tested using pkcs11-tool --test --login with PIV, SC_HSM
and OpenPGP cards.
2020-11-25 08:50:13 +01:00
Frank Morgner 30180986a0 update date in NEWS 2020-11-24 10:12:21 +01:00
Frank Morgner e13294b085 speedup macOS build
brew update is just dead slow on older travis images
2020-11-23 22:18:38 +01:00