Jakub Jelen
b3501ff669
idprime: Unbreak OS version 2 after key&cert renewal
2020-10-03 01:08:05 +02:00
Frank Morgner
0b40d3b999
idprime: check max. buffer length
...
fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25998
2020-10-02 13:23:11 +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
732ed77ad6
idprime: Unbreak reading of compressed certificates
2020-09-30 23:13:14 +02:00
Anton Logachev
03396707f0
card-rtecp: Add Rutoken ECP SC NFC ATR
2020-09-30 01:18:50 +02:00
Frank Morgner
3ebfb01a3c
itacns: fixed length checking
...
fixes https://oss-fuzz.com/testcase-detail/5116660103774208
2020-09-29 08:53:16 +02:00
rickyepoderi
57a391f16c
Issue 2105: Add new DNIe CA structure for the secure channel
2020-09-26 01:36:55 +02:00
Jakub Jelen
b577531720
coolkey: Remove dead code
...
Thanks coverity
** CID 362100: Control flow issues (DEADCODE)
/src/libopensc/card-coolkey.c: 1755 in coolkey_rsa_op()
2020-09-24 08:59:47 +02:00
Jakub Jelen
595926471b
itacns: Really do not read behind the buffer bounds
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25885
2020-09-24 08:59:47 +02:00
Doug Engert
6545cd26f4
PIV-update-DOD-Yubikey
...
Update the ATR table for PIV/CAC matrix to 2019 -10-18 version:
https://www.cac.mil/Portals/53/Documents/DoD%20Token%20utilziation%20and%20variation%20matrix%20v2_06_17October2019.docx?ver=2019-10-18-102519-120
Also update table for several PivKey cards, and added ATR for IDEMIA PIV 2.4.1.
But did not update for use of SM or VCI.
Yubico changed the ATR historical data for Yubikey 5 NFC. Code was added to recognize
it, when used with USB or NFC.
Note: Yubikey 5 NFC when used with NFC cant use touch policy. NFC reader may not provide
enough power to power the LED on button.
On branch PIV-update-DOD-Yubikey
Changes to be committed:
modified: card-piv.c
2020-09-24 08:55:01 +02:00
Taylor R Campbell
5a369a8f31
epass2003: Fix erase sequence.
...
The previous erase sequence did not always work. For example:
% pkcs15-init -C
Using reader with a card: Feitian ePass2003 00 00
New User PIN.
Please enter User PIN: 1234
Please type again to verify: 1234
Unblock Code for New User PIN (Optional - press return for no PIN).
Please enter User unblocking PIN (PUK):
Failed to create PKCS #15 meta structure: Security status not satisfied
% pkcs15-init -E
Using reader with a card: Feitian ePass2003 00 00
Failed to erase card: Security status not satisfied
This apparently bricked many people's ePass2003 devices:
https://github.com/OpenSC/OpenSC/issues/767
https://sourceforge.net/p/opensc/mailman/message/33621883/
https://github.com/OpenSC/OpenSC/wiki/Feitian-ePass2003
Feitian provided a proprietary binary blob called `FIX_TOOL' to recover
devices from this state, but declined to offer source code when asked:
https://download.ftsafe.com/files/ePass/Fix_Tool.tar.gz
https://download.ftsafe.com/files/reader/SDK/Fix_Tool_20200604.zip
With reverse-engineering help by Saleem Rashid (@saleemrashid on
Github), I was able to find the sequence of three APDUs that the tool
submits to the device to erase it. The mechanism seems to be:
1. Install a magic PIN. This is like install_secret_key, as used by
internal_install_pin, but with a few different magic constants.
2. Verify the magic PIN.
3. Delete the MF file, without selecting anything first.
With this patch, `pkcs15-init -E' successfully erases my ePass2003, and
I am able to initialize it with `pkcs15-init -C -p pkcs15+onepin' if I
set both a user pin and a PUK. (This patch does not prevent the
ePass2003 from getting into the state which could not be erased by the
old erase sequence.)
2020-09-23 08:37:09 +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
101e9c720d
coolkey: For large data, do not even expect response data
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25708
2020-09-22 23:08:27 +02:00
Jakub Jelen
8dd136ac24
pkcs15-itacns: Do not access behind the allocated buffer boundary
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25473
2020-09-15 12:41:37 +02:00
Jakub Jelen
752c088e10
pkcs15-itacns: Free allocated memory
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25475
2020-09-15 12:41:37 +02:00
Jakub Jelen
cf66cf1416
pkcs15-data: Do not fail on zero-lenght data blocks
2020-09-15 12:41:37 +02:00
Jakub Jelen
a626c63d91
itacns: Do not leaek memory if file is empty
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25475
2020-09-15 12:41:37 +02:00
Jakub Jelen
c07d9ec103
card-authentic: Avoid memory leak
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24013
2020-09-15 12:41:37 +02:00
Jakub Jelen
460a862ee0
pkcs15-cert: Avoid memory leaks
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24056
2020-09-15 12:41:37 +02:00
Jakub Jelen
777a9e0386
pkcs15-piv: Make sure we do not leak memory on errors
...
This replaces all returns from sc_pkcs15emu_piv_init() with goto err
and makes sure all allocated memory is freed on error.
Thanks oss-fuzz
https://oss-fuzz.com/testcase-detail/6243443299581952
2020-09-15 12:41:37 +02:00
Jakub Jelen
209d28a63f
pkcs15-cert: Improve logging
2020-09-15 12:41:37 +02:00
Jakub Jelen
238b783a0e
card-asepcos: Fix heap-buffer overflow
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24940
2020-09-15 12:41:37 +02:00
Jakub Jelen
94d67bed81
npa: Free allocated apps in match function
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23977
2020-09-15 12:41:37 +02:00
Jakub Jelen
d743a347d7
coolkey: Avoid memory leak when processing multiple combined objects
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24023
2020-09-15 12:41:37 +02:00
Jakub Jelen
dce4ad1aa2
coolkey: Avoid bogus check before free
2020-09-15 12:41:37 +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
Jakub Jelen
a1d35518dd
CID 357984: Avoid casting signed integer to unsigned before checking its value
2020-09-15 12:41:37 +02:00
Jakub Jelen
34a5a80870
CID 360515: Avoid dereferencing null pointer crypt_out_p.
...
Thanks coverity and oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23976
2020-09-15 12:41:37 +02:00
Zoltan Kelemen
7c8c77cf1f
Corrected highly misleading, confusing and ambiguous use of PIN length_offset
...
field. Now only the PIN offset fields are used.
This change synchronizes the code with similar changes in reader-pcsc.c
(commit eb3e00a385
).
2020-09-04 12:28:24 +02:00
Raul Metsma
57f37ffd8d
Remove unused and broken RSA EstEID support
...
Signed-off-by: Raul Metsma <raul@metsma.ee>
2020-09-02 11:21:33 +02:00
Peter Marschall
16c889cf7d
spelling fixes
...
Fix various spelling errors, mostly in comments but also in texts displayed.
Errors found & interactively fixed using 'codespell', with additional manual
checks after the fixes.
2020-08-30 10:35:14 +02:00
Ludovic Rousseau
3168f48503
Fix spelling error in comments
2020-08-29 23:22:34 +02:00
Ludovic Rousseau
e1353c0488
Fix spelling error
...
Thanks to Debian lintian:
I: opensc-pkcs11: spelling-error-in-binary
usr/lib/x86_64-linux-gnu/libopensc.so.6.0.0 certificat certificate
2020-08-29 23:19:37 +02:00
Zoltan Kelemen
f0b157b8e7
Improved comments for PIN cmd structures.
2020-08-19 10:01:58 +02:00
Zoltan Kelemen
11adcfca99
Removed 'acls' from the public interface in 'sc_pin_cmd_pin' since it is not
...
supported by most of the card drivers and can therefore not be regarded to be
part of the public interface.
Modified the only remaining card driver that used it (authentic) to store acls
in a private variable.
2020-08-19 10:01:58 +02:00
Zoltan Kelemen
6e3e81a9f4
Remove unused stored_length field.
2020-08-19 10:01:58 +02:00
Zoltan Kelemen
48d939b057
Removed length_offset since it is not used any more.
2020-08-19 10:01:58 +02:00
Zoltan Kelemen
aca0d08e29
Removed the 'crts' field from 'sc_acl_entry' type since:
...
- its definition is specific to the IAS-ECC card type
- its presence can not be assumed since it is read from non-mandatory SE type of an SDO
- it is currently not used anywhere in the code
2020-08-19 10:01:58 +02:00
Peter Marschall
376cc2d910
iso7816: set record_length for any record-oriented EF
2020-08-19 09:58:12 +02:00
Jakub Jelen
cdbcb5b7db
coolkey: Fix AddressSanitizer: stack-use-after-scope
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23979
2020-08-04 13:11:55 +02:00
Peter Marschall
8963c35189
pkcs15-sc-hsm: use correct name for EF.CDF
2020-08-03 15:34:22 +02:00
Peter Marschall
07e98b5193
pkcs15-sc-hsm: fix commit c4d7bb1
...
Set the trigger for LOG_TEST_RET() to a negative value if obj.data == NULL.
2020-08-03 15:34:22 +02:00
Frank Morgner
978c912c70
fixed Heap-buffer-overflow READ
...
7cf8087351
seemed to be incomplete. Change
the length of the buffer right before it's accessed.
fixes https://oss-fuzz.com/testcase-detail/5734055866531840
2020-07-30 02:40:02 +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
Julian Strobl
9ffb9bae63
tcos: add missing encryption certificates
2020-07-30 02:00:15 +02:00
Zoltan Kelemen
6f1df6454a
Reject the case that the PIN and PUK padding flags are different, since this
...
case can not be handled by the card driver interface. Better to detect and
fail early instead of sending invalid data to the card.
2020-07-22 22:58:57 +02:00
Zoltan Kelemen
555cb73615
Fix for using the correct info for PIN/PUK (before they were switched).
2020-07-22 22:58:57 +02:00
Zoltan Kelemen
e80906d973
Add path selection to sc_pkcs15_get_pin_info to make it work correctly with
...
local PINs. This makes the code behave the same way as PIN verification,
change and unblock, before calling the PIN command handler in the card driver.
2020-07-22 22:58:57 +02:00
Zoltan Kelemen
bad74e1ed6
Enabled code for using PUK reference for PIN unblock, when available.
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
998284dd1c
Removed unused define.
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
ba76bc0239
Improved syntactic readability without any change in functionality.
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
c903ddfce1
Fixed bounds checking and enabled the function again.
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
163b69e6a7
Change ADF selection to return FCP for Oberthur cards. No need to simulate
...
since it is supported.
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
3331a7f134
Fix MF selection APDU to use 0x0c in P2 (no data). The previous value of 0x00
...
is invalid according to IAS-ECC and resulted in 6A 86 on the Oberthur
cards that we tested with.
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
471468260e
Improved PIN unblock function:
...
- Uses PIN padding from merged policy
- Added PIN-pad support
- Use ISO 7816 layer to avoid code duplication
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
79e81eeef0
Improved PIN change function:
...
- Uses PIN padding from merged policy
- Improved PIN-pad logic and merged here from separate function
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
5ae488c1b9
Improved PIN verification function:
...
- Uses PIN padding from merged policy
- Moved PIN-pad logic into this function instead of keeping separate
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
d0b3e90431
Simlified low-level CHV verification function:
...
- Removed special PIN-pad case, moving logic into high-level function.
- Use ISO 7816 layer to avoid code duplication.
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
8c2d629f94
Functions used to control PIN padding and PIN pad use:
...
- Use PIN padding information when provided by upper layers
- Enable PIN padding at card level when min/max len set to same, nonzero value
- Allow PIN-pad use to be dynamically selected for each PIN
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
ca911e342c
Improved PIN info retrieval, now returning verification status, and attempts
...
left even when previously not available (due to card not providing it in the
SDO).
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
19063932f0
Simplified PIN policy retrieval to only read the data that is actually needed,
...
excluding the CRT info from the SE-SDO, which is not guaranteed to be
available in all card types.
Use an explicit PIN policy structure type instead of keeping the info in the
sc_pin_cmd_data, since this type of info is only used privately in the card
driver.
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
741ee73ec9
Add generic function for PIN status retrieval, for subsequent use (among
...
others intended to replace iasecc_pin_is_verified).
Base it on functionality in the ISO 7816 layer to avoid code duplication.
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
7ed876c816
Added ATR mask for Idemia (Oberthur) IAS-ECC card to recognize Cosmo V8 cards.
2020-07-22 22:57:23 +02:00
Zoltan Kelemen
eb3e00a385
Corrected highly misleading, confusing and ambiguous use of PIN length_offset
...
field. Now only the PIN offset fields are used. Also added error checking for
invalid values.
2020-07-22 22:56:09 +02:00
Zoltan Kelemen
80853bda31
Only enable static frame size for PIN padding when padding length is below
...
maximum limits. Otherwise resort to adaptive support.
2020-07-22 22:56:09 +02:00
Zoltan Kelemen
afffeccc29
Fixed problems with PIN min/max length handling:
...
- The wrong PIN was selected from the sc_pin_cmd_data structure.
- When the PIN max value was zero from the caller (meaning unknown max), the
reader max value was not used.
2020-07-22 22:56:09 +02:00
Zoltan Kelemen
1dc359cb61
Fix for issue #1999 :
...
- Reset context to undefined handle value on error since call may alter
output parameter.
- Continue to assume -1 as undefined handle value in all PCSC
implementations, to keep this fix as small and surgical as possible.
2020-07-22 22:55:30 +02:00
Jakub Jelen
b16a5cbee0
pkcs15: Free app info when allocating new and in cleanup
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23746
2020-07-07 16:21:21 +02:00
Jakub Jelen
c82aa92687
pkcs15: Clean memory on alocation failure
2020-07-07 16:21:21 +02:00
Jakub Jelen
2d6de2510c
pkcs15: Drop bogus checks
2020-07-07 16:21:21 +02:00
Jakub Jelen
4c473fba29
authentic: Clean private data on error
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23786
2020-07-07 16:21:21 +02:00
Jakub Jelen
05dcde508b
authentic: Use memmove as the memory can overlap (if path is > 2B)
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23787
2020-07-07 16:21:21 +02:00
Jakub Jelen
5098cfdb40
authentic: Do not leak memory on fail path
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23788
2020-07-07 16:21:21 +02:00
Jakub Jelen
7cf8087351
asepcos: Avoid heap-buffer-overflow
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23529
2020-07-07 16:21:21 +02:00
Jakub Jelen
c4d7bb1a7b
Do not crash on if private certificate is ignored ( #2057 )
2020-07-07 16:21:21 +02:00
Jakub Jelen
43379b3b22
coolkey: Rewrite coolkey_rsa_op() for better readability
2020-07-07 16:21:21 +02:00
Jakub Jelen
0cda376dba
pkcs15-pubkey: Make sc_pkcs15_pubkey_from_spki_fields more robust against errors
...
Original patch from Douglas E Engert <deengert@gmail.com>
2020-07-07 16:21:21 +02:00
Jakub Jelen
e759b17b66
pkcs15-pubkey: Avoid memory leaks when spki parsing fails
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22189
2020-07-07 16:21:21 +02:00
Jakub Jelen
56f4c6c34a
piv: Free pubkey on error
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22297
2020-07-07 16:21:21 +02:00
Jakub Jelen
3696331d5c
Remove more needless checks for NULL before free
2020-07-07 16:21:21 +02:00
Jakub Jelen
fea08d749d
coolkey: Avoid memory leak
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23251
2020-07-07 16:21:21 +02:00
Zoltan Kelemen
929717b505
Make PUK reference available to card driver from PKCS #15 layer for PIN
...
unblock operations. This helps some of the card drivers which otherwise
would have a hard time locating the PUK for a PIN.
2020-07-02 13:24:57 +02:00
René Liebscher
223a0949e8
Add sc_free()
...
For more details see https://github.com/OpenSC/OpenSC/issues/2054
2020-06-22 10:47:59 +02:00
René Liebscher
4d96fbfed4
Remove compiler warnings/errors
...
Recent compilers have activated some additional
checks which let the build fail. (at least with cygwin)
(Normally it would be warnings but opensc compiles
with -Werror)
GCC 9.3:
In file included from profile.c:27:
profile.c: In function '__expr_get':
profile.c:2273:18: error: array subscript has type 'char' [-Werror=char-subscripts]
2273 | while (isspace(*s))
| ^~
clang 8.0.1:
compat_getopt_main.c:102:22: error: array subscript is of type 'char' [-Werror,-Wchar-subscripts]
rc = toupper(rc);
^~~~~~~~~~~
/usr/include/ctype.h:161:25: note: expanded from macro 'toupper'
(void) __CTYPE_PTR[__x]; (toupper) (__x);})
^~~~
Actually the code is correct as isspace and others
are used here with data type char, and are to be used
with data type int.
So either the compiler should have deactivated
this error, or the ctype.h macros have to be
written so the compiler no longer complains.
As there is also a simple workaround by casting
char to unsigned char, there is no need to wait for one
of the former options to be happen sometime.
2020-06-22 10:47:02 +02:00
Jakub Jelen
7ae74c524f
piv: Avoid accessing memory after zero-length tags
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23215
2020-06-09 13:02:27 +02:00
Jakub Jelen
5e7d4fb8ba
oberthur: Avoid memory leaks
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23126
2020-06-09 13:02:27 +02:00
Jakub Jelen
0a34d11cb7
oberthur: Avoid memory leaks on error paths
2020-06-09 13:02:27 +02:00
Jakub Jelen
62403eec34
tcos: Use memset instead of for cycle
2020-06-09 13:02:27 +02:00
Jakub Jelen
9dd3370673
oberthur: Fix operator precedence
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22665
2020-06-09 13:02:27 +02:00
Jakub Jelen
a5f04188bc
pteid: Do not overwrite already set information in tokeninfo
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22578
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
Jakub Jelen
71d1f69a3a
Reformat tcos_compute_signature() for better readability
2020-06-09 13:02:27 +02:00
Jakub Jelen
e6848b6d88
tcos: Yet anoter buffer underflow as previous
2020-06-09 13:02:27 +02:00
Jakub Jelen
fa719b301f
tcos: Prevent buffer underflow
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22995
2020-06-09 13:02:27 +02:00
Jakub Jelen
d141b35596
tcos: Rewrite assert to explicit check
2020-06-09 13:02:27 +02:00
Jakub Jelen
1819ca33d6
tcos_decipher: Reformat to improve readability
2020-06-09 13:02:27 +02:00
Jakub Jelen
53395f4075
tcos: Replace assert with explicit check
...
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22999
2020-06-09 13:02:27 +02:00
Jakub Jelen
8940ed5d85
tcos: Avoid memory leak on invalid inputs
...
(make sure the pointer is initialized)
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22765#c2
2020-06-09 13:02:27 +02:00
Frank Morgner
1c7b311289
pcsc: immediately exit on hotplug events
...
fixes delayed notification for removed readers
closes https://github.com/OpenSC/OpenSC/issues/2021
2020-06-09 12:07:04 +02:00
Frank Morgner
8f6e5dc2b0
Unbreak wait for events
...
By Jabuk Jelen
Fixes https://github.com/OpenSC/OpenSC/issues/2021
2020-06-09 12:07:04 +02:00