Compare commits

...

1709 Commits

Author SHA1 Message Date
giomba 932bd27549 libgcns: ArchLinux package 2022-01-08 20:37:35 +01:00
giomba b965e20bfd libgcns: C++ version 2022-01-06 21:12:55 +01:00
giomba 060d8ddb19 libgcns: first commit 2022-01-06 20:27:23 +01:00
giomba 5167b30043 gcns.c: refactoring 2022-01-06 18:04:42 +01:00
giomba 606edadb13 gcns.c: read Italian healthcare smart card 2022-01-06 17:29:06 +01:00
Jakub Jelen c902e19921 prepare 0.22.0 release 2021-08-10 11:09:03 +02:00
Vesa Jääskeläinen e97fec4d91 pkcs11-spy: Fix attribute displaying crash in case pTemplate=NULL
In real world pTemplate=NULL case is only used by PKCS#11 test suites but
no need to crash them.

Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
2021-08-10 08:54:08 +02:00
Vesa Jääskeläinen cababca4d5 pkcs11-spy: Fix C_OpenSession() crash with phSession=NULL argument
In real world phSession=NULL case is only used by PKCS#11 test suites but
no need to crash them.

Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
2021-08-10 08:54:08 +02:00
Vesa Jääskeläinen 63a5a493a6 pkcs11-spy: Match formatting for C_OpenSession()
Match spacing and add [in] to argument dumps.

Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
2021-08-10 08:54:08 +02:00
Vesa Jääskeläinen 1b344a4847 pkcs11-spy: Fix C_GetFunctionList() crash with NULL argument
In real world ppFunctionList=NULL case is only used by PKCS#11 test suites but
no need to crash them.

Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
2021-08-10 08:54:08 +02:00
Vesa Jääskeläinen 7007eda0ba pkcs11-spy: fix random crash in print_generic()
Depending on stack state print_generic() could cause crash or spurious garbage
in logs.

Example crash:

*** buffer overflow detected ***: pkcs11test terminated

Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
2021-08-10 08:53:13 +02:00
Vesa Jääskeläinen 1991fa24ae [merge] new output for pMechas
Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
2021-08-10 08:52:42 +02:00
Vesa Jääskeläinen 6431f69dcc pkcs11-spy: Fix crash for pMechanism=NULL
Some test suites are excercising pMechanism==NULL case and this causes
crash when using pkcs11-spy for logging in between.

Centralize logging for pMechanism and handle NULL case.

Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
2021-08-10 08:52:42 +02:00
Frank Morgner 7d315b5546
Merge pull request #2379 from dengert/Fix-new-line
log.c - fix newline - Fixes:#2378
2021-08-09 14:52:41 +02:00
Doug Engert 4c923c637c log.c - fix newline - Fixes:#2378
On branch Fix-new-line
 Changes to be committed:
	modified:   log.c
2021-08-06 13:53:49 -05:00
Jakub Jelen b67261ab27 Upload also tarball as a build artifact 2021-08-04 22:08:19 +02:00
Jakub Jelen 68b7efb591 github actions: Unbreak migw builds 2021-08-04 22:08:19 +02:00
Jakub Jelen 3048156db0 Execute push-artifacts on macos 2021-08-04 22:08:19 +02:00
Jakub Jelen 1e43a6a1af Make sure the dist creates tarball for pushing artifacts 2021-08-04 22:08:19 +02:00
Doug Engert c6a9b5699a PIV-improved parsing - fix two whilhspace nits
On branch PIV-improved-parsing
 Changes to be committed:
	modified:   card-piv.c
2021-08-04 08:58:06 +02:00
Doug Engert 445a6324de Remove unused code
two lines that are never executed are removed for the code.
The LOG_TEST_GOTO_ERR before these lines will goto err.

 On branch PIV-improved-parsing
 Changes to be committed:
	modified:   src/libopensc/card-piv.c
2021-08-04 08:58:06 +02:00
Doug Engert 456ac56693 PIV Improved parsing of data from the card
Based on Fuzz testing, many of the calls to sc_asn1_find_tag were replaced
with sc_asn1_read_tag. The input is also tested that the
expected tag is  the first byte. Additional tests are also add.

sc_asn1_find_tag will skip 0X00 or 0Xff if found. NIST sp800-73-x specs
do not allow these extra bytes.

 On branch PIV-improved-parsing
 Changes to be committed:
	modified:   card-piv.c
2021-08-04 08:58:06 +02:00
Jakub Jelen 8453c0d99a Skip openpgp test for now 2021-08-04 08:57:34 +02:00
Jakub Jelen d47f42b12a README: Update badges and links from travis 2021-08-04 08:57:34 +02:00
Jakub Jelen 01cf556ba2 github-actions: Unbreak artifacts pushing 2021-08-04 08:57:34 +02:00
Jakub Jelen f43d3f8042 Add Javacard tests and mingw build to Github Actions
* PIV applet
* Isoapplet
* Gids Applet
* openpgp applet
* Split clang-tidy to separate task as it is too slow
2021-08-03 12:00:49 +02:00
Jakub Jelen 5d338739ac CI: Avoid warnings from tput
As reported by Peter Popovec
2021-08-03 12:00:49 +02:00
Jakub Jelen e683c531f6 Migrate some tests to Github Actions
This ads also retention json files with results from p11test to
make sure we are not introducing regressions for existing cards.
2021-08-03 12:00:49 +02:00
Jakub Jelen 1b329093f7 Move the cifuzz to separate file 2021-08-03 12:00:49 +02:00
Jakub Jelen bc9b9df869 Do not use EVP_PKEY_get0() for EC_KEY handling
The function is intentionally broken in OpenSSL 3.0 for provided keys
and returning NULL. But it should still work for the legacy gost engine
implementation (but I do not have a good way to check).

Discussed in openssl upstream issue:

https://github.com/openssl/openssl/issues/16081
2021-08-02 10:05:59 +02:00
Frank Morgner 99656deaf4 avoid limited size when logging data 2021-07-15 10:04:23 +02:00
Jakub Jelen 9a5a008093 pkcs15-tool: Update the logic to make it more clear for some dumb static analyzers 2021-07-15 09:51:59 +02:00
Jakub Jelen d34e84c78d eidenv: Avoid memory leak 2021-07-15 09:51:59 +02:00
Frank Morgner d90048e5bb
Merge pull request #2357 from a-dma/p11_extractable
pkcs11-tool: allow setting CKA_EXTRACTABLE during keypair generation
2021-07-05 16:21:41 +02:00
Jakub Jelen aa6574b60e New rc published 2021-06-29 18:17:19 +02:00
Jakub Jelen fd6b64b91b Update NEWS with recently merged changes 2021-06-29 13:58:55 +02:00
Alessio Di Mauro 2f94a6b155
pkcs11-tool: allow setting CKA_EXTRACTABLE during keypair generation
Section 4.9 of the PKCS#11 v2.40 specification [1], mentions
CKA_EXTRACTABLE as a valid attribute for Private Key objects. However,
when calling "pkcs11-tool" with the "--exportable" option, the
attribute is not set as part of the private key template.

[1]: http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/errata01/os/pkcs11-base-v2.40-errata01-os-complete.html
2021-06-23 15:29:29 +02:00
Doug Engert aebebac432 p11test: Use OPTIONAL_OPENSSL_CFLAGS
Needed if building with OpenSSL in non stanard location.

 Changes to be committed:
	modified:   src/tests/p11test/Makefile.am
2021-06-11 05:28:07 -05:00
Frank Morgner c42792c216
Merge pull request #2343 from Jakuje/ossl3v1
Working subset of #2337 (OpenSSL 3.0)
2021-06-07 14:38:30 +02:00
Stephan Mühlstrasser 151583ce26 C_Initialize() must copy CK_C_INITIALIZE_ARGS
C_Initialize() must make a copy of the function pointers supplied
via pInitArgs, as the PKCS#11 specification makes no guarantee that
the pInitArgs pointer is allowed to be dereferenced after C_Initialize()
returns.

Fixes issue #2170.
2021-06-07 12:44:07 +02:00
Jakub Jelen 9be6dc6606 pkcs11: Update the version to 3.0 (unused anywhere though) 2021-06-02 15:46:00 +02:00
Jakub Jelen 9d1a214340 pkcs11: Undefine internal typedef and remove its usage 2021-06-02 15:46:00 +02:00
Jakub Jelen fc2fecc80e Use const types for RSA and EC_KEY
These are anyway not supposed to be modified even in older versions of
openssl.

Visible when building with -Wno-deprecated-declarations
2021-06-02 15:46:00 +02:00
Jakub Jelen ffd6e2a576 p11test: Expect DERIVE to be set on both private and public key
Basically reverts part of 485b6cf, which turned out to be wrong.

Alternative to #2292
2021-05-31 15:36:29 +02:00
Jaime Hablutzel 465375bda2 Fixing command-line option names in error messages 2021-05-26 10:41:30 +02:00
Jakub Jelen 33426df3ff p11test: Do not return on warnings for (X)EDDSA keys 2021-05-24 11:25:53 +02:00
Jakub Jelen 8e4134841d p11test: Add new mechanisms from softhsm 2021-05-24 11:25:53 +02:00
Jakub Jelen a8a4bddfad p11test: Debug level from commandline
This replaces the debug level defined at build time with -NDEBUG,
which turned out to be quite confusing.

Fixes #2304
2021-05-24 11:25:53 +02:00
Jakub Jelen a69ab7c70c tests: Fix context for the asn1 test 2021-05-24 11:25:53 +02:00
Jakub Jelen fd96d2c960 Do not use deprecated ERR_load_ERR_strings() with OpenSSL 3.0 2021-05-24 11:25:53 +02:00
Jakub Jelen 1b92501ef9 sm: Rewrite to use non-deprecated OpenSSL 3.0 API 2021-05-24 11:25:53 +02:00
Jakub Jelen 07f5e63abf tests: verify secure messaging functions work as expected 2021-05-24 11:25:53 +02:00
Jakub Jelen 12be677cb8 Drop duplicate -Werror build flag (already used unless --disable-strict) 2021-05-24 11:25:53 +02:00
Jakub Jelen e4cf0e7b39 Basic unit test for secure messaging functions 2021-05-24 11:25:53 +02:00
Jakub Jelen 0b45e78e4f idprime: Fix RSA-PKCS mechanism with hashing on card 2021-05-24 10:42:08 +02:00
Yaroslav Isakov fc08818f6f OpenPGP: Fix read/write certs with Ed25519/X25519 public key
Proper Ed25519/X25519 certs have pubkey algo with OID 1.3.101.112/110, according to
RFC8410. This commit add these OIDs, and also fixes pubkey parsing/creation - according
to the same RFC, it's just a bytestring, without ASN.1 wrapping.

Also, according to the same RFC, EDDSA/X25519 MUST not have params, even empty.
2021-05-21 14:37:30 +02:00
Yaroslav Isakov 23dc52c903 Fixed OpenPGP logic for comparing OIDs
It's better to leave oid comparison as it was before, and drop trailing
zero byte after it, when reading from token.
2021-05-20 11:11:05 +02:00
Yaroslav Isakov 29410c170e Make OpenPGP curves to be a pointer to OpenPGP 3.4 curves list 2021-05-20 11:11:05 +02:00
Yaroslav Isakov f356d301b9 Enable ed25519/curve25519 support for Yubikey 5 2021-05-20 11:11:05 +02:00
Doug Engert 48a11c0634 Update piv-tool man pages for AES
commit 295c523e4 (William Roberts     2014-07-08 13:52:48)
added support for AES keys to card-piv.c but the man page
for piv-tool that uses the code was never  updated.

 On branch piv-tool-doc
 Changes to be committed:
	modified:   ../../doc/tools/piv-tool.1.xml
2021-05-20 11:07:29 +02:00
Doug Engert f1bc07dec1 Fix piv-tool on wondows
fopen needs "rb" for fopen in two places

fixes #2338

 On branch piv-tool-windows
 Changes to be committed:
	modified:   piv-tool.c
2021-05-20 10:37:31 +02:00
Doug Engert 8dfafe4fc2 Fix 2340 pkcs15-sec.c wrong test
if (obj->type == SC_PKCS15_TYPE_PRKEY_RSA) { is the correct test.
2021-05-17 15:00:26 +02:00
Vincent JARDIN 5256bc3d3d tests: minidriver using T0 or T1
Some cards should be used with T0 and some others with T1. Let's support
both.

Fix: issue #2326
2021-05-17 12:06:12 +02:00
Vincent JARDIN 180737d1b6 tests: minidriver runtime PINCODE
Let's define an environment MINIDRIVER_PIN=1234 in order to be able
to reuse the tests with any cards.
usage:
(cmd) set MINIDRIVER_PIN=1234

When the PIN code is not defined, let's skip the tests since it may runs
the number of trials out of the max attempts.

Moreover, some cards may have many roles, but the tests are designed for
the ROLE_USER, so let's enforce only the ROLE_USER.

Fix: issue #2326
2021-05-17 12:06:12 +02:00
Vincent JARDIN f0c059ede8 ATRMask: better describe the rule to be applied
Include some notes in order to properly define the ATR values.

Suggested-by: Doug Engert <deengert@gmail.com>
Fix: issue #2321
2021-05-12 07:51:42 +02:00
Vincent JARDIN 46c50dc51d CPx: add registration for Windows/minidrivers
Let's OpenSC be able to support the IAS/ECC CPx cards.

Suggested-by: Doug Engert <deengert@gmail.com>

Fix: issue #2321
2021-05-12 07:51:42 +02:00
Georgi Kirichkov ca01d2c5e2 Code style changes 2021-05-11 11:44:39 +02:00
Georgi Kirichkov 5ae0ef4f41 Sets card->name for IDPrime v3 and v4 cards 2021-05-11 11:44:39 +02:00
Georgi Kirichkov 072c64aaed Adds Gemalto IDPrime v4 2021-05-11 11:44:39 +02:00
Alon Bar-Lev 35a8a1d7e1 pkcs11.h: avoid C++ comments 2021-05-07 23:59:12 +02:00
Ludovic Rousseau 2ea5ed8ddd Fix 'make check' when make --jobs= is used
The error was:
PASS: test-duplicate-symbols.sh
PASS: test-pkcs11-tool-allowed-mechanisms.sh
XFAIL: test-pkcs11-tool-test.sh
XFAIL: test-pkcs11-tool-test-threads.sh
PASS: test-manpage.sh
FAIL: test-pkcs11-tool-sign-verify.sh
============================================================================
Testsuite summary for OpenSC 0.22.0-rc1
============================================================================
============================================================================
See tests/test-suite.log
Please report to https://github.com/OpenSC/OpenSC/issues
============================================================================

This is because more than 1 test is executed at the same time. So
card_cleanup() is called at the end of one test while another test is
still running.
The problem is easy to replicate using "make --jobs=2".
2021-05-06 15:05:15 +02:00
Jakub Jelen 2f145f5804 Workaround for broken Ubuntu Focal images
https://travis-ci.community/t/clang-10-was-recently-broken-on-linux-unmet-dependencies-for-clang-10-clang-tidy-10-valgrind/11527
2021-05-06 15:02:45 +02:00
Jakub Jelen 613b56ee55 Add correct prefix on the clang-tidy commandline 2021-05-05 14:22:58 +02:00
Jakub Jelen d0b847c6cf tests: Remove files after disclean 2021-05-05 14:22:58 +02:00
Jakub Jelen 835cee2e5a tests: Add correct path to enable out-of-source build 2021-05-05 14:22:58 +02:00
Jakub Jelen 06ac408bb4 travis: Invoke distcheck to make sure all needed files are packaged 2021-05-05 14:22:58 +02:00
divinehawk 98663528cf pkcs15-tool: Write data objects in binary mode 2021-05-03 11:48:28 +02:00
ihsinme 50eaa6bf57 fix possible access outside the array.
if 5000 bytes are read, then at the end of the array we will write zero beyond its boundaries, damaging the stack.
Here's a simple solution. if you see the need to increase the array itself, let me know.
2021-05-03 11:47:51 +02:00
Frank Morgner 32004e74ce added missing files to distribution 2021-05-01 01:42:11 +02:00
Anton Logachev 570fc56c47 Remove the SC_SEC_ENV_FILE_REF_PRESENT flag for Rutoken ECP cards
Rutoken ECP cards have no default SE file. Previous cards ignored
MSE with restoring default SE, but new cards don't. This requires
SC_SEC_ENV_FILE_REF_PRESENT to be removed from env flags.
2021-04-29 23:03:32 +02:00
Doug Engert 19611682bd Fix for #2283 C_Sign fails ECDSA when card can do HASH on card
Do not truncate ECDSA input to size of key if card or driver will do HASH.

 On branch Fix_for_2283_ECDSA
 Changes to be committed:
	modified:   src/libopensc/pkcs15-sec.c
2021-04-27 10:50:00 +02:00
Vincent JARDIN a21bcf4b41 IASECC/Gemalto: register application
Register application for Gemalto Dual ID ONE Cosmo.
2021-04-26 21:37:39 +02:00
Vincent JARDIN e93bd3983c IASECC/Gemalto: add support
Add support for Gemalto's IAS ECC Dual ID One Cosmo using samples from:
  http://cartesapuce-discount.com/fr/cartes-a-puce-ias-ecc/146-cartes-a-puce-protiva-ias-ecc-tpc.html

Some suppots were already available (ATR, init, etc.), but the
select_file was missing the proper cases.
2021-04-26 21:37:39 +02:00
Frank Morgner 3f19991556 updated NEWS 2021-04-26 18:13:43 +02:00
Frank Morgner 4ecb4b39ac updated documentation 2021-04-26 18:13:43 +02:00
Frank Morgner 75f24d2af7 regenerated egk-tool cmdline 2021-04-26 18:13:43 +02:00
Frank Morgner 2063a1d334 silince generation of files 2021-04-26 18:13:43 +02:00
Vincent JARDIN e3a3722ad1 IASECC/CPX: Fix SDO path
Some objects need to be read from a specific path.

IASECC_SDO_PRVKEY_TAG: from 3F00:0001
IASECC_SDO_CHV_TAG: from 3F00
2021-04-26 15:55:17 +02:00
Vincent JARDIN fcd2e665fe IASECC/CPX: fix APDU errors for SE get data
On a CPX, this object needs to be read from 3F00.

For instance:

$ opensc-explorer -r 2

OpenSC [3F00]> cd 0002
OpenSC [3F00/0002]> apdu 00 CB 3F FF 0A 4D 08 70 06 BF FB 05 02 7B 80
Sending: 00 CB 3F FF 0A 4D 08 70 06 BF FB 05 02 7B 80
Received (SW1=0x6A, SW2=0x88)
Failure: Data object not found

OpenSC [3F00/0002]> apdu 00 A4 09 04 02 3F 00
Sending: 00 A4 09 04 02 3F 00
Received (SW1=0x90, SW2=0x00)
Success!

OpenSC [3F00/0002]> apdu 00 CB 3F FF 0A 4D 08 70 06 BF FB 05 02 7B 80
Sending: 00 CB 3F FF 0A 4D 08 70 06 BF FB 05 02 7B 80
Received (SW1=0x90, SW2=0x00)
Success!

Currently, this patch limits to the CPX cards since I cannot know
the behaviour for the other cards. I could not find any reference
from the standard.

Fix: issue #2275
2021-04-26 15:55:17 +02:00
Vincent JARDIN 405ecfc402 IASECC: proper pkcs15init of Algo_refs
For some Private RSA Keys, their Algo_refs remain empty:
$ pkcs15-tool -k --verify-pin  --pin 1234
Using reader with a card: ACS ACR33U-A1 3SAM ICC Reader 00 00
Private RSA Key [CPS_PRIV_SIG]
	Object Flags   : [0x01], private
	Usage          : [0x200], nonRepudiation
	Access Flags   : [0x0D], sensitive, alwaysSensitive, neverExtract
	Algo_refs      : 0
	Access Rules   : pso_cds:01;
	ModLength      : 2048
	Key ref        : 129 (0x81)
	Native         : yes
	Path           : e828bd080f8025000001ff0010::
	Auth ID        : 01
	ID             : e828bd080f8025000001ff001001
	MD:guid        : e7aab727-f2af-e673-37bb-7d43867a6349

Private RSA Key [CPS_PRIV_AUT]
	Object Flags   : [0x07], private, modifiable
	Usage          : [0x06], decrypt, sign
	Access Flags   : [0x0D], sensitive, alwaysSensitive, neverExtract
	Algo_refs      : 6, 3, 4
	Access Rules   : pso_decrypt:01; int_auth:01;
	ModLength      : 2048
	Key ref        : 130 (0x82)
	Native         : yes
	Path           : e828bd080f8025000001ff0010::
	Auth ID        : 01
	ID             : e828bd080f8025000001ff001002
	MD:guid        : 2b6bf284-225c-80bc-8cbe-1c791db33543

Based on Usage : [0x200], nonRepudiation the SC_PKCS15_PRKEY_USAGE_NONREPUDIATION
may be set but not the SC_PKCS15_PRKEY_USAGE_SIGN so line 801 is never tested.

Having just SC_PKCS15_PRKEY_USAGE_NONREPUDIATION set and not doing anything does not
make any sense for any card.

Suggested-by: Doug Engert <deengert@gmail.com>
Fix: issue #2270
2021-04-26 15:52:09 +02:00
Vincent JARDIN 544aa4cc6b IASECC/CPX: Fix up prkeyinfo/algo_ref
Extend the current support from 9abf8ee04c
in order to add a fixup for the CPx cards.

Since the data is not properly encoded when the card is initialized
let's re-build it for each run time from the DF.

Suggested-by: Doug Engert <deengert@gmail.com>
Fix: issue #2270
2021-04-26 15:52:09 +02:00
Vincent JARDIN 137286858f IASECC/CPX: enable calls thru pkcs15-iasecc.c
Same than Gemalto's IASECC, the CPX cards need a workaround since
the PrKey does not have its Algo_regs.

We get:
pkcs15-tool -k --verify-pin --pin 1234
Using reader with a card: ACS ACR33U-A1 3SAM ICC Reader 00 00
Private RSA Key [CPS_PRIV_SIG]
	Object Flags   : [0x01], private
	Usage          : [0x200], nonRepudiation
	Access Flags   : [0x0D], sensitive, alwaysSensitive, neverExtract
	Algo_refs      : 0
	Access Rules   : pso_cds:01;
	ModLength      : 2048
	Key ref        : 129 (0x81)
	Native         : yes
	Path           : e828bd080f8025000001ff0010::
	Auth ID        : 01
	ID             : e828bd080f8025000001ff001001
	MD:guid        : e7aab727-f2af-e673-37bb-7d43867a6349

Private RSA Key [CPS_PRIV_AUT]
	Object Flags   : [0x07], private, modifiable
	Usage          : [0x06], decrypt, sign
	Access Flags   : [0x0D], sensitive, alwaysSensitive, neverExtract
	Algo_refs      : 0
	Access Rules   : pso_decrypt:01; int_auth:01;
	ModLength      : 2048
	Key ref        : 130 (0x82)
	Native         : yes
	Path           : e828bd080f8025000001ff0010::
	Auth ID        : 01
	ID             : e828bd080f8025000001ff001002
	MD:guid        : 2b6bf284-225c-80bc-8cbe-1c791db33543

We need to get Algo_regs to be set to something that is not 0.

Fix: issue #2267
2021-04-26 15:52:09 +02:00
Vincent JARDIN 39b4472f38 IASECC/CPX: export pkcs15init for missing features
Some cards, such as the CPX are missing features that should
have been initialized using:
  iasecc_pkcs15_encode_supported_algos()

Let's export this function in order to build a fixup when the DF
should be parsed.

When OPENSSL is missing, an error should be rised since this
workaround for the CPX cards cannot work. It means that
any environments that use the CPX cards must be compiled with
ENABLE_OPENSSL.

Suggested-by: Doug Engert <deengert@gmail.com>
Fix: issue #2270
2021-04-26 15:52:09 +02:00
Vincent JARDIN 396cbc46cf IASECC/CPX: set default flags
The CPX has the standard capabilities of the IASECC standard.

Let's be carefull with memory leakage, see the
previous commit 83162c5c8

Fix: issue #2270
2021-04-26 15:52:09 +02:00
Frank Morgner 4912f05701 use OpenPACE 1.1.1 2021-04-25 12:03:52 +02:00
Peter Marschall 344ac0abe6 iasec: use proper printf format specifiers for size_t
Do not hard-code the printf format specifier for size_t: use the macro instead.

This fixes compliation on 32-bit architectures.
2021-04-20 14:26:37 +02:00
Jakub Jelen d6ec00c870 cardos: Add ATR for CardOS 5.4
Hopefully fixes #2296
2021-04-15 17:59:31 +02:00
Peter Popovec dd48facd38 travis CI: testsuite fix (tests/test-pkcs11-tool-allowed-mechanisms.sh)
Ubuntu (focal) softhsm2 workaround - mechanism listing incorrect
2021-04-14 11:02:58 +02:00
Peter Popovec 7d274a0d72 travis-ci: Try to run the tests on Ubuntu 20 (Focal Fossa) 2021-04-14 11:02:58 +02:00
Jakub Jelen ef17b3fb89 tests: Fix comparison for osx 2021-04-13 21:58:47 +02:00
Jakub Jelen cae5c71f90 oberthur: Handle 1B OIDs
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32807
2021-04-13 21:58:47 +02:00
Jakub Jelen 4b3c6dec07 .travis: Fail if tests fail 2021-04-13 21:58:47 +02:00
Frank Morgner 991bb8a141 add CPDK include flags 2021-04-08 15:15:46 +02:00
Frank Morgner a83069b89f updated to Microsoft Cryptographic Provider Development Kit (CPDK) Version 8.0 2021-04-08 11:25:08 +02:00
Carsten Blüggel edb7ed25e4 pkcs11-tool: disable wrap/unwrap test until OpenSC#1796 is resolved 2021-04-07 10:25:54 +02:00
Frank Morgner 545e47b29e preparation for 0.22.0 2021-04-06 13:42:50 +02:00
Vincent JARDIN 1a3666364d IASECC/CPX: Avoid APDU Incorrect Parameters
Without this patch, we would get from the logs:
Outgoing APDU (18 bytes):
00 A4 04 00 0D E8 28 BD 08 0F 80 25 00 00 01 FF ......(....%....
00 10                                           ..
 [opensc-pkcs11] reader-pcsc.c:242:pcsc_internal_transmit: called
 [opensc-pkcs11] reader-pcsc.c:333:pcsc_transmit:
Incoming APDU (2 bytes):
6A 86 j.
 [opensc-pkcs11] apdu.c:382:sc_single_transmit: returning with: 0 (Success)
 [opensc-pkcs11] apdu.c:537:sc_transmit: returning with: 0 (Success)
 [opensc-pkcs11] card.c:523:sc_unlock: called
 [opensc-pkcs11] iso7816.c:128:iso7816_check_sw: Incorrect parameters P1-P2
 [opensc-pkcs11] card-iasecc.c:1064:iasecc_select_file: Warning: SC_ERROR_INCORRECT_PARAMETERS for SC_PATH_TYPE_DF_NAME, try again with P2=0x0C
 [opensc-pkcs11] apdu.c:548:sc_transmit_apdu: called
 [opensc-pkcs11] card.c:473:sc_lock: called
 [opensc-pkcs11] card.c:513:sc_lock: returning with: 0 (Success)
 [opensc-pkcs11] apdu.c:515:sc_transmit: called
 [opensc-pkcs11] apdu.c:363:sc_single_transmit: called
 [opensc-pkcs11] apdu.c:367:sc_single_transmit: CLA:0, INS:A4, P1:4, P2:C, data(13) 0x7fff4b339b20
 [opensc-pkcs11] reader-pcsc.c:323:pcsc_transmit: reader 'Ingenico TL TELIUM (25005334) 00 02'
 [opensc-pkcs11] reader-pcsc.c:324:pcsc_transmit:
Outgoing APDU (18 bytes):
00 A4 04 0C 0D E8 28 BD 08 0F 80 25 00 00 01 FF ......(....%....
00 10                                           ..
 [opensc-pkcs11] reader-pcsc.c:242:pcsc_internal_transmit: called
 [opensc-pkcs11] reader-pcsc.c:333:pcsc_transmit:
Incoming APDU (2 bytes):
90 00 ..

Let's align it with the behaviour of the other IASECC cards.
2021-04-01 11:11:33 +02:00
Vincent JARDIN 0df0f80b55 IASECC: log any APDU Incorrect parameters
From the logs, we can detect many 6A 86 (Incorrect P1 or P2 paremeters).
A deeper analysis will be required, but the best option to check them
is to start emitting any Warning for such events.
2021-04-01 11:11:33 +02:00
Philip Prindeville b9c0addf88 update configure.ac to be less noisy
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-01 11:09:22 +02:00
yehj c3c5f2d518 Add criteria to check if card capability SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH is available
The code segment checks the response to determine if the
SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH is available.
From the APDU manual of the sc-hsm, there's one status word:
SC_ERROR_REF_DATA_NOT_USABLE(0x6984) that should also be taken into account.
2021-04-01 10:29:33 +02:00
Frank Morgner 83162c5c87 fixed memory leak
fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32324

sc_enum_apps() causes card->cache.current_ef to be allocated for
IAS/ECC, but not freed if any other error occurs during initialization.
since sc_enum_apps() is called anyway during PKCS#15 initialization.
Having this at the card driver level (instead of the PKCS#15 level) is
not needed.
2021-03-24 23:27:01 +01:00
Frank Morgner ce0d409205 Avoid accessing Uninitialized scalar variable
regression of c581d1b26

coverity scan CID 367545
2021-03-24 23:27:01 +01:00
Jakub Jelen 7114fb71b5 coolkey: Initialize potentially uninitialized memory
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28855
2021-03-24 16:25:08 +01:00
Jakub Jelen 9cc942fd47 framework-pkcs15: Fix PKCS#11 semantics while encoding EC pubkey params 2021-03-24 16:25:08 +01:00
Jakub Jelen 7d0abdc192 p11test: Remove unnecessary spaces in JSON output 2021-03-24 16:25:08 +01:00
Jakub Jelen 370eda4bd8 framework-pkcs15: Avoid strict aliasing issues 2021-03-24 16:25:08 +01:00
Frank Morgner 5f9085fedb
Merge pull request #1960 from Jakuje/eddsa
Add support for (X)EdDSA keys in OpenPGP driver
2021-03-22 15:36:59 +01:00
Marco Trevisan (Treviño) 845eac4250 pkcs11-global: Obey to the tokenPresent parameter on C_GetSlotList
Since commit dba0f56 the tokenPresent parameter is ignored in case the
slot has been already seen.

This breaks the API expectations as we may return a slot that has no
token inserted.

So, only consider the SC_PKCS11_SLOT_FLAG_SEEN if tokenPresent is false
2021-03-22 15:35:55 +01:00
Vincent JARDIN 40e9a9c830 pkcs15: log HSM capabilities (can_do)
Some Smartcards have some capabilities (for instance the IASECC)
that can influence the can_do cases. In order to track them, it
is useful to log any checks.
2021-03-22 13:15:12 +01:00
Vincent JARDIN b18234a7d9
iasecc: Fix ACLs support when length is 6 (#2264)
* IASECC: offset is a size_t

Let's use a size_t for the offset in order to have a proper logic
along with the related arithmetics.

Fix: part if issue #2262
Suggested-by: Frank Morgner <frankmorgner@gmail.com>

* iasecc: Fix ACLs support when length is 6

ACLs with length < 6 are allowed, depending on the mask of the offset 0.
For instance, when the offset 0 is 0x7B, then length can be up to 7
when the offset 0 is 0x7A, the loop was never performing any access to
the acls[7] thanks to:
  if (!(mask & acls[0]))
    continue;

However, the oss-fuzz tools cannot guess such behavior. So let's have a
robust boundary check.

Fix: issue #2262
Fix: ae1cf0be90 'Prevent stack buffer overflow when empty ACL is returned'

Co-authored-by: Vincent JARDIN <vjardin@free.fr>
Co-authored-by: Frank Morgner <frankmorgner@gmail.com>
2021-03-22 13:08:28 +01:00
Jakub Jelen 5d4daf6c92 oberthur: One more overlooked buffer overflow
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32202
2021-03-21 09:53:13 +01:00
Jakub Jelen 715c17c469 oberthur: Fix memory leaks
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32149
2021-03-18 13:18:10 +01:00
Jakub Jelen d5dea2dd1b tests: Investigate test failure on bionic 2021-03-18 09:58:21 +01:00
Jakub Jelen 16b7c60fd3 Fix more issues with strict aliasing reported by gcc v8
Thanks popoves for reporting this issue
2021-03-18 09:58:21 +01:00
Frank Morgner 05648b0604 oberthur: fixed Heap-buffer-overflow
fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32149
2021-03-18 09:56:46 +01:00
Vincent JARDIN fc0df4e5d5 IASECC/CPX: revert removal of 3F00 from the path
Few years ago, the commit 03628449b7
did squash the 3F00nnnn path to nnnn. For instance, 3F002F00
becomes 2F00. It is an issue such as:
  00000200 [139681798813440] APDU: 00 A4 09 04 02 2F 00
  00029790 [139681798813440] SW: 6A 82

Fix: issue #2231
2021-03-17 10:58:20 +01:00
Vincent JARDIN 76507508d7 IASECC/CPX: code factorization
There are two flavours of CPX cards:
  - contact mode,
  - contactless mode
2021-03-17 10:58:20 +01:00
Vincent JARDIN 4119b2c3e7 ASN1 lax bit string decoding
Some ASN1 objects stored on some smartcards (for instance the
IASECC/CPX ones) do not comply strictly with the rules
8.6.2.3 and 8.6.2.3 from the ITU.

Since these rules are not some strict ones, let's have a loose
decoding option that can be displayed by the command:
opensc-explorer
  asn1 7001 # for instance

Fix: issue #2224
2021-03-17 10:58:20 +01:00
Vincent JARDIN b508349010 IASECC/CPX: opensc-explorer asn1 EF.ATR parsing
Let's the advance users be able to parse the ASN1 contant
for any offset.

OpenSC [3F00]> asn1 2F01 0
Error in decoding.
OpenSC [3F00]> asn1 2F01 1
43 Application 3  (1 byte): decode error, : B8 .
46 Application 6  (4 bytes): decode error: 04 B0 EC C1 ....
47 Application 7  (3 bytes): 94 01 80 ...
4F Application 15 (8 bytes): 80 25 00 00 01 FF 01 00 .%......
E0 Private 0  (16 bytes)
   02 INTEGER (2 bytes): 260
   02 INTEGER (2 bytes): 260
   02 INTEGER (2 bytes): 256
   02 INTEGER (2 bytes): 256
78 Application 24 (8 bytes)
   06 OBJECT IDENTIFIER (6 bytes):  1.3.162.15480.2
82 Context 2  (2 bytes): 36864: 90 00 ..

Fix: issue #2220
2021-03-17 10:58:20 +01:00
Vincent JARDIN 20f359ea04 IASECC/CPX: SC_PATH_TYPE_FILE_ID, wrong APDU
For SC_PATH_TYPE_FILE_ID, P2 should be 0x04, if not,
then we get the following errors:
 [opensc-pkcs11] reader-pcsc.c:324:pcsc_transmit:
Outgoing APDU (7 bytes):
00 A4 02 00 02 A0 01 .......
 [opensc-pkcs11] reader-pcsc.c:242:pcsc_internal_transmit: called
 [opensc-pkcs11] reader-pcsc.c:333:pcsc_transmit:
Incoming APDU (2 bytes):
6A 86 j.
 [opensc-pkcs11] apdu.c:382:sc_single_transmit: returning with: 0 (Success)
 [opensc-pkcs11] apdu.c:535:sc_transmit: returning with: 0 (Success)
 [opensc-pkcs11] card.c:523:sc_unlock: called
 [opensc-pkcs11] iso7816.c:128:iso7816_check_sw: Incorrect parameters P1-P2
 [opensc-pkcs11] card-iasecc.c:1107:iasecc_select_file: iasecc_select_file() check SW failed: -1205 (Incorrect parameters in APDU)
 [opensc-pkcs11] card.c:866:sc_select_file: 'SELECT' error: -1205 (Incorrect parameters in APDU)

when running:
  ./pkcs11-tool --test --login --pin abcd
2021-03-17 10:58:20 +01:00
Vincent JARDIN c581d1b26f IASECC/CPX: opensc-explorer asn1 of EF.ATR objects
Workaround the parsing of EF.ATR objects, for instance:

./opensc-explorer -r 0

OpenSC [3F00]> cat 2F01
00000000: 80 43 01 B8 46 04 04 B0 EC C1 47 03 94 01 80 4F .C..F.....G....O
00000010: 08 80 25 00 00 01 FF 01 00 E0 10 02 02 01 04 02 ..%.............
00000020: 02 01 04 02 02 01 00 02 02 01 00 78 08 06 06 2B ...........x...+
00000030: 81 22 F8 78 02 82 02 90 00                      .".x.....

OpenSC [3F00]> info 2F01
Working Elementary File  ID 2F01, SFI E8

File path:               3F00/2F01
File size:               57 bytes
EF structure:            Transparent
ACL for READ:            NONE
ACL for UPDATE:          SecOx45
ACL for DELETE:          SecOx45
ACL for WRITE:           N/A
ACL for REHABILITATE:    N/A
ACL for INVALIDATE:      N/A
ACL for LIST FILES:      N/A
ACL for CRYPTO:          N/A
Type attributes:         01
Life cycle:              Operational, activated

In order to avoid adding an offset of 1 for such objects on some
  OpenSC [3F00]> asn1 2F01 1
specific cards, then, we get:

OpenSC [3F00]> asn1 2F01
80 Context 0  (0 bytes)
43 Application 3  (1 byte): decode error: B8 .
46 Application 6  (4 bytes): decode error: 04 B0 EC C1 ....
47 Application 7  (3 bytes): 94 01 80 ...
4F Application 15 (8 bytes): 80 25 00 00 01 FF 01 00 .%......
E0 Private 0  (16 bytes)
   02 INTEGER (2 bytes): 260
   02 INTEGER (2 bytes): 260
   02 INTEGER (2 bytes): 256
   02 INTEGER (2 bytes): 256
78 Application 24 (8 bytes)
   06 OBJECT IDENTIFIER (6 bytes):  1.3.162.15480.2
82 Context 2  (2 bytes): 36864: 90 00 ..
OpenSC [3F00]>

which means:
 ef-atr.c:49:sc_parse_ef_atr_content: EF.ATR: card service 0xB8
 ef-atr.c:59:sc_parse_ef_atr_content: EF.ATR: Pre-Issuing data '04B0ECC1'
 ef-atr.c:67:sc_parse_ef_atr_content: EF.ATR: DF selection 94, unit_size 1, card caps 80
 ef-atr.c:95:sc_parse_ef_atr_content: EF.ATR: AID '8025000001FF0100'
 ef-atr.c:106:sc_parse_ef_atr_content: EF.ATR: Issuer data '02020104020201040202010002020100'
 ef-atr.c:111:sc_parse_ef_atr_content: EF.ATR: DER encoded OID 06062B8122F87802
 ef-atr.c:114:sc_parse_ef_atr_content: EF.ATR: OID 2B8122F87802
 ef-atr.c:123:sc_parse_ef_atr_content: EF.ATR: status word 0x9000

Fix: issue #2220
2021-03-17 10:58:20 +01:00
Vincent JARDIN fd83e885f7 IASECC/CPX: parse EF.ATR from ASN1 2F01 object
2F01 is:
./opensc-explorer -r 0
OpenSC [3F00]> cat 2F01
00000000: 80 43 01 B8 46 04 04 B0 EC C1 47 03 94 01 80 4F .C..F.....G....O
00000010: 08 80 25 00 00 01 FF 01 00 E0 10 02 02 01 04 02 ..%.............
00000020: 02 01 04 02 02 01 00 02 02 01 00 78 08 06 06 2B ...........x...+
00000030: 81 22 F8 78 02 82 02 90 00                      .".x.....

so the ASN1 decoder gets confused because it assumes that two bytes are
needed before getting the first tag 43/ISO7816_TAG_II_CARD_SERVICE.
In order to avoid such confusion, whenever the content of the EF.ATR/2F01 starts
with ISO7816_II_CATEGORY_TLV, we skip the first byte in order to parse
the ASN1 payload.

Fix: issue #2220
2021-03-17 10:58:20 +01:00
Vincent JARDIN 6efd7b3029 IASECC: send/recv from EF.ATR
Log the send/recv data extracted from the EF.ATR (2F01).
2021-03-17 10:58:20 +01:00
Vincent JARDIN 41edcaa413 IASECC/CPX: proper set of RSA support
The previous commit was over simplified. According to the known
mechanism, we should have the following scope:

./pkcs11-tool --module ../lib/onepin-opensc-pkcs11.so -M
Using slot 0 with a present token (0x0)
Supported mechanisms:
  SHA-1, digest
  SHA224, digest
  SHA256, digest
  SHA384, digest
  SHA512, digest
  MD5, digest
  RIPEMD160, digest
  GOSTR3411, digest
  RSA-X-509, keySize={512,2048}, hw, decrypt, sign, verify
  RSA-PKCS, keySize={512,2048}, hw, decrypt, sign, verify
  SHA1-RSA-PKCS, keySize={512,2048}, sign, verify
  SHA256-RSA-PKCS, keySize={512,2048}, sign, verify
  RSA-PKCS-PSS, keySize={512,2048}, hw, sign, verify
  SHA1-RSA-PKCS-PSS, keySize={512,2048}, sign, verify
  SHA256-RSA-PKCS-PSS, keySize={512,2048}, sign, verify

do not use the default flags yet:
  _sc_card_add_rsa_alg(card, 1024, IASECC_CARD_DEFAULT_FLAGS, 0x10001);
  _sc_card_add_rsa_alg(card, 2048, IASECC_CARD_DEFAULT_FLAGS, 0x10001);
  _sc_card_add_rsa_alg(card, 512, IASECC_CARD_DEFAULT_FLAGS, 0x10001);

Contactless specific behaviour shall be added later on.
2021-03-17 10:58:20 +01:00
Vincent JARDIN 7cd713d15d IASECC/CPX: enable RSA algorithms
Without this fix, we get:
./pkcs11-tool --module ../lib/onepin-opensc-pkcs11.so -M
Using slot 0 with a present token (0x0)
Supported mechanisms:
  SHA-1, digest
  SHA224, digest
  SHA256, digest
  SHA384, digest
  SHA512, digest
  MD5, digest
  RIPEMD160, digest
  GOSTR3411, digest

Once we include it, we get:
./pkcs11-tool --module ../lib/onepin-opensc-pkcs11.so -M
Using slot 0 with a present token (0x0)
Supported mechanisms:
  SHA-1, digest
  SHA224, digest
  SHA256, digest
  SHA384, digest
  SHA512, digest
  MD5, digest
  RIPEMD160, digest
  GOSTR3411, digest
  RSA-9796, keySize={1024,2048}, hw, decrypt, sign, verify
  RSA-PKCS, keySize={1024,2048}, hw, decrypt, sign, verify
  SHA1-RSA-PKCS, keySize={1024,2048}, sign, verify
  SHA256-RSA-PKCS, keySize={1024,2048}, sign, verify
  RSA-PKCS-KEY-PAIR-GEN, keySize={1024,2048}, generate_key_pair
2021-03-17 10:58:20 +01:00
Vincent JARDIN fd97f49a84 IASECC: CPX have 2 applications
There are 2 applications: default one (contact mode) and the contactless
mode.
2021-03-17 10:58:20 +01:00
Vincent JARDIN 560692221b IASECC/CPX: file selection and app enumeration
Thanks to this commit, we get the full support of:
  - ./opensc-explore
    cd 0001
    asn1 2F00
  - ./pkcs11-tool -O
  - etc.
2021-03-17 10:58:20 +01:00
Vincent JARDIN acb8822444 IASECC: Add support for CPx cards
The French CPx Healthcare cards are designed to support the IASECC
standard.
2021-03-17 10:58:20 +01:00
Jakub Jelen 40c50a3a42 oberthur: Handle more memory issues during initialization
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31540
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31448
2021-03-16 12:02:05 +01:00
Frank Morgner 4512676795 Nightly: in case of conflicts, add "our" changes on top 2021-03-16 11:49:02 +01:00
Frank Morgner 26fac9592d macos: add a tokend postfix for dmg 2021-03-16 11:49:02 +01:00
Raul Metsma b9080c16d6 Make sure that we build always x86_64 openssl on macOS
Signed-off-by: Raul Metsma <raul@metsma.ee>
2021-03-16 11:49:02 +01:00
Frank Morgner aae9254018 Fixed syntax error 2021-03-16 11:49:02 +01:00
Raul Metsma 578128e464 Fix build on travis and with CryptoTokenKit enabled 2021-03-16 11:49:02 +01:00
Frank Morgner 1325d5c333 travis: use newer version of xcode for pushed binaries 2021-03-16 11:49:02 +01:00
Raul Metsma 85c5610d39 Build arm64 on macOS with Xcode 12.2
Signed-off-by: Raul Metsma <raul@metsma.ee>
2021-03-16 11:49:02 +01:00
Frank Morgner 63e6683384 mac: use dedicated entitlements for binaries and scripts
fixes the codesigning issue with the unknown blobs in the entitlements

(missing "/" to complete blob)
2021-03-16 11:49:02 +01:00
Peter Popovec f46b617397 Skip authentication if card access control mechanism is not active.
Depending on the "lifecycle" of the file, we may omit the authentication
operation.  Typically if the card is in initialization or creation state,
the access control mechanism is inactive.  If authentification can be
skiped, the card driver is responsible for setting the "acl_inactive"
variable in sc_file structure.
2021-03-16 10:57:05 +01:00
Frank Morgner 8e614bfe6e Nightly: unencrypt only if encrypted key is in available 2021-03-15 14:16:12 +01:00
Jakub Jelen 8d61d0d20d Use more portable switch for uniq to unbreak osx build 2021-03-15 09:33:55 +01:00
Jakub Jelen 1ef79e99f7 reader-pcsc: Avoid strict aliasing issues 2021-03-09 23:59:58 +01:00
Jakub Jelen 60632100a0 pkcs11: Avoid redefinition of ck_interface (#2243) 2021-03-09 23:59:58 +01:00
Jakub Jelen 63031b2193 pkcs11-tool: Avoid strict-aliasing issues on 32b architectures 2021-03-09 23:59:58 +01:00
Jakub Jelen 544dcc6827 configure: Warn about strict alliasing issues in strict builds 2021-03-09 23:59:58 +01:00
Jakub Jelen 2fa6700599 Remove more issues with strict aliasing
These would demonstrate with gcc11 and can be detected with gcc
flag -Wstrict-aliasing=2 (also with older gcc)
2021-03-09 23:59:58 +01:00
Jakub Jelen 45e262f537 westcos: Avoid strict aliasing violations 2021-03-09 23:59:58 +01:00
Jakub Jelen b5f26051bb Fix build on gcc11
This made most of the applications crashing in Fedora 34 when
smart card was plugged in.

The suggested patch makes the code path more obvious for gcc to
handle.

https://bugzilla.redhat.com/show_bug.cgi?id=1930652
2021-03-09 23:59:58 +01:00
Jakub Jelen b8266a4c86 Revert "fixed atrmask for gnuk"
This reverts commit 98beb86a38.
2021-03-01 15:43:28 +01:00
Jakub Jelen 0ce245a411 p11test: Fix one-off comparison 2021-03-01 15:43:28 +01:00
Jakub Jelen 56af7de137 Change (X)EDDSA EC_PARAMS encoding to OID
This is the current interpretation of the specs after talking with
several members of PKCS #11 TC.
2021-03-01 15:43:28 +01:00
Jakub Jelen c39e31b274 pkcs11: Rewrite ec params to use sc_asn1_put_tag() 2021-03-01 15:43:28 +01:00
Jakub Jelen ae771a135f openpgp: Rewrite decipher/derive to use asn1 functions 2021-03-01 15:43:28 +01:00
Jakub Jelen cb8c7647ca asn1: Do not crash on invalid arguments 2021-03-01 15:43:28 +01:00
Jakub Jelen a020b85d94 unittests: Briefly test asn1_encode 2021-03-01 15:43:28 +01:00
Jakub Jelen 73e283b4b1 openpgp: Correctly handle curve25519 keys 2021-03-01 15:43:28 +01:00
Jakub Jelen 64b61a7556 openpgp: Do not fail hard if unknown algorithm is encountered and fix typo 2021-03-01 15:43:28 +01:00
Jakub Jelen 9bd139d1e4 openpgp: Check return code of OID decoding from ASN1 2021-03-01 15:43:28 +01:00
Jakub Jelen 8c4d325576 framework-pkcs15: Fix typo in comment 2021-03-01 15:43:28 +01:00
Doug Engert 0380142482 Fix obtaining key_length i.e. field_length pkcs15-openpgp
card-opennpgp.c and pkcs15-openpgp.c have a strang way of
using sc_object_id_t to store what they call a binary_oid
or oid_binary.  It is used to convert the EC curve asn1
returned in the cxdata.

This code uses asn1_decode_object_id to use sc_object_id_t
as used in the rest of the code.

The code and ec_curve tabes in card-openpgp.c where not changed.

pkcs15-openpgp.c was channge si to can use:
algorithm_info = sc_card_find_ec_alg(card, 0, &oid);
to retried the key_length to add to the pubkey and prkey entries.
The EC and EDDSA needs (i.e. field_length)  to run.

 On branch eddsa
 Your branch is up to date with 'Jakuje/eddsa'.

 Changes to be committed:
	modified:   card.c
	modified:   pkcs15-openpgp.c
2021-03-01 15:43:28 +01:00
Jakub Jelen 091b7670eb p11test: Reformat the script and allow running against softhsm ed25519 keys (with few tweaks)
The Ed25519 implementation in SoftHSM is now broken /non-interoperable. After fixing that,
the interoperability tests should work with this script:

 * SoftHSMv2#528: Avoid creating duplicate mechanisms
 * SoftHSMv2#522: Fix advertised min and max mechanism sizes according to final PKCS#11 3.0 specification
 * SoftHSMv2#526: Adjust EDDSA code to return valid EC_PARAMS according to the final PKCS #11 3.0 specification
2021-03-01 15:43:28 +01:00
Jakub Jelen 35cfc291ce pkcs11-tool: Add support for (X)EDDSA key generation 2021-03-01 15:43:24 +01:00
Jakub Jelen 485b6cff44 p11test: Add support for EdDSA keys 2021-03-01 15:42:29 +01:00
Jakub Jelen 32ec1f92b9 openpgp: Set reasonable usage for (X)EdDSA keys 2021-03-01 15:42:29 +01:00
Jakub Jelen e7d390f9dd openpgp: Unbreak EC algorithms for GNUK
Since 09a594d bringing ECC support to openPGP card, it did not count
with GNUK. This adds exception for GNUK to unbreak ECC signatures
as GNUK presents BCD version < 3.
2021-03-01 15:42:29 +01:00
Jakub Jelen a965829f52 openpgp: Use only Derive mechanism for curve25519 keys 2021-03-01 15:42:29 +01:00
Jakub Jelen 5d5c391793 opensc-tool: Support for new (X)EdDSA keys 2021-03-01 15:42:29 +01:00
Jakub Jelen 5178e74e1b pkcs11-tool: Support for new (X)EdDSA keys 2021-03-01 15:42:29 +01:00
Jakub Jelen 2fb688683e pkcs15-tool: Support for new (X)EdDSA keys 2021-03-01 15:42:29 +01:00
Jakub Jelen b351bf5ea4 openpgp: Initial support for (X)EdDSA keys 2021-03-01 15:42:29 +01:00
Jakub Jelen caae75758c Add internal support for (X)EdDSA keys 2021-03-01 15:42:26 +01:00
Jakub Jelen 80f80317d1 pkcs11: Add new SHA3 identifiers 2021-03-01 14:35:51 +01:00
Jakub Jelen 095c28e372 pkcs11: Add new (X)EDDSA identifiers 2021-03-01 14:35:51 +01:00
Jakub Jelen 0455a5665e winscard: Add missing constant define 2021-03-01 14:35:51 +01:00
Jakub Jelen c78fa164c9 openpgp-tool: Fix typos OpenGPG -> OpenPGP 2021-03-01 14:35:51 +01:00
Jakub Jelen a30bf95eed openpgp: Fix typo in the card name 2021-03-01 14:35:51 +01:00
Jakub Jelen a5a6757d10 pkcs11-tool: Add CKA_KEY_TYPE attribute for keygen as recommeneded in specification 2021-03-01 14:35:50 +01:00
Jakub Jelen e82f875047 pkcs11-spy: Systematize output of C_GetMechanismInfo 2021-03-01 14:35:50 +01:00
Jakub Jelen 86e01d7c47 pkcs11: Prefer CKA_EC_PARAMS over deprecated CKA_ECDSA_PARAMS by listing it first in the list 2021-03-01 14:35:50 +01:00
Jakub Jelen f726d4f201 Improve logging mostly in opengpg 2021-03-01 14:35:50 +01:00
Frank Morgner 5b42a62ec0 use macos' ${Caches} by default 2021-03-01 11:49:14 +01:00
Frank Morgner fe6864c5f3 fixed 354852 Invalid type in argument to printf format specifier 2021-02-25 23:34:57 +01:00
Frank Morgner c2670b0787 fixed 13755 Resource leak
... as reported by coverity scan.

p11cards are freed by emptying the virtual slots. virtual slots are
creatd with the framework's create_tokens. Hence, we need to free
p11card if no tokens were created.
2021-02-25 23:34:57 +01:00
Frank Morgner 881dca94ef avoid memory leak when creating pkcs#15 files 2021-02-25 23:34:57 +01:00
Frank Morgner d353a46d04 tcos: fixed memcpy with 0 or less bytes 2021-02-25 23:34:57 +01:00
Peter Popovec 6738d456ac ECDSA verify
Added support for raw ECDSA verify.
2021-02-25 18:37:18 +01:00
Frank Morgner 999874fb1c fixed potential memory issue
closes https://github.com/OpenSC/OpenSC/pull/2230
2021-02-25 18:36:39 +01:00
Luka Logar c80375eb4c Minidriver RSA-PSS signing not working
I am using a somewhat modified version of IsoApplet. Up till now it worked fine. However recently I stumbled upon a web site that
forces a client cert auth with RSA-PSS. And (at least on windows, using minidriver) it didn't work. It looks to me, that it's a bug
in the PSS support code in minidriver, as I cannot find any place where a MGF1 padding scheme is specified. And since none is specified
signing fails. This patch fixes this. It assumes, that the same hash is used for hashing and padding.
2021-02-25 18:35:57 +01:00
Frank Morgner a322c95d35 mac: disable binary verification
fixes https://github.com/OpenSC/OpenSC/issues/2194
2021-02-25 18:35:10 +01:00
Jakub Jelen 5f7c91e54f pkcs15-isoApplet: Avoid uninitialized reads
Thanks coverity

CID 365817
2021-02-25 09:08:52 +01:00
Jakub Jelen 46cfe89b3c pkcs15-iasecc: Avoid memory leak
Thanks coverity

CID 365818
2021-02-25 09:08:52 +01:00
Jakub Jelen a567ab9dca p11test: Fix possible resource leak
Thanks coverity

CID 365819
2021-02-25 09:08:52 +01:00
Jakub Jelen cee431a3ce pkcs15-iasecc: Check return value as in other cases
Thanks coverity

CID 365820
2021-02-25 09:08:52 +01:00
Jakub Jelen ffed34663d sm-global-platform: Fix possible memory leak
Thanks coverity

CID 365821
2021-02-25 09:08:52 +01:00
Jakub Jelen 3b556ef618 sm-cwa14890: Fix resource leak
CID 365822

Thanks oss-fuzz
2021-02-25 09:08:52 +01:00
Jakub Jelen 1dbe4b5a5b isoApplet: Prevent reading uninitialized values
CID 365823

Thanks coverity
2021-02-25 09:08:52 +01:00
Jakub Jelen 2f232f217b pkcs11-tool: Avoid double free and check allocation
366349 Double free

Thanks coverity
2021-02-25 09:08:52 +01:00
Jakub Jelen ae1cf0be90 iasecc: Prevent stack buffer overflow when empty ACL is returned
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30800
2021-02-25 09:08:52 +01:00
Jakub Jelen 1252aca9f1 cardos: Correctly calculate the left bytes to avoid buffer overrun
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29912
2021-02-25 09:08:52 +01:00
Jakub Jelen 17d8980cde oberthur: Avoid two buffer overflows
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30112
2021-02-25 09:08:52 +01:00
Jakub Jelen 9c91a4327e oberthur: Free another read data on failure paths 2021-02-25 09:08:52 +01:00
Jakub Jelen 7ba89daae6 apdu: Do not insert delay while fuzzing
This was timeout after 60 seconds. After skipping this call, we
get down to 1 s for the same input

Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27423
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
alt3r 3go 3044557299 openpgp: fix DO deletion
This fixes a problem reported in Nitrokey forum at

https://support.nitrokey.com/t/veracrypt-encryption-with-nitrokey-error/2872

as inability to save the VeraCrypt's keyfile onto the token
after deleting an existing one, unless the PKCS11 is reinitialized.

Reason: commit cbc53b9 "OpenPGP: Support write certificate for Gnuk"
introduced a condition on getting the blob handle, which is surplus
(the pgp_find_blob() function actually does that) and prevents
the blob refresh upon deletion, breaking the logic introduced
earlier in commit 9e04ae4 and causing the higher-level effect reported.

While at it, corrected comments to actually reflect the flow logic.

Tested on Fedora 33 using the repro steps from the forum and Nitrokey Pro.

Signed-off-by: alt3r 3go <alt3r.3go@protonmail.com>
2021-02-16 13:07:19 +01:00
ihsinme 6372adeb20 Update card-oberthur.c 2021-02-11 12:32:19 +01:00
ihsinme 0a3d7a28a7 Update card-epass2003.c 2021-02-11 12:32:19 +01:00
Zhang Xiaohui 49788678fe Small memory leak fix 2021-02-10 09:26:37 +01:00
Zhang Xiaohui 1c4a01d766 Small memory leak fix 2021-02-10 09:26:11 +01:00
Vincent JARDIN 66e5600b27 IASECC: log AID selection
Record the selection of the AID for better debugging
2021-02-05 12:09:20 +01:00
Jakub Jelen 8a6026abf5 Avoid memory leak from profile objects 2021-02-05 00:22:43 +01:00
Jakub Jelen da247384e7 pkcs11: Do not advertize VERIFY flag on the EC derive mechanisms
Amends 285db1ef
2021-02-05 00:22:43 +01:00
Jakub Jelen 176b20f339 pkcs11-tool: Display additional EC mechanism flags 2021-02-05 00:22:43 +01:00
Jakub Jelen cb074c5fa0 pkcs11: Add new mechanism flags from EC curves from current PKCS #11 3.0 2021-02-05 00:22:43 +01:00
Jakub Jelen 5633129bd8 p11test: Add CKM_ECDSA_SHA224 2021-02-05 00:22:43 +01:00
Jakub Jelen 0d693f63cb pkcs11-spy: Fix behavior of PKCS#11 3.0 applications when proxying PKCS#11 2.x module
Fixes #2204
2021-01-26 13:52:23 +01:00
Doug Engert b5ddaf6e02 Add tests of pkcs11-tool --test-threads
These should run when a PR is submitted.

 Changes to be committed:
	modified:   tests/Makefile.am
	new file:   tests/test-pkcs11-tool-test-threads.sh
2021-01-26 12:50:39 +01:00
Doug Engert f704e4f23e Pkcs11-tool changes to test a modules ability to use threads
Option --use-locking has C_Initialize pass in parameters with the
CKF_OS_LOCKING_OK to tell module to use threads. The default is it passes NULL
which says threads are not needed.

The following is not designed to be used by the general user. There are for debugging
and test scripts and only compiled if the system has threads.

    Option --test-threads <arg> can be passed multiple times. Each one starts a thread.
    <arg> is a list of 2 byte commands seperated by ":". The thread will execute these.
    Current commands are:
       IN - C_Initialize(NULL)
       IL - C_Initialize with CKF_OS_LOCKING_OK
       Pn - Pause for n seconds
       GI - C_GetInfo
       SL - C_GetSlotList
       Tn - C_GetTokenInfo  from slot_index n

These are just enough calls to see if threads are working in the module.
Output is written to stderr.

 Changes to be committed:
	modified:   doc/tools/pkcs11-tool.1.xml
	modified:   src/tools/Makefile.am
	modified:   src/tools/pkcs11-tool.c
2021-01-26 12:50:39 +01:00
Doug Engert 1b4e9f1d4a C_Initialize may be called by multiple threads
While trying to setup an OpenSC context, the global_locking
and detect cards, it is possible that multiple threads may
call C_Initialize. The current code tries to prevent this using
"if (context == NULL)"  but this is not a mutex, and
multiple threads may endup overwrite contexts and global locking and
cause additional problems, with pcsc and segfault.

FireFox appears to do this see #2032

The PR adds a mutex or Critical section to make sure only one
thread creates the context sets the global_locking  and does
the initial detect cards, etc.

This allows the global_lock (if requested) to be setup
which is then used for other calls.

All but the first call to C_Initialize will return with CKR_OK,
others will return CKR_CRYPTOKI_ALREADY_INITIALIZED.

 Date:      Mon Jan 11 12:47:12 2021 -0600
 Changes to be committed:
	modified:   src/pkcs11/pkcs11-global.c
2021-01-26 12:50:39 +01:00
Doug Engert d369965a7f pkcs11-tool support key-gen for GENERIC secret key
Fixes #2139

Added code to support  mechanism GENERIC-SECRET-KEY-GEN.

Improved --help  and doc/tools/pkcs11-tool.1.xml because key gen
of symmetric keys pass CKA_VALUE_LEN which is length of key in bytes.

Tested with:

./pkcs11-tool --module /usr/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so \
 --login --label generic-64 --keygen --key-type GENERIC:64 \
 --mechanism GENERIC-SECRET-KEY-GEN

./pkcs11-tool --module /usr/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so --login -O
2021-01-26 12:34:15 +01:00
Jakub Jelen e1c8361ff3 idprime: Create algorithme reference based on the MGF1 flags as the HASH flags are no longer present for RSA-PSS mechanism 2021-01-26 10:53:30 +01:00
Jakub Jelen 44d429c3ad padding: Pass the MGF1 information to the card driver for RSA-PSS mechanism 2021-01-26 10:53:30 +01:00
Jakub Jelen edaf921eb6 idprime: Support V3 key references 2021-01-26 10:53:30 +01:00
Jakub Jelen ac81764308 idprime: Try to use different key_reference for V3 2021-01-26 10:53:30 +01:00
Jakub Jelen a6ed34bbb5 Add support for Gemalto IDPrime OS version 3 (padded pin to 16 bytes with zeroes)
Fixes #2202
2021-01-26 10:53:30 +01:00
Peter Popovec 26adaf519c man page update, info about generating EC keys
modified:   doc/tools/pkcs15-init.1.xml
2021-01-26 10:51:44 +01:00
Peter Popovec a3ca7613cd MyEID: opensc.conf - option to disable PKCS1 padding in card.
config option for MyEID:  "disable_hw_pkcs1_padding"

If user set this option to non zero, OpenSC is forced to calculate padding
in software. This will allow users to use RSA 1024 with SHA512.
2021-01-26 00:27:47 +01:00
Doug Engert 0b0deae4be unused code removed
On branch ECDSA-flags
 Changes to be committed:
	modified:   framework-pkcs15.c
2021-01-24 23:48:00 +01:00
Doug Engert 521d420c42 pkcs11 ECDSA verify need rs converted to sequence
The --signature-format openssl in pkcs11-tool does the correct
operation to convert the OpenSSL formated signature to rs for PKCS11

This commit modifies pkcs11/openssl.c to convert back to sequence
for EVP_VerifyFinal

Without this mod the signature file was passed unmodified to
PKCS11, then to EVP_VerifyFinal but this violates PKCS11 standard.

 On branch ECDSA-flags
 Changes to be committed:
	modified:   openssl.c
2021-01-24 23:48:00 +01:00
Doug Engert 285db1ef29 ECDSA Signatures with hashes
This PR is based on discussion with @popovec in
https://github.com/OpenSC/OpenSC/issues/2181
and https://github.com/OpenSC/OpenSC/pull/2187
which was cherry-picked as 5e5300816c8

This has been tested with PIV, MyEID and Smartcard-HSM.
with ECDSA keys.

The main fixes include :
 - Setting "flags" in card drivers
 - added code to sc_pkcs15-compute-signature for handle ECDSA with hashes
 - code in framework-pkcs15.c

Signatures made by pkcs11-tool -sigm verify with openssl
but pkcs11-tool --verify  does not work with ECDSA but does with RSA
I suspect it has to do with:
and some  then creating the wrong PKCS11 mechanisms

It should work with the epass2003 which does hashes in the driver.
2021-01-24 23:48:00 +01:00
Peter Popovec 6049cb926c ECDSA-SHA1: Apply SHA1 to input data before PSO compute signature.
CKM_ECDSA and CKM_ECDSA_SHA1 cannot be registered in the same way.
We need to use sc_pkcs11_register_sign_and_hash_mechanism ()
for CKM_ECDSA_SHA1.

This fix  also enables more ECDSA-SHAxxx mechanisms in framework-pkcs15.c

Tested: MyEID 4.0.1 (secp256r1 with SHA1, SHA224, SHA256, SHA384, SHA512)

CI tests (Travis + OsEID) for ECDSA-SHAxxx mechanisms are also enabled.
2021-01-24 23:48:00 +01:00
Jakub Jelen 5f16ffae84 p11test: Explicitly return in case of SKIP macro is used
Thanks coverity

Fixes CID 365263
2021-01-22 19:07:05 +01:00
Jakub Jelen 03cbf91be5 iasecc: Avoid another memory leak
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29456
2021-01-22 19:07:05 +01:00
Jakub Jelen b820bdf5b3 tcos: Reformat tcos_decipher 2021-01-22 19:07:05 +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
Peter Popovec ba85ae75e3 opensc-explorer, command "info" - added information about LCS
Information about "Life cycle status byte" is now available in listing.
Also src/libopensc/types.h update - added more LCSB definitions.
iso7816_process_fci () update: improved tag 0x8A parsing.

Fixes in card-flex.c and card-miocos.c - SC_FILE_STATUS_xxx is not
bitfield.
2021-01-22 19:04:22 +01:00
Peter Popovec ce7fa42958 Use fresh data from FCI instead of FCP for sc_pkcs15init_authenticate()
Function sc_pkcs15init_update_file(): we will try to select the file, if
file can not be selected, the file is created, and select operation is
repeated. In both cases, the "selected_file" variable contains the current
FCI of the selected file.

Then the sc_pkcs15init_authenticate () function is called, but not with
"selected_file" variable, but "file" variable where the FCP data is present
(from the file creation operation).

Difference between FCP and FCI  (pkcs15-init -C  / MyEID card).
62 17 80 02 00 FF 82 01 01 83 02 50 31 86 03 01 3F FF 85 02 00 00 8A 01 00
6F 17 80 02 00 FF 82 01 01 83 02 50 31 86 03 01 3F FF 85 02 00 00 8A 01 01

Here it is clear that the data from FCP are outdated.  The card changed the
TAG 0x8a from 0 to 1 ("no information given", "creation state".) We need to
respect the authority of the card, FCI is to be used in next code, not FCP.

	modified:   src/pkcs15init/pkcs15-lib.c
2021-01-22 18:59:22 +01:00
Frank Morgner 7a090b994e essentially revert 1bb2547
fixes #2199

returns not allowed PKCS#11 codes to applications, however
2021-01-22 13:19:33 +01:00
Jakub Jelen 219c6cc494 framework-pkcs15: Avoid leaking memory when create object fails 2021-01-11 14:49:22 +01:00
Jakub Jelen 96ae693d5a framework-pkcs15: Return success from __pkcs15_create_object 2021-01-11 14:49:22 +01:00
Jakub Jelen db18a72c64 pkcs11: Implement PKCS #11 3.0 Profile object and its handling in tools 2021-01-11 14:49:22 +01:00
Jakub Jelen 7f9e8ba85c pkcs11-tool: Add option to list PKCS #11 3.0 interfaces 2021-01-11 14:49:22 +01:00
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
Frank Morgner 0e55a3497c fixed date in NEWS 2020-11-20 22:46:30 +01:00
Frank Morgner 96a9fcd628 prepare 0.21.0 2020-11-20 21:08:47 +01:00
Jakub Jelen 412372b024 tcos: Make sure we have at least two bytes to dive into the cycle 2020-11-18 23:02:34 +01:00
Jakub Jelen 65461e4eb5 authentic: Avoid accessing behind buffers
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26900
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26860
2020-11-18 23:02:34 +01:00
Jakub Jelen 445c651549 authentic: Improve debugging logs 2020-11-18 23:02:34 +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
Jakub Jelen 5eccebb4ee pkcs15-cert: Free memory on error
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26145
2020-11-18 23:02:34 +01:00
Jakub Jelen b5b1afe401 tcos: Avoid reading behind the end of allocated buffer
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27480
2020-11-18 23:02:34 +01:00
Jakub Jelen d3451faa21 tcos: Reformat insert_key 2020-11-18 23:02:34 +01:00
Frank Morgner 4554d69119 code signing is not available in pull requests
(since this is untrusted code)
2020-11-18 13:22:10 +01:00
Frank Morgner c4a75eb1c2 updated NEWS file with CVEs 2020-11-12 11:14:17 +01:00
Frank Morgner 3bad4089fd updated key.p12 password 2020-11-12 00:02:44 +01:00
Frank Morgner b145c2c30e added most recent changes to NEWS 2020-11-10 23:33:17 +01:00
Frank Morgner e05574d942 use correct naming scheme for launch agents 2020-11-10 23:23:11 +01:00
Frank Morgner 4d6ed77a4a Prepare macOS binaries for Notarization
- update code signing credentials, thanks to Tim Wilbrink
- split up large files into 50 MB chunks for Nightly to avoid Github's file size limit
- codesign tools/libs with hardened runtime and entitlements
- avoid relocation of app bundles on installation
- sign installer for distribution
2020-11-10 23:23:11 +01:00
Zhang Xiaohui c5508c5eae Add sc_disconnect_card() before exit() and initialize two variables 2020-11-09 10:21:14 +01:00
Zhang Xiaohui e8f27abd02 Add sc_release_context() before exit() 2020-11-09 10:21:14 +01:00
Arya Senna 4cc0d0c7c9 Update upper length for ATR and the comments. 2020-11-04 11:02:56 +01:00
Arya Senna 64de4a5001 Update minidriver.c
Fix check of ATR length for Ledger
2020-11-04 11:02:56 +01:00
Carsten Blüggel 8098b7de61 pkcs11-tool: disable wrap/unwrap test until #1796 is resolved 2020-10-27 11:28:40 +01:00
Frank Morgner c621f39034 pkcs11-register: free up memory before exiting 2020-10-27 09:48:02 +01:00
Jakub Jelen 704afd0e2d cac: Use the specific pin change operation only on HID cards 2020-10-24 21:01:18 +02:00
Jakub Jelen 42254ae792 cac: Support changing PIN with CAC ALT tokens 2020-10-24 21:01:18 +02:00
Jakub Jelen 88f3d19479 opensc: Expose iso7816_build_pin_apdu function to support different pin APDUs 2020-10-24 21:01:18 +02:00
Doug Engert ce28ea8162 PIV global pin bug
Fixes #2141

NIST 800-73-3 based cards only had 2 bits set in first pin policy byte.
NIST 800-73-4 defines additions bits in first pin policy byte.
When one of these bit is set, and the policy prefers the Global pin,
it is not recognized and the local pin is used.

 On branch PIV-global-pin-bug
 Changes to be committed:
	modified:   src/libopensc/card-piv.c
2020-10-24 00:54:55 +02:00
w00475903 26a404d6a5 pkcs15-oberthur.c:remove redundant code
Signed-off-by: whzhe <wanghongzhe@huawei.com>
2020-10-16 14:02:56 +02:00
Zhang Xiaohui 0dc3dcbc00 There may be a memory leak in main in /src/tools/sceac-example.c
When failed to access reader, cxt needs to be released before
exiting the program. Like in the patch of CVE-2019-6502, a
sc_release_context(ctx) is needed before line 71, or a
memory leak may occur.
2020-10-16 14:00:23 +02:00
w00475903 7551e14c58 westcos-tool.c:fix memory leaks in dst->modulus.data and dst->exponent.data
Signed-off-by: whzhe <wanghongzhe@huawei.com>
2020-10-14 23:09:36 +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 2f6ab4c1a2
Prepare RC1 of 0.21.0 (#2117) 2020-10-03 01:11:33 +02:00
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
Alexander 7296210224 Hide private objects only when not logged in 2020-09-28 13:01:15 +02:00
Alexander d85610b29b Fixed issue with C_FindObjectsInit, when CKU_SO does not see private objects, but CKU_USER see them 2020-09-28 13:01:15 +02:00
Conrado P. L. Gouvea 40da5cace2 pkcs11-tool: add --allow-sw flag that removes CKF_HW and allows using software tokens 2020-09-28 12:59:58 +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
Hans-Christoph Steiner 410012f100 add env vars to bash completion for PIN-related options 2020-09-22 22:48:00 +02:00
Hans-Christoph Steiner 644eae691d standardize <replaceable> PIN names in man pages
This makes all PIN-related options use the exact same term throughout the
man pages.
2020-09-22 22:48:00 +02:00
glvnst 16a0aeaa9a * tab to space for safer copy/paste
* add comment labels to steps
* DRY-out lib copy and config file install (one-shot for-loop giving cleaner control flow)
* change mv to cp during config config file install to enable simpler UNIXier mod check in future (diff opensc.conf{,.orig})
* remove refs to man pages during symlink step
* carefully remove the glob character symlinks described in #2092
* shellcheck-recommended quoting
2020-09-22 22:29:50 +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
Ludovic Rousseau 4e0fef0e27
Merge pull request #2101 from marschap/master-spelling
spelling fixes
2020-08-30 14:24:39 +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 8ada99b4d3 Fix spelling error
Thanks to Debian lintian:
I: opensc: typo-in-manual-page usr/share/man/man5/opensc.conf.5.gz
developement development
2020-08-29 23:30:32 +02:00
Ludovic Rousseau 17005c9f14 Fix spelling error
Thanks to Debian lintian:
I: opensc: typo-in-manual-page usr/share/man/man5/opensc.conf.5.gz
"allows to" "allows one to"
2020-08-29 23:28:11 +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
Ludovic Rousseau 7fc00a1178 Fix spelling error
Thanks to Debian lintian:
I: opensc: spelling-error-in-binary usr/bin/netkey-tool conatin contain
I: opensc: spelling-error-in-binary usr/bin/piv-tool conatin contain
2020-08-29 23:17:02 +02:00
Ludovic Rousseau a70b082a09 Fix spelling error
Thanks to Debian lintian:
I: opensc: spelling-error-in-binary usr/bin/egk-tool arguement argument
2020-08-29 23:14:49 +02:00
Peter Marschall 4dbfc77eba opensc-explorer: extend do_asn1() to accept offsets
Have do_asn1() accept an optional parameter indicating an offset.
If this is given then start ASN.1-decoding the file/record at this offset.
2020-08-23 22:46:26 +02:00
Peter Marschall 45e7039940 opensc-explorer: extend do_asn1() to decode records
Have do_asn1() accept an optional parameter indicating a record number.
If this is given and the file is a record-oriented file, then ASN.1-decode
the record requested.
2020-08-23 22:46:26 +02:00
Peter Marschall d345c65a5d opensc-explorer: extend do_cat()
Have do_cat() accept an optional second parameter indicating a record number.
If this is given and the file is a record-oriented file, only print the record
requested.
2020-08-23 22:46:26 +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 ad81126c07
Fix link to virt_cacard project 2020-08-05 09:11:35 +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 2b78374e37 Print error message for the case that a PUK object is not available for a PIN
during an unblock operation (this is a sign of a card with invalid PKCS #15
info). Without this error message the program just terminates silently, which
is confusing to the user.
2020-07-22 22:58:57 +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
Jakub Jelen 054cb08c90
Add CII Best practices badge
this splits also badges to separate lines for simpler diffs. They are still rendered on single line
2020-07-07 12:37:58 +02:00
Jakub Jelen 0defebfe05 doc: Recommend pin caching in combination with pin_cache_ignore_user_consent configuration option 2020-07-03 17:55:24 +02:00
Jakub Jelen 97ec23a2d9 pkcs11: Propagate ignore_user_consent
If user consent is ignored through configuration, do not present
ALWAYS_AUTHENTICATE=TRUE attribute in PKCS#11

Fixes #2039
2020-07-03 17:55:24 +02:00
Raul Metsma 7a29e6c047 Move to macOS Utilities folder
Signed-off-by: Raul Metsma <raul@metsma.ee>
2020-07-03 17:36:49 +02:00
Jakub Jelen c458d81723 SECURITY.md: Introduce security reporting process 2020-07-03 17:32:50 +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
Zoltan Kelemen bf30d64cf9 Fixes build error in opensc-notify (issue #2068). 2020-07-02 13:20:01 +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 e63f054af9
README: Fix pipeline icons from gitlab CI 2020-06-11 11:23:31 +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 c3b9152a99 .travis-ci: Explicitly require new build dependency for yubico-piv-tool 2020-06-09 13:02:27 +02:00
Jakub Jelen 57c895165f .travis-ci: yubico-piv-tool build system was changed to cmake 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
Jakub Jelen b418601942 pkcs11-spy: Dump slot id for C_WaitForSlotEvent 2020-06-09 13:02:27 +02:00
Frank Morgner 36247d85b0 pkcs11: fixed notifying twice in case of an attached reader
before 14e396273 sc_wait_for_event() only notified in case of a new
reader, but didn't add it to the internal list of readers. That's why
PKCS#11 needed to bail out early in this case (and the application had
to call C_WaitForSlotEvent a second time to actually get the related
slot). Since sc_wait_for_event() can now handle insertion correctly, we
can now immediately check (and reset) the events on the slots.
2020-06-09 12:07:04 +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
Frank Morgner 1bb2547abc respect PKCS#11 allowed return values 2020-06-08 14:18:23 +02:00
Luka Logar fc296b5488 IsoApplet: Add some more Travis tests 2020-06-08 14:18:23 +02:00
Frank Morgner 6a6b3e4b62 prevent memory leak 2020-06-08 14:18:23 +02:00
Frank Morgner 58b03b68dd check for unbound cards
closes https://github.com/OpenSC/OpenSC/pull/2045
2020-06-08 14:18:23 +02:00
Luka Logar a10b661f99 IsoApplet: Fix uninitialized public key oid during key generation 2020-06-05 14:48:50 +02:00
Peter Marschall ca5f5c8844 explorer: set stdout to O_BINARY in Windows where needed 2020-06-05 14:48:08 +02:00
Peter Marschall 5714dbfa08 opensc-explorer: add function 'get_record' 2020-06-05 14:48:08 +02:00
Peter Marschall f55c4e5c93 opensc-explorer: extend path_to_filename()
Expect a record number as 3rd parameter:
if this record number is greater than 0, indicating a single record,
then append the record number to the file name being constructed.
2020-06-05 14:48:08 +02:00
Frank Morgner 180c57fd15 fixed compiler warning 2020-06-05 09:43:38 +02:00
Frank Morgner 0f0e0b2e30 prevent out of bounds read
fixes https://oss-fuzz.com/testcase-detail/5769298181357568
2020-06-05 08:31:19 +02:00
Frank Morgner 9d294de90d prevent out of bounds write
fixes https://oss-fuzz.com/testcase-detail/5226571123392512
2020-06-04 10:04:10 +02:00
Frank Morgner 55fd3db2b5 prevent integer underflow and subsequent heap overflow
fixes https://oss-fuzz.com/testcase-detail/5666689944649728
2020-06-04 09:47:22 +02:00
Frank Morgner 4bc03cb55d fixed memory leak
fixes https://oss-fuzz.com/testcase-detail/5113223765557248
2020-06-04 00:13:57 +02:00
Frank Morgner 1125e37738 macOS: include static OpenSSL
fixes https://github.com/OpenSC/OpenSC/issues/1986
2020-06-03 21:52:03 +02:00
Feitian Technologies f334f3eabe
Bug fixed (#1859)
* Bug fixed

1. It solves the problem that can be signed without input PIN, and new code will check the state that the PIN value
2. The algorithm fails to verify sha256, cause signature failure
3. The format of distinguishing ECC and RSA key pair is added - after the key pair is generated successfully, ECC and RSA need to be distinguished when reading the public key. The return format of ECC is different from the RSA
4. Fix ECC information display bug - The problem is using pkcs15-tool -D to print ECC key pair information no display correctly
5. Modify the module attribute of generating ECC key pair, and add 0x04 flag according to pkcs11 standard
2020-06-03 14:54:39 +02:00
Frank Morgner e98f6733d9 workaround for unfinished installer
OpenSCToken currently doesn't install correctly, which is why the
installer script can't register the token plugin. Temporarily disable
this until we can properly install each sub package.
2020-06-02 13:49:40 +02:00
Frank Morgner 141a83029f ignore errors when running `pkgutil --forget` 2020-06-02 13:49:23 +02:00
Frank Morgner d756be1f48 macOS: renew code signing certificate 2020-05-30 16:03:30 +02:00
Frank Morgner 2a1a952fe7 fixed non-origin builds
in clones or local builds, CODE_SIGN_IDENTITY should only be set if
signing with it is possible. If it is not, no signing is performed by
default.
2020-05-30 16:03:30 +02:00
Frank Morgner ceb3448e06 Revert "travis-ci: Do not pass sign arguments if we do not have the secret params in PRs"
This reverts commit 57f538810e.
2020-05-30 16:03:30 +02:00
Jakub Jelen 16456922e2 pkcs11: Return CKR_TOKEN_NOT_RECOGNIZED for not recognized cards
Fixes #2030
2020-05-30 16:00:04 +02:00
Jakub Jelen e8a2644435 Remove duplicate condition
Thanks coverity
2020-05-29 09:57:39 +02:00
Jakub Jelen 38474739b3 card-cardos: Fix NULL dereference
Thanks coverity
2020-05-29 09:57:39 +02:00
Jakub Jelen b02da8348b configure: Do not check for strlcpy and strlcat in Linux.
The check is broken with clang and standard glibc does not have these anyway

And unbreak fuzzer build failure

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22192
2020-05-26 10:03:23 +02:00
Jakub Jelen 741091b3c6 travis-ci: Add clang linux target 2020-05-26 10:03:23 +02:00
Frank Morgner 0a17188710 fixed out of bounds read
fixes https://oss-fuzz.com/testcase-detail/5769032858075136
2020-05-24 23:47:29 +02:00
Piotr Majkrzak d4a9405bf4
Initial support for Polish eID card (e-dowód, eDO) (#2023) 2020-05-19 14:05:13 +02:00
Frank Morgner ed55fcd299 fixed invalid read
fixes https://oss-fuzz.com/testcase-detail/5765246676631552
2020-05-18 17:25:32 +02:00
Frank Morgner 96a7eca99a fixed memory leak
fixes https://oss-fuzz.com/testcase-detail/5633315576217600
2020-05-18 17:13:48 +02:00
Frank Morgner 4cb9788b99 fixed invalid read
fixes https://oss-fuzz.com/testcase-detail/5726023753924608
2020-05-18 16:45:24 +02:00
Frank Morgner 7e1679b2db fixed memory leak
fixes https://oss-fuzz.com/testcase-detail/5675417580339200
2020-05-18 16:38:43 +02:00
Torin Carey 93bed892a8 tests: Fix card present check
Check SC_READER_CARD_PRESENT flag rather than == 1.
Having no card present on the first loop and then inserting a card will
return rc = CARD_PRESENT | CARD_CHANGED (= 3). SEGFAULT ensures when we mistake
the unset opt_reader as having a present card.
2020-05-18 16:30:15 +02:00
Jakub Jelen 57f538810e travis-ci: Do not pass sign arguments if we do not have the secret params in PRs 2020-05-18 16:28:59 +02:00
Jakub Jelen 8175df0e47 Make sure pcscd is started when using emulation
Running from systemd has --auto-exit, which does not guaranee us that
the process is running when we start emulators
2020-05-18 16:28:59 +02:00
Jakub Jelen e1830ea6d2 Install OpenJDK 8 to build jcardsim (it does not work with Java 11) 2020-05-18 16:28:59 +02:00
Jakub Jelen 47a36efa7c travis: Update to something with sensible openssl version to make yubico-piv-tool build 2020-05-18 16:28:59 +02:00
Jakub Jelen 66bcce8a8d travis-ci: Use newer JavaCard SDK to unbreak PivApplet build to enable ECDSA support 2020-05-18 16:28:59 +02:00
Jakub Jelen 687f52233e travis-ci: Fail if any applet or tool needed for tests fails to build
(in our case, it was yubico-piv-tool and PivApplet for some time)
2020-05-18 16:28:59 +02:00
Jakub Jelen 3b3aecbf8c travis: Kill particular pid instead of killall to avoid killing unrelated processes 2020-05-18 16:28:59 +02:00
Jakub Jelen 27a819baa7 framework-pkcs15: Do not leak memory (CID 139147) 2020-05-13 21:54:16 +02:00
Jakub Jelen 19791f63d5 piv: Avoid cast ignoring errors (CID 357984)
Thanks coverity
2020-05-13 21:54:16 +02:00
Jakub Jelen 787c32d195 piv: Avoid cast to unsigned ints to properly check for errors (CID 357985)
Thanks coverity scan
2020-05-13 21:54:16 +02:00
Frank Morgner d8734baf83
Merge pull request #1924 from frankmorgner/recursion
avoid calling sc_*_binary recursively
2020-05-13 00:27:42 +02:00
Doug Engert 4ebb29ce4d card-piv.c error in using sc_asn1-put-tag
In piv_general_mutual_authenticate sc_asn1_put_tag is not used correctly.

 On branch piv-sc_asn1_put_tag-error
 Changes to be committed:
	modified:   card-piv.c
2020-05-13 00:26:18 +02:00
Frank Morgner 4e9cec1a64 fixed missing includes 2020-05-11 18:58:12 +02:00
Frank Morgner a7d563b657
Merge branch 'master' into recursion 2020-05-11 18:45:36 +02:00
Frank Morgner 2495bbecf7 macOS: pass installation if we could not start the background services 2020-05-11 18:41:16 +02:00
Frank Morgner e864aa6d76 macOS: cover minor versions of xcode
uses subshell for getting xcode version
2020-05-11 18:41:16 +02:00
Frank Morgner b08d33ceb6 Travis: seperate installer packages not needed anymore 2020-05-11 18:41:16 +02:00
Frank Morgner 0dcb910289 fixed "libtool: compile: unable to infer tagged configuration" 2020-05-11 18:41:16 +02:00
Frank Morgner 178c4a9eaa fixed checking for strlcat/strlcpy
newer clang uses a definition rather than a function
2020-05-11 18:41:16 +02:00
Frank Morgner e71b85867f macOS: added basic installer signing 2020-05-11 18:41:16 +02:00
Jakub Jelen 3af52cd1c6 tests: Temporarily exclude goid-tool from manpage tests 2020-05-11 08:06:26 +02:00
Frank Morgner c1eda42099 oberthur: fixed current file state handling
fixes https://oss-fuzz.com/testcase-detail/5644083327664128
2020-05-10 01:14:00 +02:00
Frank Morgner 7add7e9ded fixed memory leak
fixes https://oss-fuzz.com/testcase-detail/5738653415636992
2020-05-10 01:01:34 +02:00
Michael Weiser a49a64ec79 unittests: Fix out-of-source build
Commit 4fd34e28ea unintentionally replaced top_builddir with
top_srcdir when refactoring flags variables in Makefile.am. This causes
out-of-source builds to fail.

Restore top_builddir in LDADD.

Also, remove a superfluous -L flag also referencing top_srcdir from
AM_CFLAGS while at it.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>

Closes #2027.
2020-05-10 00:01:27 +02:00
Doug Engert db41cd9ab1 Various CardOS V5_* improvements
Treat CardOS V5_0 and V5_3 cards differently then older versions:

Use card->dvr_data as a pointer to cardos_data_t to store private driver
data to pass internally, especially between set security environment
and the crypto operations. Sc_get_encoding_flags sets sec_flags from
algo_info->flags in pkcs15-sec.c and it passed to decipher.

Some cards when doing a decipher may drop leading 00 byte when
returning data from RSA_RAW decipher. Add leading byte(s) as needed.

Get Cryptographic Mechanism Reference from Key Reference:

Key reference byte appears to be a 4 bit Cryptographic Mechanism Reference
and a 4 bit key reference.

This is only done if key reference & 0xF0 != 0  i.e. default Cryptographic
mechanism reference is 0. which appears to be the case for RSA RAW.
PKCS1 appears to be 0x10 and ECDSA 0x30

    See iso 7816-4 table 55 for DST:
      84 Reference of a private key
      95 Usage qualifier byte - Table 57 - 40 looks OK
      80 Cryptographic mechanism reference and referes to section 9.2

The 4 bit key reference limits card to 16 keys. In future this may not work,
but we can derive a Cryptographic Mechanism Reference from what OpenSC
thinks the card needs to do. Only know RSA RAW, PKCS1 and ECDSA.

ECDSA code has not been tested, but expected to work.

Allow setting CardOS type and flags from opensc.conf using card_atr stanza
This is a fallback if newer cards are added or older cards have problems
giving us time to make need changes in next release.

It will help in identifying what flags are needed for each card.
As user can report what combination of flags work for them. They do this by
adding to opensc.conf with something like this. (Change the ATR to your card's ATR):

        card_atr 3b:d2:18:00:81:31:fe:58:c9:03:16 {
                driver = "cardos";
                # type is decimal from cards.h:
                # SC_CARD_TYPE_CARDOS_V5_0 is 1009
                # SC_CARD_TYPE_CARDOS_V5_3 is 1010
                type = 1010;

                # flags is hex from opensc.h:
                #define SC_ALGORITHM_ONBOARD_KEY_GEN    0x80000000
                #define SC_ALGORITHM_NEED_USAGE         0x40000000

                #define SC_ALGORITHM_RSA_RAW            0x00000001 /* RSA_RAW is PAD_NONE */
                #define SC_ALGORITHM_RSA_PAD_NONE       0x00000001
                #define SC_ALGORITHM_RSA_PAD_PKCS1      0x00000002 /* PKCS#1 v1.5 padding */
                #define SC_ALGORITHM_RSA_PAD_ANSI       0x00000004
                #define SC_ALGORITHM_RSA_PAD_ISO9796    0x00000008
                #define SC_ALGORITHM_RSA_PAD_PSS        0x00000010 /* PKCS#1 v2.0 PSS */
                #define SC_ALGORITHM_RSA_PAD_OAEP       0x00000020 /* PKCS#1 v2.0 OAEP */
                #define SC_ALGORITHM_RSA_HASH_NONE      0x00000100 /* only applies to PKCS1 padding */
                # example: SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_HASH_NONE |  SC_ALGORITHM_RSA_RAW
                flags = 80000101;
                #example: SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_PAD_PKCS1
                flags = 80000002;
        }

For V5_0 and v5_3 cards, use sc_get_max_send_size and sc_get_max_recv_size
which takes care or reader sizes even on Windows where SCardControl can not get PART_10 sizes.

(commit eddea6f3c2 on Windows forces reader sizes to 255, 256
in reader-pcsc.c if not already set. It should not do this, but leave that up to card drivers.)

pkcs15-cardos.c added:

New file, pkcs15-cardos.c, added as emulation only for CardOS
V5_0 and V5_3 cards.

sc_pkcs15_bind_internal is called to get tokenInfo as CardOS
cards are substantially PKCS15 cards. But some V5_* cards have
errors in the tokenInfo, Which are corrected.

For older CardOS cards, card-cardos.c will create all the
card->algorithms.

Pkcs15-cardos.c will check for card->algorithms and if there
are none, it will do the following:

SC_CARDCTL_CARDOS_PASS_ALGO_FLAGS is called twice. First to get
the flags as set by user via opensc.conf card_atr or default
flags set by the card driver.  Then after determining from the
tokenInfo what algorithms the card can support, the new flags
are passed to card_cardos.c to create card->algorithms.

https://atos.net/wp-content/uploads/2018/11/CT_181026_LPM_CardOS_V5-3_Multifunctionality_FS_en3_web.pdf
says card supports: "“Command chaining” in accordance with ISO/IEC 7816-4"

To take advantage of this with older readers, max_send_size and max_recv_size
is now based on minimum of reader limits and  "data_field_length" from card.
This should allow card to work in older readers not capable of extended APDU.
So far current cards we have seen do no appear to support “Command chaining”.

 Changes to be committed:
	modified:   src/libopensc/Makefile.am
	modified:   src/libopensc/Makefile.mak
	modified:   src/libopensc/card-cardos.c
	modified:   src/libopensc/cardctl.h
	modified:   src/libopensc/cards.h
	new file:   src/libopensc/pkcs15-cardos.c
	modified:   src/libopensc/pkcs15-syn.c
	modified:   src/libopensc/pkcs15-syn.h
2020-05-09 23:59:51 +02:00
Doug Engert 8a5a1435f1 pkcs15-tool.c - print Supported_algorithms from tokenInfo
Some cards can provide supported algorithms in tokenInfo
which contain ECDSA OID, and PKCS11 mechanism

Don't know how many Algo_refs were actually read,
and a ref of 0 may be valid. print at least one Algo_refs.

Print the mechanism from PKCS11, and print operations
Use the $(top_srcdir)/src/pkcs11/pkcs11-display.c  on Unix
Use the $(TOPDIR)\src\pkcs11\pkcs11-display.obj on Windows

pkcs15.tool.c treat ECDSA OID as inline

pkcs15-tool prints PKCS11 mechanisms using pkcs11-display.c
Automake now warns that the default will change, in the future
so "[subdir-objects]" is added to configure.ac

 Changes to be committed:
	modified:   configure.ac
	modified:   src/tools/Makefile.am
	modified:   src/tools/Makefile.mak
	modified:   src/tools/pkcs15-tool.c
2020-05-09 23:59:51 +02:00
Doug Engert c03efeee40 sc_supported_algo_info - Put ECDSA OID as inline
Mismatch of ASN1 parsing of tokeninfo.supported_algos[n].paramters
    in one place parameter was treated as a pointer to sc_object_id
    and in another as inline structure. This caused segfaults
    in pkcs15-tool when it tried to print the OID.

 Changes to be committed:
	modified:   src/libopensc/opensc.h
	modified:   src/libopensc/pkcs15.c
2020-05-09 23:59:51 +02:00
Doug Engert 3f21dc57b7 Increase SC_MAX_SUPPORTED_ALGORITHMS from 8 to 16
CardOS cards may have more then 8 supported_algo_info entries in tokenInfo.
We may bemissing some. We have seen 8 in some pkcs15-tool -i -v output.

Simple fix is to incrase the limit. More appropriate fix is to remove the limit,
much like is done with sc_algorithm_info. and use realloc of the array.

 On branch cardos-5.3
 Changes to be committed:
	modified:   src/libopensc/pkcs15-prkey.c
	modified:   src/libopensc/pkcs15-skey.c
	modified:   src/libopensc/pkcs15.c
	modified:   src/libopensc/types.h
2020-05-09 23:59:51 +02:00
Doug Engert f5fe292ae1 pkcs11-tool - use valid data for decription tests
In tests, make sute test data is either padded, or "zero" padded
so size if data <=  modlen - 11. The smallest pad in 11 bytes,
00 | NN | PS | 00. PS is at least 8 bytes.
"zero" padding has N = 00, PS >= 8 byte of 00.

 On branch cardos-5.3
 Changes to be committed:
	modified:   tools/pkcs11-tool.c
2020-05-09 23:59:51 +02:00
Doug Engert 52d5370c1e asn1.c don't use strict mode
see:
https://github.com/OpenSC/OpenSC/issues/1995#issuecomment-607490809

 On branch cardos-5.3
 Changes to be committed:
	modified:   asn1.c
2020-05-09 23:59:51 +02:00
Jakub Jelen 797414be05 Create missing man pages (goid needs some work) 2020-05-07 02:34:12 +02:00
Jakub Jelen b091165595 doc: Drop trailing comma 2020-05-07 02:34:12 +02:00
Jakub Jelen 0a057a976d Fix typo arguement -> argument in documentation 2020-05-07 02:34:12 +02:00
Jakub Jelen a1d53aa217 tests: Temporarily whitelist example binaries in tools/ 2020-05-07 02:34:12 +02:00
Jakub Jelen 3c7823d1f0 tests: Verify every tool has a manual page 2020-05-07 02:34:12 +02:00
Jakub Jelen ddc049e37b Remove bogus file from tools directory 2020-05-07 02:34:12 +02:00
Jakub Jelen ce659b2f7a test: Fix typo in comment 2020-05-07 02:34:12 +02:00
Jakub Jelen d1457e9fa3 coolkey: Drop dead code (CID 351911)
default branch of the switch calls continue, preventing
going out of the loop without obj_info set.
2020-05-07 02:32:46 +02:00
Jakub Jelen 295f399304 reader-pcsc: Avoid use after free (CID 355473) 2020-05-07 02:32:46 +02:00
Jakub Jelen 71998501f2 piv: Replace internal implementation of put_tag with asn1
The asn1 implementation is simpler and has more throughout error and
buffer overflow checking.

Fixes #1394
2020-05-07 02:32:46 +02:00
Jakub Jelen 4c4237f8a3 tests: Cover asn1_put_tag() 2020-05-07 02:32:46 +02:00
Jakub Jelen 508f8a9fce iso7816: Do not recurse if no data was returned
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20399
2020-05-07 02:32:46 +02:00
Jakub Jelen 84ee2be122 framework-pkcs15: Copy pubkey to avoid double free 2020-05-07 02:32:46 +02:00
Jakub Jelen 75be610ea0 pkcs15: Clean memory if it was not transfered to framework-pkcs15 2020-05-07 02:32:46 +02:00
Jakub Jelen 127c8d911f pkcs15-pubkey: Avoid memory leaks when ec_params are already initialized from pkcs15-algo 2020-05-07 02:32:46 +02:00
Jakub Jelen b76e08504a piv: Fix indentation 2020-05-07 02:32:46 +02:00
Jakub Jelen ed06787b5e oberthur: Avoid memory leak when the auth_init is called multiple times
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21678
2020-05-07 02:32:46 +02:00
Jakub Jelen be57a4bf0f configure: Do not overwrite passed CFLAGS 2020-05-07 02:32:46 +02:00
Frank Morgner 1202eceeef fixed wrong error 2020-04-29 15:16:31 +02:00
Frank Morgner 7936bdef15 resolve unused variable warning on newer gcc 2020-04-29 01:25:33 +02:00
Vladimir Panteleev bb47c1a5d0 pkcs11-tool: Fix mismatched --help text
The addition of --usage-wrap did not add a corresponding help string,
which caused all help text for the options below it to be shifted by one.
2020-04-23 14:54:46 +02:00
James Bromwell 0234e1bc14 Update ISSUE_TEMPLATE.md
Note that I took out the Markdown formatting for links, because Markdown inside of HTML comments never renders.
2020-04-23 14:54:03 +02:00
Frank Morgner 3124d9f6fb
Merge pull request #1821 from alex-nitrokey/ecc-fixes
openpgp: Fixes for importing ECC keys
2020-04-23 13:35:59 +02:00
Frank Morgner 843779fe6e opensc-notify: respect signal safety
Thanks, Marcin.
5e79a2a4ab (r38486829)
2020-04-23 08:45:24 +02:00
Frank Morgner 5e79a2a4ab fixed compiler warning 2020-04-09 16:29:44 +02:00
alex-nitrokey 27ea7cc6ac
Merge branch 'master' of https://github.com/OpenSC/OpenSC into ecc-fixes 2020-04-09 10:25:00 +02:00
Raul Metsma 78a7c11d0d Simplify build matrix
Signed-off-by: Raul Metsma <raul@metsma.ee>
2020-04-08 11:32:45 +02:00
Lars Silvén 8257e0186d The PKCS#11 specifies that the PIN parameter(s) in C_Login and C_SetPIN
always should be used, even if a PIN pad reader is used. PIN must only
be fetched from the PIN pad reader if the corresponding parameter is
null.
Before this commit PIN was always fetch from the reader if the PIN could
be fetched from the reader.
The 'pkcs11-tool has also been updated. Before parameters was never
taken from the command line if a PID pad reader was used. Now PINs from
the command line is always used but if not existing the PIN is fetched
from the reader if a reader with a PIN pad is used, otherwise the user
is prompted for PIN(s) from the CLI.
2020-04-08 09:54:07 +02:00
Lars Silvén a771450ab2 From the PKCS#11 specification chapter C_SetPIN:
C_SetPIN modifies the PIN of the user that is currently logged in, or
the CKU_USER PIN if the session is not logged in. ....

This was not true for "if the session is not logged in" before this fix.
2020-04-08 09:54:07 +02:00
Frank Morgner f9b31e50dd iso-sm: fixed too short response APDU data length
one byte off error in calculation of ASN.1 length
2020-04-08 02:13:24 +02:00
Frank Morgner 2c26b7392d opensc-notify: handle reader insertion/removal events
- If readers are attatched, the new reader is probed for a card to check
if a notification needs to be sent
- removal of readers are not notified to the user, we assume that PC/SC
sends the correct card removal event
- The list of readers to be monitored is adjusted once a reader (dis)appears
- On macOS, without PnP notification, we always check for new/removed
readers with SCardListReaders
- fixes interrupt handling in opensc-notify on Unix

fixes https://github.com/OpenSC/OpenSC/issues/1874
2020-04-06 18:08:34 +02:00
Jakub Jelen 7893d2860c idprime: Fix null-dereference
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21586
2020-04-06 17:56:28 +02:00
Jakub Jelen 1ddef2cd15 iasecc: Avoid memory leak on error
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21297
2020-04-06 17:56:28 +02:00
Raul Metsma 5eff42e39e Use nologo parameter to avoid warnings in appveyor log
Signed-off-by: Raul Metsma <raul@metsma.ee>
2020-04-03 09:55:34 +02:00
Marcin Cieślak 591ffad5dc Ignore test-driver and aminclude_static.am
Those files are generate by autotools
2020-04-03 09:52:51 +02:00
Marcin Cieślak 768bd1dde7 Check if we HAVE_ENDIAN_H
BSDs will have <sys/endian.h>, Linux just <endian.h>
2020-04-03 09:52:08 +02:00
alex-nitrokey 7ba89620bf
refactoring: get rid of oid_binary in ec_tables 2020-03-24 12:09:06 +01:00
alex-nitrokey 396aabcb7b
ykneo-openpgp does not support ecc keys yet 2020-03-24 12:07:29 +01:00
Frank Morgner 7840804762 fixed typo
fixes coverity's: "Argument cannot be negative (NEGATIVE_RETURNS)"
2020-03-21 16:47:43 +01:00
Frank Morgner d5ecafc334 fixed memory leak
fixes https://oss-fuzz.com/testcase-detail/5084702283399168
2020-03-20 17:12:18 +01:00
alex-nitrokey f4d28a18b9
Add pin to command 2020-03-19 15:21:55 +01:00
alex-nitrokey b2d082f4aa
Use curve that is supported by trusty OpenSSL package 2020-03-19 14:51:18 +01:00
alex-nitrokey 1e7e6e11a4
Add key import of ecc key to openpgp Travis tests 2020-03-19 13:33:12 +01:00
alex-nitrokey 0ba44cbec6
Add length checking 2020-03-19 13:31:31 +01:00
Alexander Paetzelt e45712bd29
Merge branch 'master' into ecc-fixes 2020-03-19 11:54:18 +01:00
Frank Morgner dc29b0fe18 fixed memory leak
fixes https://oss-fuzz.com/testcase-detail/6237284133502976
2020-03-12 23:07:17 +01:00
Jakub Jelen 6ed3939ae5 coolkey: Avoid memory leak
Fixup previous attempt to avoid too large allocations

Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21059
2020-03-11 12:19:43 +01:00
Frank Morgner b91cfa8cd7 reverted accidental change of default flags 2020-03-10 12:20:31 +01:00
Frank Morgner f1bcadfbe9 pkcs11: don't try to allocate 0 byte with calloc
fixes #1978
2020-03-10 12:15:04 +01:00
Peter Marschall d628022673 OpenPGP: add additional vendors
Taken from git.gnupg.org
2020-03-10 09:19:31 +01:00
Frank Morgner 501311c4e3 TravisCI: fixed OpenPACE build 2020-03-06 15:32:22 +01:00
Frank Morgner 267aea759c use platform dependant implementation of erasing memory
fixes potentially insecure use of memset in CWA SM implementation

fixes https://github.com/OpenSC/OpenSC/issues/1957
2020-03-06 12:23:16 +01:00
Frank Morgner d06f23e89b avoid debugging PIN commands
use a higher debug level to see it anyway
2020-03-05 22:17:09 +01:00
Frank Morgner 9681193ad5 fixed macro definition 2020-03-05 12:04:58 +01:00
Frank Morgner fe24707c00 win32: recognize WiX libs for VS2017/2019 2020-03-05 12:04:58 +01:00
Frank Morgner 2f5514a2d1 appveyor: build for VS 2017, too 2020-03-05 12:04:58 +01:00
Frank Morgner 1e05e9aff0 fixed OpenPACE flags for OpenSSL 1.1.1 2020-03-05 12:04:58 +01:00
Frank Morgner b89fbce9f2 make OPENSSL_DIR configurable 2020-03-05 12:04:58 +01:00
Raul Metsma 7fb0696a29 Upgrade OpenSSL to 1.1.1
Version 1.0.2 is deprecated

Signed-off-by: Raul Metsma <raul@metsma.ee>
2020-03-05 12:04:58 +01:00
Frank Morgner 8551e84d74 fixed https://github.com/OpenSC/OpenSC/issues/1948
closes https://github.com/OpenSC/OpenSC/pull/1958
2020-03-04 23:11:03 +01:00
Peter Marschall 44c22b7820 opensc-explorer: re-factor do_put()
* replace magic magic number used as potentially too small buffer size
  by SC_MAX_EXT_APDU_DATA_SIZE
* start error message with upper-case letter
2020-03-04 21:59:38 +01:00
Peter Marschall b2f86b3997 opensc-explorer: re-factor read_and_print_record_file()
* replace magic magic number used as potentially too small buffer size
  by SC_MAX_EXT_APDU_RESP_SIZE
* start error message with upper-case letter
* return 0 on success
2020-03-04 21:59:38 +01:00
Peter Marschall 9b0983e96d opensc-explorer: re-factor do_random()
* use braces after sizeof, i.e. sizeof(X) instead of sizeof X
2020-03-04 21:59:38 +01:00
Peter Marschall b9d4f0c7d8 opensc-explorer: re-factor & fix do_update_record()
* bug fix: pass correct buffer length to sc_update_record()
* bug fix: report correct number of bytes written
* bug fix: check for offs to be small enough
* replace magic magic number used as potentially too small buffer size
  by SC_MAX_EXT_APDU_DATA_SIZE
* remove print() statement that looks suspiciously like a leftover from debugging
* start error messages with upper-case letters
* use sc_strerror(r) instead of plain numeric r in error messages
* fix spaces before opening curly braces
2020-03-04 21:59:38 +01:00
Peter Marschall be152f78b4 opensc-explorer: re-factor do_update_binary()
* replace magic magic number used as potentially too small buffer size
  by SC_MAX_EXT_APDU_DATA_SIZE
* remove print() statement that looks suspiciously like a leftover from debugging
* start error messages with upper-case letters
* use sc_strerror(r) instead of plain numeric r in error message
* fix spaces before opening curly braces
2020-03-04 21:59:38 +01:00
Peter Marschall c2a8102615 opensc-explorer: re-factor do_get()
* replace magic number used as potentially too small buffer size
  by SC_MAX_EXT_APDU_RESP_SIZE
* start error messages with upper-case letters
2020-03-04 21:59:38 +01:00
Peter Marschall b77e0faadb opensc-explorer: re-factor do_ls()
* replace magic magic number used as potentially too small buffer size
  by SC_MAX_EXT_APDU_RESP_SIZE
* replace magic number for filename by SC_MAX_PATH_STRING_SIZE
* start error messages with upper-case letters
* use braces after sizeof, i.e. sizeof(X) instead of sizeof X
* fix indentation
2020-03-04 21:59:38 +01:00
Peter Marschall f1d46401cb opensc-explorer: re-factor do_put_data()
* determine DO ID/tag the same way as do_find_tags()
* start error message with upper-case letter
* use sc_strerror(r) instead of plain numeric r in error message
* adapt size of buffer to SC_MAX_EXT_APDU_DATA_SIZE
2020-03-04 21:59:38 +01:00
Peter Marschall 968815e6ef opensc-explorer: re-factor do_get_data()
* determine DO ID/tag the same way as do_find_tags()
* replace magic magic number used as potentially too small buffer size
  by SC_MAX_EXT_APDU_RESP_SIZE
* change buffer type from unsigned char to u8 for consistency with
  do_put_data() & do_find_tags()
* give ID/tag of DO in error message
* open target file in binary mode
2020-03-04 21:59:38 +01:00
Peter Marschall f556c275f7 opensc-explorer: re-factor do_find_tags()
* set default values for variables at declaration time
* replace magic number used as potentially too small buffer size
  by SC_MAX_EXT_APDU_RESP_SIZE
* use braces after sizeof, i.e. sizeof(X) instead of sizeof X
2020-03-04 21:59:38 +01:00
Peter Marschall b6febc0c7a opensc-explorer: re-factor do_find()
* set default values for variables at declaration time
* use sizeof(fid) instead of magic number
* use braces after sizeof, i.e. sizeof(X) instead of sizeof X
* start error message with upper-case letter
2020-03-04 21:59:38 +01:00
Peter Marschall 4abacbf5c1 opensc-explorer: re-factor read_and_print_binary_file()
* rename from read_and_util_print_binary_file(); adapt callers
* use large enough buffer size SC_MAX_EXT_APDU_RESP_SIZE
  instead of potentially too small magic number
* fix spaces before opening curly braces
* avoid special casing SC_CARD_TYPE_BELPIC_EID: a successful read
  of an empty file is still a success, even if nothing can get printed
2020-03-04 21:59:38 +01:00
Peter Marschall f20b646a97 opensc-explorer: re-factor do_cd()
* do not fail on SC_FILE_TYPE_UNKNOWN: be more flexible w.r.t accepting
  unknown file types when the preceding card operations succeeded
* fix spaces before opening curly braces
2020-03-04 21:59:38 +01:00
Peter Marschall 78c79c0efb opensc-explorer: refactor arg_to_path()
* fix indentation
* fix spaces before opening curly braces
2020-03-04 21:59:38 +01:00
Jakub Jelen 88dce12181 gids-tool: Remove empty condition
Empty block without comment

Thanks lgtm
2020-03-04 21:27:56 +01:00
Jakub Jelen e429fe03c5 cardos: Avoid always-true condition
Comparison is always true because offset >= 1.

Thanks lgtm
2020-03-04 21:27:56 +01:00
Jakub Jelen 15b1e93b51 cac: Avoid always-true condition
Comparison is always true because pathlen >= 3.

Thanks lgtm
2020-03-04 21:27:56 +01:00
Jakub Jelen 5721961be2 pkcs11-tool: Properly report invalid signatures
Comparison is always false because rv <= 0.

Thanks lgtm
2020-03-04 21:27:56 +01:00
Jakub Jelen 6638949513 goid-tool: Fix wrong printf arguments
This argument should be of type 'wchar_t *' but is of type 'unsigned short *'

Thanks lgtm
2020-03-04 21:27:56 +01:00
Jakub Jelen 0a610319bd pkcs11-tool: Fix wrong printf arguments
This argument should be of type 'unsigned int' but is of type 'unsigned long'

Thanks lgtm
2020-03-04 21:27:56 +01:00
Jakub Jelen f301ec98b6 travis-ci: There is no files option in cache
The error was

cache: unknown key files (isetup-5.5.6.exe)
2020-03-04 21:27:56 +01:00
Jakub Jelen b8d9b840ee travis-ci: Remove deprecated sudo option
The warning was

jobs.include: deprecated key sudo (The key `sudo` has no effect anymore.)
2020-03-04 21:27:56 +01:00
Jakub Jelen aeef29238e tests: Update tests to reflect current behavior of decompress 2020-03-04 21:27:56 +01:00
Jakub Jelen c3924859a9 Update gengetopt generated code with a new version to remove hardcoded paths 2020-03-04 21:27:56 +01:00
Jakub Jelen 44bc324864 actalis: Check return codes
CID 127776
2020-03-04 21:27:56 +01:00
Jakub Jelen e3e461aad9 coolkey: Avoid insane allocations and use correct variable type
CID 341847
2020-03-04 21:27:56 +01:00
Jakub Jelen 2a88d82cad compression: Validate inputs to decompression functions
CID 353531
CID 353530
2020-03-04 21:27:56 +01:00
Jakub Jelen 7bfca52bab iasecc: Free old driver data if the driver was initialized correctly
CID: 354007
2020-03-04 21:27:56 +01:00
Jakub Jelen 677710c72b dnie: Avoid insane memory allocations
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20916
2020-03-04 21:27:56 +01:00
Jakub Jelen 7d3b82c204 epass2003: Avoid memory leaks if no file_out is passed
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20898
2020-03-04 21:27:56 +01:00
Jakub Jelen a623226a87 Avoid memory leaks from sc_parse_ef_attr()
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20710
2020-03-04 21:27:56 +01:00
Jakub Jelen 9c0a7adbfc iasecc: Avoid memory leaks on error
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20700
2020-03-04 21:27:56 +01:00
Jakub Jelen d31ebe2fec gemsafeGPK: Fix typo in comment 2020-03-04 21:27:56 +01:00
Jakub Jelen c69add3b64 cac: Correctly avoid recursion (amends 09531d72)
Closes: #1920

Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19725
2020-03-04 21:27:56 +01:00
Frank Morgner dba0f56722 pkcs11: fixed state tracking
- when listing the slots, we don't have a hotplug slot anymore with
slot->reader == NULL. Instead, we're now using this state for any left
over slots when a reader is removed. So we don't need to include this in
the slot list

- when listing the slots, we need to remember which slots the
application has seen already, to not shrink the list of slots (which is
allowed in PKCS#11 v2.2, but NSS can't handle this)
2020-03-04 21:06:43 +01:00
Frank Morgner 2a6bf1e577 pkcs11: lower debug level of virtual slots 2020-03-04 14:29:34 +01:00
Frank Morgner 7e7458edce pkcs11: restore creating 4 virtual slots for each reader
fixes old token slot ids
(https://github.com/OpenSC/OpenSC/pull/1970#issuecomment-594400562)
2020-03-04 14:25:08 +01:00
Doug Engert 8d519ed3c4 Add calls to DEBUG_VSS
On branch PKCS11-SLOTS-2
 Changes to be committed:
	modified:   pkcs11-global.c
	modified:   slot.c
2020-03-04 13:39:12 +01:00
Doug Engert 2e89f1634f Debug PKCS11 virtual slots
Macro DEBUG_VSS and routine _debug_virtual_slots were added.

DEBUG_VSS(slot, "printf like format string" [,args...]) will print the virtual_slots
to the opensc-debug.log showing were it was called from.
If slot is not NULL and found in the table it will be highlighted
with an "*".

In gdb: call _debug_virtual_slots(slot) can be used along with
another window to tail opensc-debug.log

 On branch PKCS11-SLOTS-2

Date:      Fri Feb 21 08:19:37 2020 -0600
 Changes to be committed:
	modified:   src/pkcs11/sc-pkcs11.h
	modified:   src/pkcs11/slot.c
2020-03-04 13:37:37 +01:00
Frank Morgner 649ee272ec reader-cryptotokenkit: fixed handling of reattached reader 2020-03-03 22:55:27 +01:00
Frank Morgner 14e396273c reader-pcsc: fixed handling of detatching events
- allows re-attatching a reader to an existing reader object by
resetting the SC_READER_REMOVED flag
- readers that are flagged with SC_READER_REMOVED are not used for
SCardGetStatusChange to avoid SCARD_E_UNKNOWN_READER

fixes https://github.com/OpenSC/OpenSC/issues/1903
2020-03-03 22:55:27 +01:00
Frank Morgner 5b9af96851 pkcs11: reclaim unused slots based on reader description
When a reader is removed and reattached, this re-uses the old slot
without relying on the fact that the sc_reader_t is unchanged.
2020-03-03 22:55:27 +01:00
Frank Morgner ce704f5eb1 removed unused plug_and_play parameter
see 1fb741338a
2020-03-03 22:55:27 +01:00
Frank Morgner d54f346937 pkcs11: simpify reader removal
- reader (slot) description is already initialized init_slot_info()
- objects and logins are already released in slot_token_removed
2020-03-03 22:55:27 +01:00
Doug Engert af40303fe8 Improved Handling of PKCS11 Slots
OpenSC PKCS11 now retains slots even when the reader is removed.
It can do this because existing OpenSC reader handling in ctx.c,
reader-pcsc.c and PC/SC allow OpenSC to do this.

This simplifies the code, and allow a reader to be reinserted
and use the existing slot. This matching is actually done
in reader-pcsc.c because PC/SC returns the unique ids based on
the OS reader names. This is then used as the manufacturerID

By not deleting slots the slot list can only increase which is a
restriction of Firefox. It does not fix all the Firefox issues, but
it does not go into a loop, when all the readers are removed.

The defaults in opensc.conf for max-virtual-readers and slots-per-card
allow for 4 different readers used during one session.

 On branch PKCS11-SLOTS-3
 Changes to be committed:
	modified:   sc-pkcs11.h
	modified:   slot.c
2020-03-03 22:55:27 +01:00
Frank Morgner ad7eb834cf fixed indenting 2020-03-03 22:55:27 +01:00
Frank Morgner c212776f45 fixed dashes 2020-02-27 23:12:54 +01:00
Frank Morgner 906108bb69 dnie: fixed length checking of uncompressed data
fixes https://oss-fuzz.com/testcase-detail/5632848910614528
2020-02-27 23:12:54 +01:00
Frank Morgner 261e0b6b0d unified documentation of handling PIN/PUK on CLI 2020-02-27 23:12:54 +01:00
Frank Morgner 6b1770e7ad pkcs15-init: removed --options-file
use an environment variable to pass a hidden PIN code instead of the
options file

fixes 13814 Resource leak as reported by Coverity Scan
2020-02-27 23:12:54 +01:00
Frank Morgner dca02dd9a0 fixed 323588 Uninitialized scalar variable
accessing uninitialized data with mlock is undefined behavior
2020-02-27 23:12:54 +01:00
Peter Marschall 21ee26b070 openpgp-tool: fix key generation with non-standard exponent length
Address issue #1949 by reading non-default algorithm attributes for
key generation from the key's algorithm attributes DO, if that exists.
2020-02-27 22:59:05 +01:00
Peter Marschall 81ace3689d opensc-explorer: extend do_info()
* distinguish between Internal and Working EFs
* add information optionally available in sc_file_t
  - record_count
  - record_length
  - type_attr
* align all labelled values
2020-02-27 22:55:38 +01:00
Peter Marschall 95cae64f83 opensc-explorer: replace magic numbers by SC_MAX_PIN_SIZE
Replace magic numbers, used as size of PIN-type buffers,
with the symbolic constant SC_MAX_PIN_SIZE, fixing
- readability / understandability
- too small sizes (e.g. for GnuPG cards)
2020-02-27 22:54:50 +01:00
Frank Morgner 70716be815 macOS: register CTK driver on installation 2020-02-27 22:49:27 +01:00
Frank Morgner 6a9241b532 macOS: unregister CTK driver on uninstallation
fixes https://github.com/frankmorgner/OpenSCToken/issues/24
2020-02-27 22:49:27 +01:00
Frank Morgner 8f4a6c703b align comment with implementation order 2020-02-20 01:42:18 +01:00
Frank Morgner 31d8c2dfd1 Revert "pkcs11: fixed slotIDs when a new slot list is requested"
This reverts commit 7fb72ccf7b.
2020-02-19 16:09:20 +01:00
Peter Marschall cd5c91b8ef iso7816: extend iso7816_process_fci()
* define file type SC_FILE_TYPE_UNKNOWN
* explicitly set file->type to SC_FILE_TYPE_UNKNOWN for unkown files
* store full-length file type attributes via sc_file_set_type_attr()
* parse # of records for record-oriented EFs
* parse record length for for EFs with fixed-size records
  Note: I am not sure, parsing the record length only for EFs with fixed-
        size records is the correct approach.
        My interpretation of the norm is slightly different, but it seems
        to be in-line what's currently in opensc:
        - there's a comment hinting at that interpretation
        - otherwise variable size records fail to be read in opensc-explorer
        So I leave it this way for now.
2020-02-18 20:47:26 +01:00
Frank Morgner e0b27af205 fixed Undefined-shift
fixes https://oss-fuzz.com/testcase-detail/5644419049193472
2020-02-13 10:39:41 +01:00
Frank Morgner 6c855c561c fixed memory leak
fixes https://oss-fuzz.com/testcase-detail/5739164513599488
2020-02-12 04:48:40 +01:00
Frank Morgner 0d82c95a02 removed unused call to sc_detect_card_presence() 2020-02-12 04:34:45 +01:00
Jakub Jelen 5450f61681 Unbreak build with -fno-common (default in gcc10) 2020-02-11 07:36:31 +01:00
Frank Morgner 1fb1341389 ignore OpenPACE man page generation
fixes https://github.com/frankmorgner/OpenSCToken/issues/26
2020-02-11 04:12:10 +01:00
Frank Morgner a0e1bf7ae5 fixed compiler error 2020-02-10 10:17:16 +01:00
Frank Morgner ea2991ea69 fixed memory leak
also, use sc_file_free instead of free

fixes https://oss-fuzz.com/testcase-detail/4905082200260608
2020-02-10 10:17:16 +01:00
Frank Morgner 2493c5de07 fixed memory leak
fixes https://oss-fuzz.com/testcase-detail/6237284133502976
2020-02-10 10:17:16 +01:00
Frank Morgner d7e02d3bf5 fixed memory leak
Fixes https://oss-fuzz.com/testcase-detail/5151975710916608
2020-02-10 10:17:16 +01:00
Peter Marschall 8e466ad568 OpenPGP: add 3 more OpenPGP card vendors
* taken from GnuPG's git
2020-02-10 00:41:02 +01:00
Charlène 2f7d0cf20f Put user supplied CFLAGS on top priority 2020-02-07 08:57:26 +01:00
Jakub Jelen 34dad7f543 idprime: Add missing terminator in ATR list
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20510
2020-02-04 15:44:19 +01:00
Jakub Jelen 63435adc68 coolkey: Do not return bogus error if read already failed 2020-02-04 13:57:15 +01:00
Jakub Jelen 2a0f53dd4f coolkey: Avoid heap buffer overflow
for malformend combinded objects, the ID and header were parsed before
making sure we have at least that lenght available.

Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20131
2020-02-04 13:57:15 +01:00
Jakub Jelen 09531d720a cac: Avoid stack overflow on infinite recursion in CCC chaining
Thanks oss-fuzz

Fixes: #1920

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19725
2020-02-04 13:57:15 +01:00
Frank Morgner e9308a2011 addeed zlib test data 2020-02-04 13:56:53 +01:00
Frank Morgner f1044f3645 tccardos: fixed error checking 2020-02-04 13:56:53 +01:00
Frank Morgner c339136c73 tccardos: fixed freeing file object 2020-02-04 13:56:53 +01:00
Frank Morgner 723176d62f avoid calling memcpy with length 0 2020-02-04 13:56:53 +01:00
Frank Morgner 3687f71bf7 fixed 123497 Dereference after null check
Thanks to Coverity Scan
2020-02-04 13:56:53 +01:00
Frank Morgner 5475dbcb3c fixed Uninitialized scalar variable
Thanks to Coverity Scan
2020-02-04 13:56:53 +01:00
Frank Morgner 3dede423e6 fixed Out-of-bounds access
Thanks to Coverity scan
2020-02-04 13:56:53 +01:00
Frank Morgner 8db1cbe35f use a more explicit assignment 2020-02-04 13:56:53 +01:00
Frank Morgner 40b3aeb626 travis: output results of unittests on errors 2020-02-04 13:56:53 +01:00
Frank Morgner d138522e33 added detection of zlib compression
... and always set outLen to 0 in case of an error in sc_decompress
2020-02-04 13:56:53 +01:00
Frank Morgner 094aa68632 fixed Explicit null dereferenced
Thanks to Coverity Scan
2020-02-04 13:56:53 +01:00
Frank Morgner 72836fa3cb Fixed Dereference before null check
As reported by coverity scan
2020-02-04 13:56:53 +01:00
Doug Engert 0fd77d642c Minidriver additionl fixes
Use __FUNCTION__ as defind in log.h so will compile with any compiler.
logprint additional handles as size_t

Add check in reader-pcsc.c pcsc_user_reader for minidriver only.

 On branch minidriver-5
 Changes to be committed:
	modified:   src/libopensc/reader-pcsc.c
	modified:   src/minidriver/minidriver.c
2020-02-01 22:42:02 +01:00
Doug Engert 111246f1d2 Better error debug messages for Minidriver
Add MD_FUNC_CALLED(pCardData, level) and  MD_FUNC_RETURN(pCardData, level, ...)
macros.

Handles are type __int3264 in VS2015 are casted as size_t when printing so
all bytes are printed. size_t on Windows are also treated as 32 or 64 bits.
SC_FORMAT_LEN_SIZE is used in the format.
 (Works with VS2105 needs to be tested on other platforms.)

 On branch minidriver-4

 Changes to be committed:
	modified:   minidriver.c

Minidriver.c and reader-pcsc.c - reuse OpenSC reader structure

Windows CNG is managing the insertion and removal of the reader and the card
and will call CardAcquireContext and CardDeleteContext as needed if
the card or reader change. But different processes or threads may establish
different PCSC connects to the same reader and card but with different handles.

Reuse the OpenSC reader when windows uses the same reader but with different
handles. Tests show the certutil -v -scinfo works the same.
Associate_card is only need when called from
CardAcquireContext and disassociate_card is only need when called from
CardDeleteContext.
No need to call reinit_card_for(pCardData, name) just because the handles changed.

This may be the fix for #1763 because calls like CardCreateContainerEx remain
in card state rather then being lost when the handles changed.

 Changes to be committed:
	modified:   src/libopensc/reader-pcsc.c
	modified:   src/minidriver/minidriver.c
2020-02-01 22:42:02 +01:00
Doug Engert 348551c920 Add EC parameters to PKCS15 public key in OpenPGP driver - Fixes #1906
The EC Parameters are the way the EC curve is presented to the outside world,
and in most cases is present in a matching certificate in the SPKI.

card-openpgp.c is modified to add the EC named_curve to the PKCS15 public key.
OpenPGP specs only provide this via the "Algorithm Attributes" for the 3 keys
via tags C1, C2 and C3 These contain the OID (not DER encoded) for the EC curve.

PKCS15 has two ways to encode a "pubkey" as it was originally written for RSA.
But other algorithms have parameters. X509 certificates encode the public key
in the SPKI and PKIX requires the parameters to be in the SPKI. PKCS15
allows for using a SPKI as source for a public key.

pgp_get_pubkey_pem will return the DER encoded RSA pubkey as before by
calling sc_pkcs15_encode_pubkey
pgp_get_pubkey_pem will return the DER encoded EC pubkey with parameters by
calling sc_pkcs15_encode_pubkey_as_spki which calls sc_pkcs15_fix_ec_parameters
internally to map DER encoded OID to named_curve.

For readability, "sc_pkcs15_pubkey_t pubkey;" definitions are changed to
"sc_pkcs15_pubkey_t p15pubkey;"

sc_pkcs15_erase_pubkey is used to avoid memory leaks.

 On branch openpgp-ec-pub-curve

 Date:      Tue Jan 21 09:43:56 2020 -0600
 Changes to be committed:
	modified:   src/libopensc/card-openpgp.c
2020-02-01 22:39:05 +01:00
Frank Morgner 0cd19b59e1 pkcs11-tool: add --usage-wrap (disabled by default)
fixes https://github.com/OpenSC/OpenSC/issues/1913
2020-02-01 22:29:35 +01:00
Frank Morgner 7e0465370f
Merge pull request #1914 from marschap/PGPtool-fixes
PGPtool fixes
2020-02-01 22:27:58 +01:00
Frank Morgner 8d4af9eb0b pkcs11: fixed right padding of token label with ' '
fixes https://github.com/OpenSC/OpenSC/issues/1922
2020-02-01 22:20:48 +01:00
Lewis Porter 723129bc12 Check if card name is null in acos atrust driver
opensc-tool segfaults when trying to read a card  that doen’t populate the name field. This commit adds a null check before calling strcmp().
2020-01-31 16:15:23 +01:00
Frank Morgner 45a77ab88d
Merge pull request #1772 from Jakuje/idprime
Add support for Gemalto IDPrime smart cards
2020-01-31 15:49:29 +01:00
Frank Morgner 70baccbe95 iso7816_*_sfid: return the number of bytes processed 2020-01-31 15:04:31 +01:00
Frank Morgner ad8b9f5034 sc_*_binary: interpret SC_SUCCESS as EOF 2020-01-31 14:47:45 +01:00
Frank Morgner 167c03fde4 updated documentation 2020-01-31 08:40:48 +01:00
Frank Morgner 1f9b3f3538 sc_*_record: return the number of bytes processed 2020-01-30 23:54:45 +01:00
Frank Morgner 91af2c7513 repeat sc_erase_binary if needed
return the number of bytes processed
2020-01-30 23:49:36 +01:00
Frank Morgner 230e2f9a60 documentation 2020-01-30 23:22:41 +01:00
Frank Morgner 14aaa64d3e avoid calling sc_*_binary recursively
- lock the card early to avoid deselection of the file
- check on integer overflows of indices

fixes https://github.com/OpenSC/OpenSC/issues/1919
2020-01-30 22:27:10 +01:00
Frank Morgner a501c0d185
sc_decompress_zlib_alloc: check inputs, avoid int underflow (#1907)
- turns out, you can shrink a buffer with realloc on some implementations
- realloc is never called with 0 (which would free the data)
- length checking is done in zlib, we just do the allocation

closes https://github.com/OpenSC/OpenSC/issues/1905
2020-01-30 09:45:44 +01:00
Frank Morgner b119781b02 myeid: fixed memory leak
Credits to OSS-Fuzz

Fixes https://oss-fuzz.com/testcase-detail/5671550682660864
2020-01-29 14:47:12 +01:00
Raul Metsma 092370f8a5 Checkout OpenSC.tokend when actually is needed
Signed-off-by: Raul Metsma <raul@metsma.ee>
2020-01-28 09:59:34 +01:00
Peter Marschall 5d576f4b31 openpgp-tool: use specialDO_size from driver in do_dump_do() 2020-01-26 13:30:28 +01:00
Peter Marschall 471df32faa OpenPGP: correctly determine max. special DO size
In pre-v3 cards, it is hard-coded to 254 bytes.
In v3+ cards, it is stored in the "extended capabilities" DO 00C0.

Make the determined size available as a variable in the driver data.
2020-01-26 13:29:02 +01:00
Peter Marschall 7d3e4b0878 openpgp-tool: increase buffer for private DOs
* OpenPGP v3 increased the size for private DOs. Adapt to it.
* Use the symbolic constant from the refactored OpenPGP driver
  instead of relying on magic numbers.
2020-01-26 13:15:47 +01:00
Peter Marschall cd4dc5a9e7 OpenPGP: refactor definitions into header file
Factor out constants and structure definitions into a header file
so that they can be also used consistently in openpgp-tool.
2020-01-26 13:14:37 +01:00
Peter Marschall 7ef40cdc17 openpgp-tool: update copyright 2020-01-26 13:14:37 +01:00
Peter Marschall a9873b87dd openpgp-tool: force use of 'openpgp' driver
Follow the example of other card-specific tools and explicitly force
the use of the correct driver, and fail if it cannot be set.
2020-01-26 13:13:52 +01:00
Liam Dawson 713396116d macOS: remove leftover files on uninstall
Fixes #1898
2020-01-23 12:38:43 +01:00
Frank Morgner 0ae3441949 adapt to comment 2020-01-22 13:59:33 +01:00
Frank Morgner 61c20cf83d
Merge pull request #1896 from marschap/explorer-card-drivers
opensc-explorer: make '--card-driver ?' list all available drivers
2020-01-22 09:20:29 +01:00
Jakub Jelen 4ef7ed9ffd fuzz: Fix invalid write in fuzzer
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20188
2020-01-21 22:35:21 +01:00
Jakub Jelen a487e9595e p11test: Generate valid json if the test is not properly finished 2020-01-21 22:35:21 +01:00
Jakub Jelen 889815629b p11test: Properly finalize the ec_sign test 2020-01-21 22:35:21 +01:00
Frank Morgner b7690a45d7 sc_decompress_zlib_alloc: check inputs, avoid int underflow
- turns out, you can shrink a buffer with realloc on some implementations
- realloc is never called with 0 (which would free the data)
- length checking is done in zlib, we just do the allocation

closes https://github.com/OpenSC/OpenSC/issues/1905
2020-01-20 10:13:27 +01:00
Frank Morgner ee1c8073c2 pkcs11-tool: allow tests with keys that don't require PIN
... such as the 9e key of a PIV card.
2020-01-17 16:04:39 +01:00
Frank Morgner 5c55546685
Merge pull request #1830 from Jakuje/fuzz
Introduce unit tests and address more oss-fuzz issues  (mostly ASN1 parser)
2020-01-17 15:15:20 +01:00
Peter Marschall 6b295e4207 tools: correctly check return value of getopt_long()
According to the specs, getopt_long() returns -1, which is often,
but not necessarily the value of EOF.
2020-01-12 09:42:30 +01:00
Peter Marschall a0adbc9ef2 dnie-tool: cleanup
- remove command line option '--card-driver';
- instead force driver 'dnie' and fail if card is not a DNIe card
- overhaul option parsing
  - remove unused variable 'long_optind'
  - bail out with usage message on all unknown/unhandled args
  - correctly terminate option parsing (no infinite loop)
- slight refactoring
  - avoid magic constant '0x0f'
  - make variable 'tries_left' more local
  - move dependent code into if block
2020-01-12 09:42:09 +01:00
Peter Marschall 58ecb4aba2 cardos-tool: cleanup
- remove command line option '--card-driver';
- instead force driver 'cardos' and fail if card is not a CardOS card
- overhaul option parsing
      - remove unused variable 'long_optind'
      - bail out with usage message on all unknown/unhandled args
      - correctly terminate option parsing (no infinite loop)
2020-01-12 09:40:54 +01:00
Peter Marschall 04f4f589a1 piv-tool: cleanup
- remove command line option '--card-driver';
- instead force driver 'PIV-II' and fail if card is not a PIV card
- overhaul option parsing
  - remove unused variable 'long_optind'
  - make work option '--reader' ( "r:" was missing in the optstring!!!)
  - bail out with usage message on all unknown/unhandled args
  - correctly terminate option parsing (no infinite loop)
2020-01-12 09:40:53 +01:00
Peter Marschall 5514a0529f dnie-tool: rename option '--driver' to '--card-driver'
Rename option '--driver' to '--card-driver' for increased consistency.

In addition, extend it the same way opensc-explorer was extended. I.e.
treat the question mark given as argument to option '--card-driver'
special: list all available drivers instead of stupidly bailing out.

In contrast to opensc-tool and opensc-explorer, which are card-agnostic,
I am not sure whether the option '--card-driver' makes sense on this
card-specific tool.
2020-01-12 09:36:49 +01:00
Peter Marschall a10368769c cardos-tool: make '--card-driver ?' list all available drivers
Extend cardos-tool the same way opensc-explorer was extended. I.e.
treat the question mark given as argument to option '--card-driver'
special: list all available drivers instead of stupidly bailing out.

In contrast to opensc-tool and opensc-explorer, which are card-agnostic,
I am not sure whether the option '--card-driver' makes sense on this
card-specific tool.
2020-01-12 09:36:49 +01:00
Peter Marschall 30fdc7de4a piv-tool: make '--card-driver ?' list all available drivers
Extend piv-tool the same way opensc-explorer was extended. I.e.
treat the question mark given as argument to option '--card-driver'
special: list all available drivers instead of stupidly bailing out.

In contrast to opensc-tool and opensc-explorer, which are card-agnostic,
I am not sure whether the option '--card-driver' makes sense on this
card-specific tool.
2020-01-12 09:36:49 +01:00
Peter Marschall 94288b438e opensc-tool: make '--card-driver ?' list all available drivers
Extend opensc-tool the same way opensc-explorer was extended. I.e.
treat the question mark given as argument to option '--card-driver'
special: list all available drivers instead of stupidly bailing out.
2020-01-12 09:36:49 +01:00
Peter Marschall 5da40bf027 opensc-explorer: make '--card-driver ?' list all available drivers
Make opensc-explorer a bit more user friendly by treating the question mark
given as argument to option '--card-driver' special: list all available
drivers instead of stupidly bailing out.
2020-01-12 09:36:49 +01:00
Peter Marschall a40cde2d04 util: refactor listing card drivers
Make util_list_card_drivers() a function in util.c to allow
consistent listing of available card drivers from tools.
2020-01-12 09:36:49 +01:00
Jakub Jelen a46b24bacd Import new license file with correct address
From

https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
2020-01-09 15:35:11 +01:00
Jakub Jelen 1ed9c7483d tests: Skip most of the broken tests on current Ubuntu 2020-01-08 14:32:41 +01:00
Jakub Jelen c8e40a19db If make check does not pass, do not continue with other tests and dump logs 2020-01-08 12:57:35 +01:00
Jakub Jelen 3b40018f4d tests: Skip the allowed_mechanisms test on Ubuntu 2020-01-08 12:23:06 +01:00
Jakub Jelen 60e7b49027 tests: Add path to softhsm pkcs11 module for Ubuntu 2020-01-08 12:23:06 +01:00
Jakub Jelen b52e6db353 tests: Enable allowed_mechanisms test as the SoftHSM is already updated in Fedora 31 2020-01-08 12:22:45 +01:00
Jakub Jelen 0fe341c34e Add missing dist file for tests 2020-01-07 17:18:05 +01:00
Jakub Jelen 23fcccecf4 reader-pcsc: Add a way to create corpus files for fuzzing 2020-01-07 17:18:05 +01:00
Jakub Jelen 1742dfc045 fuzzing: Add corpus file from my cards
The corpus is generated using a local build with

    #define APDU_LOG_FILE "apdulog"

and by running:

    ./src/tools/pkcs11-tool -L --module ./src/pkcs11/.libs/opensc-pkcs11.s

cb50689bf49ccb45a2af690848517305dcf1e429 -- my Yubikey
830e1bf4c7f0c539e9686bc1517d6f87907d4bf8 -- PIV Test Card 14
9ad3fc3cb11967be927bad9263d326783c450e37 -- CAC card
b2b75c07a2c427c15ecd40ce47a9814279745b7d -- old CAC card
7cf8e9b31dcee040ee438441aca2aecb523ed5e9 -- CardOS 5.x
741a0aae7b5b08c0ad2822ede5b3364302b28b31 -- CAC Alt token
de913ba454f894cfc38a16dd122ad673d32ac480 -- coolkey
2020-01-07 17:18:05 +01:00
Jakub Jelen d1db793211 fuzz_pkcs15_reader: Record the ATR in fuzzer 2020-01-07 17:18:05 +01:00
Jakub Jelen a1b5feea96 pkcs15-coolkey: Improve logging and formatting 2020-01-07 17:18:05 +01:00
Jakub Jelen 82ba7f311f pkcs15-syn: Improve logging 2020-01-07 17:18:05 +01:00
Jakub Jelen 900cf7aca9 coolkey: Improve logging 2020-01-07 17:18:05 +01:00
Jakub Jelen cae3b71d75 gp: Define the structure packed, as it is used directly to read data inside 2020-01-07 17:18:05 +01:00
Jakub Jelen 4fd34e28ea unittests: Add coverage for simpletlv parsers 2020-01-07 17:07:48 +01:00
Jakub Jelen 8fd5ffd54e simpletlv: Avoid writing before all sanity checks in sc_simpletlv_put_tag() 2020-01-07 17:07:48 +01:00
Jakub Jelen b0d3a70b91 coolkey: Improve logging of return codes 2020-01-07 17:07:48 +01:00
Jakub Jelen a4cd265e7c unittests: Cover the decompression API with tests 2020-01-07 17:07:48 +01:00
Jakub Jelen 90aaa9e083 unittests: Increase coverage of decode_entry() 2020-01-07 17:07:48 +01:00
Jakub Jelen 586f0a3e42 unittests: Reproducer for empty OCTET STRINGs calling malloc(0) 2020-01-07 17:07:48 +01:00
Jakub Jelen 9a6cf6af3e configure: Add option to generate code coverage (for unit tests)
./configure --enable-code-coverage --disable-optimization
make check
make code-coverage-capture
lcov --summary OpenSC-*-coverage.info

This does not work well with Windows so on windows it should be disabled (WIP)
2020-01-07 17:07:48 +01:00
Jakub Jelen e8af4fc167 unittests: Add more coverage corner cases for BIT STRINGs 2020-01-07 14:50:48 +01:00
Jakub Jelen 8ddfafe057 asn1: Empty bit string requires empty zero-bits indicator 2020-01-07 14:50:48 +01:00
Jakub Jelen 3af6d7999e unittests: Add tests for non-minimal OBJECT ID encoding
Thanks @hkario for suggestions
2020-01-07 14:50:48 +01:00
Jakub Jelen 2c913155a2 asn1: Do not accept non-minimal encoding of OBJECT IDs 2020-01-07 14:50:48 +01:00
Jakub Jelen 37c8c46623 unittests: Simplify the OBJECT ID tests 2020-01-07 14:50:48 +01:00
Jakub Jelen 1e2b0fe45f unittests: Restructure the BIT STRING tests 2020-01-07 14:50:48 +01:00
Jakub Jelen 71e45bb5a7 unittest: Rewrite the INTEGER unittests to use macros and avoid code duplication 2020-01-07 14:50:47 +01:00
Jakub Jelen aaa302ca35 asn1: Allow non-strict INTEGER parsing for other code paths (FCI parsing) 2020-01-07 14:50:47 +01:00
Jakub Jelen fefff2e462 asn1: Simplify the OID decoding 2020-01-07 14:50:47 +01:00
Jakub Jelen 4569009418 unittests: Improve test coverage mostly with negative test cases
Thanks @hkario for review
2020-01-07 14:50:47 +01:00
Jakub Jelen 89ed273e81 cac1: Simplify the cycle definintion 2020-01-07 14:50:47 +01:00
Jakub Jelen 4faf517af4 asn1: Handle more corner cases of OBJECT ID parsing 2020-01-07 14:50:47 +01:00
Jakub Jelen c449aa4430 asn1: Reject integers with bogus zero/non-zero bytes on left 2020-01-07 14:50:47 +01:00
Jakub Jelen d3e9b55223 asn1: Distinguish error codes for invalid objects from implementation limitation (integer size) 2020-01-07 14:50:47 +01:00
Jakub Jelen 1271299955 ans1: Verify the padding in BIT STRING contains only zero bits 2020-01-07 14:50:47 +01:00
Jakub Jelen 611d1cea4c unittests: Verify BIT STRING parsing as integers 2020-01-07 14:50:47 +01:00
Jakub Jelen c1814571bd asn1: Avoid invalid unused bits values 2020-01-07 14:50:47 +01:00
Jakub Jelen 8d49e4a305 unittests: Test encoding of OIDs and integers 2020-01-07 14:50:47 +01:00
Jakub Jelen 61af2c1d0a asn1: Add support for encoding large values in OIDs 2020-01-07 14:50:47 +01:00
Jakub Jelen 7971bfded3 unittests: Verify parsing of more OIDs 2020-01-07 14:50:47 +01:00
Jakub Jelen 19501715d7 asn1: Correctly handle OIDs with second octet > 39 2020-01-07 14:50:47 +01:00
Jakub Jelen b6b9a886f9 unittests: Verify negative ASN1 integeres parsing 2020-01-07 14:50:47 +01:00
Jakub Jelen 8e6d2e251d unittests: Reproducer for undefined shift in ASN1 parser 2020-01-07 14:50:47 +01:00
Jakub Jelen 8e8c3735bc idprime: Reflect the OS version in the card name 2020-01-07 14:16:46 +01:00
Jakub Jelen bebb5be6e0 idprime: Simplify applet selection and limit file size to sensible values 2020-01-07 14:16:46 +01:00
Jakub Jelen 3537cbbc78 Unbreak RSA-PSS padding 2020-01-07 14:16:46 +01:00
Jakub Jelen fe8f6297f0 idprime: Add support for longer PINs 2020-01-07 14:16:46 +01:00
Jakub Jelen 5017768e5b idprime: Detect the newer version of OS using CPLC data 2020-01-07 14:16:46 +01:00
Jakub Jelen 2c9510af1e Improve parsing of the root file and store also the object length 2020-01-07 14:16:46 +01:00
Jakub Jelen fdcc843e78 idprime: Implement a way of getting token label from special card structure 2020-01-07 14:16:46 +01:00
Jakub Jelen 48e3239857 pkcs15-cac: Use constants rather than magic numbers 2020-01-07 14:16:46 +01:00
Jakub Jelen 9db15089b8 p11test: Avoid memory leaks 2020-01-07 14:16:46 +01:00
Jakub Jelen f61d9b3b53 Implement new Gemalto IDPrime driver
The card is largely ISO 7816 compliant, but does not provide any
simple way of listing the content which is supported by current
PKCS#15 implementation therefore the PKCS#15 emulator had to be
used.

The certificates are compressed in a similar way as in DNIE
cards which complicates reading from the card and which I think
could be moved to the shared ISO (or some other file since I saw
that code already many times).

The card supports wide range of algorithms including
RSA-PSS and RSA-OAEP padding schemes in-card. On the other hand,
it does not allow raw RSA and SHA1 hashes on card anymore.

The card is manufactured by Gemalto so it has strict ATR which
can be used for detection.
2020-01-07 14:16:46 +01:00
Jakub Jelen 3a3a465e6b Add basic support for OEAP decryption in OpenSC internals 2020-01-07 13:30:28 +01:00
Jakub Jelen 40c41cee0c pkcs11-tool: Make the SHA256 default for OAEP decryption
It is already default in all the other functions and it really makes sense since
the SHA1 is being obsoleted
2020-01-07 13:29:53 +01:00
Jakub Jelen 2882c93ec1 pkcs15: Expose the map_usage() function from CAC to other pkcs15 emulators 2020-01-07 13:29:53 +01:00
Jakub Jelen 5e1bfe0acc Drop the pkcs15.h from simpletlv.h 2020-01-07 13:29:53 +01:00
Frank Morgner fe44567d2b avoid redefinition of NDEBUG
fixes https://github.com/OpenSC/OpenSC/issues/1799
2020-01-07 11:27:57 +01:00
Peter Marschall 4d2b860c7f OpenPGP: add ATR for Yubikey 5 2020-01-07 11:09:00 +01:00
Peter Marschall 31b8c7a404 OpenPGP: first steps at supporting OpenPGP card spec 3.4 2020-01-07 11:09:00 +01:00
alex-nitrokey 3af3d0ecee openpgp: add nistp256 and secp251k1 curves for gnuk devices 2020-01-07 11:08:25 +01:00
carblue f14043aad6 opensc-explorer get: prevent sc_read_binary applied on record-based files 2020-01-07 10:35:39 +01:00
carblue c1fb5b130e opensc-tool print_file: fix addressing records 2020-01-07 10:24:10 +01:00
carblue 5dd9fcb25c Fix asn1.c:print_tags_recursive 2020-01-07 10:18:46 +01:00
carblue 4ad55997e0 sc_pkcs15_decode_skdf_entry: break all looping on oid match: on average better performance 2020-01-07 10:17:39 +01:00
Frank Morgner cfd5519b98 simplify PIV I/O 2020-01-07 10:06:23 +01:00
Frank Morgner 31169afb72 fixed fuzzing build
wrapping/unwrapping is hopefully correctly initialized
2020-01-06 22:34:16 +01:00
Priit Laes 0b4b7fbaf0 openssl: Drop all compatibility checks for <=openssl-1.0.0 2020-01-06 15:47:07 +01:00
Priit Laes 295cf100a8 Bump minimum required openssl version to 1.0.1
Everything older than 1.0.2 is not longer supported by the OpenSSL team.
2020-01-06 15:47:07 +01:00
Julian Strobl 6b84407c3d tcos: fix indentation and braces
Increase readability. No content-based changes.
2020-01-06 15:43:46 +01:00
Frank Morgner 45e29056cc Release 0.20.0 2019-12-29 13:42:06 +01:00
Frank Morgner a2b133ef4f Updated NEWS 2019-12-29 13:39:01 +01:00
Khem Raj 05e3f7b667 Fix misleading code indentation
Fixes
error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
         if(cipher)
         ^
../../../git/src/libopensc/card-entersafe.c:369:2: note: previous statement is here
        if(sbuf)
        ^
2019-12-28 18:18:06 +01:00
Julian Strobl e9aa163fe5 pkcs11-tool: fix output of test_decrypt
Before the output looked like this, if a public key was not found:
```
  testing key 1 (IDKey2)
    RSA-X-509: OK
    RSA-PKCS: OK
  testing key 2 (IDKey3)
couldn't find the corresponding pubkey for validation
couldn't find the corresponding pubkey for validation
    RSA-X-509:     RSA-PKCS:   testing key 3 (IDKey4)
couldn't find the corresponding pubkey for validation
couldn't find the corresponding pubkey for validation
```

Now:
```
  testing key 1 (IDKey2)
    RSA-X-509: OK
    RSA-PKCS: OK
  testing key 2 (IDKey3) -- can't find corresponding public key, skipping
  testing key 3 (IDKey4) -- can't find corresponding public key, skipping
```
2019-12-28 18:15:55 +01:00
Julian Strobl 81940e123b pkcs11-tool: align output for test_signature
Before it was a bit confusing, e.g.:
```
  testing key 1 (2048 bits, label=IDKey2) with 1 signature mechanism
    RSA-X-509: OK
couldn't find the corresponding pubkey
  testing key 2 (0 bits, label=IDKey3) with 1 signature mechanism -- can't be used to sign/verify, skipping: can't obtain modulus
```

The error message in line 3 is for IDKey3 and not for IDKey2.

With this patch the output is aligned with `test_verify`:
```
  testing key 1 (IDKey2) with 1 mechanism
    RSA-X-509: OK
  testing key 2 (IDKey3) with 1 mechanism -- can't find corresponding public key, skipping
```
2019-12-28 18:15:55 +01:00
Julian Strobl 9eed40ea31 tcos: add encryption certificate for IDKey
Fixes https://github.com/frankmorgner/OpenSCToken/issues/21
2019-12-28 18:15:55 +01:00
Frank Morgner 1cc6087126 fix buffer length for printing DFs 2019-12-19 04:44:59 +01:00
Benjamin DELPY b59456b6e4 Update card-gids.c to support 3072 & 4096 RSA key sizes 2019-12-19 04:33:14 +01:00
Julian Strobl 187d908feb tcos: allow correct input length when signing
For 2048 bit keys the padded input is 256 bytes long.

Fixes https://github.com/frankmorgner/OpenSCToken/issues/20
2019-12-19 04:30:27 +01:00
Julian Strobl 55b7a6fefd Revert "tcos: Do not advertize non-functional RSA RAW algorithms"
This reverts commit bee5c6d639.

See https://github.com/frankmorgner/OpenSCToken/issues/20#issuecomment-566455157
2019-12-19 04:30:27 +01:00
Frank Morgner 333c41c5d5 pgp: don't write beyond oid object
fixes Stack-buffer-overflow
https://oss-fuzz.com/testcase-detail/6329203163398144
2019-12-18 14:55:46 +01:00
Jakub Jelen af42a93874 tests: Add missing script to the release tarball 2019-12-17 16:09:35 +01:00
Jakub Jelen ee78b0b805 pkcs15-coolkey: Fix EC key type and fail on invalid key types
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19251
2019-12-11 09:19:45 +01:00
Jakub Jelen 708cedbdad dir: Correctly free allocated memory on error
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19265
2019-12-11 09:19:45 +01:00
dojo 17d9d8450c Enabled extended APDU support for StarCOS 3x cards 2019-12-05 16:48:11 +01:00
dojo a450b3427e Fix path unifying of StarCOS 3.5 cards 2019-12-05 16:48:11 +01:00
dojo 9f2c112ecb Add new ATR for StarCOS 3.5 2019-12-05 16:48:11 +01:00
dojo c99d62c04a Add PIN encoding detection for StarCOS 3x cards 2019-12-05 16:48:11 +01:00
Doug Engert 5fa633075d GIDS Decipher fix for TPM
GIDS decipher APDU fails with status '65 00' or '67 00' if
"Padding Indication" byte is present. Debug logs of Microsoft
certutil -v -scinfo  using Microsoft drivers show that for a
decipher, the "Padding Indication" is not present. It maybe
needed if Secure Messaging is added later.

Extended APDU is turned off as this may not be supported on
some cards. Chaining is used used instead, it works on all cards.

RAW RSA is turned off, it is supported.

Tested with pkcs11-tool on Windows 10 with a TPM 2.0 module.

 On branch gids-decipher
 Changes to be committed:
	modified:   src/libopensc/card-gids.c

 Date:      Tue Dec 3 18:08:32 2019 -0600
 interactive rebase in progress; onto 01678e87
 Last commands done (3 commands done):
    squash c968d0dd GIDS No Padding Indication Byte
    squash 0fa940fc Take 3
 No commands remaining.
 You are currently rebasing branch 'gids-decipher' on '01678e87'.
2019-12-05 16:33:27 +01:00
Raul Metsma e91853bda8 Simplify code and card detection
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-12-05 10:51:55 +01:00
AdriaoNeves 366adbd546 Fixing invalid signature with 3072 RSA bits in GemsafeV1 2019-12-05 10:46:21 +01:00
AdriaoNeves dbe932152d Fixing invalid signature with 3072 RSA bits in GemsafeV1 2019-12-05 10:46:21 +01:00
Jakub Jelen 642a3ee734 cardos: Use more appropriate RSA flags for CardOS 5
Fixes #1864
2019-12-05 10:45:34 +01:00
Jakub Jelen afe255c5b2 Remove never set constants and their handling in cardos driver 2019-12-05 10:45:34 +01:00
Jakub Jelen 2bab09ac03 tcos: Use unique IDs for certificates 2019-12-05 10:43:17 +01:00
Jakub Jelen 88e3c44f22 tcos: Drop undocumented tags from security environment data 2019-12-05 10:43:17 +01:00
Jakub Jelen bee5c6d639 tcos: Do not advertize non-functional RSA RAW algorithms 2019-12-05 10:43:17 +01:00
Jakub Jelen 424eca8bef tcos: Remove duplicate lines 2019-12-05 10:43:17 +01:00
Jakub Jelen 4c67bbf383 coolkey: Avoid addressing behind allocated buffers
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19222
2019-12-04 21:47:47 +01:00
Jakub Jelen c246f6f69a coolkey: Make sure the object ID is unique when filling list
Thanks to oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19208
2019-12-04 21:47:47 +01:00
Andreas Schwier 32b49894c5 sc-hsm: Add ATR for faster token variant 2019-12-04 21:43:47 +01:00
Andreas Schwier 7858f3cd06 sc-hsm: Add support for SmartCard-HSM MicroSD card 2019-12-04 21:43:47 +01:00
Frank Morgner 78548a9394 mac: don't forget to uninstall OpenSCTokenApp
fixes https://github.com/OpenSC/OpenSC/issues/1862
2019-12-04 14:55:23 +01:00
Frank Morgner 39c1400fac opensc-notify: fixed name in plist 2019-12-04 14:55:23 +01:00
Jakub Jelen 8ab39bdec7 pkcs11-session: Explicitly reset login_user and release lock 2019-12-04 12:00:07 +01:00
Frank Morgner e9957b9a92 include build-package-from-ci in autoconfig/automake 2019-12-02 16:54:32 +01:00
Frank Morgner 754a409191 added build-package-from-ci until proper dmg creation is realized in CI 2019-12-02 12:31:53 +01:00
Frank Morgner 433377f76e macos: use start_selected instead of selected
otherwise the user's choice would be overwritten when the user clicks
some other installation option.

also, use the domain tag to install to the local drive only
2019-12-02 12:29:32 +01:00
Frank Morgner 118929df93 macos: use generic location for NotificationProxy
to be installed with OpenSC core and to be used from
the tools, tokend and CTK
2019-12-02 08:22:34 +01:00
Frank Morgner a581cbfc2d mac: group CTK token seperately in installer 2019-12-01 00:16:47 +01:00
Jakub Jelen ef61a95b31 coolkey: Make sure the matching objects have same lengths
This ensures that we do not go behind the allocated buffer if
we get wrong data.

Thanks to oss-fuzz:

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19031
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19032
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19038
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19039
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19040
2019-11-29 22:48:00 +01:00
Jakub Jelen aa6d3e1d36 coolkey: Fix the comparator return value 2019-11-29 22:48:00 +01:00
Jakub Jelen 249e928176 gp: Correctly check for the CPLC data length 2019-11-29 22:47:26 +01:00
Jakub Jelen 4f3d87d03c coolkey: Split the CPLC related structures and function to the generic GP file 2019-11-29 22:47:26 +01:00
Jakub Jelen 326955a147 reader-pcsc: Preserve the CARD_PRESENT flag to make sure the card is detected after reader reinsertion 2019-11-28 11:18:25 +01:00
Jakub Jelen 4bd8cda966 pkcs11-session: When we notice logout in lower layers, while pkcs11 thinks we are logged in, invalidate all sessions in given slot 2019-11-28 11:18:25 +01:00
Jakub Jelen e0e1f10bd3 pkcs11/slot: Fix indentation 2019-11-28 11:18:25 +01:00
Oskar Wiksten 79a51e0d18 pkcs11: Support for RSA PSS padding in verify
* Explicitly copies the mechanism parameters during a PKCS#11 `C_VerifyInit`
  and `C_DecryptInit` operation.
* Resolves issues where the calling application deallocates the `pParameter`
  pointer in the `CK_MECHANISM` struct between calls to `C_VerifyInit` and
  `C_Verify`, or between `C_DecryptInit` and `C_Decrypt`.
* These mech parameters are used in RSASSA-PSS and RSAES-OAEP, for example.
* This commit copies the same fix that was applied to `sc_pkcs11_sign_init` in
  commit e5707b545e for supporting RSASSA-PSS.
2019-11-28 11:17:12 +01:00
AdriaoNeves ce71b171e2 Add support for 4K RSA keys in GemsafeV1 2019-11-23 22:13:28 +01:00
carblue 6d98f8c8d8 card-myeid.c: issue #1219 2019-11-23 21:38:14 +01:00
carblue d4823541b7 pkcs15-init: Fix issue #1219 2019-11-23 21:38:14 +01:00
Jakub Jelen 2d02de4233 coolkey: Do not return uninitialized data if card does not return CPLP data
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18990
2019-11-18 14:02:07 +01:00
Frank Morgner bec794fbee fixed memory leak
https://crbug.com/oss-fuzz/18953
2019-11-18 14:01:50 +01:00
Jakub Jelen c4dcac5de7 pkcs15-prkey: Free allocated data on all error exit paths
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18790
2019-11-14 19:36:01 +01:00
Jakub Jelen 6d6d158f13 pkcs15-cert: Free data on all error exit paths
https://oss-fuzz.com/testcase-detail/5645063405436928
2019-11-14 19:36:01 +01:00
Jakub Jelen 5645fe2d16 muscle: Check length first before calling memcmp() 2019-11-14 19:36:01 +01:00
Jakub Jelen 1594b1167d muscle: Initialize variables and check return codes 2019-11-14 19:36:01 +01:00
Jakub Jelen 7360c4bf0c muscle: Avoid access uninitialized memory 2019-11-14 19:36:01 +01:00
Jakub Jelen 2c68c0662c coolkey: Avoid success from init if there are no reasonable data raturned
Thanks to oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18918
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18915
2019-11-14 19:36:01 +01:00
Jakub Jelen 75847f4e93 Make ef_dir variable local
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18821
2019-11-13 15:48:40 +01:00
Jakub Jelen f11c286bc6 coolkey: Refactor the object listing to avoid invalid memory access
Probably resolves some bad memory access from oss-fuzz such as

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18907
2019-11-13 15:48:33 +01:00
Jakub Jelen 07d3d8e0df compression: Free allocated data and return error if nothing was uncompressed
Also harmonizes the return codes from decompress*() functions

Fixes oss-fuzz issue

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18771
2019-11-13 15:48:25 +01:00
Frank Morgner 5557f34f5e Revert "pkcs15-pubkey: Avoid memory leaks"
This reverts commit 0977b5496a.
2019-11-12 11:57:43 +01:00
Jakub Jelen b79db82ae7 openpgp: Workaround non-compliant Yubikey 5 OpenPGP applets
Fixes #1850
2019-11-12 03:38:09 +01:00
Jakub Jelen 0977b5496a pkcs15-pubkey: Avoid memory leaks
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18758
2019-11-11 22:02:53 +01:00
Jakub Jelen cc917b541f asn1: Avoid calling malloc with 0 argument
Caused problems reported by oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18758
2019-11-11 22:02:41 +01:00
Jakub Jelen cd51430ba7 asn1: Avoid malloc(0) also from BIT STRING and GENERALIZED TIME structures 2019-11-11 22:02:30 +01:00
Jakub Jelen e50bc29bd9 card-setcos.c: Avoid unsigned integer underflow
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18798
2019-11-11 22:02:18 +01:00
Jakub Jelen c173563ad2 coolkey: Accept only SW=90 00 as success to prevent interpretting invalid values 2019-11-11 22:02:08 +01:00
Jakub Jelen ef3e223917 coolkey: Do not interpret empty answers as success
Thanks to oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18868
2019-11-11 22:01:56 +01:00
Peter Popovec e6a24b71ab MyEID: fix max_recv_size
MyEID 3.3.3 is not working with hardcoded max_recv_size=256 in
card-myeid.c. Use max_recv_size=255 if card major version < 40

Fixes #1852
2019-11-11 21:01:51 +01:00
Frank Morgner a8de0070fd fixed Null-dereference READ
https://oss-fuzz.com/testcase-detail/5644373382922240
Thanks to OSS-Fuzz
2019-11-06 23:38:37 +01:00
Frank Morgner 1a069ca71e fixed Global-buffer-overflow READ 1
https://oss-fuzz.com/testcase-detail/5685978287308800
Thanks to OSS-Fuzz
2019-11-06 23:08:43 +01:00
Frank Morgner 8fea658fe9 fixed 121888 Time of check time of use 2019-11-05 21:49:30 +01:00
Frank Morgner 3a5a90450e fixed 333715 Dereference after null check 2019-11-05 21:49:30 +01:00
Frank Morgner 7007b4a889 fixed 127766 Out-of-bounds read 2019-11-05 21:49:30 +01:00
Frank Morgner 8d7092c0cb 13598 Unchecked return value 2019-11-05 21:49:30 +01:00
Frank Morgner 192994fa13 fixed 13608 Unchecked return value 2019-11-05 21:49:30 +01:00
Frank Morgner 804cb68057 removed 339153 Logically dead code 2019-11-05 21:49:30 +01:00
Frank Morgner 8d3dfb2f6d ignore for 339158 Dereference before null check 2019-11-05 21:49:30 +01:00
Frank Morgner 07cff0e168 fixed 341844 Incorrect deallocator used 2019-11-05 21:49:30 +01:00
Frank Morgner 8b6ba40a8e fixed 341853 Resource leak 2019-11-05 21:49:30 +01:00
Frank Morgner fa35be5859 fixed 347857 Resource leak 2019-11-05 21:49:30 +01:00
Frank Morgner 2a2662fb3d fixed 348981 Resource leak 2019-11-05 21:49:30 +01:00
Frank Morgner 7a1e42e135 fixed compiler warning
fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18701
2019-11-05 10:58:32 +01:00
Frank Morgner c3f23b836e fixed UNKNOWN READ
Reported by OSS-Fuzz
https://oss-fuzz.com/testcase-detail/5681169970757632
2019-11-03 04:45:28 +01:00
Frank Morgner 6263afbe43 fixed memory leak
Reported by OSS-Fuzz
https://oss-fuzz.com/testcase-detail/5697134632632320
2019-11-03 04:38:09 +01:00
Jakub Jelen d3f60a657f pkcs15*: Fail if there is no fallback file_app 2019-11-01 15:53:40 +01:00
Jakub Jelen b75c002cfb cac1: Correctly handle the buffer limits
Found by oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18618
and others
2019-11-01 15:53:40 +01:00
pkubaj bfa8415ea3 Fix build on ARM, PPC
Those architectures use unsigned char by default, and command variable is later compared to -1.
2019-11-01 15:51:06 +01:00
Jakub Jelen fb15a7dd86 reader-pcsc: Handle yubikey reinsertion
When the application (NSS) does not use WaitForSlotEvent and just
opportunistically tries to detect card and reader removals with
C_GetSlotInfo() and C_GetSessionInfo(), we might get errors in
various plcaes, in the sc_lock() function, when we try to transfer
other messages or when we ask for the reader status.

This is generally too late to call any disconnect functions because no
PC/SC handles are valid anymore. The reader state from PCSC
is searched by name so we can be pretty sure it is very similar
reader (with same name as the old one) and I hope we can reuse the
reader structure and just call the pcsc_connect() on that as we do
with invalid handles.

Otherwise we detect this issue in the refresh_attributes() (called
from C_GetSlotInfo()), where we can report the slot change in the
expected manner.

Fixes #1822
2019-11-01 15:50:34 +01:00
Jakub Jelen 0ea11523a3 Improve logging of exit codes 2019-11-01 15:50:34 +01:00
Frank Morgner 3c87ffaa02 fuzzing: correctly consume fuzzing data 2019-11-01 15:49:10 +01:00
Arnout Engelen a3ee8cefc8 Generate consistent docbook id's 2019-11-01 14:23:40 +01:00
Jakub Jelen 424ebf8ed1 pkcs15: Avoid insane allocations
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18592
2019-10-31 02:18:36 +01:00
Jakub Jelen 51363d3392 cac: Make sure we do not leak memory
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18564
2019-10-31 02:18:20 +01:00
Jakub Jelen 829a73c941 card-npa: Remove dead code 2019-10-31 02:18:04 +01:00
Jakub Jelen 6c7b4bed37 pkcs15*: Avoid null dereference from fuzzers
Thanks oss-fuzz.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18591
2019-10-31 02:17:44 +01:00
Frank Morgner 49f59d9fc9 clean up already enumerated apps 2019-10-29 17:54:40 +01:00
Nuno Goncalves 3ac47fbea9 replace SC_FUNC_CALLED(...,1) with SC_FUNC_CALLED(..., SC_LOG_DEBUG_NORMAL) (close #1698)
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2019-10-28 09:51:28 +01:00
Nuno Goncalves 60581ecc82 remove trailing whitespace
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2019-10-28 09:51:28 +01:00
Frank Morgner 026b6ab43d fuzzing: validate PIN only if it's a PIN
https://oss-fuzz.com/testcase-detail/5693809152753664
2019-10-26 23:56:19 +02:00
Frank Morgner 3c286b3cb1 fixed Null-dereference READ
https://oss-fuzz.com/testcase-detail/5734505646391296

Thanks to OSS-Fuzz
2019-10-26 23:50:11 +02:00
Jakub Jelen 61cd7fcdb2 card-mcrd: Free the allocated structures on cleanup
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18416
2019-10-25 20:25:06 +02:00
Jakub Jelen 6522df7587 pkcs15: Avoid null dereference in fuzzers
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16617
2019-10-25 20:22:40 +02:00
Jakub Jelen 532b06d07e pkcs15: Avoid insane allocations
and use single max constant accross the code

https://oss-fuzz.com/testcase-detail/6314983763214336
2019-10-25 20:22:40 +02:00
Jakub Jelen f0310f7776 Add fuzzing status to the readme 2019-10-25 20:22:40 +02:00
Jakub Jelen 6810eb6cf1 fuzz_pkcs15_reader: Unbreak strict builds
The error was

fuzz_pkcs15_reader.c: In function ‘fuzz_get_chunk’:
fuzz_pkcs15_reader.c:66:19: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
   66 |     *chunk_size = (uint16_t) data->Data;
      |                   ^
cc1: all warnings being treated as errors
2019-10-25 20:22:40 +02:00
Jakub Jelen cc466eea94 asn1: Avoid undefined shifts by adding explicit cast
The error was:
asn1.c:681:23: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
	    #0 0x5e9b11 in decode_bit_field opensc/src/libopensc/asn1.c:681:23

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18487
2019-10-25 20:19:50 +02:00
Jakub Jelen 0d091c8e0c asn1: Avoid integer overflow
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18475
2019-10-23 13:50:52 +02:00
Jakub Jelen 6ce6152284 pkcs15-prkey: Simplify cleaning memory after failure
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18478
2019-10-23 13:50:52 +02:00
Jakub Jelen 19f4c7e428 card-mcrd.c: Avoid null dereference
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18477
2019-10-23 13:50:52 +02:00
Jakub Jelen 1be013d08e asn1: Fix undefined shift in OID parser
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16618
2019-10-22 09:42:18 +02:00
Jakub Jelen 630d6adf32 pkcs15-prkey: Avoid memory leak
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16625
2019-10-22 09:41:14 +02:00
Jakub Jelen 62049ea18c Avoid memory leaks from file selection
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17106
2019-10-22 09:38:30 +02:00
Jakub Jelen 6ef0ac6e67 asn1: Correctly parse negative integers
The negative integers were parsed uterly wrong, resulting in undefined
shift overflows as reported by oss-fuzz.

The current implementation takes negated values (properly masked) and
calculates two's complement in the end, which results in correct values
and correct data handling.

https://oss-fuzz.com/testcase-detail/5125815506829312
2019-10-22 09:33:46 +02:00
Jakub Jelen ff893d2224 pkcs15: Remove unused code 2019-10-22 09:22:59 +02:00
Jakub Jelen 5e9e5b232c card-piv: Fix indentation 2019-10-22 09:17:24 +02:00
Jakub Jelen 459e4ecc37 piv: Avoid insane allocations in fuzzer 2019-10-22 09:17:12 +02:00
Jakub Jelen 544d576b00 asn1: Do not pass null argument to memcpy
Reported by clang analyzer:

src/libopensc/asn1.c:1080:2: note: Null pointer passed as an argument to a 'nonnull' parameter

        memcpy(p, data, datalen);
2019-10-22 09:15:49 +02:00
Jakub Jelen 889d598bcd asn1: Initialize values to avoid comparison with garbage
Reported by clang analyzer:

src/libopensc/asn1.c:2115:14: warning: The right operand of '<' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]

        if (halflen < r_len || halflen < s_len)   {
2019-10-22 09:15:36 +02:00
Frank Morgner 01678e871e CI: retry pushing 10 times to nightly 2019-10-18 14:31:09 +02:00
Frank Morgner 8ded1ae94b travis: include pkgs to later assamble with opensctoken 2019-10-17 23:30:39 +02:00
Frank Morgner 2017626ed2 integrate OpenSCToken 2019-10-17 23:30:17 +02:00
Raul Metsma f4ac617c19 Remove unused card type
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-10-16 13:16:56 +02:00
Frank Morgner 3a1bd36e20
Use onepin-opensc-pkcs11.so for Chromium (#1828)
* pkcs11-register: Fixed detection of already registered OpenSC

Anny configuration of onepin-opensc-pkcs11.so and opensc-pkcs11.so
should be enough to skip registering the default module again.

* Use onepin module for generic NSS DB

fixes https://github.com/OpenSC/OpenSC/issues/1818

May have the disadvantage that some other programs that use NSS don't
see the signature keys. However, we currently only know for sure that
Chromium is using the generic NSS DB.
2019-10-16 13:16:22 +02:00
alex-nitrokey c695a4e35f
Add support for pubkey import if announced in algorithm attributes 2019-10-09 17:18:21 +02:00
alex-nitrokey 606fae5a8e
Use ecpointQ for better code readability 2019-10-09 15:02:36 +02:00
alex-nitrokey ca5b3977d8
Fix ecc oid handling while storing existing keys 2019-10-08 17:11:00 +02:00
alex-nitrokey 8eb5673058
Check keyformat for RSA only inside if RSA key is to be imported 2019-10-08 15:43:40 +02:00
Jakub Jelen eac516fd41 dir: Avoid insane allocations
Resolves:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17449
2019-10-03 13:57:09 +02:00
Jakub Jelen 5490d73f31 card: Avoid integer overflows
Resolves:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17007
2019-10-03 13:57:09 +02:00
Jakub Jelen 34bd879400 openpgp: Properly free the allocated file structure
Resolves:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16879
2019-10-03 13:57:09 +02:00
Jakub Jelen 79cb753921 cac: Free the certificate data on failure
Resolves:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16819
2019-10-03 13:57:09 +02:00
Jakub Jelen d6435b0af4 pkcs15-din-66291: Fix indentation 2019-10-03 13:57:09 +02:00
Frank Morgner 53ff7182fb
pkcs11-tool: disable wrap/unwrap test (#1808)
... until https://github.com/OpenSC/OpenSC/issues/1796 is resolved
2019-10-01 11:52:33 +02:00
Frank Morgner e2491a7d7f
pkcs11-tool: fixed displaying secret key attributes (#1807)
fixes https://github.com/OpenSC/OpenSC/issues/1805
2019-10-01 11:51:55 +02:00
Frank Morgner d965156fe6 fuzz_pkcs15_decode: fixed use after free 2019-09-30 20:02:12 +02:00
Andreas Schwier aae529547c sc-hsm: Fix maximum APDU size to 4K version (Fixes #1794) 2019-09-20 20:35:54 +02:00
Vicente Jimenez Aguilar d4a97c6959 [DOC] dnie-tool -a option includes sw version 2019-09-16 13:50:10 +02:00
Andreas Kemnade b9810e62d6 cardos5: fix reading of serial number
The corresponding GET DATA command only returns the serial,
nothing else.
Tested with CardOS 5.0 and 5.3 cards. The serial number
is the same as shown with other tools
2019-09-16 13:09:16 +02:00
Frank Morgner 25bc8fc167 fix https://github.com/OpenSC/OpenSC/issues/1786
Thanks to Alexandre Gonzalo
2019-09-16 13:06:38 +02:00
Doug Engert 3b632e64a1 Fix #1731 sc_format_apdu_cse_lc_le fails to set Le correctly
Changed four places where "<" should be "<=" so Le will be set correctly
Previous for 65K (extended) or 256 (short) Le is left set to 0.
This then caused Le to be to be not added to APDU as Le==0
Code later converts actual Le in APDU to be set to 0 to mean 256 or 65K.

SC_APDU_CASE_*_EXT are changed to SC_APDU_CASE_* so sc_detect_apdu_cse
to set the cse based on card capabilities as well as data chaining.

This commit is not well tested and neds review.

 On branch fix-1731
 Changes to be committed:
	modified:   src/libopensc/card.c
2019-09-09 12:49:56 +02:00
Frank Morgner 28a93fdf55 fixed memory leak 2019-09-09 09:37:33 +02:00
Frank Morgner 2eaf422cb2 refactor DIN 66291 profile to avoid memory confusion 2019-09-09 09:34:37 +02:00
Frank Morgner 12218d4b0b prepare 0.20.0 2019-09-05 14:24:30 +02:00
Frank Morgner 64d3d81036 fixed invalid free 2019-09-05 08:51:13 +02:00
Frank Morgner 769db0297b fixed memory leak
Credits to OSS-Fuzz
2019-09-02 09:43:50 +02:00
Peter Popovec 5b8095ca2c string null-termination fix
strncpy does not generate null-terminated string, fixed by memcpy.
2019-09-02 09:32:12 +02:00
Frank Morgner f621305140 fixed undefined behavior when parsing negative ASN.1 Integer 2019-08-30 23:45:40 +02:00
Frank Morgner 3e110995bc fixed undefined behavior
Credits to OSS-Fuzz
2019-08-30 23:45:40 +02:00
Frank Morgner e971ffb48e fixed memory leak
Credits to OSS-Fuzz
2019-08-30 23:45:40 +02:00
Frank Morgner 849de1d9e3 fixed memory leak when parsing malformed PKCS#15 data
Credits to OSS-Fuzz
2019-08-30 23:45:40 +02:00
Frank Morgner 6f40e9c553 Unbreak Travis build 2019-08-30 23:15:53 +02:00
Frank Morgner f5bea72637
Add support for 4K RSA keys in CardOS 5 (#1776)
fixes https://github.com/OpenSC/OpenSC/issues/1764
2019-08-29 09:43:37 +02:00
Frank Morgner b5b0991ec0 Travis: test openpgp key generation 2019-08-28 11:06:55 +02:00
Frank Morgner a1d3e76999 openpgp: handle cards with static algorithms
fixes https://github.com/OpenSC/OpenSC/issues/1659
2019-08-28 11:06:55 +02:00
Jakub Jelen 530175009c tests/common: Add different path to softhsm pkcs11 library to test also on different architectures 2019-08-28 11:01:50 +02:00
Jakub Jelen cc9020f56a pkcs15-sc-hsm: Avoid potential memory leaks 2019-08-28 11:01:50 +02:00
Jakub Jelen fb67ffdca6 pkcs15-sc-hsm: Avoid potential memory leaks 2019-08-28 11:01:50 +02:00
Jakub Jelen 14e1f3c4d3 pkcs15-tccardos: Make sure we do not overrun buffers in this wild parsing 2019-08-28 11:01:50 +02:00
Jakub Jelen 489886724f pkcs15-tccardos: Avoid negative indexing 2019-08-28 11:01:50 +02:00
Jakub Jelen cab5d3da17 iasecc-sdo: Avoid potential memory leak 2019-08-28 11:01:50 +02:00
Jakub Jelen 070a37cebd card-authentic: Avoid potential memory leaks 2019-08-28 11:01:50 +02:00
Jakub Jelen 1b32bfe4e5 card-coolkey: Avoid potential null dereference 2019-08-28 11:01:50 +02:00
Jakub Jelen 24eaa3eaa1 card-jcop: Avoid left-shift of negative values 2019-08-28 11:01:50 +02:00
Jakub Jelen 2f643948f1 ctx: Avoid potential memory leaks reported by clang 2019-08-28 11:01:50 +02:00
Jakub Jelen 14dec11ebd travis-ci: Try to run the tests with more recent distros
The javacard simulation unfortunately does not work with anything newer
2019-08-28 11:01:50 +02:00
Frank Morgner bdca524aa8 Fixed memory leak
Credits to OSS-Fuzz
2019-08-27 15:59:46 +02:00
Frank Morgner 03ea3f719c fixed memory leak
Credits to OSS-Fuzz
2019-08-27 15:40:32 +02:00
Frank Morgner 9b4b080be7 fixed compiler warning 2019-08-27 15:27:15 +02:00
Frank Morgner a3fc7693f3 Fixed out of bounds access in ASN.1 Octet string
Credit to OSS-Fuzz
2019-08-27 15:21:46 +02:00
Frank Morgner 412a6142c2 fixed out of bounds access of ASN.1 Bitstring
Credit to OSS-Fuzz
2019-08-27 15:19:22 +02:00
Ludovic Rousseau 2bfd022180 pkcs11-spy: add support of CKM_*_PSS in C_VerifyInit()
In bdb1961dee the same code was added to
C_SignInit(). Now it is also used in C_VerifyInit().
2019-08-27 14:52:10 +02:00
Frank Morgner 2eab2bcd74 fixed out of bounds accessing array
Credit to OSS-Fuzz
2019-08-27 14:00:34 +02:00
Ludovic Rousseau 2240abcef1 spy: display -1 instead of 18446744073709551615
buf_len is a CK_ULONG (unsigned long). But if the attribute is sensitive
or is not extractable or is invalid for the object then the library set
the buffer length value to (CK_LONG)-1.

It is more friendly to see "-1" instead of "18446744073709551615" (on
64-bits CPU)
2019-08-26 10:53:09 +02:00
Ludovic Rousseau 43a8f870e5 pkcs11-spy: add support of CKA_OTP_* values 2019-08-26 10:18:04 +02:00
Ludovic Rousseau e35a7e7395 Add definition of CKA_OTP_* constants 2019-08-26 10:17:05 +02:00
Pierre-Louis Palant b0241eefa1 Integrated virt_CACard in CI jobs (#1757)
Was: "Implement OpenSC CI without HW cards" (https://github.com/OpenSC/OpenSC/pull/1757)
2019-08-20 15:17:14 +02:00
Frank Morgner 9099d95c77 fixed interface change
fixes https://github.com/OpenSC/OpenSC/issues/1768
2019-08-20 14:21:44 +02:00
Peter Popovec d7a86d397f opensc-tool: do not connect card if not neccesary, fix util.c errors
opensc-tool: for options --version, --list-readers, -D, etc. we do not
need to connect card/reader. This removes unnecessary error messages
if card is not present in card reader or if reader is not available.
util.c: use symbolic error codes, pass error codes to caller without change.
2019-08-20 13:38:51 +02:00
Frank Morgner b6be87a348 make sc_format_apdu_ex agnostic to card properties 2019-08-20 13:38:20 +02:00
Frank Morgner 0c563df0c1 document sc_format_apdu_ex() 2019-08-20 13:38:20 +02:00
Frank Morgner 0e97ef2ce3 don't use sc_format_apdu_ex in default driver
fixes https://github.com/OpenSC/OpenSC/issues/1731
closes https://github.com/OpenSC/OpenSC/pull/1734
2019-08-20 13:38:20 +02:00
Frank Morgner 8dc67e6a61 use statement for noop 2019-08-20 13:38:20 +02:00
Raul Metsma fdf80761cf Remove duplicate code
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-08-20 13:38:00 +02:00
Jakub Jelen 9b47462a51 Fix portability warning from coverity
CID 344928 (#1 of 1): Sizeof not portable (SIZEOF_MISMATCH)
suspicious_sizeof: Passing argument object_handles of type CK_OBJECT_HANDLE_PTR and argument objects_length * 8UL /* sizeof (CK_OBJECT_HANDLE_PTR) */ to function realloc is suspicious. In this case, sizeof (CK_OBJECT_HANDLE_PTR) is equal to sizeof (CK_OBJECT_HANDLE), but this is not a portable assumption.
2019-08-20 13:28:54 +02:00
Jakub Jelen 1a0a8e637b p11test: Check return values
CID undefined (#1 of 1): Unchecked return value (CHECKED_RETURN)
10. check_return: Calling RSA_set0_key without checking return value (as is done elsewhere 7 out of 8 times).
2019-08-20 13:28:54 +02:00
Jakub Jelen 818aa5b69c p11test: Avoid possible issues reported by coverity
* The fail_msg() in cmocka has a way not to fail, which confuses coverity. Adding explicit retunr/exit should address this issue
 * Reformat some code in p11test
2019-08-20 13:28:54 +02:00
Jakub Jelen 2958b71c9a typo 2019-08-20 13:28:54 +02:00
Frank Morgner 7d8009e429 PC/SC: handle resets in SCardTransmit
fixes https://github.com/OpenSC/OpenSC/issues/1725
2019-08-20 13:25:06 +02:00
Frank Morgner aa489baf74
md: added missing cardos5 ATRs (#1750)
fixes https://github.com/OpenSC/OpenSC/issues/1735
2019-08-20 13:24:33 +02:00
Frank Morgner 8f838bc1e0 fixed passing LIB_FUZZING_ENGINE 2019-08-19 16:44:54 +02:00
Peter Popovec 426772298a pkcs15-tool: inconsistent -r option fix
Option -r is used in other opensc tools to specify card reader.  pkcs15-tool
uses -r to specify cerfificate.  This fix intorduces warning message if -r
is used, and for future versions of pkcs15-tool -r is used to specify
reader.
2019-08-05 01:14:35 +02:00
Doug Engert 93bdc8c826 Support OpenSSL when deprecated defines have been removed Fixes 1755
sc-ossl-compat.h will check if OpenSSL has been built with or without some
deprecated defines. OpenSSL will provide defines for some of these if
built to still support depreacted routines but not if built with
"no-depracted". .

This commit will define some of the needed defines if ther are not
defined by OpenSSL. Thus if a distro builds OpenSSL with "no-depracted"
it can still be used.

 On branch fix-1755
 Changes to be committed:
	modified:   src/libopensc/sc-ossl-compat.h
2019-07-31 20:12:22 +02:00
Frank Morgner af8f965009 fixed memory leak 2019-07-26 15:23:02 +02:00
Frank Morgner bf8d449795 fixed memory leak 2019-07-26 15:23:02 +02:00
Frank Morgner 973b09f943 fixed exports 2019-07-26 15:23:02 +02:00
Frank Morgner 72f474f09f use consistent parameters
- in sc_pkcs15_wrap()
- and sc_pkcs15_derive()
2019-07-26 15:23:02 +02:00
Frank Morgner e28ada99fe added parameter checking 2019-07-26 15:23:02 +02:00
Frank Morgner b7f202221c fixed undefined reference 2019-07-26 15:23:02 +02:00
Frank Morgner 86c4d3384b removed undefined reference to sc_pkcs15_create 2019-07-26 15:23:02 +02:00
Frank Morgner 45dfc14573 fixed memory leak 2019-07-26 15:23:02 +02:00
Frank Morgner 755ac78a02 added fuzzing with libFuzzer and OSS-Fuzz
makes cmocka detection not required for building tests
2019-07-26 15:23:02 +02:00
Rosen Penev 7159400086 treewide: Fix compilation without deprecated OpenSSL APIs 2019-07-26 08:49:18 +02:00
programatix 91b9aea42a Update pkcs15-sec.c
When card supports SC_ALGORITHM_RSA_PAD_PKCS1 but not SC_ALGORITHM_RSA_HASH_NONE, then the DigestInfo need to be removed.

Current check make requires the card to not support both SC_ALGORITHM_RSA_PAD_PKCS1 and SC_ALGORITHM_RSA_HASH_NONE to have the removal done.
2019-07-26 08:48:10 +02:00
Jó Ágila Bitsch a7766b3de3 allow chaining for pkcs15-init --store-private-key EC keys
when importing a private key onto a pkcs15 card, if the card does not support
extended APDUs, we need to use chaining to store keys longer than 255 bytes.

While for RSA keys, this check was included, it was missing for EC keys.
This patch adds the SC_APDU_FLAGS_CHAINING flag to apdu.flags if data length is
greater than 255 and the card caps does not include SC_CARD_CAP_APDU_EXT.

Fixes #1747
2019-07-24 01:25:49 +02:00
Peter Popovec 8a20b980b9 travis.yml - install socat and ant packages.
Fixes #1745
2019-07-24 01:22:43 +02:00
Raul Metsma d14cf97d7a Allow to create temporary objects with readonly sessions and readonly cards
Fixes #1719

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-07-22 13:34:59 +02:00
Daniel Kouril 916434f3a2 Fix using environmental variables on WIN32. 2019-07-22 13:32:46 +02:00
carblue 709fa98bb5 opensc-tool: fix --list-algorithms for AES 2019-07-22 13:09:30 +02:00
Frank Morgner ba19a467e4
Rutoken Lite (#1728)
* card-rtecp: Add Rutoken Lite

* avoid seperate rutoken lite driver

* added rutoken lite to minidriver

closes #1722
2019-07-22 13:05:32 +02:00
programatix 130e9bb068 Update strings.c 2019-07-04 10:12:23 +02:00
programatix 6b97071bb3 Update strings.c
The check condition is obviously wrong. It should check for EQUAL. The original bitwise check caused any other language to turn into DE because as long as a bit is filtered, it will hit.
2019-07-04 10:12:23 +02:00
Dmitriy Fortinskiy 3c1624676d card-rtecp,card-rutoken: Set specific card types 2019-07-02 12:13:57 +02:00
Dmitriy Fortinskiy 60a2cf16c7 card-rtecp: Fix list_files on T0 cards
Rutoken ECP SC over T0 expects Get Response after SW1=61 which
is not called with zero le.
2019-07-02 12:13:57 +02:00
Frank Morgner 7fb72ccf7b pkcs11: fixed slotIDs when a new slot list is requested
fixes https://github.com/OpenSC/OpenSC/issues/1706

regression of 24b7507a69
2019-06-30 10:24:11 +02:00
Andreas Schwier e7a8c00566 sc-hsm: Use CHR in CSR based on device serial number 2019-06-21 15:08:14 +02:00
Peter Marschall 229dd32e3a opensc-explorer: fix APDU command
Do not ignore first parameter.
2019-06-21 14:34:38 +02:00
Timo Teräs 19711d0a13 myeid: fix EC key upload, and avoid data copying
Fixes regression from commit 3688dfe which did not consider that
the zero prefixing tests were too generic and matched EC keys too.

This simplifies the code even further and avoids data copying
when possible. Proper test is now included to do data value prefixing
only for the RSA keys it is needed.

Closes #1701.
2019-06-17 15:19:08 +02:00
Jakub Jelen 8c12835c9e Update the build status also in the readme 2019-06-17 12:49:11 +02:00
Jakub Jelen 368563ddd6 doc: Fix the description of switch in manual page (copy&paste error) 2019-06-17 12:49:11 +02:00
Jakub Jelen 1c0d26d0f0 .travis.yml Include the MyEID emulation using OsEID simulator in separate target
This also avoids running the make check in the simulation runs, which generates
a lot of output (from clang-tidy)
2019-06-17 12:49:11 +02:00
Jakub Jelen 9197dfe5ae myeid: Detect also OsEID card in the MyEID driver and difference them with separate types 2019-06-17 12:49:11 +02:00
Jakub Jelen 07c0a47b37 card-openpgp: Fix typo in the EC Key size 2019-06-17 12:49:11 +02:00
Jakub Jelen b65275d6f8 p11test: Improve error reporting on unknown EC groups 2019-06-17 12:49:11 +02:00
Jakub Jelen 87770df65b p11test: Implement simple derive tests 2019-06-17 12:49:11 +02:00
Jakub Jelen 852f057ce3 p11test: Add MD5 mechanisms pretty-print 2019-06-17 12:49:11 +02:00
Jakub Jelen 86fd200462 sc-hsm: Check the operation first 2019-06-17 12:49:11 +02:00
Jakub Jelen df0bbc110e pkcs11-spy: Dump EC Derive parameters 2019-06-17 12:49:11 +02:00
Jakub Jelen 10abef9206 pkcs15-sec: Drop unused code (copied from RSA decipher) 2019-06-17 12:49:11 +02:00
Jakub Jelen 272e380898 Set correctly flags for ECDH derive operations 2019-06-17 12:49:11 +02:00
Jakub Jelen 6d751e8b22 opensc.h: Add missing raw ecdh algorithm 2019-06-17 12:49:11 +02:00
Jakub Jelen 293760c0d0 Fix derive operation detection in MyEID and sc-hsm drivers 2019-06-17 12:49:11 +02:00
Andreas Schwier 58fa53ac91 sc-hsm: Add missing secp384r1 curve parameter 2019-06-14 14:29:58 +02:00
Frank Morgner 94388f9538 fixed more clang-tidy warnings 2019-06-05 13:48:51 +02:00
Nuno Goncalves 0322401aae gemsafeV1: remove redundant match card call to allow for opensc.conf match
At the point when gemsafe_match_card is called, the card type is already known,
either because of a previous match at card.c, or because it is forced at opensc.conf.

With this redundant match it's not possible to force selection on opensc.conf.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2019-06-05 13:43:52 +02:00
Raul Metsma 3a192e2c87 pkcs11-tool: Add extractable option to key import
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-06-03 10:59:58 +02:00
Doug Engert a2dd500624 Fix pkcs11-tool encryption error Fix #1694
Make sure data being encrypted is less then the modulus.

 On branch pkcs11-tool-encryption
 Changes to be committed:
	modified:   ../tools/pkcs11-tool.c
2019-05-31 14:16:24 +02:00
Frank Morgner 278960bf88 AppVeyor: push build artifact in PRs as well 2019-05-31 14:15:37 +02:00
Frank Morgner 3a665f6479 allow single character strings with sc_hex_to_bin
fixes https://github.com/OpenSC/OpenSC/issues/1684
fixes https://github.com/OpenSC/OpenSC/issues/1669
2019-05-31 14:15:37 +02:00
Nuno Goncalves e3ff3be4fe pteid: add new ATRs
One ATR have been confirmed on my personal card and also added to the official middleware:

https://svn.gov.pt/projects/ccidadao/changeset/321/middleware-offline/trunk/_src/eidmw/minidriver/makemsi/pteidmdrv.inf

There is another ATR I am adding blind from the official middleware:

https://svn.gov.pt/projects/ccidadao/changeset/321/middleware-offline/trunk/_src/eidmw/minidriver/makemsi/pteidmdrv.inf

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2019-05-31 14:12:12 +02:00
Andreas Schwier be294d01be sc-hsm: Add configuration section for 4K 2019-05-31 14:11:49 +02:00
Andreas Schwier f2a6209c94 Add SmartCard-HSM 4K ATR (#1681) 2019-05-31 14:11:49 +02:00
Ludovic Rousseau 7afa74e049
Merge pull request #1693 from LudovicRousseau/fix
Add missing ulIvBits field to CK_GCM_PARAMS
2019-05-31 14:00:52 +02:00
Ludovic Rousseau cc189585c8 pkcs11-spy: display CK_GCM_PARAMS.ulIvBits field 2019-05-29 15:17:15 +02:00
Ludovic Rousseau 0fbd2663e6 Add missing ulIvBits to CK_GCM_PARAMS
The PKCS#11 specification text does not document the ulIvBits field.
But the header file defining CK_GCM_PARAMS uses it.
Since the header file is the normative version we need to add it.

See also https://github.com/Pkcs11Interop/Pkcs11Interop/issues/126o
and https://lists.oasis-open.org/archives/pkcs11-comment/201602/msg00001.html
and https://www.oasis-open.org/committees/document.php?document_id=58032&wg_abbrev=pkcs11
2019-05-29 15:17:15 +02:00
Frank Morgner 65a86b8331 travis: fixed PATH on macOS 2019-05-21 19:36:17 +02:00
Frank Morgner b7b501d0a5 fixed issues reported by clang-analyzer 2019-05-21 19:34:46 +02:00
Frank Morgner 3c83a80b57 fixed printing non primitive tag
fixes undefined bitshift
2019-05-21 19:34:46 +02:00
Frank Morgner 1423c6bb90 CI: integrate clang-tidy (disabled)
files that have warnings are currently excluded
2019-05-21 19:34:46 +02:00
Raul Metsma 1e59643caa Remove process_arr unused file argument and fix clang-tidy warnings
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-05-21 19:34:46 +02:00
Jakub Jelen e501c5ae81 Unbreak build without OpenSSL 2019-05-21 18:44:06 +02:00
Frank Morgner 65d607af66 fixed 325860 Dereference before null check 2019-05-14 14:50:17 +02:00
Frank Morgner 630bcbedd4 fixed 337490 Unchecked return value 2019-05-14 14:50:17 +02:00
Frank Morgner e275b34269 fixed 339157 Unused value 2019-05-14 14:50:17 +02:00
Martin Paljak a5f63fed0c
Merge pull request #1635 from OpenSC/esteid-2018
EstEID 2018+ driver
2019-05-02 12:54:21 +03:00
Martin Paljak 2829c5870f Address review comments
Change-Id: I9aa97c8a9878dddd3e6f1a2baa877d188b9d7fe5
2019-05-02 11:51:02 +03:00
Martin Paljak 5f5d40521e Avoid 6282 reply for a successful operation
Change-Id: I5d4d3103692fc6db51f13fc5338360289c26af9a
2019-05-02 11:51:02 +03:00
Martin Paljak fc8e9bf3f3 Address review comments and further reduce LOC
and make sure the card is always handled emulated card first

Change-Id: I60174c2793bb882fb73716f62a652d84e028382c
2019-05-02 11:51:02 +03:00
Martin Paljak b3d4a0d69a EstEID 2018+ driver
This adds support for a minimalistic, small and fast card profile based on IAS-ECC.

Based on information from https://installer.id.ee/media/id2019/TD-ID1-Chip-App.pdf
and proprietary driver snoops.

Thanks to @metsma and @frankmorgner.

Change-Id: I2e4b4914d8a3b991d9a639728695abf4a2362ca0
2019-05-02 11:47:31 +03:00
Andreas Kemnade c3a9458fa8 egk-tool: fix missed initialisation of card pointer
If util_connect_card_ex() fails, sc_disconnect_card() will use a
random pointer leading to segmentation faults.
2019-05-02 10:09:08 +02:00
Andreas Kemnade 209be72979 eGK: fix path for vd/gvd
path was wrong, the same as for pd
2019-05-02 10:09:08 +02:00
Andreas Kemnade 9ca836975a Starcos: added another ATR for 2nd gen. eGK (TK) 2019-05-02 10:09:08 +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
Frank Morgner f0a6a568f4 fixed Local variable hides global variable 2019-05-02 10:08:28 +02:00
Frank Morgner 0bc95cb6a1 added include guards 2019-05-02 10:08:28 +02:00
Frank Morgner 86ba3ea489 fixed Wrong type of arguments to formatting function 2019-05-02 10:08:28 +02:00
Raul Metsma 5123531e62 Fix EstEID 3.4 signing
opensc master requires now SC_ALGORITHM_RSA_HASH_NONE

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-05-02 10:06:19 +02:00
Frank Morgner 7449b00768 pkcs11: avoid double initialization of notify 2019-04-26 23:51:37 +02:00
Frank Morgner c671083ee3 fixed missing file 2019-04-25 16:46:07 +02:00
Frank Morgner 7df789ec5d fixed 337490 Unchecked return value 2019-04-25 15:44:11 +02:00
Frank Morgner 8382f243b2 fixed 337891 Out-of-bounds write 2019-04-25 15:44:11 +02:00
Frank Morgner 1a656f2abe use OpenPACE 1.1.0 2019-04-25 15:44:11 +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
Timo Teräs 3688dfe238 MyEID: simplify key component loading
Encode the component ID to be key type and component ID. This allows
each combination to be unique and direct mapping to card component
ID type in the code by just taking the low byte. This simplifies
the code, and reduces confusion as there is now only one #define
for each component.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2019-04-25 14:53:10 +02:00
Timo Teräs 3f832ca6da MyEID: implement support for 4K RSA keys (MyEID 4.5+)
MyEID starting version 4.5 supports 4K RSA keys. The card also
now supports proper APDU chainging (for sending large APDUs) and
receiving large responses via GET_RESPONSE splitting.

This updates the following:
* detection code properly announces 3K and 4K RSA support
  when available
* APDU chaining is used when possible
* use ISO GET_RESPONSE handling for large responses
* max_recv_size is set to 256 which it always was supposed to be
  as the old cards respond with that large responses too
* use the 2K signing kludge only on cards that need it
* unwrap and decipher code paths unified to the extent possible

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2019-04-25 14:53:10 +02:00
Timo Teräs 0e25c1d2a6 MyEID: detect card from ATR historical data instead of full ATR
This will simplify the matching code, and match prototype cards.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2019-04-25 14:53:10 +02:00
Raul Metsma 3d22d04113 No need link to libssl
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-25 14:52:43 +02:00
Ludovic Rousseau ffaaf1c0d3 pkcs11-spy: parse CKM_AES_GCM for C_EncryptInit() 2019-04-25 14:52:20 +02:00
Ludovic Rousseau 69727c79ad pkcs11.h: add CK_GCM_PARAMS structure 2019-04-25 14:52:20 +02:00
Ludovic Rousseau 98ec27e768 pkcs11-spy: log pParameter buffer for C_EncryptInit & C_DecryptInit 2019-04-25 14:52:20 +02:00
Frank Morgner bfa94dc90d
Merge pull request #1600 from AlexandreGonzalo/trustonic_pkcs11 2019-04-25 14:51:54 +02:00
Frank Morgner b06398c1af macOS: install man, doc, completion to /usr/local 2019-04-25 14:49:40 +02:00
alegon01 e21cb5712c Fix in encrypt_decrypt(), initialize the mgf 2019-04-24 14:03:35 +02:00
Jakub Jelen 13429baed0 cac: Avoid signed/unsigned casting reported by coverity
src/libopensc/card-cac.c:1707: negative_returns: "val_len" is passed to a parameter that cannot be negative.
2019-04-23 14:49:45 +02:00
Frank Morgner abc6cfbe68 Added more CI card testing 2019-04-18 02:03:28 +02:00
Frank Morgner 8f2b4c7923 macos: use hierarchical layout for installer 2019-04-18 01:42:58 +02:00
Dmitriy Fortinskiy 8cf1e6f769 pkcs11-tool: List supported GOST mechanisms 2019-04-17 16:42:12 +02:00
Dmitriy Fortinskiy a5382d32fd pkcs11-tool: Show GOSTR3410-2012 keys 2019-04-17 16:42:12 +02:00
Dmitriy Fortinskiy 0e12b1dc71 pkcs11-tool: Generate GOSTR3410-2012 keys 2019-04-17 16:42:12 +02:00
Dmitriy Fortinskiy 4614beb87e pkcs11-tool: Add keys access flags 2019-04-17 16:40:41 +02:00
Dmitriy Fortinskiy 2600f1ae43 win32: Add Rutoken ECP ATRs to the minidriver 2019-04-17 16:38:49 +02:00
Dmitriy Fortinskiy aff2059ec1 card-rtecp: Fix SELECT FILE 2019-04-17 16:38:49 +02:00
Dmitriy Fortinskiy fe4dae4d31 card-rtecp: Add Rutoken ECP SC ATR 2019-04-17 16:38:49 +02:00
Raul Metsma 91a1dd9af4 Option to delete object by index
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-17 14:38:40 +02:00
Raul Metsma 3935d501bf Implement Secret Key write object
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-17 14:37:49 +02:00
Frank Morgner 46930fc0c4 added missing outline-choice 2019-04-08 11:16:13 +02:00
Frank Morgner 79306833bf fixed typo 2019-04-08 11:16:13 +02:00
Frank Morgner 58d201de4b autostart is a subfeature of OpenSC tools 2019-04-08 11:16:13 +02:00
Frank Morgner ea8fe5e760 win32 installer: changed wording 2019-04-08 11:16:13 +02:00
Frank Morgner 34b1ebc15d win32: install opensc.dll only with the tools
everything else is statically linked
2019-04-08 11:16:13 +02:00
Frank Morgner be2df3b66b WiX: count versions for installer 2019-04-08 11:16:13 +02:00
Frank Morgner 3ef295705f don't use deprecated WiX option 2019-04-08 11:16:13 +02:00
Frank Morgner 066c30bb4e opensc-notify: add to autostart 2019-04-08 11:16:13 +02:00
Frank Morgner 9092782f94 CI: only push artifacts on OpenSC/OpenSC 2019-04-08 11:16:13 +02:00
Frank Morgner 159821497c egk-tool: fixed verbose logging 2019-04-08 11:16:13 +02:00
Frank Morgner fe95520e3e explicitly import libpkcs11.h 2019-04-08 11:16:13 +02:00
Frank Morgner 6f9b58af72 added pkcs11-register 2019-04-08 11:16:13 +02:00
Jakub Jelen 83eeafca3c tests: Check the behavior of CKA_ALLOWED_MECHANISMS 2019-04-08 11:15:19 +02:00
Jakub Jelen fc4d600634 pkcs11-tool: Allow to set CKA_ALLOWED_MECHANISMS when creating an objects
Also list them in the attributes listing
2019-04-08 11:15:19 +02:00
Jakub Jelen 775d120517 tests: Verify the ECDSA signatures work 2019-04-08 11:15:19 +02:00
Jakub Jelen 8c99e5076a tests: Verify the pkcs11-tool --test works
Note, that it does not work now until #1600 will get resolved. Then,
move the test to TESTS in the Makefile.am
2019-04-08 11:15:19 +02:00
alegon01 f631b5f733 Fix in encrypt_decrypt(), check for (in_len <= sizeof orig_data) 2019-04-05 10:39:52 +02:00
alegon01 4913feadb8 Fix in encrypt_decrypt(), check for (in_len <= sizeof orig_data) 2019-04-05 10:38:12 +02:00
Frank Morgner fd20ffe608
optimize bin/hex low parsing level functions (#1646)
* optimize sc_hex_to_bin

* optimize sc_bin_to_hex

* added documentation

closes https://github.com/OpenSC/OpenSC/pull/1643

thanks to carblue <ka6613-496@online.de>
2019-04-04 12:52:08 +02:00
Frank Morgner 0abe9d11c7 pkcs11: (de-) initialize notifications on load
fixes https://github.com/OpenSC/OpenSC/issues/1507
fixes https://github.com/OpenSC/pkcs11-helper/issues/16
2019-04-04 11:04:50 +02:00
Raul Metsma 9ba8f56037 Change u8 *data to const because sc_apdu unsigned char *data is const
Name sc_format_apdu parameters for IDE help hints

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-03 22:15:54 +02:00
Frank Morgner f3d8ad9f90 macOS: fixed propagating OpenPACE flags 2019-04-03 14:50:04 +02:00
Frank Morgner f1e9108502 fix cygwin build
fixes https://github.com/OpenSC/OpenSC/issues/607
2019-04-01 12:54:06 +02:00
Raul Metsma 4ba086bfd4 Use strdup and fix all casts
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-01 12:53:33 +02:00
Martin Paljak ea74308512 iso7816_read_binary: do not assume that 6282 is returned with data
Instead of a double check_sw call in case there is no data, assume
that a SW is properly sent by the card and do not expose
SC_ERROR_FILE_END_REACHED outside of the function
(like sc_pkcs15_read_file)

This is to facilitate Estonian eID 2018+ that instead of properly returning
6282 with trunkated data, 9000 is returned and next READ BINARY returns
6b00 (invalid p1/p2). The change should be generally harmless for well-behaving
cards.

Change-Id: I7511ab4841d3bcdf8d6f4a37a9315ea4ac569b10
2019-04-01 12:51:00 +02:00
Peter Popovec f070c99b65 opensc-tool: do not use card driver to read ATR
If card driver fails to connect to card, 'opensc-tool -a' may fail to print
ATR even if ATR is available from card reader.  Before use of card driver,
do only card reader connect, then print ATR.  Only if it is neccesary, use
card driver for the rest of opensc-tool functions.
2019-03-25 14:34:26 +01:00
Frank Morgner b389b19ca5
Merge pull request #1633 from metsma/esteid
Only EstEID 3.5 has EC 384 keys
2019-03-25 14:31:02 +01:00
Frank Morgner 2f4df1b93e tools: unified handling of gengetopt 2019-03-25 14:30:09 +01:00
Frank Morgner fc9277b778 use compat_getopt_long if getopt_long is not available
uses the autoconf way for replacing getopt.h

fixes https://github.com/OpenSC/OpenSC/issues/1527
2019-03-25 14:30:09 +01:00
Raul Metsma 7ae54f490d Remove dead code (#1638) 2019-03-25 14:28:53 +01:00
Frank Morgner 8dea0a9028 fix overlapping memcpy
Fixes https://github.com/OpenSC/OpenSC/issues/1631
2019-03-18 23:33:24 +01:00
Frank Morgner 6aa5410e73 goid-tool: live with short length APDUs 2019-03-18 13:59:11 +01:00
Raul Metsma 4d2254a092 Only EstEID 3.5 has EC 384 keys
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-03-13 23:01:07 +02:00
Frank Morgner 2e87e4cfed fixed issues from review 2019-03-13 21:22:19 +01:00
Frank Morgner b7ec7f95b1 pkcs11: fixed token label 2019-03-13 21:22:19 +01:00
Frank Morgner 0079d836f3 pkcs11: truncate oversized labels with '...' 2019-03-13 21:22:19 +01:00
Raul Metsma 1e6d3df201 Remove un-lincenced header file
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-03-13 21:19:26 +01:00
Frank Morgner 71b85d15e4 opensc.conf: Configure handling of private_certificate
possible choices: ignore, protect, declassify

fixes https://github.com/OpenSC/OpenSC/issues/1430
2019-03-13 21:18:57 +01:00
Frank Morgner 1e0743b29f removed untested use of SC_SEC_OPERATION_AUTHENTICATE
fixes https://github.com/OpenSC/OpenSC/issues/1271
2019-03-13 21:17:54 +01:00
Frank Morgner 106b3a28b1 acos5: removed incomplete driver
fixes https://github.com/OpenSC/OpenSC/issues/1204
2019-03-13 21:17:54 +01:00
Frank Morgner 9fa1722f73 sc_bin_to_hex returns a Nul terminated string 2019-03-13 21:17:00 +01:00
Frank Morgner eb8f28db20 fixed error handling 2019-03-13 21:17:00 +01:00
Frank Morgner d4f1decd15 Make sure card's strings are Nul terminated
Avoids out of bounds reads when using internal operations with the given string
2019-03-13 21:17:00 +01:00
Frank Morgner d953998aa3 npa-tool: force default card driver 2019-03-13 12:01:09 +01:00
alegon01 31831c300b Remove the call to OPENSSL_init_crypto() which is not needed. I have a segmentation fault when the process exits. 2019-03-12 08:52:06 +01:00
Raul Metsma f341b758e6 Add installer option to deselect tokend
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-03-11 23:22:11 +01:00
Frank Morgner 6472027848 tools: release context when card connection fails 2019-03-07 22:18:54 +02:00
Pierre Ossman bc4eeda573 Remove readers when smart card service stops
The code already removes all active cards when the service goes
away, but it doesn't remove the reader. This can be a bit confusing
since they will still be polled and listed.
2019-03-07 21:51:02 +02:00
Pierre Ossman 9ed5f63c17 Fix smart card removal handling for older PC/SC
Older PC/SC doesn't have the code SCARD_E_NO_READERS_AVAILABLE, so fix
the code to handle such systems as well.
2019-03-07 21:51:02 +02:00
Pierre Ossman 9e9bdac2f1 Handle reader going missing
It might just be this specific reader going missing, and not all
of them.
2019-03-07 21:51:02 +02:00
Raul Metsma b227fb8b9f Cleanup EstEID 1.0/1.1 lefovers
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-03-07 21:31:08 +02:00
Scott Gayou 0d79675497 Small memory leak fix (CVE-2019-6502 in #1586)
CVE-2019-6502 was assigned to what appears to be a very minor
memory leak that only occurs on an error-case in a CLI tool.
If util_connect_card fails, we still need to release the sc
context previously allocated by sc_context_create else memory
will leak.
2019-03-06 19:51:43 +01:00
alegon01 728d099a53 FIX typo OpenSSL vs OpenSsl. 2019-03-06 11:35:11 +01:00
alegon01 b327b76134 FIX use pseudo_randomize() for a proper initialization of orig_data in encrypt_decrypt(). 2019-03-06 10:26:05 +01:00
Frank Morgner 19c5ab315d fixed uninitialized use of variable 2019-03-06 08:53:47 +01:00
Frank Morgner 070370895f fixed 333707 Dereference before null check 2019-03-06 00:42:38 +01:00
Frank Morgner 8fbd0b3ee1 fixed 333708 Dereference after null check 2019-03-06 00:42:38 +01:00
Frank Morgner ba185954c5 fixed 333709 Unchecked return value 2019-03-06 00:42:38 +01:00
Frank Morgner e8f8f0bfbb fixed 333714 Uninitialized scalar variable 2019-03-06 00:42:38 +01:00
Frank Morgner 9abe44f03c fixed 333715 Dereference after null check 2019-03-06 00:42:38 +01:00
Frank Morgner e876cf62eb fixed 333711 Dereference before null check 2019-03-06 00:42:38 +01:00
Frank Morgner b1a58c7925 removed dead code 2019-03-06 00:42:38 +01:00
Frank Morgner 27526de021 implemented sc_format_apdu_ex 2019-03-05 13:54:13 +01:00
Frank Morgner 155b197932 sc-hsm: require T=1 connection 2019-03-05 13:47:45 +01:00
Frank Morgner f3e6639de6 added GoID CVCA 2019-03-05 13:17:15 +01:00
alegon01 7271fe610b Add support for the OpenSsl signature format for the signature verification. 2019-02-18 16:03:41 +01:00
Frank Morgner 20daced605 fixed special case of deletion in gnuk_write_certificate 2019-02-14 09:22:23 +01:00
Frank Morgner 1a61ae849f fixed Null pointer argument in call to memcpy 2019-02-14 09:22:23 +01:00
Frank Morgner b6fadb469f fixed sc_decompress_zlib_alloc return code 2019-02-14 09:22:23 +01:00
Frank Morgner 6e48de83c7 avoid allocation of 0 bytes 2019-02-14 09:22:23 +01:00
Frank Morgner f4fccfd94e fixed undefined bitshift 2019-02-14 09:22:23 +01:00
Frank Morgner c858d4b3d1 fixed argument checking 2019-02-14 09:22:23 +01:00
Frank Morgner 6fdb29a470 fixed use of uninitialized values 2019-02-14 09:22:23 +01:00
Frank Morgner 01d515a026 fixed use of garbage value 2019-02-14 09:22:23 +01:00
Frank Morgner 8ea77a83e0 fixed misuse of realloc 2019-02-14 09:22:23 +01:00
Frank Morgner 32e1995300 fixed dead assignment 2019-02-14 09:22:23 +01:00
Frank Morgner e4a01643a6 fixed possible NULL pointer dereference 2019-02-14 09:22:23 +01:00
Frank Morgner 53954e9ff1 fixed OpenSSL handling in PKCS#11 mapping
prevents NULL pointer dereference
2019-02-14 09:22:23 +01:00
Frank Morgner b708cab0a3 fixed assignment of garbage value 2019-02-14 09:22:23 +01:00
Frank Morgner 85485eb9b0 fixed unused assignments 2019-02-14 09:22:23 +01:00
Frank Morgner fdb0e6d581 Fixed Potential leak of memory 2019-02-14 09:22:23 +01:00
alegon01 9ae507c5f8 Fix indentation. 2019-02-12 14:09:26 +01:00
alegon01 b63a868e68 Fix build when EVP_PKEY_CTX_set_rsa_oaep_md is not defined. 2019-02-12 10:42:39 +01:00
Raul Metsma c2cc83754e select_esteid_df is only used in card-mcrd.c
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-02-12 08:56:20 +01:00
Raul Metsma f37a8a5c52 is_esteid_card is only used card-mcrd.c
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-02-12 08:56:20 +01:00
Peter Marschall 4757466f27 OpenPGP: space police
remove trailing spaces & tabs
2019-02-12 08:55:59 +01:00
Alex Karabanov 04ef9dbf3b Fix build on cygwin in strict mode (#1605) 2019-02-11 20:50:12 +01:00
Frank Morgner be33e82b75 goid-tool: fixed possible memory leak
internally created context needs to be freed if TA/CA is done without
an existing SM context from PACE
2019-02-11 15:41:32 +01:00
Frank Morgner 72cdc9d82e goid-tool: fixed confusion about always/never acl 2019-02-08 15:08:03 +01:00
Frank Morgner aca9d79f6d fixed parsing SoCManager info 2019-02-07 16:56:33 +01:00
alegon01 973625773b Fix encrypt_decrypt() for CKM_RSA_PKCS_OAEP. It is working fine now with OpenSsl 1.1.1a. 2019-02-07 10:42:48 +01:00
alegon01 084624f340 Fix CKM_RSA_PKCS in encrypt_decrypt(). 2019-02-05 12:03:51 +01:00
alegon01 9aa413bd7e Fix CKM_RSA_X_509 encrypt_decrypt(). Improve the code for CKM_RSA_PKCS and CKM_RSA_PKCS_OAEP. For these alogs, only CKM_SHA_1 is supported. 2019-02-05 11:35:42 +01:00
alegon01 d25fbe3cec Remove 2 useless comments in encrypt_decrypt(). 2019-02-05 11:24:33 +01:00
Frank Morgner 928fbf2f03 goid-tool: implented PIN/FP verification for PAccess 2019-02-04 16:01:56 +01:00
alegon01 3d09823df0 Fix build when OPENSSL_NO_RIPEMD and OPENSSL_NO_CAST are defined. Fix formatting. 2019-02-04 14:26:02 +01:00
alegon01 f030aa2c25 Add support for CKM_RSA_X_509 in encrypt_decrypt() and decrypt_data(). 2019-02-04 14:23:13 +01:00
alegon01 9b7605ff3c Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). Only set the OAEP params for CKM_RSA_PKCS_OAEP, I had an issue with a variable not initialized. 2019-02-01 15:27:55 +01:00
alegon01 cf617da4bd Before calling encrypt_decrypt() make sure that the mechanism is for RSA and supports decryption, otherwise skip it. 2019-02-01 11:37:47 +01:00
alegon01 2be799f739 Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). fix mechanism value in call to util_fatal(). fix formatting. 2019-02-01 11:35:25 +01:00
alegon01 16ca73ae40 Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). fix mechanism value in call to util_fatal(). 2019-02-01 11:19:33 +01:00
alegon01 968bfa8444 Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). 2019-02-01 09:16:59 +01:00
alegon01 ff3448fb18 Fix build when OPENSSL_NO_RIPEMD and OPENSSL_NO_CAST are defined. 2019-02-01 09:13:21 +01:00
alegon01 f412995811 Bug fix in verify_signature() when the buffer to verify is larger than 1025 bytes. In this case, the signature length given to C_VerifyFinal() was incorrect. 2019-02-01 09:10:02 +01:00
Frank Morgner 3dd0638623 initialize package suffix with branch and PR 2019-01-31 16:01:14 +01:00
Raul Metsma 36c5461c99 Make function more readable
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-01-30 22:02:14 +01:00
Hannu Honkanen ec176443e2 Fixes an issue that appeared in 6bf9685 (PR #1540). In case use_pinpad==0 && pinsize == 0, uninitialized pinbuf was passed to sc_pkcs15_verify_pin causing problems. 2019-01-30 22:01:52 +01:00
opensignature 84f0a88edb Remove postecert and infocamere support because no longer issued (#1584)
* Remove postecert and infocamere support because no longer issued

* Remove wrong changes

* reset NEWS

* EC_POINT_set_affine_coordinates_GFp and EC_POINT_get_affine_coordinates_GFp are
deprecated, use EC_POINT_set_affine_coordinates and EC_POINT_get_affine_coordinates

* If OPENSSL API version is < 3 use old functions EC_POINT_[sg]et_affine_coordinates_GFp

* Move the OpenSSL compatibility stuff to src/libopensc/sc-ossl-compat.h
2019-01-30 22:01:24 +01:00
Alexander Paetzelt 09a594d0f0 OpenPGP Card v3 ECC support (#1506)
* pgp: initialize ecc keys for OPC3

* Add supported ECC algorithms by card version

* Add tasks identified so far

* pgp: Recognize ECC set on card

* pgp: get_pubkey_pem read ECC pubkey from card

* pgp: minor code changes for ECC compatibility

* pgp: expand sc_cardctl_openpgp_keygen_info to hold ec info

* Fix segfault problem in pkcs15-pubkey.c

* pgp: enable key generation with pkcs15-init and ECC

* pgp: adapt calculate_and_store_fingerprint to accept ECC

* pgp: adapt rest of pgp_gen_key and subfunctions to accept ECC

* pgp: add kdf parameters for ECDH fingerprint calculation

* pgp: enable key import with pkcs15-init and ECC

* pkcs15-pubkey: fix_ec_parameters onlz accpets explicit data or named_curve

* Fix some mistakes during merge

* More clean up for PR

* Fix some ugly alignments

* Improve code readability

* Prevent unitialized variable by using FUNC_RETURN

* OpenPGP: add length check

* pgp: save exponent length in bits for sc_cardctl_openpgp_keystore_info_t

* pgp: length checks and reallocations

* pgp: oid init added

* OpenPGP: slightly re-factor pgp_update_new_algo_attr()

* replace loop copy with memcpy()
* use ushort2bebytes() to set RSA modulus & exponent
* use symbolic name SC_OPENPGP_KEYFORMAT_RSA_STD for the key import format

* OpenPGP: slighly re-factor pgp_parse_and_set_pubkey_output()

* check for RSA modulus & exponent lengths not being a multiple of 8
* make sure RSA modulus & exponent lengths are always set
* remove a left-over RSA setting from the EC code

* pgp: adding BYTES4BITS

* pgp: initialization of values in pgp_build_extended_header_list based on key type

* pgp: add BYTES4BITS and remove unnecessary tests

* Fix broken pgp_update_new_algo_attr

* pgp: fix the ecpoint_len variable
2019-01-30 22:00:36 +01:00
Frank Morgner 7a7ff50422 fixed memory leaks during card initialization 2019-01-30 21:57:59 +01:00
Frank Morgner f486486413 removed unused defines 2019-01-30 21:57:59 +01:00
Frank Morgner 97a58cb441 fixed https://github.com/OpenSC/OpenSC/issues/1581 2019-01-30 21:57:59 +01:00
Frank Morgner aed95b2f2b pkcs11: check inputs
prevents NULL pointer dereference
2019-01-30 21:57:59 +01:00
Frank Morgner 993f6f5cc6 Use opensc-pkcs11.so for static build of pkcs11-tool
Statically link opensc-pkcs11 into pkcs11-tool with --disable-shared
2019-01-30 21:57:59 +01:00
Frank Morgner 887340c04d Generalized fuzzing script 2019-01-30 21:57:59 +01:00
Frank Morgner 7f7bcbff52 fixed misuse of realloc
calling it with size 0 leads to a free, which eventually may lead to a
double free corruption.
2019-01-30 21:57:59 +01:00
Frank Morgner d0b499cda3 reuse previous fuzzing results if possible 2019-01-30 21:57:59 +01:00
Frank Morgner 9e5d7bc873 added minimal test script for fuzzing with AFL
Credits go to https://www.x41-dsec.de/lab/blog/smartcards/
2019-01-30 21:57:59 +01:00
Frank Morgner 2ad7453718 use const qualifier for sc_simpletlv_read/put_tag 2019-01-30 21:57:59 +01:00
Frank Morgner 893be0d9c0 fixed memory leaks 2019-01-30 21:57:59 +01:00
Frank Morgner 83c4ebe9d6 goid-tool: reset authentication status 2019-01-30 13:00:14 +01:00
Frank Morgner fc08d89247 goid-tool: differ PAccess and SoCManager usage 2019-01-30 09:35:16 +01:00
Frank Morgner a8c84d490a handle multiple verifications when changing secret 2019-01-30 09:35:11 +01:00
Raul Metsma 70d690ace7 r value is already checked on line 113 (#1582) 2019-01-24 13:15:13 +01:00
Jakub Jelen f161c3a178 Remove repeated words from manual pages 2019-01-23 20:41:01 +01:00
Frank Morgner 4916d07ff2 fixed unused check 2019-01-20 23:02:21 +01:00
Frank Morgner 1565f48084 added LGTM badge 2019-01-20 23:02:21 +01:00
Frank Morgner 79d019fc5f fixed typo
closes https://github.com/OpenSC/OpenSC/issues/1576
2019-01-20 23:02:21 +01:00
Frank Morgner 745b8cf420 added include guards to compatibility headers 2019-01-20 23:02:21 +01:00
Frank Morgner 6bf7c0d219 don't hide global variables 2019-01-20 23:02:21 +01:00
Frank Morgner 1991dcea0d removed unused comparison 2019-01-20 23:02:21 +01:00
Frank Morgner 3fe198f21e treat records with size_t 2019-01-20 23:02:21 +01:00
Frank Morgner 1106508656 removed tautologic comparison 2019-01-20 23:02:21 +01:00
Frank Morgner 4b30858092 pkcs11-tool: fixed argument type
reported by lgtm
2019-01-20 23:02:21 +01:00
Frank Morgner d806ee3245 fixed unsafe usage of gmtime
reported by lgtm
2019-01-20 23:02:21 +01:00
Frank Morgner b8b4f7c36f goid-tool: added error checking for verify/change 2019-01-18 23:02:36 +01:00
Martin Paljak c3a9837b10 Add mechanisms used by SoftHSM2
/Library/OpenSC/bin/pkcs11-tool --module /usr/local/lib/softhsm/libsofthsm2.so -M

will not show any more numeric mechanisms.

Source: https://www.cryptsoft.com/pkcs11doc/STANDARD/include/v240e01/pkcs11t.h
2019-01-15 13:07:58 +02:00
Raul Metsma 3c1d425eb9 Remove unused include
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-01-15 12:48:26 +02:00
Mat e19fe680c4 Add object type "secrkey" to help of --type switch in pkcs11-tool (#1575)
* Add object type "secrkey" to help of --type switch in pkcs11-tool

Reading an object with pkcs11-tool requires the `--type` switch. The help for that switch is currently incomplete as it is missing the (not very friendly named" *secrkey* option used to read out a secret key object.

I have added this information to the help description.

* Update man page

Describe secrkey option of pkcs11-tool's --type switch in man page
2019-01-15 07:32:41 +01:00
Hannu Honkanen 87d7eb2214 Select MyEID applet with AID in myeid_init() to ensure that it is selected before sending other commands. 2019-01-15 07:32:03 +01:00
Doug Engert 08a02ed5d2 Fix PKCS#11 Object Restrictions
Framework-pkcs15.c silently ignores adding objects if MAX_OBJECTS
is exceeded while creating the fw_data objects. This simple fix
is to change the MAX_OBJECTS from 64 to 128. A better fix would
be to realloc the objects arrays as needed.

__pkcs15_create_data_object and __pkcs15_create_secret_key_object
now return rv like the other  __pkcs15_create_*_object routines.

pkcs15_dobj_get_value now calls sc_pkcs15_read_data_object just like
the other pkcs15_*_get_value routines. The problem was introduced
in 0c3412bb 2018-04-09 which added:
 `return sc_to_cryptoki_error(SC_SUCCESS, "C_GetAttributeValue");`
before trying to read the data object.

The MAX_OBJECT problem was discovered while trying to use a new PIV
card with 24 standard cert objects and 10 other objects for a total
of 106 objects. Each cert object corresponds to a cert, pubkey,
private key, and the cert object itself for a possible 112 data objects.

The pkcs15_dobj_get_value was found while running:
running pkcs11-tool -r -y data --application-id 2.16.840.1.101.3.7.2.1.1
using git bisect to locate the bad commit.  The pkcs11 data objects are
created last from the pkcs15 objects which are a linked list with no limits.

 On branch fix-object-restrictions
	modified:   src/pkcs11/framework-pkcs15.c
2019-01-15 07:31:39 +01:00
Frank Morgner 53dfde94a9 iso-sm: fixed allocating enough data
regression from aa940e8619
2019-01-15 07:31:20 +01:00
Frank Morgner 7d36bab701 don't force the max buffer size with Le=0
This happens, when we know the size will be smaller, but we still use
Le=0 in case of SM.
2019-01-15 07:31:20 +01:00
Frank Morgner 609e2d89cf added GoID Tool 2019-01-15 07:31:20 +01:00
Frank Morgner 141ec6ab23 added shortcut to update binary via sfid 2019-01-15 07:31:20 +01:00
Frank Morgner 1eda4c1795 sc-hsm-tool: add support for initializing biometry 2019-01-15 07:31:20 +01:00
Frank Morgner 3611b5c9f2 tools: fixed colors if -v is specified 2019-01-15 07:30:46 +01:00
Frank Morgner fbb4d1f843 tools: use consistent behavior of -v
-v switches to debug output to stderr in OpenSC tools regardless of the opensc.conf setting
2019-01-15 07:30:46 +01:00
Frank Morgner 0af46c88b7 added tests for Microsoft CryptoAPI
imported from https://github.com/CardContact/sc-hsm-embedded
2019-01-15 07:30:13 +01:00
Frank Morgner d9e253bd1b reduce the number of builds
a single build of clang and gcc each is enough
2019-01-15 00:10:55 +01:00
Frank Morgner f453c412b6 Simulate and test Open Source Java Card Applets
Compiles jCardSim, IsoApplet, GidsApplet, ykneo-openpgp, PivApplet as described [here](https://github.com/OpenSC/OpenSC/wiki/Smart-Card-Simulation).  Thanks to https://github.com/arekinath/jcardsim/ this is now also possible on Linux in combination with https://github.com/frankmorgner/vsmartcard.

Travis-CI now also runs some basic personalization and PKCS#11-tests.

This commit also adds caching of apt, brew and maven packages as well as the OpenSSL/OpenPACE build on macOS
2019-01-15 00:10:55 +01:00
Peter Marschall bb6b78937f OpenPGP: harmonize error messages around 'key_id'
* consistently use term "Invalid key ID; must be 1, 2, or 3" in error messages
  about invalid key IDs instead of various alternatives.
* use error type SC_ERROR_INVALID_ARGUMENTS instead of SC_ERROR_INVALID_DATA
  when the key_id was passed to the respective function
* harmonize the checks to consistently use 'key_id < ... || key_id > ...'

In addition, initialize a variable to keep clang & compilers on OSX happy.
2019-01-06 22:34:52 +01:00
Peter Marschall 57e66fd42e OpenPGP: harmonize error messages
Combine sequences
	sc_log(..., "...");
	LOG_FUNC_RETURN(...);
where c_log() prints a constant string
by
	LOG_TEST_RET(..., "...");

This change results in shorter, more concise code as well as
better harmonized error messages.
2019-01-06 22:34:52 +01:00
Peter Marschall 5544418339 OpenPGP: harmonize error messages used in LOG_TEST...() calls
Don't terminate the messages with a period, because they are going to end up
as the first argument to a format string of the form "%s: ...".
I.e. they will be part of a longer string and terminated by a colon anyway.
2019-01-06 22:34:52 +01:00
Peter Marschall b95d936e6c OpenPGP: allow reading large DOs in v3 cards
Set the read buffer size in pgp_read_blob() large enough to contain DOs
with the maximum size defineable in the extended capabilities DO 00C0.
2019-01-06 22:28:14 +01:00
Frank Morgner ee9abfcc71 Appveyor: use deploy_script 2019-01-04 00:46:41 +01:00
Frank Morgner 5c50dc58da fixed 320270 Dereference after null check 2019-01-04 00:44:45 +01:00
Frank Morgner aa940e8619 iso-sm: avoid allocation of big chunk of data
Use unencrypted APDU's resplen to estimate the size of the required SM
response buffer
2019-01-04 00:43:48 +01:00
Frank Morgner 6f0f42c506 fixed use of uninitialized data
When card->sm_ctx.ops.free_sm_apdu gets called in sc_sm_single_transmit
with a prior transmission error, then `sm_encrypt` still tries to
decrypt the response and hence, accesses the previously uninitialized
`resp`.
2019-01-04 00:43:48 +01:00
Peter Marschall a6ee84f13d opensc-explorer: fix 'pin_info' command
Correctly treat 'data.pin1.logged_in' as tristate instead of boolean.
While at it, fix visual glitch to not wrap around a stand-alone period.
2019-01-02 09:08:00 +01:00
Peter Marschall d577802ea7 OpenPGP: emulate SC_PIN_CMD_GET_INFO command for cards not supporting it 2019-01-02 09:06:54 +01:00
Peter Marschall 7092d32830 OpenPGP: get rid of "magic" constants in pgp_gen_key()
Use defined symbolic names for well-known DOs to copy data to a correctly
defined buffer 'apdu_data' using ulong2bebytes() instead of relying on
"magic" constants and C's string semantic.
Also use 'sizeof(apdu_data)' instead of additional magic constants.
2019-01-02 09:05:51 +01:00
Peter Marschall 4c51a53bed OpenPGP: get rid of "magic" constants in gnuk_delete_key()
Use defined symbolic names for well-known DOs to copy data to a correctly
defined buffer 'data' using ulong2bebytes() instead of relying on
"magic" constants and C's string semantic.
Also use 'sizeof(data)' instead of strange strlen() calculations.
2019-01-02 09:05:51 +01:00
Peter Marschall 0a903522b8 OpenPGP: get rid of "magic" constants in pgp_build_extended_header_list()
Use defined symbolic names for well-known DOs to copy data to a correctly
defined buffer 'data' using ulong2bebytes() instead of relying on
"magic" constants.
2019-01-02 09:05:51 +01:00
Jakub Jelen aa7118192a p11test: Use function compatible with OpenSSL 1.0.2 2018-12-31 21:56:45 +01:00
Peter Marschall 391131bb5e OpenPGP: use "hist_bytes" DO 5F52 as args to pgp_parse_hist_bytes()
Fix glitch that crept in during re-factoring.
This should unbreak Yubikeys.
2018-12-31 21:56:18 +01:00
Peter Marschall 1a60cd761f OpenPGP: fix value for EXT_CAP_MSE
enum _ext_caps is a set of bit flags
2018-12-31 21:56:18 +01:00
Peter Marschall bc17e23bd6 OpenPGP: fix spec interpretation error in hist_byte parsing
Command chaining is available with OpenPGP card spec 1.1+, not only with 3.0+
2018-12-31 21:56:18 +01:00
Peter Marschall 54dd9f4878 OpenPGP: revert 4d8b2c12ed
It broke OpenPGP on Yubikey NEOs and maybe other older versions too.

Reverting it restores functionality for those Yubikeys.
2018-12-31 21:56:18 +01:00
Doug Engert 075cac482b PIV - Some VA cards have LCS = 0F Terminated
Changes to be committed:
	modified:   card-piv.c
2018-12-27 14:25:45 +01:00
Doug Engert 7fbcd6e920 PIV - test i7e
On branch piv-improved-matching
 Changes to be committed:
	modified:   card-piv.c
2018-12-27 14:25:45 +01:00
Doug Engert a78becb76e PIV - Fix blanks and use returned value
On branch piv-improved-matching
 Changes to be committed:
	modified:   card-piv.c
2018-12-27 14:25:45 +01:00
Doug Engert 1fe1d40e38 PIV - Improved error handling of get_challenge
Random data from PIV card is obtained using GENERAL AUTHENTICATE command
for a request of a Challenge from the card. "00 87 00 9B 04 7C 02 81 00"
Usually 8 bytes are returned.

NIST 800-73-3_PART2, "A.1 Authentication of the PIV Card Application Administrator"
"Table 11. Authentication of PIV Card Application Administrator" shows an example of
how to do this.

Some cards (one I have: 3b:7d:96:00:00:80:31:80:65:b0:83:11:17:d6:83:00:90:00)
will not allow 2 of these commands in a row. (Maybe assuming command is only
used as in Table 11 and is expecting the second command.)

Code was added to card-piv.c so if "6A 80" is returned, try the command one more time.
For any other GENERAL AUTHENTICATE failure, SC_ERROR_NOT_SUPPORTED is returned.
piv_get_challenge may be called within a loop from sc_get_challenge if more random
data is needed thus causing the the 2 commands to sent in a row.

On branch piv-improved-matching
 Changes to be committed:
	modified:   card-piv.c
2018-12-27 14:25:45 +01:00
Doug Engert e13c0b83ef PIV - Improved Card Matching for Dual CAC/PIV and PIVKEY cards.
Not all PIV applets are the same. Different versions of NIST 800-73 and improperly implemented
or not implemented required features of NIST 800-73 cases problems. Have a look at the card_issues
listed in card-piv.c. The PIV driver has tried to detect the differences based on clues found in
the ATR historical bytes and vendor version numbers for some cards.

At the same time it has tried to support the possibility there are multiple applets
on a card that the user may want to use at the same time from different applications.
This has lead to some detection problems with Dual CAC/PIV cards. The same cards
sold by the vendor may have only a PIV applet that may not be the same PIV applet that
is on the Dual PIV/CAC cards.

http://www.cac.mil/Portals/53/Documents/CAC-utilziation-and-variation-matrix-v2.03-20May2016.doc
defines a number of official CAC cards in active service. A table of the ATRs for these is now used
to detect these cards. The PIV version of the CCC is also read to see if any CAC PKI objects
are defined in the CCC, indicating it is a Dual CAC/PIV, even if the ATR is not listed.

A more conservative approach to try and handle multiple applets on a card is used. Based
on issues with the implementation of the PIV applet this may not be possible to do.
So for many cards no additional detection will be done at the start of every transaction,
and the login state can not be detected correctly.

ATRs for PIVKEY are also in the match table, as these cards have a log of issues.

Other PIV cards in the future or not yet tested may not be covered properly by this patch.
Extra debugging was added with "PIV_MATCH" to help with these other cards.
With "debug = 7;", `grep PIV_MATCH opensc-debug.log` can be used to see how a card
type and card_issues are derived.

On branch piv-improved-matching
 Changes to be committed:
	modified:   card-piv.c
	modified:   cards.h
2018-12-27 14:25:45 +01:00
Peter Marschall dc505be808 openpgp-tool: use binary OR for calculating 32-bit integers from byte
Also avoid potential unintended sign extension (SIGN_EXTENSION).
2018-12-27 14:13:41 +01:00
Frank Morgner b11cc3871e tools: harmonize card initialization 2018-12-18 14:50:45 +01:00
Jakub Jelen 4d8b2c12ed card-openpgp: Workaround parsing historical bytes on Yubikey to set correct capabilities 2018-12-18 14:50:08 +01:00
Jakub Jelen 26aed9441a padding: Do not set wrong flags if the raw capability is not available
Thanks Doug Engert for pointing the issue out
2018-12-18 14:50:08 +01:00
Jakub Jelen 070190d72e padding: Resotre the PAD_NONE if nothing else is specified
Patch from Doug Engert
2018-12-18 14:50:08 +01:00
Jakub Jelen f0b47a51d3 p11test: Report key sizes for missing certificates 2018-12-18 14:50:08 +01:00
Jakub Jelen ed6267512c p11test: Do not report usage on incomplete keys 2018-12-18 14:50:08 +01:00
Jakub Jelen 28deeb2a00 p11test: Do not report and try pairs without private key 2018-12-18 14:50:08 +01:00
Jakub Jelen 969e29e663 p11test: Do not talk about multipart encryption 2018-12-18 14:50:08 +01:00
Khem Raj 35cb70b5d6 Remove redundant logging
Same information is printed a few line below in same function, the only
difference is that there it takes care of case when label is NULL pointer
unlike this line

secondly, every function call to cosm_write_tokeninfo() in this file
passes label=NULL, and then it tries to print a null pointer

Fixes errors like
src/libopensc/log.h:48:47: error: '%s' directive argument is null
[-Werror=format-overflow=]

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2018-12-18 13:50:08 +01:00
Peter Marschall b1539545d0 OpenPGP: free() unconditionally in error handling of pgp_store_key() 2018-12-17 09:49:57 +01:00
Peter Marschall c7fc7cc134 OpenPGP: refactor error handling in pgp_calculate_and_store_fingerprint()
* initialize pointers to NULL
* explicitly compare pointers to NULL
* use LOG_TEST_*() macros instead of explicit coding
2018-12-17 09:49:57 +01:00
Peter Marschall bf2a9bc53b OpenPGP: refactor error handling in pgp_build_extended_header_list()
* use LOG_TEST_*() macros instead of explicit coding
2018-12-17 09:49:57 +01:00
Peter Marschall 7916d45857 OpenPGP: refactor error handling in pgp_store_key()
* use LOG_TEST_*() macros instead of explicit coding
* harmonize use of card->ctx: saves one variable
* explictly compare pointers to != NULL
2018-12-17 09:49:57 +01:00
Peter Marschall 08b9f362c0 OpenPGP: refactor error handling in pgp_gen_key()
* use LOG_TEST_*() macros instead of explicit coding
2018-12-17 09:49:57 +01:00
Peter Marschall d3e730b621 OpenPGP: refactor error handling in pgp_put_data_plain()
* use LOG_TEST_*() macros instead of explicit coding
2018-12-17 09:49:57 +01:00
Peter Marschall 738c933609 OpenPGP: a few cleanups for Gnuk
* make sure to remain within buffer size in pgp_read_blob()
* make logic more readable in pgp_get_data()
2018-12-17 09:49:57 +01:00
Peter Marschall 01287e393e framework-pkcs15: fix warning
* fix -Werror=format-truncation= warning in pkcs15_init_slot()
* do not only remove blanks from the end, but all spaces
2018-12-09 23:44:00 +01:00
Jakub Jelen a7a9326f35 Add simple Sanity test for pkcs11-tool sign&verify operations 2018-12-06 09:27:50 +01:00
Jakub Jelen 8fb611bb1c Move the test into separate directory
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-12-06 09:27:50 +01:00
Frank Morgner f2145eca79 don't debug pointers 2018-12-06 09:26:42 +01:00
Frank Morgner 5474370b17 always log APDUs with SC_LOG_DEBUG_NORMAL 2018-12-06 09:26:42 +01:00
Frank Morgner a899a46b09 replaced SC_TEST_RET with LOG_TEST_RET 2018-12-06 09:26:42 +01:00
Frank Morgner 907c9479e2 replace sc_debug_hex with sc_log_hex 2018-12-06 09:26:42 +01:00
Frank Morgner d4f1a26215 respect SM debug level 2018-12-06 09:26:42 +01:00
Frank Morgner e3dda8894e log errors in verbose 2018-12-06 09:26:42 +01:00
Frank Morgner 00a150f74c replaced SC_FUNC_RETURN with LOG_FUNC_RETURN 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
Luka Logar 18dc38a618 Fix some pkcs15-init issues
1. pkcs15-init is using XKU but it should use cert KU to check private key usage instead.
2. Don't mark imported keys as ALWAYSSENSITIVE and NEVEREXTRACTABLE as they are not.
3. When importing keys from PKCS#12 files (with several certs inside), use consecutive IDs for additional certificates (instead of starting from 45).
2018-12-05 12:43:08 +01:00
Luka Logar ba77042911 Fix token label formatting
PKCS#15 token label may be padded with spaces, trim it when making a PKCS#11 token label in order not to loose closing parenthesis.
I would actually prefer for the token label to be "myCard (User PIN)" instead of current "User PIN (myCard)"

before:
$ pkcs11-tool --list-slots
Available slots:
Slot 0 (0x0): OMNIKEY AG CardMan 3121 00 00
  token label        : User PIN (myCard
...

after:
$ pkcs11-tool --list-slots
Available slots:
Slot 0 (0x0): OMNIKEY AG CardMan 3121 00 00
  token label        : User PIN (myCard)
...
2018-12-05 12:42:30 +01:00
Luka Logar 2552fde05f Fix some pinpad reader related issues (#1540)
1. Show pinpad reader capabilities even for uninitialised tokens. This way pinpad can be used during initialisation.
2. Make possible to create so-pin object during initialisation even if no so-pin was provided (on the command line) but pinpad reader is used and card profile contains so-pin data.
2018-12-05 12:41:58 +01:00
Hannu Honkanen 7d640e62c1 Fixed incorrect conversion fron int to CK_BBOOL when converting PKCS#15 user consent to a PKCS#11 attribute 2018-12-05 12:10:42 +01:00
Hannu Honkanen 9e5a324903 Edited according to PR review: CKA_ALWAYS_AUTHENTICATE only associated with private keys. Defined a custom attribute to achieve same functionality with secret keys. Updated man pages. 2018-12-05 12:10:42 +01:00
Hannu Honkanen ee8c80af4f Implemented handling of CKA_ALWAYS_AUTHENTICATE attribute when importing and generating keys, mapping it to pkcs#15 userConsent field. Added command line options to pkcs11-tool and pkcs15-init tool to use the feature. 2018-12-05 12:10:42 +01:00
Frank Morgner b01ca2dcc9
added support for colors (#1534)
because everyone loves colors
2018-11-25 22:08:36 +01:00
Jakub Jelen f1f98f829c pkcs11-tool: Unbreak signature and verification in pkcs11-tool 2018-11-25 22:07:33 +01:00
Jakub Jelen fd2343f4a2 cac: Dump the data model number, which is useful for the capabilities detection
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-11-25 22:07:33 +01:00
Shahin Hajikhorasani 0fca7df33a Update reader-pcsc.c (#1537)
Error handling extended in case of changing the card reader
2018-11-25 22:05:35 +01:00
Mounir IDRASSI 1ab93312cd SM: fix crash if nested GET RESPONSE issued during sm session fails or returns invalid MAC. 2018-11-21 15:35:53 +01:00
Frank Morgner d4f039cb50 speed up checking out nightly branch 2018-11-20 13:02:29 +01:00
Frank Morgner ad83c2c5a9 use proper debug level for card matching 2018-11-20 12:48:58 +01:00
Doug Engert 764c61446e pkcs15-crypt - Handle keys with user_consent - Fixes #1292
This fixes problem as stated in:
https://github.com/OpenSC/OpenSC/issues/1292#issuecomment-431879472

pkcs15-crypt.c will treat keys with user_consent like PKCS#11 would.
SC_AC_CONTEXT_SPECIFIC is set when doing a verify so a card driver can
take action if needed.

card-piv.c is currently the only driver doing so.
It uses this to hold the card lock so both the VERIFY and following crypto
operations are in the same transaction. The card enforces this restriction.
Without this additional APDUs may be sent before every transaction to test
that the expected applet is selected.

Unlike the circumvention of using ignore_user_consent=true and pin caching
this modification allows a pin pad reader to be used for keys requiring user_consent.

 On branch pkcs15-context-specific
 Changes to be committed:
	modified:   pkcs15-crypt.c
2018-11-20 11:53:57 +01:00
Hannu Honkanen aa8f666f46 Removed unnecessary spaces from framework-pkc15.c as requested.
pkcs15: added explicit comparison when checking return value of sc_compare_oid() to make the logic more obvious.
2018-11-20 11:52:54 +01:00
Hannu Honkanen 7f91b6e07f MyEID: add AES algorithms to tokenInfo as supported during init. It is better to do it already in init, because adding them in C_UnwrapKey operations would require SO-PIN which is inconvenient.
pkcs15: added function to get a specific supported algorithm, checking also OID.
This is needed because for AES there are different OIDs for each key length.
2018-11-20 11:52:54 +01:00
Hannu Honkanen c051ef64dd Convert sequences of four spaces to tabs to fix indentation problems. 2018-11-20 11:52:54 +01:00
Hannu Honkanen 3ec39919c3 pkcs15-lib: Must use keyargs->value_len instead of keyargs->key.data_len * 8 when calling check_key_compatibility(), to get correct result in key unwrap operations. In this case data_len is 0, but value_len contains the key length in bits. 2018-11-20 11:52:54 +01:00
Steve Ross abdbb9d8c0 Enable CoolKey driver to handle 2048-bit keys.
For a problem description, see <https://github.com/OpenSC/OpenSC/issues/1524>.
In a nutshell, for a card with the CoolKey applet and 2048-bit keys,
the command
	pkcs11-tool --test --login
fails to complete all of its tests.

This commit consists of a patch from @dengert.

To avoid triggering an error when the data exceeds 255 bytes, this commit
limits the amount of the payload sent to the CoolKey applet on the card based
on the maximum amount of data that the card can receive, and overhead bytes
(namely, a header and nonce) that accompany the payload.

With this change, the command
	pkcs11-tool --test --login
succeeds.
2018-11-19 12:42:17 +01:00
Frank Morgner d4e6c0c0dd travis: fixed installation of completion templates 2018-11-14 12:57:22 +01:00
Frank Morgner ee3fdc6938 fixed missing function stub 2018-11-13 15:50:17 +01:00
Frank Morgner 2cb6f9c94f fixed compilation without OpenSSL
closes https://github.com/OpenSC/OpenSC/pull/1518
2018-11-13 15:50:17 +01:00
Frank Morgner f3a2962358 pkcs11: perform memory cleanup on dll unload 2018-11-13 15:50:17 +01:00
Frank Morgner 447335bc1f md: clean OpenSSL memory when DLL is unloaded 2018-11-13 15:50:17 +01:00
Frank Morgner 027ccad439 allow specifying the size of OpenSSL secure memory
... and set it for builds where we're linking OpenSSL statically (i.e.
Windows and macOS)

fixes https://github.com/OpenSC/OpenSC/issues/1515
2018-11-13 15:50:17 +01:00
Andreas Kemnade eddea6f3c2 fix logic of send/recv sizes in config files
- they are not set if
  SCardControl(card_handle, CM_IOCTL_GET_FEATURE_REQUEST, ...
  fails
- regarding max_send_size the logic is inverted
2018-11-09 08:56:53 +01:00
Frank Morgner c032b2f15d CID 320271 (#1 of 1): Dereference before null check (REVERSE_INULL) 2018-11-06 15:53:17 +01:00
Frank Morgner 3c0a16dc39 CID 321790 (#1 of 1): Resource leak (RESOURCE_LEAK) 2018-11-06 15:53:17 +01:00
Frank Morgner 1e7bb83659 CID 324485 (#1 of 2): Integer overflowed argument (INTEGER_OVERFLOW) 2018-11-06 15:53:17 +01:00
Frank Morgner 609095a4f4 CID 325860 (#1 of 1): Dereference before null check (REVERSE_INULL) 2018-11-06 15:53:17 +01:00
Frank Morgner 54c9d65a48 CID 325861 (#1 of 1): Dereference before null check (REVERSE_INULL) 2018-11-06 15:53:17 +01:00
Peter Marschall c6d252611b openpgp-tool: add missing length check in prettify_name() 2018-11-06 12:41:19 +01:00
Peter Marschall 4e5805dc5d openpgp-tool: don't uppercase hex string 2018-11-06 12:41:19 +01:00
Peter Marschall afda163dc6 openpgp-tool: fix typo 2018-11-06 12:41:19 +01:00
Peter Marschall ec3830fe66 openpgp-tool: use more compatible strftime() format spec
Replace the Single UNIX specific shorthand %T for %H:%M:%S with the latter
to keep MingW happy.
2018-11-06 12:41:19 +01:00
Peter Marschall 85258f2951 openpgp-tool: use key type to indicate key to generate
Instead of only expecting a key length, and implicitly assuming RSA
as the key algorithm, introduce option --key-type to pass the key type
as a string.

When generating the key determine key algorithm and attributes based on
the key type passed.

If no key was given, default to "rsa2048".
2018-11-06 12:41:19 +01:00
Peter Marschall c9f5e05aca openpgp-tool: new option --key-info to display key info 2018-11-06 12:41:19 +01:00
Peter Marschall 1866c3e930 openpgp-tool: new option --card-info to display card info 2018-11-06 12:41:19 +01:00
Frank Morgner 263b945f62 md: added support for PSS 2018-11-06 12:38:57 +01:00
Frank Morgner 99a9029848 md: use constants for AlgId comparison 2018-11-06 12:38:47 +01:00
Frank Morgner 22c8204a2f Merge remote-tracking branch 'upstream/pr/1393'
closes https://github.com/OpenSC/OpenSC/pull/1393
2018-11-06 10:51:24 +01:00
Frank Morgner 13c7574510 PIV: less debugging
- debugging pointers is useless in static log file
- removed double debugging of APDUs
2018-11-06 01:42:41 +01:00
Jakub Jelen eaed345a76 Add missing header file to the tarball 2018-11-05 09:15:20 +01:00
Jakub Jelen 9342f8ad0a padding: Fix error checking in RSA-PSS 2018-11-05 09:15:20 +01:00
Jakub Jelen 0f5d73d816 framework-pkcs15.c: Add SHA224 mechanism for PKCS#1.5 2018-11-05 09:15:20 +01:00
Jakub Jelen 8ccc39352a p11test: Do not report incomplete key pairs 2018-11-05 09:15:20 +01:00
Jakub Jelen d2671ee05b framework-pkcs15.c: Add PKCS#1 mechanisms also if SC_ALGORITHM_RSA_HASH_NONE is defined 2018-11-05 09:15:20 +01:00
Jakub Jelen 7e0ef7c16c framework-pkcs15.c: Reformat
* Reasonable line lengths
 * Correct indentation
 * Add missing SHA224 mechanism
2018-11-05 09:15:20 +01:00
Jakub Jelen 7cced08a88 coolkey: Check return values from list initialization (coverity)
>>>     CID 324484:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "list_init" without checking return value (as is done elsewhere 8 out of 9 times).
2018-11-05 09:15:20 +01:00
Jakub Jelen f276f7f8f4 coverity: Add allocation check
*** CID 323588:  Uninitialized variables  (UNINIT)
/src/libopensc/sc.c: 873 in sc_mem_secure_alloc()
2018-11-05 09:15:20 +01:00
Hannu Honkanen 351e0d2bd6 Merge remote-tracking branch 'upstream/master' into wrapping-rebased and resolve conflicts 2018-11-02 13:42:41 +02:00
Hannu Honkanen b35fb19ec4 Resolved conflict in pkcs15_create_secret_key 2018-11-02 13:28:51 +02:00
Peter Marschall 26025b2f5d pkcs15-tool: list & dump cleanups
* when listing public keys, do not cut object labels in compact mode
* when listing private keys in compact mode, left align labels
* make hex codes at least 2 chars wide by changing "0x%X" to "0x%02X"
2018-11-01 12:25:04 +01:00
Frank Morgner c70888f9ab allow compilation with --disable-shared 2018-11-01 00:17:22 +01:00
Frank Morgner 54cb1099a0 fixed warnings about precision loss 2018-11-01 00:17:22 +01:00
Frank Morgner 5c7b7bb0b1 fixed minor XCode documentation warnings 2018-11-01 00:17:22 +01:00
Hannu Honkanen f88419bc63 Removed pointless curly brackets 2018-10-31 10:36:50 +02:00
Hannu Honkanen 7bb53423a1 Code cleanup and minor corrections according to review. pkcs15-lib: Extractable keys are now marked as native. Check return value of check_key_compatibility in more explicit way to avoid misunderstandings. 2018-10-31 10:36:41 +02:00
Hannu Honkanen 90ec7123ba Corrections and code cleanup as requested in review. Changed value to void* in sc_sec_env_param_t, because param_type defines type of the value. Fixed handling of secret key length in framework-pkcs15 and pkcs15-lib: CKA_VALUE_LEN from PKCS#11 is in bytes, PKCS#15 objects need key length in bits. Rebased on top of upstream/master and resolved merge conflicts. 2018-10-31 10:27:03 +02:00
Lars Silvén 84317f4e9d Fixing missing call to sc_unlock. 2018-10-31 10:27:03 +02:00
Hannu Honkanen 8ebb43d440 Removed #ifdef USE_PKCS15_INIT around __pkcs15_create_secret_key_object. This function is now used also when reading and parsing a card, not only when creating new objects. 2018-10-31 10:27:03 +02:00
Hannu Honkanen ec297b618f sc_pkcs15_wrap: Fixed checking target key type. (checked partly from wrapping key) 2018-10-31 10:27:03 +02:00
Hannu Honkanen e636b64377 Fixed: Return OK by PKCS#11 convention if NULL out buffer is provided, when caller wants to query required buffer size. 2018-10-31 10:27:03 +02:00
Hannu Honkanen f2c041d290 card-myeid: Removed NULL out buffer assertion to allow caller to query required buffer size.
mechanism.c: Bug fix to sc_pkcs11_wrap. Wrong operation was stopped in end of the function.
2018-10-31 10:27:03 +02:00
Hannu Honkanen 287a63c704 Fixes to key wrapping and unwrapping code: Set IV correctly in symmetric unwrap. Correctly distinguish symmetric and asymmetric operation when building APDUs. Check CKA_TOKEN from the pkcs15 object in framework_pkcs15. Updated some comments. 2018-10-31 10:27:03 +02:00
Hannu Honkanen 861d8b308b Fixed myeid_unwrap with symmetric keys: set correct p2 and no padding indicator byte. 2018-10-31 10:27:03 +02:00
Hannu Honkanen 4ce7e5289b Fixed setting secret key length. CKA_VALUE_LEN comes as number of bytes, so multiply it by 8 to set correct bit length to the key file. 2018-10-31 10:27:03 +02:00
Hannu Honkanen eba75ead20 framework-pkcs15: set CKA_EXTRACTABLE into pkcs#15 secret key object's access flags when set. pkcs15-sec: Return needed buffer size correctly when an insufficient buffer is provided. 2018-10-31 10:27:03 +02:00
Hannu Honkanen f74150b53d Proprietary attribute bits in FCP had to be adjusted due to conflicts with existing attributes. The needed changes were made to both card and OpenSC code. 2018-10-31 10:27:03 +02:00
Hannu Honkanen c891ad2aad Fixed version check for key wrapping functionality. Return needed buffer size in myeid_wrap_key, if no buffer or too small buffer is provided. 2018-10-31 10:27:03 +02:00
Lars Silvén 6b8c284d3e Fixing pointer conversion that is invalid on some architectures. 2018-10-31 10:27:03 +02:00
Hannu Honkanen 550d4eb030 Small fixes to key wrapping and unwrapping. Handle target file ref using sc_sec_env_param type. Transmit initialization vector in symmetric key operations from PKCS#11 layer (mechanism param) to the card driver level, allow setting it in sc_set_security_env. 2018-10-31 10:27:03 +02:00
Hannu Honkanen 2487bc18d1 When creating symmetric keys, use CKK_ definitions (key type) rather than CKM_ definitions (mechanism) to specify the key type. 2018-10-31 10:24:19 +02:00
Hannu Honkanen 7454133272 Added flags to distinguish AES ECB and CBC modes. Added SC_ALGORIHM_UNDEFINED definition to be used with CKK_GENERIC_SECRET type keys. Added sc_sec_env_param type, which can be used to define additional parameters when settings security environment. This is now used for setting IV in symmetric crypto and target EF in key wrapping/unwrapping. 2018-10-31 10:24:19 +02:00
Hannu Honkanen a2156da044 Fix encoding of SC_ASN1_CHOICE entry "parameters" in c_asn1_algorithm_info. Format only the selected entry of the choice. 2018-10-31 10:24:19 +02:00
Hannu Honkanen ae5675ca22 Fixed MSE for unwrap operation. Fixed wrong P1 when formatting APDU in myeid_unwrap_key. 2018-10-31 10:24:19 +02:00
Hannu Honkanen aa814fd8e8 Implemented C_Wrap into PKCS#11 interface. Added support for wrapping and unwrapping with secret keys into framework-pkcs15.c and all the way to the card driver level. 2018-10-31 10:24:19 +02:00
Hannu Honkanen a9ee85452e Resolved a merge conflict. Included both changes manually. 2018-10-31 10:24:19 +02:00
Hannu Honkanen c217b254fc MyEID: Initial implementation of key wrapping and unwrapping operations, and the related additions to myeid_set_security_env. 2018-10-31 10:24:19 +02:00
Hannu Honkanen edd48b3200 pkcs15init:
- Added session_object flag to sc_pkcs15init_skeyargs to enable on-card session objects.
- Corrections to handling native and extractable flags
- Allow creating an empty secret key EF for receiving an unwrapped key later.
2018-10-31 10:24:19 +02:00
Hannu Honkanen 9d6ac01c27 pkcs15init: Handle user_consent and set new proprietary information flags in myeid_create_key(). 2018-10-31 10:24:19 +02:00
Hannu Honkanen 1c09fa8a22 Handle AES algorithm. Doesn't set any flags, but check for AES is needed to avoid SC_ERROR_NOT_SUPPORTED. 2018-10-31 10:24:19 +02:00
Hannu Honkanen 7fc6c52f81 Set native=1 as default when decoding. Check supported algorithms and set PKCS#11 key type, if key supports AES. 2018-10-31 10:22:16 +02:00
Hannu Honkanen 9772edc7d1 Handle -u option (x509-usage) when storing secret keys. 2018-10-31 10:22:16 +02:00
Hannu Honkanen a10480d50e Continued implementation of unwrap: Creation of a target key object on card to receive an unwrapped key. Setting target key path in sc_security_env_t. 2018-10-31 10:22:16 +02:00
Hannu Honkanen 5f51d5d315 Added implementation of C_UnwrapKey all the way from PKCS#11 interface to the card driver level.
Not yet complete, but can be run with CKA_TOKEN=FALSE set in the target object. Currently unwrapping emulated
with a decrypt operation in card-myeid.c. To be improved.
2018-10-31 10:22:16 +02:00
Jakub Jelen e2b1fb81e0 Restore minimal CAC1 driver for legacy cards (#1502)
* Add minimal CAC1 driver for legacy cards.

It is using the same pkcs15 backend as the CAC2 cards as well as some of
the CAC2 driver methods.

The separation is made mostly for easier card matching or disabling.
2018-10-30 17:27:28 +01:00
Frank Morgner c3bef7d527 fixed compilation with XCode 10
fixes https://github.com/OpenSC/OpenSC/issues/1485
2018-10-24 10:34:43 +02:00
Frank Morgner 5095e29ae3 gio: avoid unneccessary unitialization 2018-10-22 21:44:07 +02:00
Doug Engert 2fd8e278f5 pkcs11/openssl.c - add missing mechanisms fixes #1497
On branch pkcs11-openssl-c
 Changes to be committed:
	modified:   ../pkcs11/openssl.c
2018-10-19 08:27:47 +02:00
Vadim Penzin 195d53b8a2 Fix division by zero in SimCList when appending to an empty list. 2018-10-16 12:10:04 +02:00
Frank Morgner 8c535c184f removed duplicate code for adding padding
Fixes padding handling of SC_ALGORITHM_RSA_PAD_NONE introduced with
e5707b545e
2018-10-15 15:21:52 +02:00
Jakub Jelen 46c99e769d ctx: Move coolkey driver up after improving the matching
Fixes #1483
2018-10-15 12:14:22 +02:00
Jakub Jelen f220d0b77d coolkey: Improve card matching to avoid mismatches in muscle 2018-10-15 12:14:22 +02:00
Jakub Jelen 55a8478ed6 cac: These functions do not have to be exposed 2018-10-15 12:14:22 +02:00
Frank Morgner ac276b1202
starcos: fixed decipher with 2.3 (#1496)
closes https://github.com/OpenSC/OpenSC/issues/765
fixes https://github.com/OpenSC/OpenSC/issues/1495
2018-10-11 22:50:37 +02:00
Luka Logar d517d8e18d Fix minidriver padding
Commit e5707b545e broke signing using minidriver on Windows.

More specifically changing #define SC_ALGORITHM_RSA_PAD_NONE from 0x00000000 to 0x00000001 caused a call to sc_pkcs1_encode() to fail as the padding algorithm was not specified anywhere in the CardSignData() implementation. It kind of worked as long as SC_ALGORITHM_RSA_PAD_NONE was 0x00000000, but the above mentioned commit broke this.

Now padding algorithm has to be explicitly specified, otherwise a call to sc_pkcs1_encode() will fail.
2018-10-11 12:47:48 +02:00
Peter Marschall 550665b906 OpenPGP: refactor pgp_get_card_features()
Use pgp_parse_alog_attr_blob() to get the algorithm attribute DO's contents.
2018-10-10 14:52:29 +02:00
Peter Marschall 8a564107a8 OpenPGP: introduce gpg_parse_algo_attr_blob()
Introduce a central function to parse the algorithm atributes in DOs C1 - C3.
2018-10-10 14:52:29 +02:00
Peter Marschall 248ece23c6 OpenPGP: bail out on non-RSA key generation/import
Also add the necessary algorithm info where necessary.
2018-10-10 14:52:29 +02:00
Peter Marschall c2f02f72bd OpenPGP: adapt data structures to support RSA alternatives
* update callers to use the adapted structures.
2018-10-10 14:52:29 +02:00
Peter Marschall 772d20969a OpenPGP: first steps to support key types beyond RSA
- rename 'keytype' in some OpenPGP-specific types to 'key_id'
  because they key ID was what the field was used for
- introduce field 'algorithm' in the structures above
  to indicate the key's algorithm: RSA, ...
- define constant SC_OPENPGP_KEYALGO_RSA and use it
- rename constants SC_OPENPGP_KEYFORMAT_* to SC_OPENPGP_KEYFORMAT_RSA_*
  because they are RSA specific
2018-10-10 14:52:29 +02:00
Peter Marschall f1ae31aea4 OpenPGP: expose additional algorithms only with EXT_CAP_ALG_ATTR_CHANGEABLE
List additional algorithms & attributes as supported only when the card
supports changing the algorithms attributes DOs and exposes this by having
the EXT_CAP_ALG_ATTR_CHANGEABLE capability set.

Using different algorithms and attributes requires changing the algorithm
attributes DOs. If that is not supported - as indicated by a missing
EXT_CAP_ALG_ATTR_CHANGEABLE capability - then only those algorithms
described by the current algorithms attributes DOs' contents can be used.

In addition simplify setting the flags.
2018-10-10 14:52:29 +02:00
Peter Marschall 44d6116c59 OpenPGP: slight cleanups
* use variables if they are already there
* be a bit more explicit in logging
* more consistent tag format: %04X
* cleanup flag setting for _sc_card_add_rsa_alg()
2018-10-10 14:52:29 +02:00
Frank Morgner ea6f7cfe1d
Added memory locking for secrets (#1491)
When caching a PIN in memory or using an OpenSSL private key this data should not be swapped to disk.
2018-10-10 14:52:01 +02:00
gabrielmuller 6bf67f7917 onepin option also needs PIN to CREATE
I previously changed the default option but forgot to make the same change for onepin.
2018-10-08 21:35:23 +02:00
Peter Marschall a8db9cb4f0 openpgp-tool: harmonize error messages
* use symbolic constants for errors & success
* use util_error() to show errors
* print error messages to stderr
2018-10-04 09:41:31 +02:00
Peter Marschall e4a0b09968 openpgp-tool: remove unnecessary variable
* 'opt_keylen' was only set, but never used => remove
* passing the key length is not an action => do not mark it as such
2018-10-04 09:41:31 +02:00
Jakub Jelen a5daaaff0c piv-tool: Error checking 2018-10-01 23:07:34 +02:00
Jakub Jelen ef724e1e57 pkcs15-authentic: Do not confuse static analyzers 2018-10-01 23:07:34 +02:00
Jakub Jelen 52959df9f6 pkcs15-oberthur: Avoid memory leaks on failures 2018-10-01 23:07:34 +02:00
Jakub Jelen a1dfdbbdbc pkcs15-oberthur-awp: Do not confuse cppcheck 2018-10-01 23:07:34 +02:00
Jakub Jelen e920ef8eb8 opensc-explorer: Make static analyzers happy 2018-10-01 23:07:34 +02:00
Jakub Jelen 16c5a352a4 piv-tool: Avoid memory leaks on realloc failure 2018-10-01 23:07:34 +02:00
Jakub Jelen 9a690a96e0 sc-hsm-tool: Avoid memory leak 2018-10-01 23:07:34 +02:00
Jakub Jelen bce43e6855 Remove dead code 2018-10-01 23:07:34 +02:00
Jakub Jelen 74105300bf card-iasecc: Avoid memory leaks on failure 2018-10-01 23:07:34 +02:00
Jakub Jelen 674e5e8b3d ctx: Require dll parameter otherwise we are leaking it 2018-10-01 23:07:34 +02:00
Jakub Jelen a85a4a8b48 pkcs15-authentic: Avoid memory leak on failure 2018-10-01 23:07:34 +02:00
Jakub Jelen 65e1cd2df7 muscle: Check return values 2018-10-01 23:07:34 +02:00
Jakub Jelen a2ab2071bb piv: Check return value of sc_lock() 2018-10-01 23:07:34 +02:00
Jakub Jelen b8133c2545 pkcs15-myeid: Return value checking 2018-10-01 23:07:34 +02:00
Jakub Jelen 8e0078a6f9 pkcs15-myeid: Do not confuse coverity with potential double-free 2018-10-01 23:07:34 +02:00
Jakub Jelen e5da6b66b9 iso7816: Replace asserts with explicit length checks to make coverity happy 2018-10-01 23:07:34 +02:00
Jakub Jelen b9e33a3c64 Coverity warnings
card-piv.c
	make sure the string is null terminated before passing it
	to hex_to_bin routine, which expects it
pkcs15-cac.c
	free cn_name on failure
pkcs11-tool.c
	make sure the string is null terminated before passing it to
	parse_certificate(), which expects it
2018-10-01 23:07:34 +02:00
Raul Metsma 83b188c950 Remove long expired EstEID 1.0/1.1 card support
Signed-off-by: Raul Metsma <raul@metsma.ee>
2018-09-30 21:25:13 +02:00
Jakub Jelen e456e609a6 Avoid memory leaks during verification 2018-09-30 21:23:27 +02:00
Jakub Jelen 424d828627 slot: Switch cleanup steps to avoid segfaults on errors
and some more sanity checking

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-09-30 21:23:27 +02:00
Jakub Jelen 9a853176b8 pkcs11-tool: Support for signature verification
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-09-30 21:23:27 +02:00
Nicholas Wilson e5707b545e Add support for PSS padding to RSA signatures
A card driver may declare support for computing the padding on the card,
or else the padding will be applied locally in padding.c.  All five
PKCS11 PSS mechanisms are supported, for signature and verification.

There are a few limits on what we choose to support, in particular I
don't see a need for arbitrary combinations of MGF hash, data hash, and
salt length, so I've restricted it (for the user's benefit) to the only
cases that really matter, where salt_len = hash_len and the same hash is
used for the MGF and data hashing.

------------------------------------------------------------------------
Reworked and extended in 2018 by Jakub Jelen <jjelen@redhat.com> against
current OpenSC master, to actually work with existing PIV cards:
 * extended of missing mechanisms (SHA224, possibility to select MGF1)
 * compatibility with OpenSSL 1.1+
 * Removed the ANSI padding
 * Formatting cleanup, error checking

Based on the original work from

https://github.com/NWilson/OpenSC/commit/42f3199e66

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-09-30 21:23:27 +02:00
Jakub Jelen be2cc38565 p11test: Add missing CKM_SHA224_RSA_PKCS_PSS
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-09-30 21:23:27 +02:00
Jakub Jelen fb94b639bc doc: Fix the pkcs11-tool example
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-09-30 21:23:27 +02:00
Peter Marschall f471048ef7 remove source-less doc/tools/files.html
The current version, which gets re-generated from XML source, is in doc/files/.
2018-09-30 18:40:55 +02:00
Gabriel Müller 551fcccb90 Changed outdated "STARCOS SPK 2.3" name to "STARCOS".
modified:   src/libopensc/pkcs15-infocamere.c
    modified:   src/libopensc/pkcs15-starcert.c
    modified:   src/pkcs15init/pkcs15-lib.c

Changed isf_acl to also need SO PIN for CREATE.
    modified:   src/pkcs15init/starcos.profile
2018-09-28 16:50:39 +02:00
Frank Morgner 496a9b571d fixed error handling 2018-09-25 12:13:57 +02:00
Frank Morgner 0ae825f8d9 fixed error checking
closes https://github.com/OpenSC/OpenSC/pull/1343
2018-09-25 11:09:07 +02:00
konstantinpersidskiy 0c3412bb37 Fix C_SetAttributeValue for CKA_VALUE for data obj 2018-09-25 10:51:10 +02:00
konstantinpersidskiy ccdb314d49 Fix C_GetAttributeValue for attr with 0 length 2018-09-25 10:51:10 +02:00
konstantinpersidskiy c9d6c30a83 Fix data object with empty value creation 2018-09-25 10:51:10 +02:00
Peter Marschall 3cc2670f3e opensc-explorer: avoid warnings on readline-less builds 2018-09-24 00:03:13 +02:00
Peter Marschall 14a31a3c42 opensc-explorer: refactor main()
* localize variables
* print errors to stderr
* release allocated resources
* return error code on error - improve non-interactive use
* do not show help on unknown commands when used non-interactively
2018-09-24 00:03:13 +02:00
Peter Marschall 9616ad4d94 opensc-explorer: fix&clarify handling of interactive mode
* make 'interactive' a global variable
* set it when opensc was called with the SCRIPT argument
* document the behaviour in the manual page

Make interactive a global variable and set it in main.
2018-09-24 00:03:13 +02:00
Peter Marschall c5679bfe39 opensc-explorer: refactor read_cmdline()
* add comments
* simplify #ifdef logic
* increase commandline buffer in non-interactive / non-readline case
2018-09-24 00:03:13 +02:00
Peter Marschall ca9538761b opensc-explorer: refactor parse_cmdline()
* add comments
* always terminate argv[] with a NULL element
* fail if number of arguments is too large
2018-09-24 00:03:13 +02:00
Peter Marschall c9db3f7385 opensc-explorer: allow arguments for 'help'
When arguments are given, compare them like ambguous_match() does,
and show the matching ones only.

Add documentation of the 'help' command to the manual page.

In main loop on multiple matches, show help on matching commands only.
2018-09-24 00:03:13 +02:00
Peter Marschall c817be8faa opensc-explorer: refactor ambiguous_match()
* most importantly: immediately return success on exact match
  - this allows one command to be a prefix of another one
  - it fixes the long-standing breakage between 'find' and 'find_tags'
* fail on second prefix-only match instead of waiting until the end
* check all parameters
* add comments
* inform caller on whether the match was ambiguous or there was no match
* move printing error messages to processing loopt in main()
2018-09-24 00:03:13 +02:00
Peter Marschall 593a90f64e opensc-explorer: write error messages to stderr
Clarify the distinction between error messages and status messages or prompts.
Prepare for better non-interactive support.
2018-09-24 00:03:13 +02:00
Peter Marschall 77297f7965 opensc-explorer: check length of argument to option --mf
* fail when it is too long
* replace a magic numerical constant
2018-09-24 00:03:13 +02:00
Peter Marschall bd97c2b139 opensc-explorer: clarify command parsing in manual page 2018-09-24 00:03:13 +02:00
Peter Marschall 9d501766b4 opensc-explorer: extend 'random' to allow writing to a file
Accept a file name as a second argument to the 'random' command
to allow storing the generated random bytes to the file given.

Forbid writing binary data to stdout in interactive mode.
2018-09-24 00:03:13 +02:00
Peter Marschall 7a4a9f1951 opensc-explorer: refactor do_put() slightly
Avoid misunderstandings by renaming a variable that refers to an
input file handle from 'outf' to 'inf'.
2018-09-24 00:03:13 +02:00
Peter Marschall 1245b617d1 opensc-explorer: refactor do_apdu() slightly
* limit buffer to SC_MAX_EXT_APDU_BUFFER_SIZE
* fix buffer length calculation to correctly calculate the available space
* add length checks when parsing passed data into buffer
2018-09-24 00:03:13 +02:00
Peter Marschall 58da74bc32 opensc-explorer: refactor do_put_data() slightly
* increase input buffer size
* avoid magic number
* notify caller on error details when parsing fails
2018-09-24 00:03:13 +02:00
Peter Marschall aed4b00145 opensc-explorer: harmonize display of command arguments
* consistently show ellipsis for repeatable arguments as 3 dots
* embrace alternative mandatory arguments with curly braces
* use hyphens instead of spaces within non-literal arguments
  for improved alignment with the manual page
2018-09-24 00:03:13 +02:00
Peter Marschall fa2421c89d opensc-explorer: overhaul man page
- harmonize structure
- add missing commands (e.g. '#')
- extend description of commands
- fix description of commands (e.g. 'do_put')
2018-09-24 00:03:13 +02:00
Peter Marschall c69f10c2ab opensc-explorer: add command 'pin_info'
Get information on a PIN or key from the card via sc_pin_cmd()'s
SC_PIN_CMD_GET_INFO functionality.
2018-09-24 00:03:13 +02:00
Jakub Jelen 9d44adbc4e Missing header release tarball 2018-09-14 22:39:57 +02:00
Frank Morgner 4fad530e9a appveyor: fixed msi naming 2018-09-14 08:32:11 +02:00
Frank Morgner 00d1501ae6 pkcs11: fail in C_CreateObject/C_DestroyObject if write protected 2018-09-14 08:23:08 +02:00
Frank Morgner 129946ca96 pkcs11: CKF_WRITE_PROTECTED based on card's read_only flag
uses `md_read_only` as `read_only` for both, PKCS#11 and Minidriver
2018-09-14 08:23:08 +02:00
Frank Morgner db4ed9f4a2 export _sc_match_atr_block 2018-09-14 08:23:08 +02:00
Frank Morgner e36c1468e5 md: derive md_read_only from PKCS#15 profile 2018-09-14 08:23:08 +02:00
Priit Laes 1f06a76b1a openssl: Bump openssl requirement to 0.9.8 2018-09-14 08:21:40 +02:00
Priit Laes 9fa730bb95 openssl: PKG_CHECK_MODULES can take a list of packages. Use this for openssl 2018-09-14 08:21:40 +02:00
Priit Laes 9d16e6e177 openssl: Use define for openssl minimum version specification 2018-09-14 08:21:40 +02:00
Frank Morgner f1691fc91f updated NEWS 2018-09-13 13:47:21 +02:00
Frank Morgner 3750d70106 pgp: detect gnuk with newer fw
closes https://github.com/OpenSC/OpenSC/issues/1475
2018-09-13 13:46:27 +02:00
Jakub Jelen f885ee4a17 opensc.conf: Make the example syntax correct 2018-09-12 21:24:39 +02:00
Frank Morgner 66fe060363 fixed gcc 8 compiler waring
closes https://github.com/OpenSC/OpenSC/pull/1474
2018-09-12 13:10:06 +02:00
Raul Metsma 430a9b3f5a Commit c463985fed broke EstEID PIN verify
Signed-off-by: Raul Metsma <raul@metsma.ee>
2018-09-12 12:30:05 +02:00
Frank Morgner 719d2cbe21 Updated NEWS 2018-09-12 09:45:19 +02:00
Frank Morgner 83c0bff640 pgp: added new ATRs to windows installer 2018-09-11 22:18:19 +02:00
Alon Bar-Lev d8a2a7bf88 reader-ctapi: ctapi_connect: remove unused variable
from day 1 return value of _sc_parse_atr was ignored.
2018-09-09 14:55:28 +02:00
alex-nitrokey 083c18045e Make deciphering with AUT-key possible for OpenPGP Card >v3.2 (fixes #1352) (#1446) 2018-09-06 10:57:23 +02:00
alex-nitrokey 748234b7cc Fix SM algorithm in extended capabilities 2018-09-05 23:42:14 +02:00
Frank Morgner 012a425819 fixed generating files documentation 2018-09-05 23:18:55 +02:00
Frank Morgner ea2024decf appveyor: fix release build 2018-09-05 09:59:00 +02:00
Frank Morgner 3352960265 fixed maintainer-clean target 2018-09-05 08:55:14 +02:00
Frank Morgner 62a2847300 add missing files.xml to distribution 2018-09-04 13:55:19 +02:00
Frank Morgner 39bd1ddd58 fixed wrong condition
fixes https://github.com/OpenSC/OpenSC/issues/1465
2018-09-04 13:51:40 +02:00
Frank Morgner ddec3a437c remove -Release in windows artifact 2018-08-31 16:38:51 +02:00
Frank Morgner e238f4d6fb don't include tag in windows artifact 2018-08-31 16:38:51 +02:00
alex-nitrokey b572b383b2 Add supported algorithms for OpenPGP Card (Fixes #1432) (#1442) 2018-08-31 14:38:14 +02:00
asc 2b60a0db0f Add support for SmartCard-HSM 4K (V3.0) 2018-08-31 13:42:44 +02:00
Frank Morgner 972f9eb35b fixed PKCS11-Spy dll default
fixes https://github.com/OpenSC/OpenSC/issues/1464
2018-08-31 13:36:33 +02:00
Frank Morgner c79adb6c11 include PACKAGE_NAME in msi instead of VSVER
uploads nightly only for VS12 build
2018-08-31 13:34:33 +02:00
Frank Morgner a3ca935b16 win32: use standard build of zlib
fixes https://github.com/OpenSC/OpenSC/issues/1461
2018-08-31 13:34:33 +02:00
Frank Morgner 0ddfd2d521 deploy only when on master 2018-08-30 22:06:21 +02:00
asc 0ab5b92dc5 Allow building tests on Ubuntu 16.04, which has libcmocka 1.0.1 (#1405) 2018-08-30 13:27:36 +02:00
Frank Morgner b5a6f9aa6e prepare 0.19.0 2018-08-27 13:40:20 +02:00
Frank Morgner db438f61c1 ias/ecc: fixed GET CHALLENGE 2018-08-24 13:59:03 +02:00
Frank Morgner 94f9fdf145 ias/ecc: fixed card detection
regression of 439a95f2d
2018-08-24 13:51:15 +02:00
Frank Morgner 5daec17e32 ias/ecc: ignore missing serial on card initialization
fixes problem in card detection introduced in
50b000047c
2018-08-24 13:50:53 +02:00
Frank Morgner 5a25bd33cc macos: use HFS+ for backward compatibility
fixes https://github.com/OpenSC/OpenSC/issues/1398
2018-08-24 09:27:13 +02:00
Frank Morgner 5b428e4323 upload CI build artifacts to OpenSC/Nightly
builds are uploaded as seperate branches to
https://github.com/OpenSC/Nightly If the repository gets too big,
branches can easily be removed. The repository is written via Travis CI
and AppVeyor with a secure token from user https://github.com/OpenSC-CI
2018-08-24 09:23:58 +02:00
Raul Metsma 336b282324 Reuse gp_select_aid
Signed-off-by: Raul Metsma <raul@metsma.ee>
2018-08-23 20:37:38 +02:00
Doug Engert 719ec39b3e Use sc_asn1_read_tag to read first tag of partially block (#1454)
Sc_asn1_read_tag can return SC_ERROR_ASN1_END_OF_CONTENTS
which indicates the tag and length are OK, but any value
is not completely contained in the buffer supplied. card-piv.c
can use this when reading just the beginning of a object to
determine the size of a buffer needed to hold the object.
2018-08-23 20:35:24 +02:00
Frank Morgner 97f0a341b0 fixed typo 2018-08-23 10:14:25 +02:00
Frank Morgner 70c4813f30 fixed Dereference before null check 2018-08-23 09:59:45 +02:00
Frank Morgner 67fbf15741 fixed NULL dereference 2018-08-23 09:51:04 +02:00
Priit Laes 45f407c021 Mark driver-specific global sc_atr_table structures as const
As most of the drivers do not modify these, we can mark them as const.
Two drivers that we cannot convert are dnie and masktech.

section                 size
.data                  35232 ->   25472
.data.rel.ro           36928 ->   46688
2018-08-22 22:50:30 +02:00
Priit Laes 2eae5e70f5 Mark atr table argument as const in match_atr_table and _sc_match_atr functions
This allows us to mark driver-specific atr tables as constants.
2018-08-22 22:50:30 +02:00
Frank Morgner fcd719d30f
Merge pull request #1447 from Jakuje/x41sec-merge
Security issues idefnitifed by fuzzing. For more information, see the blog post:

https://www.x41-dsec.de/lab/blog/smartcards/
2018-08-20 15:11:51 +02:00
Frank Morgner ff8ec86f26 avoid looping forever in GET CHALLENGE
fixes https://github.com/OpenSC/OpenSC/issues/1440
2018-08-20 14:37:20 +02:00
Frank Morgner fcf00e66cd Starcos: added ATR for 2nd gen. eGK
fixes https://github.com/OpenSC/OpenSC/issues/1451
2018-08-20 14:27:02 +02:00
Frank Morgner 59d634e9e8 fixed low privilege `make distcheck`
regression of b0a20fa7ca
2018-08-20 12:03:44 +02:00
Frank Morgner 48d30ac7da Don't overwrite existing opensc.conf
fixes https://github.com/OpenSC/OpenSC/issues/1449
partially reverts c003f3825e
2018-08-20 12:03:44 +02:00
Jakub Jelen 5ec26573da coolkey: Do not overflow allocated buffer 2018-08-14 16:13:22 +02:00
Jakub Jelen 79c0dbaa4e cac: Avoid OOB reads for inconsistent TLV structures 2018-08-14 16:13:22 +02:00
Frank Morgner 50b000047c ias/ecc: disable iccsn parsing
if someone wants to implement this with memory bounds checking, please
raise your hands
2018-08-14 16:13:22 +02:00
Frank Morgner 0b44793900 tcos: use ISO7816 fci parser 2018-08-14 16:13:22 +02:00
Frank Morgner 30fe0ad453 pgp: fixed integer underflow 2018-08-14 16:13:22 +02:00
Frank Morgner 92a98cb3bb mcrd: converted assert to proper error handling 2018-08-14 16:13:22 +02:00
Frank Morgner 78f0055338 fixed uninitialized use of variable 2018-08-14 16:13:22 +02:00
Frank Morgner 03628449b7 iasecc: fixed unbound recursion 2018-08-14 16:13:22 +02:00
Frank Morgner 5807368ed4 fixed bad memory access 2018-08-14 16:13:22 +02:00
Doug Engert 384626533e PIV Security Changes
Add return code if "out" is smaller then received data.

Remove extra blanks.
2018-08-14 16:13:22 +02:00
Doug Engert 3e5a9a42c3 Remove in PIV driver need for aid_file
Remove aid_file and aidfile variables in card-piv.c. These are not needed
as piv_select_aid parses the returned data from a SELECT AID command.

In response to e-mail from X41 group on 6/11/2018.

 On branch x41-piv-2
 Changes to be committed:
	modified:   card-piv.c
2018-08-14 16:13:22 +02:00
Jakub Jelen d5d15105dd cac: Ignore end of content errors (#7)
The CAC buffers are split to separate TL and V buffers so we need to ignore this error
2018-08-14 15:50:13 +02:00
Frank Morgner 83f45cda2a Added bounds checking to sc_simpletlv_read_tag()
- Logic is identical to sc_asn1_read_tag()
- Fixes out of bounds access e.g. in cac_parse_CCC
2018-08-14 15:50:13 +02:00
Frank Morgner ffe38fd87f sc_asn1_read_tag: fixed tracking of consumed bytes
fixes return buffers that are outside the allocated memory space
2018-08-14 15:50:13 +02:00
Frank Morgner 360e95d45a fixed out of bounds writes
Thanks to Eric Sesterhenn from X41 D-SEC GmbH
for reporting the problems.
2018-08-14 15:50:13 +02:00
Frank Morgner 8fe377e93b fixed out of bounds reads
Thanks to Eric Sesterhenn from X41 D-SEC GmbH
for reporting and suggesting security fixes.
2018-08-14 15:50:13 +02:00
Frank Morgner f66ceab4bb fixed typo
fixes https://github.com/OpenSC/OpenSC/issues/1443
2018-08-09 15:50:51 +02:00
Frank Morgner 849c9785e3 added missing rule for opensc.conf.5.xml 2018-08-09 15:46:53 +02:00
Frank Morgner 80d44a5b99 use proper prefix in documentation 2018-08-05 12:28:50 +02:00
Frank Morgner 9294058d5c fixed requesting DWORD with sc_ctx_win32_get_config_value
the length of the value is not determined by strlen()
2018-08-05 11:35:12 +02:00
Frank Morgner cd557df54d md: change semantics of cancelling the PIN pad prompt
md_pinpad_dlg_allow_cancel now defines whether or not the user is asked
before verifying the PIN on the PIN pad. This can be denied without
interaction with the PIN pad. A checkbox in the dialog allows the user
to change this setting, which is saved in the registry by the path of
the process.

This change fixes the progress bar to match the actual configured
timout. The progressbar now fills instead of running empty, which seemed
less frightening for most users.

This change also fixes some copy/paste errors in the documentation of
opensc.conf(5).
2018-08-05 11:35:12 +02:00
Frank Morgner da40c61d13 npa/sc-hsm: don't call EAC_cleanup()
In Minidriver, when the DLL is called in multiple threads, this can
lead to a deinitialization of OpenSSL's OIDs in one thread making them
unavailable from other threads of the same process. As result, CVCs
cannot be veriefied anymore during chip authentication.
2018-08-05 11:35:12 +02:00
Frank Morgner 0f9c7d126a win32 installer: automatically start SCardSvr 2018-08-05 11:35:12 +02:00
Frank Morgner 79fb808adf opensc-notify: localize exit menu entry 2018-08-05 11:35:12 +02:00
Frank Morgner 0f1fdb7872 opensc-notify: add Exit button to tray icon 2018-08-05 11:35:12 +02:00
Frank Morgner 4a3a3e5df2 opensc-notify: implement win32 message dispatching 2018-08-05 11:35:12 +02:00
Frank Morgner 11aaf15776 removed outdated solaris files 2018-08-05 11:33:21 +02:00
Jakub Jelen 2190bb927c Drop support for CAC 1
This removes code related to the old CAC 1 specification, while
preserving the CAC 2 functionality including CAC Alt token detection
for the tokens without CCC or ACA.

The detection based on SELECT APPLET APDU is improved to require also
the READ BUFFER APDU working, which should fail on misbehaving Java cards.
2018-08-03 01:51:44 +02:00
Jakub Jelen f097d88b3a coolkey: Drop bogus ; 2018-08-03 01:50:05 +02:00
Jakub Jelen 8e8193f8f5 coolkey: Unbreak get_challenge with correct instruction code 2018-08-03 01:50:05 +02:00
Raul Metsma dfe932d00d OMNIKEY 3x21 and 6121 Smart Card Reader are not pinpad readers
macOS 10.13 ships with ccid driver 1.4.27 (fixed in 1.4.29) and this version identifies these readers wrongly as pinpad readers.

Signed-off-by: Raul Metsma <raul@metsma.ee>
2018-07-28 13:42:20 +02:00
Frank Morgner 4de0d06a93 use single quotes for passing define
makes sure that the shell doesn't evaluate parts of the define
2018-07-17 14:49:27 +02:00
Frank Morgner a0b6643fa7 Use hard coded default SM module (path)
- avoids the need to set this default in opensc.conf
- fixes loading of (unknown) local library
- removes some unused defines from config.h
2018-07-17 14:49:27 +02:00
Frank Morgner c003f3825e Distribute a minimal opensc.conf
closes https://github.com/OpenSC/OpenSC/issues/1102
2018-07-17 14:49:27 +02:00
Frank Morgner e226ad265a Removed unused option `hide_empty_tokens` 2018-07-17 14:49:27 +02:00
Frank Morgner 47ee3a3978 added manual page opensc.conf(5)
splits the HTML documentation into files.html and tools.html
2018-07-17 14:49:27 +02:00
Frank Morgner 16275c2683 fixed memory leak 2018-07-17 13:31:14 +02:00
Frank Morgner 3042a39705 removed unused variable 2018-07-17 13:16:06 +02:00
Doug Engert fbc9ff84bc Some cards may return short RSA signatures without leading zero bytes.
Add leading zeros to RSA signature so it is the size of modulus.
Return modulus length.

 Changes to be committed:
	modified:   src/libopensc/pkcs15-sec.c
2018-07-11 22:30:50 +02:00
Frank Morgner 376de5bd4c make bash completion directory configurable 2018-07-11 21:55:05 +02:00
Jakub Jelen 1eaae6526b pkcs15-tool: Build with current gcc
The argument to strncpy is not the length of the target buffer,
but the source one (excluding the null byte, which will be
copied anyway).
2018-07-11 10:48:10 +02:00
Jakub Jelen e9314adf4b Testsuite also depends on openssl, use correct variables for linking 2018-07-11 10:48:10 +02:00
Jakub Jelen 7c8ed4dc03 Correct name in the automake 2018-07-11 10:48:10 +02:00
Jakub Jelen 3a7a1ba31f Do not fail if we found unknown tag or the count does not match
* The HID tokens present such undocumented tags
2018-07-11 10:48:10 +02:00
Jakub Jelen bf3382d4d9 Standardize logging and include also AID 2018-07-11 10:48:10 +02:00
Jakub Jelen 3480d9fc99 Log also information about unitialized slots with correct labels 2018-07-11 10:48:10 +02:00
Jakub Jelen 1c2a7f8dd2 HID Alt tokens have the other bunch of slots in other undocumented AID 2018-07-11 10:48:10 +02:00
Peter Marschall 1eb8391b4a OpenPGP: slightly re-factor pgp_get_card_features()
* length checks where needed
* more & better comments
2018-07-11 10:47:39 +02:00
Peter Marschall 7332a37abb OpenPGP: add serial number to card name 2018-07-11 10:47:39 +02:00
Peter Marschall 6d6efa2ded OpenPGP: fix FIXME in pgp_new_blob()
Form a correct path instead ofmusising an array of 2 u8's.
Perform proper error checking.
2018-07-11 10:47:39 +02:00
Peter Marschall 215fcdad15 OpenPGP: include detailed version into card name
... for "standard" OpenPGP cards.

This gives more detailed information to the user on the detailed specs
the card adheres to.

In addition it fixes a long-standing annoyance that every standard 2.x
card matching the v2.0 ATR was announced as CryptoStick 1.2.
This ATR is not only used in the CryptoStick 1.2, but also also in
ZeitControl cards as well as NitroKeys, ...
2018-07-11 10:47:39 +02:00
Peter Marschall 2e1b47a79a OpenPGP: improve get_full_pgp_aid()'s parameter checking 2018-07-11 10:47:39 +02:00
Peter Marschall 2a7a6a62fa OpenPGP: limit scope of variable 2018-07-11 10:47:39 +02:00
Peter Marschall 15125b03ab OpenPGP: use LOG_FUNC_CALLED & LOG_FUNC_RETURN symmetrically
To help debugging,
- replace plain return's after LOG_FUNC_CALLED()
  has been called with LOG_FUNC_RETURN()
- use LOG_FUNC_CALLED() & LOG_FUNC_RETURN() pairs more often
2018-07-11 10:47:39 +02:00
Peter Marschall fcecd1bdd2 OpenPGP: update comments on function use: ABI or internal 2018-07-11 10:47:39 +02:00
Peter Marschall 0d6be5db26 OpenPGP: define & set LCS (lifecycle support) as extended capability
Use it in pgp_erase_card() to slightly simplify the code.
2018-07-11 10:47:39 +02:00
Peter Marschall 3af54b2fe0 OpenPGP: harmonize some comments 2018-07-11 10:47:39 +02:00
Peter Marschall 3a59b0a182 OpenPGP: parse "extended length info" DO 7f66 on init 2018-07-11 10:47:39 +02:00
Peter Marschall f73005791c OpenPGP: improve parsing of extended capabilities 2018-07-11 10:47:39 +02:00
Peter Marschall dea5fd9551 OpenPGP: add new DOs introduced with OpenPGP card spec v3.0 & v3.3
For some files spec states CONSTRUCTED, but we treat them as SIMPLE,
because we only need parts of their contents.
2018-07-11 10:47:39 +02:00
Peter Marschall 9dbdf42e9e OpenPGP: update references to specifications 2018-07-11 10:47:39 +02:00
Peter Marschall 14cd6ee39e OpenPGP: clarify meaning of padding byte in pgp_decipher() 2018-07-11 10:47:39 +02:00
Peter Marschall 4323a3d37c OpenPGP: add new DO D5 introduced with OpenPGP card spec v2.1
... and make it accessible for v2.1+ cards
2018-07-11 10:47:39 +02:00
Peter Marschall 4ec37adea8 OpenPGP: extend manufacturer list in pkcs15-openpgp.c 2018-07-11 10:46:56 +02:00
Eugene Bright 332535c544 Workaround subject and issuer fields overflow
Structure `x509cert_info` fields `subject` and `issuer`
are doubled in size up to 512 bytes.

We have to use dynamic memory allocation
to completely overcome the issue.

Relates to OpenSC/OpenSC#1412.
2018-07-11 10:13:14 +02:00
Frank Morgner 2c0d1b9ab0 reset sc_card_t during card detection
fixes https://github.com/OpenSC/OpenSC/issues/1417
2018-07-11 10:12:42 +02:00
asc 6f8bfc399b Fix usage indicator for PSS 2018-07-11 10:07:28 +02:00
asc 6e0689638c Add checking for supported CKM_RSA_PKCS_PSS combinations 2018-07-11 10:07:28 +02:00
Leif Erik Wagner e2f0e367b1 Implement RSA PSS for GoID / SmartCard-HSM 2018-07-11 10:07:28 +02:00
Peter Marschall 99fa4f4a57 pkcs15-tool: harmonize non-short output for -C, -D,
Make sure to have an empty line between information printed for individual
objects, but not in short mode.
This makes output of -D and -C more consistent.
2018-07-11 10:05:30 +02:00
Sean Enck 0ceef8778b Fixes #1421, when a tool has no OPTSWITHARGS it will produce invalid bash (completion) output syntax 2018-07-11 10:03:50 +02:00
Gianfranco Costamagna a6b4605b86 card-piv.c: initialize variable to fix a ppc64el build failure
This fixes a build failure with optimized ppc64el and new gcc builds
card-piv.c: In function ‘piv_validate_general_authentication.isra.3’:
card-piv.c:2390:9: error: ‘rbuflen’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    body = sc_asn1_find_tag(card->ctx, rbuf, rbuflen, 0x7c, &bodylen);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2018-07-11 09:54:51 +02:00
Frank Morgner 88de66bb13 fixed `make distcheck` 2018-07-04 18:12:58 +02:00
Stanislav Brabec 4db9db7403 Add GenericName to the desktop file
Add optional GenericName to org.opensc.notify.desktop. GenericName is
recently widely used for menu rendering in desktop environments.
2018-07-04 09:50:07 +02:00
Stanislav Brabec b0a20fa7ca Use correct bash-completion path
Recent versions of bash is leaving /etc/bash_completion.d. The correct
directory is specified by pkg-config --variable completionsdir
bash-completion.

Fixes https://github.com/OpenSC/OpenSC/issues/1403
2018-07-04 09:50:07 +02:00
Jakub Jelen 155ecc11f3 Adjust the p11test readme after merge
Resolves: #1415
2018-07-04 09:46:43 +02:00
Frank Morgner 452e1d3b96 fixed used of uninitialized return value 2018-06-30 01:17:57 +02:00
Frank Morgner b3e3ab61c0 avoid integer underflow 2018-06-29 17:14:55 +02:00
Frank Morgner 971dac2f78 unignore result 2018-06-29 17:14:55 +02:00
Frank Morgner 6184c1fbab avoid out of bounds read 2018-06-29 17:14:55 +02:00
Frank Morgner 03c5280626 avoid NULL dereference 2018-06-29 17:14:55 +02:00
Frank Morgner ed0d829eab removed unused check 2018-06-29 17:14:55 +02:00
Frank Morgner 259b7ec41c check return value 2018-06-29 17:14:55 +02:00
Frank Morgner c026f37677 warn about error in sc_enumerate_apps 2018-06-29 17:14:55 +02:00
Frank Morgner 6819759946 fixed memory leak 2018-06-29 17:14:55 +02:00
Frank Morgner 5f39d7ab74 use correct length of binary ATR 2018-06-29 17:14:55 +02:00
Frank Morgner 0e9565754c avoid uninitialized output after sc_file_dup 2018-06-29 17:14:55 +02:00
Alon Bar-Lev 31cbf83738 build: support >=libressl-2.7 2018-06-28 08:58:07 +02:00
Peter Marschall 0603c3b7fc iso7816: fix typo in previous commit 2018-06-24 10:34:49 +03:00
Peter Marschall 2818e0f703 iso7816: update & extend error codes
While at it, do some space policing.
2018-06-24 10:34:49 +03:00
Frank Morgner 1ca1a024df card-npa: fixed memory leak
fixes https://github.com/OpenSC/OpenSC/issues/1396
2018-06-22 09:23:00 +02:00
Frank Morgner d831076974 opensc-notify: use generic icon
fixes https://github.com/OpenSC/OpenSC/issues/1402
2018-06-22 08:52:49 +02:00
Peter Popovec 5dcea4440e pkcs15-tool: added support for reading NIST ssh keys
'pkcs15-tool --read-ssh-key' is now able to read NIST ECC keys from card.
Only 256, 384 and 521 field lengths are supported (same as allowed in
ssh-keygen -t ecdsa). Issue #803 is partialy fixed by this patch.
Openssh PKCS11 interface patches for ECC are now available, please check
https://bugzilla.mindrot.org/show_bug.cgi?id=2474
2018-06-21 15:26:15 +02:00
Jakub Jelen 1f352d4c6d muscle: Properly clean up the applet memory footprint 2018-06-21 12:48:57 +02:00
Jakub Jelen 5b3da5d462 cac: Missing memory cleanup 2018-06-21 12:48:57 +02:00
Jakub Jelen 2682741293 cac: Avoid segfaults from get_challenge() 2018-06-21 12:48:57 +02:00
Jakub Jelen f392d7426f Utilize autoconf variables for cmocka usage 2018-06-21 12:48:57 +02:00
Jakub Jelen f9f3bc3ae0 configure: Check for cmocka header file 2018-06-21 12:48:57 +02:00
Jakub Jelen 3998fffbdc configure: Use correct variables for testsuite 2018-06-21 12:48:57 +02:00
Jakub Jelen 0789961320 Add a badge about card status 2018-06-21 12:48:57 +02:00
Frank Morgner 9c2afad417 fixed copy/paste error 2018-06-20 00:56:01 +02:00
Frank Morgner 8b3f5b7d97 epass2003: fixed logical error 2018-06-19 23:24:36 +02:00
Frank Morgner 9150d92447 fixed out of bounds access 2018-06-19 23:22:00 +02:00
Frank Morgner d8cdf66d3d fixed memory leak 2018-06-19 23:15:29 +02:00
ytoku 63ed8d7368 gids: file selection via gids_select_file 2018-06-19 08:00:01 +02:00
ytoku 46c0bbd803 gids: use file id instead of path in gids_delete_key_file 2018-06-19 08:00:01 +02:00
ytoku ab16228e26 gids: fix gids_delete_cert 2018-06-14 14:05:45 +02:00
asc 31941bc3d9 sc-hsm: Ensure that applet returns version information (Fix #1377) 2018-06-11 22:51:45 +02:00
Peter Marschall 7c99adaaa6 PIV: limit scope of some variables 2018-06-11 22:37:42 +02:00
Peter Marschall f2ba0ad9be PIV: refactor to use sc_compacttlv_find_tag() 2018-06-11 22:37:42 +02:00
Jakub Jelen 40b02b2582 Namespace the function name, update comment 2018-06-11 22:31:44 +02:00
Jakub Jelen 50b5eb3b69 Allow using up to 16 certificates 2018-06-11 22:31:44 +02:00
Jakub Jelen 9dda83e48e cac: Verbose logging, avoid OOB reads 2018-06-11 22:31:44 +02:00
Jakub Jelen 930d457304 Log bad length buffers 2018-06-11 22:31:44 +02:00
Jakub Jelen 298afb072e Properly check length also of the applet entry 2018-06-11 22:31:44 +02:00
Jakub Jelen f27ee858c2 Carefully check the length of the buffers before accessing them.
The lengths are static and based on the GCS-IS 2.1 specification
2018-06-11 22:31:44 +02:00
Jakub Jelen a73b3d549b Address review comments:
* Refactor cac_properties_t structure to make its creation more readable
 * Avoid manual allocation in cac_get_acr() and clean up bogus pointers
 * Avoid bogus comments
 * Properly check lengths of retrieved values
2018-06-11 22:31:44 +02:00
Jakub Jelen aacac57230 Another note/todo about PINs on uninitialized cards 2018-06-11 22:31:44 +02:00
Jakub Jelen d24c23ac0c Use applet properties to recognize buffer formats
Previously, the code handled all the data objects as SimpleTLV,
which caused invalid encoding when we tried to merge TL + V buffers
into single PKCS#15 buffers.

This change is using GET PROPERTIES APDU after applet selection
to explore objects, figure out encoding and check the status of
PKI objects initialization to avoid reading them.
2018-06-11 22:31:44 +02:00
Jakub Jelen 450cff470a Inspect the Alt tokens through the ACA applet
The previous solution was just guessing AIDs of the PKI objects
and trying if they answer.

This solution is inspecting card based on the Service Applet Table
(listing all the applets on the card) and using GET PROPERTIES APDU
listing all the available OIDs of the applet.

This was successfully tested with standard CAC card
(with different ACA AID) and uninitialized HID Alt tokens with empty
certificates slots.
2018-06-11 22:31:44 +02:00
Jakub Jelen ee7b6f4035 cac: Log unknown tags 2018-06-11 22:31:44 +02:00
Jakub Jelen cde06a499c Use correct AID and Object ID 2018-06-11 22:31:44 +02:00
Jakub Jelen 2138d5fe32 One more todo based on the testing with a new libcacard 2018-06-11 22:31:44 +02:00
Jakub Jelen 426914674c Unbreak encoding last tag in the data objects 2018-06-11 22:31:44 +02:00
Jakub Jelen 5b420318d4 Allocate private data outside and avoid memory leaks 2018-06-11 22:31:44 +02:00
Jakub Jelen 92df907681 Typo, clean up comments, dump more useful information from CCC 2018-06-11 22:31:44 +02:00
Jakub Jelen 52451ac438 card-cac.c: Dump also the MSCUID 2018-06-11 22:31:44 +02:00
asc 335c242ce0 Filter certificates other than CKC_X_509 2018-06-08 08:28:37 +02:00
Jakub Jelen 89a8e0cb64 Avoid memory leaks from the failed card detections 2018-06-08 08:26:49 +02:00
Andreas Kemnade 23706635a8 cardos: create pin in mf
If cardos cards are initialized by other software and there is a pinref
without the msb set, also the pin verify works without that bit set.

This patch changes pin initialisation so that the pin is created in mf
which has the effect that pin verify works without | 0x80 to the
pin ref.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
2018-06-08 08:23:37 +02:00
Laurent Bigonville 694822554e dnie: Consider that everything not APPLE or WIN32 is "linux"
This should fix the FTBFS on architectures like kfreebsd

Fixes: #1366
2018-06-08 08:22:58 +02:00
Peter Marschall e6ad737430 OpenPGP: add cast forgotten in previous commit 2018-06-08 08:21:11 +02:00
Peter Marschall ba9eebceaf OpenPGP: refactor do_dump_do()
- limit length of data to write even in raw mode to the real length
- cluster variuable definitions
- restrict scope of variables
- introduce a variable length to make the purpose more obious
- start preprocessor directives at column one
- add comments where needed
- harmonize coding style: space after "if" and casts
2018-06-08 08:21:11 +02:00
Peter Marschall 4a1bf9fb21 OpenPGP: limit output of -d in non-raw mode to real length 2018-06-08 08:21:11 +02:00
Peter Marschall 85f4ba6c5f OpenPGP: allow calling -d multiple times
Put the arguments passed to option -d into an array instead of only
storing the latest value.
During output, iterate over the values passed in via the option.
2018-06-08 08:21:11 +02:00
Peter Marschall 1da7da5e99 OpenPGP: make parsing of option -d more robust
* accept flexible option arguguments: 1-4, 101-104, 0101-0104, ...
2018-06-08 08:21:11 +02:00
Peter Marschall 41d89b52fc OpenPGP: treat option --del-key as an action 2018-06-08 08:21:11 +02:00
Peter Marschall da6e30b38b OpenPGP: clarify usage text 2018-06-08 08:21:11 +02:00
Peter Marschall 266b811e55 compact TLV - add generic sc_compacttlv_find_tag() function (#1374)
* new function sc_compacttlv_find_tag()

Add function sc_compacttlv_find_tag() to search for a tag in a
compact-TLV structure.

* OpenPGP: use sc_compacttlv_find_tag()

While doing so, fix a typo affection OpenPGP v3.x cards
2018-06-08 08:17:13 +02:00
asc 6dfeb9959f Fix #1371 introduced by 45ad44e 2018-06-08 08:13:32 +02:00
Laurent Bigonville f2042f2270 Do not display opensc-notify in the application list
opensc-notify doesn't propose a GUI that can be displayed to the users,
so it doesn't make sense to display it in the application list/launcher

Fixes: #1379
2018-06-06 22:48:12 +02:00
Peter Marschall 76725d5f80 .travis.yml: partially revert commit cb3113a 2018-06-06 22:43:46 +02:00
Peter Marschall ff9df38665 src/tools: remove HELP2MAN_LOCALE from Makefile.am 2018-06-06 22:43:46 +02:00
Peter Marschall c16903140d src/tools: remove deleted man pages from Makefile.am's EXTRA_DIST 2018-06-06 22:43:46 +02:00
Peter Marschall 008845efb3 src/tools: remove legacy man pages generated using help2man
Now that we have proper DocBook sources for them, they can be safely removed.
2018-06-06 22:43:46 +02:00
Peter Marschall a27ade7789 .travis.yml: remove references to help2man
Now that we have proper DocBook sources for all man pages formerly
generated using help2man, it is not needed anymore.
2018-06-06 22:43:46 +02:00
Peter Marschall cedc5a1cf6 configure.ac: remove references to help2man
Now that we have proper DocBook sources for all man pages formerly
generated using help2man, it is not needed anymore.
2018-06-06 22:43:46 +02:00
Peter Marschall 184bc137cd OpenPGP: extend & sort man page
Also try to consolidate the coding style a bit
2018-06-06 22:43:46 +02:00
Peter Marschall 85468868fb man pages: add missing options to make test-manpage.sh happy 2018-06-06 22:43:46 +02:00
Peter Marschall dbe2fcef2c test-manpages.sh: make more robust & more easily readable
Call the tools to be tested with option '--help' to avoid
triggering automatic actions when no option is given.

Exampleswhy the old behaviour is bad:
- opensc-notify: blocks the build
- opensc-explorer: tries to open the card
2018-06-06 22:43:46 +02:00
Peter Marschall 59412aeee3 src/tools: stop building man pages here (see doc/tools)
They have been moved to doc/tools and are generated there.
2018-06-06 22:43:46 +02:00
Peter Marschall 5a3134556b doc/tools: slight markup improvements
* get rid of hard-coded markup like e.g. { ... | ... } or [ ... ]
  in favour of DocBook's proper tags
* use tags better matching the purpose,
  e.g. use <filename class"directory"> instead of <command> for directories
* improve consistency in <replaceable>s
2018-06-06 22:43:46 +02:00
Peter Marschall 98c9a1588b doc/tools/tools.xml: sort, remove duplicates, add new tools 2018-06-06 22:43:46 +02:00
Peter Marschall ad6b46ea45 doc/tools: add DocBook sources for new tools
* egk-tool.1.xml
* npa-tool.1.xml
* opensc-asn1.1.xml
* opensc-notify.1.xml
2018-06-06 22:43:46 +02:00
Peter Marschall a884953c85 card-dnie: use size_t-specific format specifier in printf
Instead ogf blindly using "%lu", use "%"SC_FORMAT_LEN_SIZE_T"u"
to cope with the various implementations.

This fixes a bug introduced in commit 20b1d829
2018-06-04 12:00:42 +02:00
Peter Marschall 8d503df754 OpenPGP: add missing symbolic constants for card versions 2018-05-31 10:16:23 +02:00
Peter Marschall 3e3e478476 OpenPGP: correctly parse hist_bytes
Instead of simply searching for a trigger byte with the risk of
getting garbage, correctly parse historical bytes from ATR as well
as the "historical bytes" DO as compact TLV structures.

In addition
- prepare for additional data used in OpenPGP cards 3.x
- ignore [per the spec] chaining capability fo OpenPGP cards 1.x
2018-05-31 10:16:23 +02:00
Peter Marschall c725c9c2e7 OpenPGP: 1st go at better parsing of hist_bytes
Use hist_bytes from already parsed ATR in reader->atr_info.hist_bytes
instead of the raw ATR from card->atr
2018-05-31 10:16:23 +02:00
Frank Morgner 4d0e740947 card-npa: Use EF.DIR for card recognition
This is also done in the official AusweisApp2 and avoids confusion with
other tokens that also have an EF.CardAccess and are capable of
verifying the PIN via PACE.

Fixes https://github.com/OpenSC/OpenSC/issues/1360
2018-05-28 22:34:13 +02:00
Peter Marschall d70c140d7a opensc-notify: fix typo 2018-05-27 23:18:13 +02:00
Peter Marschall 0352f298cc npa-tool: fix typo in option parsing 2018-05-27 23:18:13 +02:00
Frank Morgner 42833b6129 added more missing files
fixes https://github.com/OpenSC/OpenSC/issues/1368
2018-05-24 13:51:12 +02:00
Frank Morgner 5985bf13ee ignore more files 2018-05-23 22:31:32 +02:00
Frank Morgner 1aa85671db added missing files to distribution
fixes https://github.com/OpenSC/OpenSC/issues/1368
2018-05-23 22:26:39 +02:00
rmartinc 20b1d829b9 Always allocate resp buffer in DNIe. 2018-05-23 14:22:28 +02:00
Frank Morgner 19df418fb6 fixed usage of get_challenge 2018-05-23 14:20:28 +02:00
Frank Morgner 784435d00c starcos: check for the maximum length of GET RANDOM
Some cards only support fetching 8 bytes and less
2018-05-23 14:20:28 +02:00
Frank Morgner cbba3b82f2 SC-HSM: Check maximum for get_challenge 2018-05-23 14:20:28 +02:00
Frank Morgner 410cdf0dcc refactored sc_get_challenge
Let sc_get_challenge() do sc_lock() and loop through the card driver's
get_challenge() until enough bytes were collected. The card driver's
get_challenge() now returns the number of bytes collected (less or equal
than requested) or an error code.

- Allow more code re-use.
- PIV driver now uses ASN.1 parser for reading the random bytes
2018-05-23 14:20:28 +02:00
Doug Engert 91812cf40f Context Specific Login Using Pin Pad Reader Fix
sc_pkcs15_verify_pin say:

/* if pin cache is disabled, we can get here with no PIN data.
 * in this case, to avoid error or unnecessary pin prompting on pinpad,
 * check if the PIN has been already verified and the access condition
 * is still open on card.
 */

It then call sc_pkcs15_get_pin_info

A context specific login is used in PKCS#11 to force the user
to enter the PIN again and a verify command be sent to the card.
(Actually it could be a different value for the PINi depending on the card)
sc_pkcs15_get_pin_info will then call the card driver, but does not
say why it is testing the login status.sc_pkcs15_get_pin_info may return
SC_PIN_STATE_LOGGED_IN=1 and sc_pkcs15_verify_pin will then skip sending
the actual verify command to the card via _sc_pkcs15_verify_pin

To avoid this, sc_pkcs15_get_pin_info will set data.pin_type = pin_info->auth_method;
In the case of a context specific login, this is SC_AC_CONTEXT_SPECIFIC
and the card driver can take action and can return SC_PIN_STATE_LOGGED_IN=0
so the verify will be done.

The PIV driver card-piv.c does this. Other drivers could do something similar.

 Date:      MOn May 21 20:40:00 2018 -0500

 On branch History-fixes
 Changes to be committed:
	modified:   card-piv.c
	modified:   pkcs15-pin.c
2018-05-23 14:19:05 +02:00
Doug Engert 08ec4b85e1 PIV Better Handling of Reset
If a PIV card does not have  or support a Discovery Object and
is known to lose the login state when the PIV AID is selected,
nothing was done  in piv_card_reader_lock_obtained.
If was_reset > 0 select the PIV AID to at least get the
PIV AID selected.

For other cards either reading the Discovery a object and/or
selecting the PIV AID will make sure the PIV AID is selected.
If multiple applications are using the card, this will allow
the first one to select the AID, and any others that handle
a reset will not cause interference wit the first.

 On branch History-fixes
 Changes to be committed:
	modified:   card-piv.c
2018-05-23 14:19:05 +02:00
Doug Engert d7d674129e PIV History Object Related Changes - Fixes #1330
&& is replaced by || in the test of valid key references
for retired keys found in the Historic object.

For retired keys, the user_consent flag was being set by default.
Thus a C_Login(CKU_CONTEXT_SPECIFIC) would be required.
NIST 800-73 only requires PIN_Always on the Sign Key.

To extend the usefullnes of "retired keys" on non government
issued PIV-like cards, code had already been added
to use the certificate keyUsage flags to override the NIST
defined key usage flags. The NONREPUDATION  flag is now used
to set the user_consent flag.

So rather then always requiring C_Login(CKU_CONTEXT_SPECIFIC)
for any retured key, the code only requires it for non government
cards where teh certificate has NONREPUDATION.

 Changes to be committed:
	modified:   card-piv.c
	modified:   pkcs15-piv.c
2018-05-23 14:19:05 +02:00
Jakub Jelen 6b85099401 pkcs11_enable_InitToken made global configuration option
* Previously, it was dependent on ATR blocks, but it did
   not allow enrolling various types of cards without knowning
   their ATR in advance.
 * Improved documnetation for this option in configuration files

Resolves: #1265
2018-05-23 14:16:34 +02:00
Frank Morgner 45e4f546c2 regenerated built files (gengetopt/help2man)
includes an explicit locale for help2man to recognize umlauts.

partially fixes https://github.com/OpenSC/OpenSC/issues/1365
2018-05-21 20:57:13 +02:00
Peter Marschall 4590d915b9 bootstrap.ci: stop echoing executed commands 2018-05-21 20:45:04 +02:00
Peter Marschall 882080cdf7 version.m4: remove unused macro PACKAGE_VERSION_REVISION 2018-05-21 20:45:04 +02:00
Peter Marschall 4cbdf53b8b bootstrap.ci: cleanup - remove unused code & options 2018-05-21 20:45:04 +02:00
Peter Marschall 8b3e53c730 bootstrap.ci: stop playing with unused PACKAGE_VERSION_REVISION
PACKAGE_VERSION_REVISION is not used outside bootstrap.ci;
remove everything  that deals with it.
2018-05-21 20:45:04 +02:00
Peter Marschall 59a7478011 configure.ac: extend AC_INIT
Define macro PRODUCT_URL and use it as additional argument to AC_INIT().
2018-05-21 20:45:04 +02:00
Peter Marschall e4cab31763 bootstrap.ci: flexibilize option -R
When -R is given, accept indication of -rc resp. ~rc version
strings in git describe's output.
2018-05-21 20:45:04 +02:00
Peter Marschall a6b596d09a version.m4: overhaul
- add macro PACKAGE_VERSION_REVISION dealt with in bootstrap.ci
- restrict to those macros only that are mangled by bootstrap.ci
- update comments on the file's purpose and the processes around it
2018-05-21 20:45:04 +02:00
Peter Marschall c57c743ed0 configure.ac: stop including version.m4
Do not blindly override already defined variables or macros with
outdated values by including version.m4

This makes sure the definitions of variables or macros defined earlier
in configure.ac remain intact; e.g. it keeps the macro PRODUCT_BUGREPORT
set to the GitHub URL instead of pointing to a SourceForge mail address.
2018-05-21 20:45:04 +02:00
Jakub Jelen 9b4e00b24b gp.c: Properly check the SWs of the APDU when selecting AID 2018-05-18 23:52:01 +02:00
Jakub Jelen b6e08e008e Move the Global Platform related commands to separate file and port existing code to that 2018-05-18 23:52:01 +02:00
Jakub Jelen 8d4fbc34c3 coolkey: Make uninitialized cards working as expected with ESC
Original patch from John Magne <jmagne@redhat.com>
2018-05-18 23:52:01 +02:00
Jakub Jelen 58aeb62573 OPENSC_DRIVER: restrict driver list instead of forcing one (#1277)
Using the forced-driver prevents parsing of additional constructions
in configuration files (for example flags based on ATRs). This
implementation replaces transparently the existing list defined in
card_drivers.

Resolves: #1266
2018-05-18 23:50:26 +02:00
Frank Morgner c463985fed
Removed code for obsolete cards from D-Trust (#1261) 2018-05-18 23:49:59 +02:00
Frank Morgner 439a95f2d2
If card initialization fails, return SC_ERROR_INVALID_CARD (#1251)
fixes https://github.com/OpenSC/OpenSC/issues/946
2018-05-18 23:49:29 +02:00
Frank Morgner ae31408f81 fixed checking SW in iso7816_read_binary_sfid
fixes https://github.com/OpenSC/OpenSC/issues/1360
2018-05-18 23:39:16 +02:00
Frank Morgner 01f712d5da
Use explicit locking for OpenSC tools (#1344)
* opensc-explorer: use explicit locking

fixed https://github.com/OpenSC/OpenSC/issues/1043

* opensc-tool: use explicit locking

* pkcs15-crypt: use explicit locking
2018-05-18 23:21:14 +02:00
Alon Bar-Lev 62de900b1a build: fix --disable-sm 2018-05-18 23:20:21 +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
David Ward 14afdf38e3 Do not temporarily set SC_READER_REMOVED on all readers (#1335)
* reader-pcsc: Do not temporarily set SC_READER_REMOVED on all readers

Fixes #1324.

* reader-cryptotokenkit: Do not temporarily set SC_READER_REMOVED on all readers

See #1324.
2018-05-18 13:11:49 +02:00
Frank Morgner 36b88c3ad7 reader-pcsc: allow fixing the length of a PIN
fixes https://github.com/OpenSC/OpenSC/issues/1221
closes https://github.com/OpenSC/OpenSC/pull/1288
2018-05-18 12:57:46 +02:00
Frank Morgner 078e99fdca Removed unused configuration option `zero_ckaid_for_ca_certs`
It was used to make pkcs11-tool work with vendor defined PKCS#11
modules. If this behavior is still desired, pass the define
ZERO_CKAID_FOR_CA_CERTS during the build
2018-05-18 12:46:51 +02:00
Frank Morgner d11e05fe1f Generalized configuration option `ignored_readers` 2018-05-18 12:46:51 +02:00
Frank Morgner 4fca7d08c1 removed configuration option `force_card_driver`
Use `card_drivers` or `OPENSC_DRIVER` instead
2018-05-18 12:46:51 +02:00
Frank Morgner 6ab6d7bad9 removed configuration option `reopen_debug_file`
Simply re-open the debug file every time on Windows and don't do it
everywhere else.
2018-05-18 12:46:51 +02:00
Frank Morgner 5d7ed37246 Removed configuration option `paranoid-memory`
Don't pretend that we're capable of performing memory locking. The
implementation of that, `sc_mem_alloc_secure()` (also removed), was
almost unused anyway.
2018-05-18 12:46:51 +02:00
Frank Morgner 58b6cc05aa Reordered card driver detection
Workaround to not detect the MUSCLE applet as whatever other card driver
selects an AID first. MUSCLE applet will always return 9000, which will
confuse other card drivers. Since this bug is not going to go away any
time soon, we simply detect the MUSCLE applet first and hope that other
applets don't have a similar bug.
2018-05-18 12:36:28 +02:00
Frank Morgner f04a2654d9 card-muscle: be more relaxed in card initialization
closes https://github.com/OpenSC/OpenSC/pull/1248
2018-05-18 12:36:28 +02:00
Jakub Jelen 9858d05589 PKCS#11 testsuite (#1224)
* Initial version of pkcs11 testsuite

* Refactor test cases to several files, clean up awful and unused stuff

* Static mechanism list based on the actual token offer

* Get rid of magic numbers

* Documentation

* License update based on the original project

* Verbose readme

* Cleanup unused code, long lines and method order

* Typo; More verbose errors

* Use fallback mechanisms

* Refactor object allocation and certificate search

* PKCS11SPY mentioned, more TODO

* add SHA mechanisms

* Do not try to Finalize already finalized cryptoki

* Add more flags and mechanisms

* Do not list table for no results

* Logical order of the tests (regression last)

* read ALWAYS_AUTHENTICATE from correct place

* ALWAYS_AUTHENTICATE for decryption

* Test EC key length signature based on the actual key length

* Shorten CKM_ list output, add keygen types detection

* Skip decrypting on non-supported mechanisms

* Fail hard if the C_Login fails

* Reorganize local FLAGS_ constants

* Test RSA Digest mechanisms

* Correct mechanisms naming, typos

* Do not attempt to do signature using empty keys

* CKM_ECDSA_SHA1 support

* Correct type cast when getting attributes

* Report failures from all mechanisms

* Standardize return values, eliminate complete fails, documentation interface

* Wait for slot event test

* Add switch to allow interaction with a card (WaitForSlotEvent)

* At least try to verify using C_Verify, if it fails, fall back to openssl

* Get rid of function_pointers

* Get rid of additional newline

* Share always_authenticate() function between the test cases

* Refactor Encrypt&decrypt test to functions

* Do not overwrite bits if they are not provided by CKA, indentation

* Cleanup and Break to more functions Sign&Verify test

* CKM_RSA_X_509 sign and verify with openssl padding

* More TODO's

* Proper abstracted padding with RSA_X_509 mechanism

* Add ongoing tasks from different TODO list

* Update instructions. Another todo

* Variables naming

* Increase mechanism list size, use different static buffers for flags and mechanism names

* nonstandard mechanism CKM_SHA224_RSA_PKCS supported by some softotkens

* Get rid of loop initial declarations

* Loop initial declaration, typos, strict warnings

* Move the p11test to the new folder to avoid problems with dynamically linked opensc.so

* Update path in README

* Possibility to validate the testsuite agains software tokens

* Add possibility to select slot ID on command-line (when there are more cards present)

* Clean up readme to reflect current options and TODOs

* Do not attempt to use keys without advertised sign&verify bits to avoid false positives

* Get and present more object attributes in readonly test; refactor table

* New test checking if the set of attributes (usage flags) is reasonable

* Test multipart signatures. There is not reasonable mechanism supporting multipart encryption

* Use PKCS#11 encryption if possible (with openssl fallback)

* Identify few more mechanisms (PSS) in the lest

* Resize table to fit new mechanisms

* Remove initial loop declaration from multipart test

* Use pkcs11-tool instead of p11tool form most of the operations (master have most of the features)

* Preparation for machine readable results

* Refactor log variables out of the main context, try to export generic data

* Do not write to non-existing FD if not logging

* Export missing data into the log file in JSON

* Store database in json

* Sanity check

* Avoid uninitialized structure fields using in state structure

* Dump always_authenticate attribute too

* Manual selection of slots with possibility to use slots without tokens

* Do not free before finalizing

* Proper cleanup of message in all cases

* Proper allocation and deallocation of messages

* Sanitize missing cases (memory leaks)

* Suppressions for testing under valgrind

* Better handling message_lengt during sign&verify (avoid invalid access)

* Suppress another PCSC error

* Do not use default PIN. Fail if none specified

* Sanitize initialization. Skip incomplete key pairs

* Add missing newline in errors

* Fix condition for certificate search

* Avoid several calls for attributes of zero length

* Handle if the private key is not present on the card

* Improve memory handling, silent GCC warning of 'unused' variable

* Fail early with missing private key, cleanup the messages

* Use correct padding for encryption

* Cache if the card supports Verify/Encrypt and avoid trying over and over again

* Loosen the condition for the Usage flags

* OpenSSL 1.1.0 compatibility

* Add missing mechanisms

* Do not require certificates on the card and pass valid data for RSA_PKCS mechanisms

* Add missing PIN argument in runtest.sh

* Add OpenSSL < 1.1 comatible bits

* Add SHA2 ECDSA mechanisms handling

* Use public key from PKCS#11 if the certificate is missing (or compare it with certificate)

* Avoid long definitions in OpenSSL compat layer

* In older OpenSSL, the header file is ecdsa.h

* Add missing config.h to apply compat OpenSSL layer

* ASN1_STRING_get0_data() is also new in 1.1.0

* Return back RSA_X_509 mechanism

* Drop bogus CKM_* in the definitions

* Drop CKM_SHA224_RSA_PKCS as it is already in pkcs11.h

* Update documentation

* Use NDEBUG as intended

* typos, cleanup

* Typos, cleanup, update copyright

* Additional check for OpenCryptoki, generate more key types on soft tokens

* Prepare for RSA-PSS and RSA-OAEP

* Use usage&result flags for the tests, gracefully ignore PSS&OAEP

* pkcs11.h: Add missing definitions for PSS

* PSS and OAEP tests

readonly: Typos, reformat

* Working version, memory leak

* Tweak message lengths for OAEP and PSS

* Skip tests that are not aplicable for tokens

* configure.ac: New switch --enable-tests

Do not attempt to build tests if cmocka is not available or
--enable-tests is provided. It makes also more lightweight release
builds out of the box (or with --disable-tests).

* travis: Install cmocka if not available

* Do not build tests on Windows and make dist pass

* Try to install cmocka from apt and from brew

* Do not require sudo (cmocka from apt and brew works)
2018-05-18 12:31:55 +02:00
Frank Morgner eb60481f89 Updated NEWS for 0.18.0 2018-05-16 13:48:37 +02:00
Frank Morgner 1798bbe692 manuals: added missing "Authors" section 2018-05-16 13:43:25 +02:00
Frank Morgner 99eed0aa82 pkcs15-init: documented remaining commandline switches
fixes https://github.com/OpenSC/OpenSC/issues/1267
2018-05-04 23:38:24 +02:00
Frank Morgner 318329d5b7 macOS: disable notifications only in PKCS#11 module
basically reverts
c35eb1c9bc
by applying a more selective fix for
https://github.com/OpenSC/OpenSC/issues/1174
2018-04-27 23:16:14 +02:00
Frank Morgner 2dad9a9fde gio: changed default symbols 2018-04-27 12:26:48 +02:00
Frank Morgner ac5852836d GIO: Check connection to DBus before notifying
avoids error messages when dbus is not available.
2018-04-27 12:26:48 +02:00
Frank Morgner 537a208c25 Use non unique flag for App ID
When loaded as PKCS#11 module, OpenSC will reuse the application
identifier for each instance. We don't want to put any burdon on the
primary GApplication, so we use a non unique ID.

fixes https://github.com/OpenSC/OpenSC/issues/1332
2018-04-27 12:26:48 +02:00
Frank Morgner 099270092a added documentation of some command line options 2018-04-27 09:23:34 +02:00
Frank Morgner 90a5b262d0 nPA: fixed matching for newer cards
they have other ATRs... match if EF.CardAccess is found
2018-04-26 21:55:54 +02:00
Frank Morgner 4e83e2e1b3 reader-pcsc: fixed default for disconnect_action
Initialize it to "leave", even if no pcsc configuration block was given.
2018-04-26 14:48:54 +02:00
Frank Morgner dd1a606d0d updated tools.xml for inclusion in wiki 2018-04-25 23:43:08 +02:00
Frank Morgner 58a824527b sc-hsm: fixed default labels for GoID 2018-04-25 23:27:55 +02:00
David Ward 841e13c9c1 macOS: Update description at top of MacOSX/build-package script
Explicitly mention that this script builds the tokend and command
line tools (as it does not build the CryptoTokenKit app extension).

Add two missing packages in the list of build dependencies.
2018-04-25 13:01:49 +02:00
David Ward bddef2485f macOS: Remove unused build code for the CryptoTokenKit app extension
OpenSCToken (https://github.com/frankmorgner/OpenSCToken) is now a
standalone package that provides the CryptoTokenKit app extension.
It includes its own 'build-package' script, which handles building
the OpenSC library and statically linking against it.

The 'MacOSX/' directory in OpenSC itself is only used to build the
macOS tokend. Remove unused code for building a CryptoTokenKit app
extension from this directory (which no longer works). This should
help to avoid confusion when building OpenSC for macOS.
2018-04-25 13:01:49 +02:00
David Ward fff4ca901d Provide more space for card holder name in CAC token label
The PKCS#15 emulation layer for the CAC uses a single PIN. Set its
label to "PIN" (rather than the card type "CAC I" or "CAC II"), so
that the PIN label will be omitted from the token label, providing
more space for the card holder name instead.

This is intended to match the behavior used for PIV cards, which
was changed with commit 56c8f59b25.
2018-04-24 14:35:11 +02:00
David Ward eb0f4e1850 Slightly adjust pull request template
During a pull request, it might not be possible for all components
(such as the PKCS#11 module, Windows minidriver, or macOS tokend)
to be tested by the same person using the same card; not everyone
has access to all of the platforms supported by OpenSC. When there
are no card-specific changes, each component might be tested by a
different person using a different type of card.

The pull request template contains a checklist with each component
that needs to be tested (which can be adapted as needed). However,
this checklist also includes an item for the type of card used for
testing. This should certainly be included in the message, but it
doesn't quite seem to belong in the checklist as a separate item,
particularly when considering the multiple-card testing situation
described above. It seems that the checklist is intended to track
specific tasks that still need to be completed.

This change slightly adjusts the template in order to handle this.
(It is still just a template, and it can be adapted for each pull
request as needed.)
2018-04-24 12:31:48 +02:00
Peter Marschall 504d267e76 openpgp: don't treat OpenPGP v3 cards special in src/libopensc/pkcs15-syn.c
As OpenPGP v3 cards are backward compatible with earlier versions,
fix an inconsitency in src/libopensc/pkcs15-syn.c
2018-04-22 21:32:17 +02:00
Frank Morgner 3bfede17d4 AppVeyor: let configure know that we're building with native tools 2018-04-20 15:09:06 +02:00
David Ward 2c167a9982 Address compiler warnings when using --disable-optimization (#1325)
* Handle errors as intended in sc_pkcs15emu_openpgp_add_data()

If a data object can be read, but it cannot be added to the PKCS#15
framework, return from this function with an error; do not continue
reading other data objects. Otherwise, do not return an error from
this function when a data object cannot be read or is empty.

Improve existing comments for clarity.

* Address other compiler warnings when using --disable-optimization

Certain variables that are not initialized when they are declared
prevent the build from completing, when --disable-optimization is
passed to ./configure.
2018-04-15 09:37:43 +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
473 changed files with 54887 additions and 18738 deletions

3
.clang-format Normal file
View File

@ -0,0 +1,3 @@
BasedOnStyle: Google
IndentWidth: 4

View File

@ -1,7 +1,9 @@
### Problem Description
<!--
Please read about [reporting bugs](https://github.com/OpenSC/OpenSC/wiki/How-to-report-bugs-so-that-they-can-be-fixed) before opening an issue.
Please read about reporting bugs on the wiki before opening an issue:
https://github.com/OpenSC/OpenSC/wiki/How-to-write-a-good-bug-report
-->
### Proposed Resolution
@ -21,7 +23,7 @@ Debug output is essential to identify the problem. You can enable debugging by e
#debug_file = opensc-debug.log
```
Please use [Gist](https://gist.github.com/) or a similar code paster for longer logs. Before pasting here, remove your sensitive data from your log (e.g. PIN code or certificates).
Please use a Gist (https://gist.github.com/) or a similar code paster for longer logs. Before pasting here, remove your sensitive data from your log (e.g. PIN code or certificates).
```
Paste Log output with less than 10 lines here (between the backticks)

View File

@ -1,14 +1,17 @@
<!--
Thank you for your pull request.
If this fixes a github issue, make sure to have a line saying 'Fixes #XXXX' (without quotes) in the commit message.
If this fixes a GitHub issue, make sure to have a line saying 'Fixes #XXXX'
(without quotes) in the commit message.
Mention which card(s) are used during testing. To get the name of your card,
run this command: `opensc-tool -n`
-->
##### Checklist
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->
- [ ] Documentation is added or updated
- [ ] New files have a LGPL 2.1 license statement
- [ ] Tested with the following card: <!-- use `opensc-tool -n` to get the name of your card -->
- [ ] tested PKCS#11
- [ ] tested Windows Minidriver
- [ ] tested macOS Tokend
- [ ] PKCS#11 module is tested
- [ ] Windows minidriver is tested
- [ ] macOS tokend is tested

37
.github/add_signing_key.sh vendored Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
set -ex -o xtrace
pushd .github/
tar xvf secrets.tar
KEY_CHAIN=mac-build.keychain
# Create the keychain with a password
security create-keychain -p travis $KEY_CHAIN
# Make the custom keychain default, so xcodebuild will use it for signing
security default-keychain -s $KEY_CHAIN
# Unlock the keychain for one hour
security unlock-keychain -p travis $KEY_CHAIN
security set-keychain-settings -t 3600 -u $KEY_CHAIN
# Add certificates to keychain and allow codesign to access them
curl -L https://developer.apple.com/certificationauthority/AppleWWDRCA.cer > AppleWWDRCA.cer
security import AppleWWDRCA.cer \
-k ~/Library/Keychains/$KEY_CHAIN \
-T /usr/bin/codesign -T /usr/bin/productsign
security import DeveloperIDApplication.cer \
-k ~/Library/Keychains/$KEY_CHAIN \
-T /usr/bin/codesign -T /usr/bin/productsign
security import DeveloperIDInstaller.cer \
-k ~/Library/Keychains/$KEY_CHAIN \
-T /usr/bin/codesign -T /usr/bin/productsign
security import key.p12 \
-k ~/Library/Keychains/$KEY_CHAIN -P $KEY_PASSWORD \
-T /usr/bin/codesign -T /usr/bin/productsign
security unlock-keychain -p travis $KEY_CHAIN
# https://docs.travis-ci.com/user/common-build-problems/#mac-macos-sierra-1012-code-signing-errors
security set-key-partition-list -S apple-tool:,apple: -s -k travis $KEY_CHAIN
popd

54
.github/build.sh vendored Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash -e
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig;
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
if [ "$GITHUB_BASE_REF" == "master" ]; then
./bootstrap.ci -s "-pr$PR_NUMBER"
else
./bootstrap.ci -s "$GITHUB_BASE_REF-pr$PR_NUMBER"
fi
else
BRANCH=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
if [ "$BRANCH" == "master" ]; then
./bootstrap
else
./bootstrap.ci -s "$BRANCH"
fi
fi
if [ "$RUNNER_OS" == "macOS" ]; then
./MacOSX/build
exit $?
fi
if [ "$1" == "mingw" -o "$1" == "mingw32" ]; then
if [ "$1" == "mingw" ]; then
HOST=x86_64-w64-mingw32
elif [ "$1" == "mingw32" ]; then
HOST=i686-w64-mingw32
fi
unset CC
unset CXX
./configure --host=$HOST --with-completiondir=/tmp --disable-openssl --disable-readline --disable-zlib --disable-notify --prefix=$PWD/win32/opensc || cat config.log;
make -j 2
# no point in running tests on mingw
else
# normal procedure
./configure --disable-dependency-tracking
make -j 2
make check
fi
# this is broken in old ubuntu
if [ "$1" == "dist" ]; then
make distcheck
make dist
fi
sudo make install
if [ "$1" == "mingw" -o "$1" == "mingw32" ]; then
# pack installed files
wine "C:/Program Files/Inno Setup 5/ISCC.exe" win32/OpenSC.iss
fi

36
.github/push_artifacts.sh vendored Executable file
View File

@ -0,0 +1,36 @@
#!/bin/bash
set -ex -o xtrace
BUILDPATH=${PWD}
BRANCH="`git log --max-count=1 --date=short --abbrev=8 --pretty=format:"%cd_%h"`"
git clone --single-branch https://${GH_TOKEN}@github.com/OpenSC/Nightly.git > /dev/null 2>&1
pushd Nightly
git checkout -b "${BRANCH}"
for file in ${BUILDPATH}/win32/Output/OpenSC*.exe ${BUILDPATH}/opensc*.tar.gz ${BUILDPATH}/OpenSC*.dmg ${BUILDPATH}/OpenSC*.msi ${BUILDPATH}/OpenSC*.zip
do
if [ -f ${file} ]
then
# github only allows a maximum file size of 50MB
MAX_MB_FILESIZE=50
if [ $(du -m "$file" | cut -f 1) -ge $MAX_MB_FILESIZE ]
then
split -b ${MAX_MB_FILESIZE}m ${file} `basename ${file}`.
else
cp ${file} .
fi
git add `basename ${file}`*
fi
done
git commit --message "$1"
i=0
while [ $i -le 10 ] && ! git push --quiet --set-upstream origin "${BRANCH}"
do
sleep $[ ( $RANDOM % 32 ) + 1 ]s
git pull --rebase origin --strategy-option ours "${BRANCH}"
i=$(( $i + 1 ))
done
popd

8
.github/remove_signing_key.sh vendored Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
set -ex -o xtrace
pushd .github/
security delete-keychain mac-build.keychain
rm -f DeveloperIDApplication.cer DeveloperIDInstaller.cer key.p12
popd

BIN
.github/secrets.tar.enc vendored Normal file

Binary file not shown.

24
.github/setup-java.sh vendored Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash -e
# Select the right java
sudo update-java-alternatives -s java-1.8.0-openjdk-amd64
sudo update-alternatives --get-selections | grep ^java
export PATH="/usr/lib/jvm/java-8-openjdk-amd64/bin/:$PATH"
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
env | grep -i openjdk
# VSmartcard
./.github/setup-vsmartcard.sh
# Javacard SDKs
git clone https://github.com/martinpaljak/oracle_javacard_sdks.git
export JC_HOME=$PWD/oracle_javacard_sdks/jc222_kit
export JC_CLASSIC_HOME=$PWD/oracle_javacard_sdks/jc305u3_kit
# jCardSim
git clone https://github.com/arekinath/jcardsim.git
pushd jcardsim
env | grep -i openjdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
mvn initialize && mvn clean install
popd

42
.github/setup-linux.sh vendored Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash -e
DEPS="docbook-xsl libpcsclite-dev xsltproc gengetopt libcmocka-dev help2man pcscd check softhsm2 pcsc-tools libtool make autoconf autoconf-archive automake libssl-dev zlib1g-dev pkg-config libreadline-dev openssl git"
if [ "$1" == "clang-tidy" ]; then
DEPS="$DEPS clang-tidy"
elif [ "$1" == "cac" ]; then
DEPS="$DEPS libglib2.0-dev libnss3-dev gnutls-bin libusb-dev libudev-dev flex libnss3-tools"
elif [ "$1" == "oseid" ]; then
DEPS="$DEPS socat gawk xxd"
elif [ "$1" == "piv" -o "$1" == "isoapplet" -o "$1" == "gidsapplet" -o "$1" == "openpgp" ]; then
if [ "$1" == "piv" ]; then
DEPS="$DEPS cmake"
fi
DEPS="$DEPS ant openjdk-8-jdk"
elif [ "$1" == "mingw" -o "$1" == "mingw32" ]; then
DEPS="$DEPS wine wine32 xvfb wget"
sudo dpkg --add-architecture i386
if [ "$1" == "mingw" ]; then
DEPS="$DEPS binutils-mingw-w64-x86-64 gcc-mingw-w64-x86-64 mingw-w64"
elif [ "$1" == "mingw32" ]; then
DEPS="$DEPS binutils-mingw-w64-i686 gcc-mingw-w64-i686"
fi
fi
# make sure we do not get prompts
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y build-essential $DEPS
if [ "$1" == "mingw" -o "$1" == "mingw32" ]; then
if [ ! -f "$(winepath 'C:/Program Files/Inno Setup 5/ISCC.exe')" ]; then
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16
export DISPLAY=:99.0
[ -d isetup ] || mkdir isetup
pushd isetup
[ -f isetup-5.5.6.exe ] || wget http://files.jrsoftware.org/is/5/isetup-5.5.6.exe
sleep 5 # make sure the X server is ready ?
wine isetup-5.5.6.exe /SILENT /VERYSILENT /SP- /SUPPRESSMSGBOXES /NORESTART
popd
fi
fi

32
.github/setup-macos.sh vendored Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
brew install automake
# gengetopt
curl https://ftp.gnu.org/gnu/gengetopt/gengetopt-2.23.tar.xz -L --output gengetopt-2.23.tar.xz
tar xfj gengetopt-2.23.tar.xz
pushd gengetopt-2.23
./configure && make
sudo make install
popd
# help2man
curl https://ftp.gnu.org/gnu/help2man/help2man-1.47.16.tar.xz -L --output help2man-1.47.16.tar.xz
tar xjf help2man-1.47.16.tar.xz
pushd help2man-1.47.16
./configure && make
sudo make install
popd
# openSCToken
export PATH="/usr/local/opt/ccache/libexec:$PATH"
git clone https://github.com/frankmorgner/OpenSCToken.git
sudo rm -rf /Library/Developer/CommandLineTools;
# TODO make the encrypted key working in github
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$encrypted_3b9f0b9d36d1_key" ]; then
openssl aes-256-cbc -K $encrypted_3b9f0b9d36d1_key -iv $encrypted_3b9f0b9d36d1_iv -in .github/secrets.tar.enc -out .github/secrets.tar -d;
.github/add_signing_key.sh;
else
unset CODE_SIGN_IDENTITY INSTALLER_SIGN_IDENTITY;
fi

8
.github/setup-vsmartcard.sh vendored Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
if [ ! -d "vsmartcard" ]; then
git clone https://github.com/frankmorgner/vsmartcard.git
fi
pushd vsmartcard/virtualsmartcard
autoreconf -vis && ./configure && make -j2 && sudo make install
popd

47
.github/test-cac.sh vendored Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash -e
# install the opensc
sudo make install
export LD_LIBRARY_PATH=/usr/local/lib
# VSmartcard
./.github/setup-vsmartcard.sh
# libcacard
if [ ! -d "libcacard" ]; then
git clone https://gitlab.freedesktop.org/spice/libcacard.git
fi
pushd libcacard
./autogen.sh --prefix=/usr && make -j2 && sudo make install
popd
# virt_cacard
if [ ! -d "virt_cacard" ]; then
git clone https://github.com/Jakuje/virt_cacard.git
fi
pushd virt_cacard
./autogen.sh && ./configure && make
popd
sudo /etc/init.d/pcscd restart
pushd src/tests/p11test/
./p11test -s 0 -p 12345678 -i -o virt_cacard.json &
sleep 5
popd
# virt_cacard startup
pushd virt_cacard
./setup-softhsm2.sh
export SOFTHSM2_CONF=$PWD/softhsm2.conf
./virt_cacard &
wait $(ps aux | grep '[p]11test'| awk '{print $2}')
kill -9 $(ps aux | grep '[v]irt_cacard'| awk '{print $2}')
popd
# cleanup -- this would break later uses of pcscd
pushd vsmartcard/virtualsmartcard
sudo make uninstall
popd
diff -u3 src/tests/p11test/virt_cacard{_ref,}.json

36
.github/test-gidsapplet.sh vendored Executable file
View File

@ -0,0 +1,36 @@
#!/bin/bash -e
# install the opensc
sudo make install
export LD_LIBRARY_PATH=/usr/local/lib
# setup java stuff
. .github/setup-java.sh
# GidsApplet
git clone https://github.com/vletoux/GidsApplet.git;
javac -classpath jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar GidsApplet/src/com/mysmartlogon/gidsApplet/*.java;
echo "com.licel.jcardsim.card.applet.0.AID=A000000397425446590201" > gids_jcardsim.cfg;
echo "com.licel.jcardsim.card.applet.0.Class=com.mysmartlogon.gidsApplet.GidsApplet" >> gids_jcardsim.cfg;
echo "com.licel.jcardsim.card.ATR=3B80800101" >> gids_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.host=localhost" >> gids_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.port=35963" >> gids_jcardsim.cfg;
# log errors from pcscd to console
sudo systemctl stop pcscd.service pcscd.socket
sudo /usr/sbin/pcscd -f &
PCSCD_PID=$!
# start the applet and run couple of commands against that
java -noverify -cp GidsApplet/src/:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard gids_jcardsim.cfg >/dev/null &
PID=$!;
sleep 5;
opensc-tool --card-driver default --send-apdu 80b80000190bA0000003974254465902010bA00000039742544659020100;
opensc-tool -n;
gids-tool --initialize --pin 123456 --admin-key 000000000000000000000000000000000000000000000000 --serial 00000000000000000000000000000000;
kill -9 $PID
# cleanup
sudo kill -9 $PCSCD_PID

41
.github/test-isoapplet.sh vendored Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash -e
# install the opensc
sudo make install
export LD_LIBRARY_PATH=/usr/local/lib
# setup java stuff
./.github/setup-java.sh
# The ISO applet
git clone https://github.com/philipWendland/IsoApplet.git;
javac -classpath jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar IsoApplet/src/net/pwendland/javacard/pki/isoapplet/*.java;
echo "com.licel.jcardsim.card.applet.0.AID=F276A288BCFBA69D34F31001" > isoapplet_jcardsim.cfg;
echo "com.licel.jcardsim.card.applet.0.Class=net.pwendland.javacard.pki.isoapplet.IsoApplet" >> isoapplet_jcardsim.cfg;
echo "com.licel.jcardsim.card.ATR=3B80800101" >> isoapplet_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.host=localhost" >> isoapplet_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.port=35963" >> isoapplet_jcardsim.cfg;
# log errors from pcscd to console
sudo systemctl stop pcscd.service pcscd.socket
sudo /usr/sbin/pcscd -f &
PCSCD_PID=$!
# start the applet and run couple of commands against that
java -noverify -cp IsoApplet/src/:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard isoapplet_jcardsim.cfg >/dev/null &
PID=$!;
sleep 5;
opensc-tool --card-driver default --send-apdu 80b800001a0cf276a288bcfba69d34f310010cf276a288bcfba69d34f3100100;
opensc-tool -n;
pkcs15-init --create-pkcs15 --so-pin 123456 --so-puk 0123456789abcdef;
pkcs15-tool --change-pin --pin 123456 --new-pin 654321;
pkcs15-tool --unblock-pin --puk 0123456789abcdef --new-pin 123456;
pkcs15-init --generate-key rsa/2048 --id 1 --key-usage decrypt,sign --auth-id FF --pin 123456;
pkcs15-init --generate-key rsa/2048 --id 2 --key-usage decrypt --auth-id FF --pin 123456;
pkcs15-init --generate-key ec/secp256r1 --id 3 --key-usage sign --auth-id FF --pin 123456;
pkcs15-tool -D;
pkcs11-tool -l -t -p 123456;
kill -9 $PID;
# cleanup
sudo kill -9 $PCSCD_PID

40
.github/test-openpgp.sh vendored Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash -e
# install the opensc
sudo make install
export LD_LIBRARY_PATH=/usr/local/lib
# setup java stuff
. .github/setup-java.sh
# The OpenPGP applet
git clone --recursive https://github.com/Yubico/ykneo-openpgp.git;
cd ykneo-openpgp;
ant -DJAVACARD_HOME=${JC_HOME};
cd $TRAVIS_BUILD_DIR;
echo "com.licel.jcardsim.card.applet.0.AID=D2760001240102000000000000010000" > openpgp_jcardsim.cfg;
echo "com.licel.jcardsim.card.applet.0.Class=openpgpcard.OpenPGPApplet" >> openpgp_jcardsim.cfg;
echo "com.licel.jcardsim.card.ATR=3B80800101" >> openpgp_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.host=localhost" >> openpgp_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.port=35963" >> openpgp_jcardsim.cfg;
# log errors from pcscd to console
sudo systemctl stop pcscd.service pcscd.socket
sudo /usr/sbin/pcscd -f &
PCSCD_PID=$!
# start the applet and run couple of commands against that
java -noverify -cp ykneo-openpgp/applet/bin:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard openpgp_jcardsim.cfg >/dev/null &
PID=$!;
sleep 5;
opensc-tool --card-driver default --send-apdu 80b800002210D276000124010200000000000001000010D276000124010200000000000001000000;
opensc-tool -n;
openpgp-tool --verify CHV3 --pin 12345678 --gen-key 2;
pkcs15-init --verify --auth-id 3 --pin 12345678 --delete-objects privkey,pubkey --id 2 --generate-key rsa/2048;
pkcs11-tool -l -t -p 123456;
kill -9 $PID
# cleanup
sudo kill -9 $PCSCD_PID

54
.github/test-oseid.sh vendored Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash -e
# install the opensc
sudo make install
export LD_LIBRARY_PATH=/usr/local/lib
if [ ! -d oseid ]; then
git clone https://github.com/popovec/oseid
fi
pushd oseid/src/
make -f Makefile.console
if [ ! -d tmp ]; then
mkdir tmp
fi
socat -d -d pty,link=tmp/OsEIDsim.socket,raw,echo=0 "exec:build/console/console ...,pty,raw,echo=0" &
PID=$!
sleep 1
echo "# OsEIDsim" > tmp/reader.conf
echo 'FRIENDLYNAME "OsEIDsim"' >> tmp/reader.conf
echo "DEVICENAME $PWD/tmp/OsEIDsim.socket" >> tmp/reader.conf
echo "LIBPATH $PWD/build/console/libOsEIDsim.so.0.0.1" >> tmp/reader.conf
echo "CHANNELID 1" >> tmp/reader.conf
sudo mv tmp/reader.conf /etc/reader.conf.d/reader.conf
cat /etc/reader.conf.d/reader.conf
popd
sudo /etc/init.d/pcscd restart
# Needed for tput to not report warnings
export TERM=xterm-256color
pushd oseid/tools
echo | ./OsEID-tool INIT
./OsEID-tool RSA-CREATE-KEYS
./OsEID-tool RSA-UPLOAD-KEYS
./OsEID-tool RSA-DECRYPT-TEST
./OsEID-tool RSA-SIGN-PKCS11-TEST
./OsEID-tool EC-CREATE-KEYS
./OsEID-tool EC-UPLOAD-KEYS
./OsEID-tool EC-SIGN-TEST
./OsEID-tool EC-SIGN-PKCS11-TEST
./OsEID-tool EC-ECDH-TEST
popd
# this does not work as we have random key IDs in here
#pushd src/tests/p11test/
#./p11test -s 0 -p 11111111 -o oseid.json || true
#diff -u3 oseid_ref.json oseid.json
#popd
# cleanup -- this would break later uses of pcscd
kill -9 $PID
rm oseid/src/card_mem
sudo rm /etc/reader.conf.d/reader.conf

45
.github/test-piv.sh vendored Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash -e
# install the opensc
sudo make install
export LD_LIBRARY_PATH=/usr/local/lib
# setup java stuff
. .github/setup-java.sh
# The PIV Applet
git clone --recursive https://github.com/arekinath/PivApplet.git
pushd PivApplet
JC_HOME=${JC_CLASSIC_HOME} ant dist
popd
# yubico-piv-tool is needed for PIV Applet management
git clone https://github.com/Yubico/yubico-piv-tool.git
pushd yubico-piv-tool
mkdir build
pushd build
cmake .. && make && sudo make install
popd
popd
# log errors from pcscd to console
sudo systemctl stop pcscd.service pcscd.socket
sudo /usr/sbin/pcscd -f &
PCSCD_PID=$!
# start the applet and run couple of commands against that
java -noverify -cp PivApplet/bin/:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard PivApplet/test/jcardsim.cfg >/dev/null &
PID=$!
sleep 5
opensc-tool --card-driver default --send-apdu 80b80000120ba000000308000010000100050000020F0F7f
opensc-tool -n
yubico-piv-tool -v 9999 -r 'Virtual PCD 00 00' -P 123456 -s 9e -a generate -A RSA2048
yubico-piv-tool -v 9999 -r 'Virtual PCD 00 00' -P 123456 -s 9a -a generate -A ECCP256
pkcs11-tool -l -t -p 123456
kill -9 $PID
# cleanup
sudo kill -9 $PCSCD_PID

28
.github/workflows/cifuzz.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: CIFuzz
on:
pull_request:
paths:
- '**.c'
- '**.h'
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'opensc'
dry-run: false
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'opensc'
fuzz-seconds: 600
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v1
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts

176
.github/workflows/linux.yml vendored Normal file
View File

@ -0,0 +1,176 @@
name: Linux
on:
pull_request:
paths:
- '**.c'
- '**.h'
push:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: .github/setup-linux.sh
- run: .github/build.sh dist
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: opensc-build
path:
opensc*.tar.gz
build-ubuntu-18:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- run: .github/setup-linux.sh
- run: .github/build.sh
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
key: ${{ runner.os }}-18-${{ github.sha }}
build-mingw:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: .github/setup-linux.sh mingw
- run: .github/build.sh mingw
- name: Cache build artifacts
uses: actions/upload-artifact@v2
with:
name: opensc-build-mingw
path:
win32/Output/OpenSC*.exe
build-mingw32:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: .github/setup-linux.sh mingw32
- run: .github/build.sh mingw32
- name: Cache build artifacts
uses: actions/upload-artifact@v2
with:
name: opensc-build-mingw32
path:
win32/Output/OpenSC*.exe
test-piv:
runs-on: ubuntu-18.04
needs: [build-ubuntu-18]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
key: ${{ runner.os }}-18-${{ github.sha }}
- run: .github/setup-linux.sh piv
- run: .github/test-piv.sh
test-isoapplet:
runs-on: ubuntu-18.04
needs: [build-ubuntu-18]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
key: ${{ runner.os }}-18-${{ github.sha }}
- run: .github/setup-linux.sh isoapplet
- run: .github/test-isoapplet.sh
test-gidsapplet:
runs-on: ubuntu-18.04
needs: [build-ubuntu-18]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
key: ${{ runner.os }}-18-${{ github.sha }}
- run: .github/setup-linux.sh gidsapplet
- run: .github/test-gidsapplet.sh
test-openpgp:
runs-on: ubuntu-18.04
needs: [build-ubuntu-18]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
key: ${{ runner.os }}-18-${{ github.sha }}
- run: .github/setup-linux.sh openpgp
# the openpgp sometimes fails
- run: .github/test-openpgp.sh || true
build-clang-tidy:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}
- run: .github/setup-linux.sh clang-tidy
- run: .github/build.sh
test-cac:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}
- run: .github/setup-linux.sh cac
- run: .github/test-cac.sh
test-oseid:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}
- run: .github/setup-linux.sh oseid
- run: .github/test-oseid.sh
push-artifacts:
runs-on: ubuntu-latest
needs: [build, build-mingw]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
key: ${{ runner.os }}-${{ github.sha }}
- name: Pull mingw build artifacts
uses: actions/download-artifact@v2
with:
name: opensc-build-mingw
- run: git config --global user.email "builds@github.com"
- run: git config --global user.name "Github Actions";
- run: .github/push_artifacts.sh "Github Actions ${GITHUB_REF}"
if: ${{ github.event_name != 'pull_request' && github.repository == 'OpenSC/OpenSC' }}

39
.github/workflows/macos.yml vendored Normal file
View File

@ -0,0 +1,39 @@
name: OSX
on:
pull_request:
paths:
- '**.c'
- '**.h'
push:
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- run: .github/setup-macos.sh
- run: .github/build.sh
- name: Cache build artifacts
uses: actions/upload-artifact@v2
with:
name: opensc-build-macos
path:
OpenSC*.dmg
push-artifacts:
runs-on: macos-latest
needs: [build]
steps:
- uses: actions/checkout@v2
- name: Pull build artifacts
uses: actions/download-artifact@v2
with:
name: opensc-build-macos
- run: git config --global user.email "builds@github.com"
- run: git config --global user.name "Github Actions";
- run: .github/push_artifacts.sh "Github Actions ${GITHUB_REF}"
if: ${{ github.event_name != 'pull_request' && github.repository == 'OpenSC/OpenSC' }}
# TODO this fails probably because the key is not loaded in keychain before with
# security: SecKeychainDelete: The specified keychain could not be found.
# - run: .github/remove_signing_key.sh; rm -f .github/secrets.tar

58
.gitignore vendored
View File

@ -4,6 +4,7 @@ core
archive
acinclude.m4
aclocal.m4
aminclude_static.am
autom4te.cache
compile
confdefs.h
@ -22,6 +23,7 @@ mkinstalldirs
so_locations
stamp-h*
tags
test-driver
.deps
.libs
.#*#
@ -49,7 +51,6 @@ tags
*.gz
*.bz2
*.[0-9]
*.html
*.gif
*.css
*.out
@ -57,51 +58,37 @@ tags
*.obj
*.exp
*.res
*.ggo
ChangeLog
doc/tools/cardos-tool
doc/tools/cryptoflex-tool
doc/tools/*-tool
doc/tools/eidenv
doc/tools/iasecc-tool
doc/tools/netkey-tool
doc/tools/openpgp-tool
doc/tools/opensc-explorer
doc/tools/opensc-tool
doc/tools/gids-tool
doc/tools/piv-tool
doc/tools/pkcs11-tool
doc/tools/pkcs11-register
doc/tools/pkcs15-crypt
doc/tools/pkcs15-init
doc/tools/pkcs15-tool
doc/tools/sc-hsm-tool
doc/tools/westcos-tool
doc/tools/dnie-tool
doc/tools/opensc-asn1
doc/tools/opensc-notify
doc/files/opensc.conf.5.xml
etc/opensc.conf.win
etc/opensc.conf
etc/opensc.conf.example
src/common/compat_getopt_main
src/minidriver/opensc-minidriver.inf
src/tools/cardos-tool
src/tools/iasecc-tool
src/tools/openpgp-tool
src/tools/sc-hsm-tool
src/tools/westcos-tool
src/tools/pkcs15-tool
src/tools/*-tool
src/tools/pkcs15-crypt
src/tools/pkcs15-init
src/tools/piv-tool
src/tools/eidenv
src/tools/opensc-explorer
src/tools/opensc-tool
src/tools/gids-tool
src/tools/rutoken-tool
src/tools/cardos-info
src/tools/cryptoflex-tool
src/tools/netkey-tool
src/tools/pkcs11-tool
src/tools/dnie-tool
src/tools/npa-tool
src/tools/gcns
src/tools/sceac-example
src/tools/opensc-notify
src/tools/opensc-notify.plist
src/tools/org.opensc.notify.desktop
src/tools/pkcs11-register
src/tools/pkcs11-register.plist
src/tools/pkcs11-register.desktop
src/tools/opensc-asn1
win32/OpenSC.iss
win32/OpenSC.wxs
@ -128,5 +115,14 @@ src/tests/lottery
src/tests/p15dump
src/tests/pintest
src/tests/prngtest
src/tests/p11test/p11test
tests/*.log
tests/*.trs
src/tests/unittests/*.log
src/tests/unittests/*.trs
src/tests/unittests/asn1
src/tests/unittests/compression
src/tests/unittests/simpletlv
version.m4.ci

126
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,126 @@
before_script:
# Avoid picking up PIV endpoint in CAC cards
- sed -e "/PIV-II/d" -i src/libopensc/ctx.c
# enable debug messages in the testsuite
- sed -e "s/^p11test_CFLAGS/#p11test_CFLAGS/g" -i src/tests/p11test/Makefile.am
- ./bootstrap
- ./configure
- make -j4
- make check
- make install
- ldconfig /usr/local/lib
- git clone https://github.com/PL4typus/virt_cacard.git
- cd virt_cacard && export CACARD_DIR=$PWD && ./autogen.sh && ./configure && make
variables:
SOFTHSM2_CONF: softhsm2.conf
CNTNR_REGISTRY: pl4typus/opensc-images
FEDORA29_BUILD: fedora-29
FEDORA30_BUILD: fedora-30
UBUNTU_BUILD: ubuntu-18.04
DEBIAN_BUILD: debian-testing
.job_base: &base_job
artifacts:
expire_in: '1 week'
when: on_failure
paths:
- src/tests/p11test/*.log
.job_template: &functional_test
<<: *base_job
artifacts:
expire_in: '1 week'
when: on_failure
paths:
- src/tests/p11test/*.log
- src/tests/p11test/*.json
- tests/test-suite.log
cache:
paths:
- src/tests/p11test/*.json
.virt_cacard: &virt_cacard
only:
- virt_cacard
script:
- ./setup-softhsm2.sh
- cd ../src/tests/p11test/
- pcscd -x
- ./p11test -s 0 -p 12345678 -o cac.json -i | tee cac.log &
- sleep 5
- cd $CACARD_DIR
- ./virt_cacard &
- cd ../src/tests/p11test/
- wait $(ps aux | grep '[p]11test'| awk '{print $2}')
- kill -9 $(ps aux | grep '[v]irt_cacard'| awk '{print $2}')
- if [[ -f cac_old.json ]]; then diff -u3 cac_old.json cac.json; fi
- cp cac.json cac_old.json
# cache the results for the next run
tags:
- shared
.virt_cacard_valgrind: &virt_cacard_valgrind
only:
- virt_cacard
script:
- ./setup-softhsm2.sh
- cd ../src/tests/p11test/
# remove the dlcose() calls to have reasonable traces
- sed '/if(pkcs11_so)/I {N;d;}' -i p11test_loader.c
- make
- pcscd -x
- valgrind --leak-check=full --trace-children=yes --suppressions=p11test.supp ./p11test -s 0 -p 12345678 -i 2>&1| tee cac.log &
- sleep 5
- cd $CACARD_DIR
- ./virt_cacard &
- wait $(ps aux | grep '[v]algrind'| awk '{print $2}')
- kill -9 $(ps aux | grep '[v]irt_cacard'| awk '{print $2}')
- cd ../src/tests/p11test/
- grep "definitely lost:.*0 bytes in 0 blocks" cac.log
tags:
- shared
################################
## Virtual CACard ##
################################
Fedora29 Build and Test virt_cacard:
<<: *functional_test
image: $CI_REGISTRY/$CNTNR_REGISTRY/$FEDORA29_BUILD:latest
<<: *virt_cacard
Fedora30 Build and Test virt_cacard:
<<: *functional_test
image: $CI_REGISTRY/$CNTNR_REGISTRY/$FEDORA30_BUILD:latest
<<: *virt_cacard
Ubuntu18.04 Build and Test virt_cacard:
<<: *functional_test
image: $CI_REGISTRY/$CNTNR_REGISTRY/$UBUNTU_BUILD:latest
<<: *virt_cacard
Debian-testing Build and Test virt_cacard:
<<: *functional_test
image: $CI_REGISTRY/$CNTNR_REGISTRY/$DEBIAN_BUILD:latest
<<: *virt_cacard
Fedora29 Build and Test virt_cacard with valgrind:
<<: *base_job
image: $CI_REGISTRY/$CNTNR_REGISTRY/$FEDORA29_BUILD:latest
<<: *virt_cacard_valgrind
Fedora30 Build and Test virt_cacard with valgrind:
<<: *base_job
image: $CI_REGISTRY/$CNTNR_REGISTRY/$FEDORA30_BUILD:latest
<<: *virt_cacard_valgrind
Ubuntu18.04 Build and Test virt_cacard with valgrind:
<<: *base_job
image: $CI_REGISTRY/$CNTNR_REGISTRY/$UBUNTU_BUILD:latest
<<: *virt_cacard_valgrind
Debian-testing Build and Test virt_cacard with valgrind:
<<: *base_job
image: $CI_REGISTRY/$CNTNR_REGISTRY/$DEBIAN_BUILD:latest
<<: *virt_cacard_valgrind

View File

@ -1,95 +1,363 @@
language: c
sudo: false
addons:
apt_packages:
- binutils-mingw-w64-i686
- binutils-mingw-w64-x86-64
- docbook-xsl
- gcc-mingw-w64-i686
- gcc-mingw-w64-x86-64
- libpcsclite-dev
- mingw-w64
- wine
- xsltproc
- gengetopt
- help2man
matrix:
include:
- compiler: clang
os: osx
osx_image: xcode9.4
env: DO_PUSH_ARTIFACT=yes
- compiler: clang
os: osx
osx_image: xcode12.2
env: DO_PUSH_ARTIFACT=yes
- compiler: clang
os: linux
dist: focal
- compiler: gcc
os: linux
dist: bionic
env:
- DO_SIMULATION=javacard
- ENABLE_DOC=--enable-doc
- compiler: gcc
os: linux
dist: focal
env:
- DO_SIMULATION=oseid
- env:
- HOST=x86_64-w64-mingw32
- DO_PUSH_ARTIFACT=yes
- env:
- HOST=i686-w64-mingw32
- DO_PUSH_ARTIFACT=yes
- env: DO_COVERITY_SCAN=yes
- compiler: gcc
os: linux
dist: bionic
env:
- DO_SIMULATION=cac
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
# The next declaration are encrypted environment variables, created via the
# "travis encrypt" command using the project repo's public key
# COVERITY_SCAN_TOKEN
- secure: "UkHn7wy4im8V1nebCWbAetnDSOLRUbOlF6++ovk/7Bnso1/lnhXHelyzgRxfD/oI68wm9nnRV+RQEZ9+72Ug1CyvHxyyxxkwal/tPeHH4B/L+aGdPi0id+5OZSKIm77VP3m5s102sJMJgH7DFd03+nUd0K26p0tk8ad4j1geV4c="
# GH_TOKEN
- secure: "cUAvpN/XUPMIN5cgWAbIOhghRoLXyw7SCydzGaJ1Ucqb9Ml2v5iuLLuN57YbZHTiWw03vy6rYVzzwMDrHX8r3oUALsv7ViJHG4PzIe7fAFZsZpHECmGsp6SEnue7m7BNy3FT8KYbiXxnxDO0SxmFXlrPAYR0WMZCWx2TENYcafs="
- COVERITY_SCAN_BRANCH_PATTERN="(master|coverity.*)"
- COVERITY_SCAN_NOTIFICATION_EMAIL="viktor.tarasov@gmail.com"
- COVERITY_SCAN_BUILD_COMMAND="make -j 4"
- COVERITY_SCAN_PROJECT_NAME="$TRAVIS_REPO_SLUG"
- SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
matrix:
fast_finish: true
include:
- compiler: clang
os: osx
- compiler: gcc
os: osx
- compiler: clang
os: linux
env: ENABLE_DOC=--enable-doc
- compiler: gcc
os: linux
env: ENABLE_DOC=--enable-doc
- os: linux
env: HOST=x86_64-w64-mingw32
- os: linux
env: HOST=i686-w64-mingw32
- os: linux
env: DO_COVERITY_SCAN=yes
# Commented out because of a bug in travis images for Focal:
# https://travis-ci.community/t/clang-10-was-recently-broken-on-linux-unmet-dependencies-for-clang-10-clang-tidy-10-valgrind/11527
#addons:
# apt_packages:
# - binutils-mingw-w64-i686
# - binutils-mingw-w64-x86-64
# - docbook-xsl
# - gcc-mingw-w64-i686
# - gcc-mingw-w64-x86-64
# - libpcsclite-dev
# - mingw-w64
# - xsltproc
# - gengetopt
# - libcmocka-dev
# - help2man
# - pcscd
# - pcsc-tools
# - check
# - ant
# - socat
# - cmake
# - clang-tidy
# - softhsm2
before_install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
brew update;
brew uninstall libtool;
brew install libtool;
brew install gengetopt help2man;
# homebrew is dead slow in older images due to the many updates it would need to download and build.
# here, we build the additional dependencies manually to get around this
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
curl https://ftp.gnu.org/gnu/gengetopt/gengetopt-2.23.tar.xz -L --output gengetopt-2.23.tar.xz;
tar xfj gengetopt-2.23.tar.xz;
pushd gengetopt-2.23;
./configure && make;
sudo make install;
popd;
curl https://ftp.gnu.org/gnu/help2man/help2man-1.47.16.tar.xz -L --output help2man-1.47.16.tar.xz;
tar xjf help2man-1.47.16.tar.xz;
pushd help2man-1.47.16;
./configure && make;
sudo make install;
popd;
export PATH="/usr/local/opt/ccache/libexec:$PATH";
git clone https://github.com/frankmorgner/OpenSCToken.git;
sudo rm -rf /Library/Developer/CommandLineTools;
fi
- if [ "$TRAVIS_OS_NAME" = "osx" -a "$TRAVIS_PULL_REQUEST" = "false" -a -n "$encrypted_3b9f0b9d36d1_key" ]; then
openssl aes-256-cbc -K $encrypted_3b9f0b9d36d1_key -iv $encrypted_3b9f0b9d36d1_iv -in .github/secrets.tar.enc -out .github/secrets.tar -d;
.github/add_signing_key.sh;
else
unset CODE_SIGN_IDENTITY INSTALLER_SIGN_IDENTITY;
fi
- if [ "${DO_SIMULATION}" = "javacard" ]; then
sudo apt-get install -y openjdk-8-jdk;
sudo update-java-alternatives -s java-1.8.0-openjdk-amd64;
sudo update-alternatives --get-selections | grep ^java;
export PATH="/usr/lib/jvm/java-8-openjdk-amd64/bin/:$PATH";
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/;
env | grep -i openjdk;
fi
- if [ "${DO_SIMULATION}" = "cac" ]; then
sudo apt-get install -y libglib2.0-dev libnss3-dev pkgconf libtool make autoconf autoconf-archive automake libsofthsm2-dev softhsm2 softhsm2-common help2man gnutls-bin libcmocka-dev libusb-dev libudev-dev flex libnss3-tools libssl-dev libpcsclite1;
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig;
fi
- if [ -n "${HOST}" ]; then
sudo apt-get install -y wine;
fi
- if [ "$TRAVIS_DIST" == "focal" ]; then
sudo apt-get install -yq --allow-downgrades libc6=2.31-0ubuntu9.2 libc6-dev=2.31-0ubuntu9.2;
fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo -E apt-get -yq --no-install-suggests --no-install-recommends --allow-downgrades --allow-remove-essential --allow-change-held-packages install binutils-mingw-w64-i686 binutils-mingw-w64-x86-64 docbook-xsl gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 libpcsclite-dev mingw-w64 xsltproc gengetopt libcmocka-dev help2man pcscd pcsc-tools check ant socat cmake clang-tidy softhsm2;
fi
before_script:
- ./bootstrap
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
./bootstrap;
fi
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" != "false" ]; then
./bootstrap.ci -s "-pr$TRAVIS_PULL_REQUEST";
fi
- if [ "$TRAVIS_BRANCH" != "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
./bootstrap.ci -s "-$TRAVIS_BRANCH";
fi
- if [ "$TRAVIS_BRANCH" != "master" -a "$TRAVIS_PULL_REQUEST" != "false" ]; then
./bootstrap.ci -s "-$TRAVIS_BRANCH-pr$TRAVIS_PULL_REQUEST";
fi
- if [ -z "$HOST" ]; then
CFLAGS="-Werror" ./configure $ENABLE_DOC --enable-dnie-ui;
else
if [ ! -f "$(winepath 'C:/Program Files (x86)/Inno Setup 5/ISCC.exe')" ]; then
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16;
export DISPLAY=:99.0;
wget http://files.jrsoftware.org/is/5/isetup-5.5.6.exe;
[ -d isetup ] || mkdir isetup;
pushd isetup;
[ -f isetup-5.5.6.exe ] || wget http://files.jrsoftware.org/is/5/isetup-5.5.6.exe;
wine isetup-5.5.6.exe /SILENT /VERYSILENT /SP- /SUPPRESSMSGBOXES /NORESTART;
popd;
fi;
unset CC;
unset CXX;
./configure --host=$HOST --disable-openssl --disable-readline --disable-zlib --disable-notify --prefix=${TRAVIS_BUILD_DIR}/win32/opensc || cat config.log;
./configure --host=$HOST --with-completiondir=/tmp --disable-openssl --disable-readline --disable-zlib --disable-notify --prefix=${TRAVIS_BUILD_DIR}/win32/opensc || cat config.log;
fi
# Optionally try to upload to Coverity Scan
# On error (propably quota is exhausted), just continue
# On error (probably quota is exhausted), just continue
- if [ "${DO_COVERITY_SCAN}" = "yes" ]; then curl -s 'https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh' | bash || true; fi
- if [ "${DO_SIMULATION}" = "javacard" ]; then
set -ex;
git clone https://github.com/frankmorgner/vsmartcard.git;
cd vsmartcard/virtualsmartcard;
autoreconf -vis && ./configure && sudo make install;
cd $TRAVIS_BUILD_DIR;
sudo systemctl stop pcscd.service pcscd.socket;
git clone https://github.com/martinpaljak/oracle_javacard_sdks.git;
export JC_HOME=$PWD/oracle_javacard_sdks/jc222_kit;
export JC_CLASSIC_HOME=$PWD/oracle_javacard_sdks/jc305u3_kit;
git clone https://github.com/arekinath/jcardsim.git;
cd jcardsim;
env | grep -i openjdk;
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/;
mvn initialize && mvn clean install;
cd $TRAVIS_BUILD_DIR;
git clone https://github.com/philipWendland/IsoApplet.git;
javac -classpath jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar IsoApplet/src/net/pwendland/javacard/pki/isoapplet/*.java;
echo "com.licel.jcardsim.card.applet.0.AID=F276A288BCFBA69D34F31001" > isoapplet_jcardsim.cfg;
echo "com.licel.jcardsim.card.applet.0.Class=net.pwendland.javacard.pki.isoapplet.IsoApplet" >> isoapplet_jcardsim.cfg;
echo "com.licel.jcardsim.card.ATR=3B80800101" >> isoapplet_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.host=localhost" >> isoapplet_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.port=35963" >> isoapplet_jcardsim.cfg;
git clone https://github.com/vletoux/GidsApplet.git;
javac -classpath jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar GidsApplet/src/com/mysmartlogon/gidsApplet/*.java;
echo "com.licel.jcardsim.card.applet.0.AID=A000000397425446590201" > gids_jcardsim.cfg;
echo "com.licel.jcardsim.card.applet.0.Class=com.mysmartlogon.gidsApplet.GidsApplet" >> gids_jcardsim.cfg;
echo "com.licel.jcardsim.card.ATR=3B80800101" >> gids_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.host=localhost" >> gids_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.port=35963" >> gids_jcardsim.cfg;
git clone --recursive https://github.com/Yubico/ykneo-openpgp.git;
cd ykneo-openpgp;
ant -DJAVACARD_HOME=${JC_HOME};
cd $TRAVIS_BUILD_DIR;
echo "com.licel.jcardsim.card.applet.0.AID=D2760001240102000000000000010000" > openpgp_jcardsim.cfg;
echo "com.licel.jcardsim.card.applet.0.Class=openpgpcard.OpenPGPApplet" >> openpgp_jcardsim.cfg;
echo "com.licel.jcardsim.card.ATR=3B80800101" >> openpgp_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.host=localhost" >> openpgp_jcardsim.cfg;
echo "com.licel.jcardsim.vsmartcard.port=35963" >> openpgp_jcardsim.cfg;
git clone --recursive https://github.com/arekinath/PivApplet.git;
cd PivApplet;
JC_HOME=${JC_CLASSIC_HOME} ant dist;
cd $TRAVIS_BUILD_DIR;
git clone https://github.com/Yubico/yubico-piv-tool.git;
cd yubico-piv-tool;
mkdir build; cd build;
cmake .. && make && sudo make install;
cd $TRAVIS_BUILD_DIR;
set +ex;
fi
- if [ "${DO_SIMULATION}" = "oseid" ]; then
git clone https://github.com/popovec/oseid;
cd oseid/src/;
make -f Makefile.console;
mkdir tmp;
socat -d -d pty,link=tmp/OsEIDsim.socket,raw,echo=0 "exec:build/console/console ...,pty,raw,echo=0" &
PID=$!;
sleep 1;
echo "# OsEIDsim" > tmp/reader.conf;
echo 'FRIENDLYNAME "OsEIDsim"' >> tmp/reader.conf;
echo "DEVICENAME ${TRAVIS_BUILD_DIR}/oseid/src/tmp/OsEIDsim.socket" >> tmp/reader.conf;
echo "LIBPATH ${TRAVIS_BUILD_DIR}/oseid/src/build/console/libOsEIDsim.so.0.0.1" >> tmp/reader.conf;
echo "CHANNELID 1" >> tmp/reader.conf;
sudo mv tmp/reader.conf /etc/reader.conf.d/reader.conf;
cat /etc/reader.conf.d/reader.conf;
cd $TRAVIS_BUILD_DIR;
sudo /etc/init.d/pcscd restart;
fi
- if [ "${DO_SIMULATION}" = "cac" ]; then
git clone https://github.com/frankmorgner/vsmartcard.git;
cd vsmartcard/virtualsmartcard;
autoreconf -vis && ./configure && make -j4 && sudo make install;
cd $TRAVIS_BUILD_DIR;
git clone https://gitlab.freedesktop.org/spice/libcacard.git;
cd libcacard && ./autogen.sh --prefix=/usr && make -j4 && sudo make install;
cd $TRAVIS_BUILD_DIR;
git clone https://github.com/PL4typus/virt_cacard.git;
cd virt_cacard && ./autogen.sh && ./configure && make;
cd $TRAVIS_BUILD_DIR;
sudo /etc/init.d/pcscd restart;
fi
script:
- if [ "${DO_COVERITY_SCAN}" != "yes" ]; then
if [ $TRAVIS_OS_NAME == osx ]; then
if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
./MacOSX/build;
else
make;
make -j 4;
fi;
fi
- if [ -z "$HOST" -a "${DO_COVERITY_SCAN}" != "yes" ]; then
make check && make dist;
- if [ -z "$HOST" -a "${DO_COVERITY_SCAN}" != "yes" -a -z "$DO_SIMULATION" ]; then
make check && make distcheck || (cat tests/*log src/tests/unittests/*log && exit 1);
fi
- if [ ! -z "$HOST" -a "${DO_COVERITY_SCAN}" != "yes" ]; then
make install;
wine "C:/Program Files (x86)/Inno Setup 5/ISCC.exe" win32/OpenSC.iss;
fi
- if [ "${DO_SIMULATION}" = "javacard" ]; then
set -ex;
sudo make install;
export LD_LIBRARY_PATH=/usr/local/lib;
sudo /usr/sbin/pcscd -f &
PCSCD_PID=$!;
java -noverify -cp IsoApplet/src/:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard isoapplet_jcardsim.cfg >/dev/null &
PID=$!;
sleep 5;
opensc-tool --card-driver default --send-apdu 80b800001a0cf276a288bcfba69d34f310010cf276a288bcfba69d34f3100100;
opensc-tool -n;
pkcs15-init --create-pkcs15 --so-pin 123456 --so-puk 0123456789abcdef;
pkcs15-tool --change-pin --pin 123456 --new-pin 654321;
pkcs15-tool --unblock-pin --puk 0123456789abcdef --new-pin 123456;
pkcs15-init --generate-key rsa/2048 --id 1 --key-usage decrypt,sign --auth-id FF --pin 123456;
pkcs15-init --generate-key rsa/2048 --id 2 --key-usage decrypt --auth-id FF --pin 123456;
pkcs15-init --generate-key ec/secp256r1 --id 3 --key-usage sign --auth-id FF --pin 123456;
pkcs15-tool -D;
pkcs11-tool -l -t -p 123456;
kill -9 $PID;
java -noverify -cp GidsApplet/src/:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard gids_jcardsim.cfg >/dev/null &
PID=$!;
sleep 5;
opensc-tool --card-driver default --send-apdu 80b80000190bA0000003974254465902010bA00000039742544659020100;
opensc-tool -n;
gids-tool --initialize --pin 123456 --admin-key 000000000000000000000000000000000000000000000000 --serial 00000000000000000000000000000000;
kill -9 $PID;
java -noverify -cp ykneo-openpgp/applet/bin:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard openpgp_jcardsim.cfg >/dev/null &
PID=$!;
sleep 5;
opensc-tool --card-driver default --send-apdu 80b800002210D276000124010200000000000001000010D276000124010200000000000001000000;
opensc-tool -n;
openpgp-tool --verify CHV3 --pin 12345678 --gen-key 2;
pkcs15-init --verify --auth-id 3 --pin 12345678 --delete-objects privkey,pubkey --id 2 --generate-key rsa/2048;
pkcs11-tool -l -t -p 123456;
kill -9 $PID;
java -noverify -cp PivApplet/bin/:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard PivApplet/test/jcardsim.cfg >/dev/null &
PID=$!;
sleep 5;
opensc-tool --card-driver default --send-apdu 80b80000120ba000000308000010000100050000020F0F7f;
opensc-tool -n;
yubico-piv-tool -v 9999 -r 'Virtual PCD 00 00' -P 123456 -s 9e -a generate -A RSA2048;
yubico-piv-tool -v 9999 -r 'Virtual PCD 00 00' -P 123456 -s 9a -a generate -A ECCP256;
pkcs11-tool -l -t -p 123456;
kill -9 $PID;
sudo kill -9 $PCSCD_PID;
set +ex;
fi
- if [ "${DO_SIMULATION}" = "oseid" ]; then
set -ex;
sudo make install;
export LD_LIBRARY_PATH=/usr/local/lib;
cd oseid/tools;
echo | ./OsEID-tool INIT;
./OsEID-tool RSA-CREATE-KEYS;
./OsEID-tool RSA-UPLOAD-KEYS;
./OsEID-tool RSA-DECRYPT-TEST;
./OsEID-tool RSA-SIGN-PKCS11-TEST;
./OsEID-tool EC-CREATE-KEYS;
./OsEID-tool EC-UPLOAD-KEYS;
./OsEID-tool EC-SIGN-TEST;
./OsEID-tool EC-SIGN-PKCS11-TEST;
./OsEID-tool EC-ECDH-TEST;
kill -9 $PID;
set +ex;
fi
- if [ "${DO_SIMULATION}" = "cac" ]; then
cd $TRAVIS_BUILD_DIR;
make check && sudo make install || (cat tests/*log src/tests/unittests/*log && exit 1);
export LD_LIBRARY_PATH=/usr/local/lib;
cd src/tests/p11test/;
./p11test -s 0 -p 12345678 -i &
sleep 5;
cd $TRAVIS_BUILD_DIR/virt_cacard;
./setup-softhsm2.sh;
export SOFTHSM2_CONF=$PWD/softhsm2.conf;
./virt_cacard &
wait $(ps aux | grep '[p]11test'| awk '{print $2}');
kill -9 $(ps aux | grep '[v]irt_cacard'| awk '{print $2}');
fi
after_script:
# kill process started during compilation to finish the build, see
# https://github.com/moodlerooms/moodle-plugin-ci/issues/33 for details
@ -97,4 +365,22 @@ after_script:
killall services.exe;
fi
cache: ccache
# keep in sync with appveyor.yml
- if [ "${DO_PUSH_ARTIFACT}" = "yes" -a "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_REPO_SLUG" = "OpenSC/OpenSC" ]; then
git config --global user.email "builds@travis-ci.org";
git config --global user.name "Travis CI";
.github/push_artifacts.sh "Travis CI build ${TRAVIS_JOB_NUMBER}";
fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
.github/remove_signing_key.sh;
rm -f .github/secrets.tar;
fi
cache:
apt: true
ccache: true
directories:
- $HOME/.m2/
- openssl_bin
- openpace_bin
- isetup

37
COPYING
View File

@ -1,8 +1,8 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -10,7 +10,7 @@
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
@ -111,8 +111,8 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
@ -158,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
@ -267,7 +267,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
@ -432,7 +432,7 @@ decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
@ -455,8 +455,8 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
@ -485,7 +485,7 @@ convey the exclusion of warranty; and each file should have at least the
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
@ -501,4 +501,3 @@ necessary. Here is a sample; alter the names:
That's all there is to it!

View File

@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--
https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/DistributionDefinitionRef/
-->
<installer-gui-script minSpecVersion="2">
<allowed-os-versions>
<os-version min="10.10"/>
@ -6,17 +9,57 @@
<background file="background.jpg" mime-type="image/jpeg" scaling="tofit"/>
<welcome file="Welcome.html" mime-type="text/html"/>
<title>@PACKAGE_STRING@</title>
<pkg-ref id="com.apple.tokend.opensc"/>
<options customize="never" require-scripts="false"/>
<options customize="allow" require-scripts="false" rootVolumeOnly="true"/>
<script>
<![CDATA[
function osx_before_catalina() {
if((system.compareVersions(system.version.ProductVersion, '10.15')) == -1)
{
return true;
}
else
{
return false;
}
}
function osx_after_catalina() {
if((system.compareVersions(system.version.ProductVersion, '10.15')) >= 0)
{
return true;
}
else
{
return false;
}
}
function osx_after_yosemite() {
if((system.compareVersions(system.version.ProductVersion, '10.12')) >= 0)
{
return true;
}
else
{
return false;
}
}
]]>
</script>
<choices-outline>
<line choice="default">
<line choice="com.apple.tokend.opensc"/>
</line>
<line choice="default" />
<line choice="startup" />
<line choice="tokend" />
<line choice="token" />
</choices-outline>
<choice id="default"/>
<choice id="com.apple.tokend.opensc" visible="true">
<pkg-ref id="com.apple.tokend.opensc"/>
<choice id="default" title="PKCS#11 module and smart card tools" enabled="false">
<pkg-ref id="org.opensc-project.mac">OpenSC.pkg</pkg-ref>
</choice>
<choice id="tokend" title="TokenD-based smart card driver" start_selected="osx_before_catalina()">
<pkg-ref id="org.opensc-project.tokend">OpenSC-tokend.pkg</pkg-ref>
</choice>
<choice id="token" title="CryptoTokenKit-based smart card driver" visible="osx_after_yosemite()" start_selected="osx_after_catalina()">
<pkg-ref id="org.opensc-project.mac.opensctoken">OpenSCToken.pkg</pkg-ref>
</choice>
<choice id="startup" title="Automatic startup items">
<pkg-ref id="org.opensc-project.startup">OpenSC-startup.pkg</pkg-ref>
</choice>
<pkg-ref id="com.apple.tokend.opensc" onConclusion="none">OpenSC.pkg</pkg-ref>
</installer-gui-script>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<false/>
<key>com.apple.security.automation.apple-events</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<false/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>

View File

@ -1,31 +1,23 @@
#!/bin/bash
# Building the installer is only tested and supported on 10.9+ with Xcode 6.0.1
# Built package targets 10.10
# Building should also work on older versions with older revisions or slight changes, YMMV
# Build the macOS installer for the tokend and command line tools.
#
# This is only tested and supported on macOS 10.10 or later, using Xcode 6.0.1.
# Building should also work on older macOS versions with slight changes; YMMV.
# You need to have the following from homebrew or macports or fink:
# autoconf automake libtool pkg-config
# You need to install the following packages from homebrew or macports or fink:
# autoconf automake libtool pkg-config help2man gengetopt
# If you want to compile with OpenSCToken/CryptoTokenKit set the following:
#ENABLE_CRYPTOTOKENKIT="--disable-pcsc --enable-cryptotokenkit"
# When using CryptoTokenKit, code signing is required
#SIGNING_IDENTITY=BA3CE53D402E3C75246557E2890F929F4A778DDE
if test -z "$ENABLE_CRYPTOTOKENKIT"; then
export MACOSX_DEPLOYMENT_TARGET="10.10"
else
export MACOSX_DEPLOYMENT_TARGET="10.12"
fi
export MACOSX_DEPLOYMENT_TARGET="10.10"
set -ex
test -x ./configure || ./bootstrap
BUILDPATH=${PWD}
# Locate the latest OSX SDK
SDK_PATH=$(xcrun --sdk macosx --show-sdk-path)
# Set SDK path
export CFLAGS="$CFLAGS -isysroot $SDK_PATH -arch x86_64"
xcode_ver=$(xcodebuild -version | sed -En 's/Xcode[[:space:]](.*)/\1/p')
base_ver="12.2"
if [ $(echo -e $base_ver"\n"$xcode_ver | sort -V | head -1) == "$base_ver" ]; then
export BUILD_ARM="true"
fi
export SED=/usr/bin/sed
PREFIX=/Library/OpenSC
@ -36,41 +28,59 @@ if ! pkg-config libcrypto --atleast-version=1.0.1; then
if ! test -e $BUILDPATH/openssl_bin/$PREFIX/lib/pkgconfig; then
# Build OpenSSL manually, because Apple's binaries are deprecated
if ! test -e openssl; then
git clone --depth=1 https://github.com/openssl/openssl.git -b OpenSSL_1_0_2-stable
git clone --depth=1 https://github.com/openssl/openssl.git -b OpenSSL_1_1_1-stable
fi
cd openssl
KERNEL_BITS=64 ./config --prefix=$PREFIX
MACHINE=x86_64 ./config no-shared --prefix=$PREFIX
make clean
make update
make depend
make
make INSTALL_PREFIX=$BUILDPATH/openssl_bin install_sw
make -j 4
make DESTDIR=$BUILDPATH/openssl_bin install_sw
if test -n "${BUILD_ARM}"; then
make clean
MACHINE=arm64 KERNEL_BITS=64 ./config no-shared --prefix=$PREFIX
make -j 4
make DESTDIR=$BUILDPATH/openssl_arm64 install_sw
lipo -create $BUILDPATH/openssl_arm64/$PREFIX/lib/libcrypto.a $BUILDPATH/openssl_bin/$PREFIX/lib/libcrypto.a -output libcrypto.a
lipo -create $BUILDPATH/openssl_arm64/$PREFIX/lib/libssl.a $BUILDPATH/openssl_bin/$PREFIX/lib/libssl.a -output libssl.a
mv libcrypto.a $BUILDPATH/openssl_bin/$PREFIX/lib/libcrypto.a
mv libssl.a $BUILDPATH/openssl_bin/$PREFIX/lib/libssl.a
fi
cd ..
fi
export OPENSSL_CFLAGS="`env PKG_CONFIG_PATH=$BUILDPATH/openssl_bin/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openssl_bin pkg-config --static --cflags libcrypto`"
export OPENSSL_LIBS="` env PKG_CONFIG_PATH=$BUILDPATH/openssl_bin/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openssl_bin pkg-config --static --libs libcrypto`"
fi
# Locate the latest OSX SDK
SDK_PATH=$(xcrun --sdk macosx --show-sdk-path)
export CFLAGS="$CFLAGS -isysroot $SDK_PATH"
if test -n "${BUILD_ARM}"; then
export CFLAGS="$CFLAGS -arch x86_64 -arch arm64"
export LDFLAGS="$LDFLAGS -arch x86_64 -arch arm64"
fi
export OBJCFLAGS=$CFLAGS
if ! test -e $BUILDPATH/openpace_bin/$PREFIX/lib/pkgconfig; then
if ! test -e openpace; then
git clone --depth=1 https://github.com/frankmorgner/openpace.git
git clone --depth=1 https://github.com/frankmorgner/openpace.git -b 1.1.1
fi
cd openpace
autoreconf -vis
./configure --disable-shared --prefix=$PREFIX CRYPTO_CFLAGS="$OPENSSL_CFLAGS" CRYPTO_LIBS="$OPENSSL_LIBS"
./configure --disable-shared --prefix=$PREFIX CRYPTO_CFLAGS="$OPENSSL_CFLAGS" CRYPTO_LIBS="$OPENSSL_LIBS" HELP2MAN=/usr/bin/true
touch src/cvc-create.1 src/cvc-print.1
make DESTDIR=$BUILDPATH/openpace_bin install
cd ..
export OPENPACE_CFLAGS="`env PKG_CONFIG_PATH=$BUILDPATH/openssl_bin/$PREFIX/lib/pkgconfig:$BUILDPATH/openpace_bin/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openpace_bin pkg-config --static --cflags libeac` $OPENSSL_CFLAGS"
export OPENPACE_LIBS="` env PKG_CONFIG_PATH=$BUILDPATH/openssl_bin/$PREFIX/lib/pkgconfig:$BUILDPATH/openpace_bin/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openpace_bin pkg-config --static --libs libeac` $OPENSSL_LIBS"
fi
export OPENPACE_CFLAGS="`env PKG_CONFIG_PATH=$BUILDPATH/openssl_bin/$PREFIX/lib/pkgconfig:$BUILDPATH/openpace_bin/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openpace_bin pkg-config --static --cflags libeac` $OPENSSL_CFLAGS"
export OPENPACE_LIBS="` env PKG_CONFIG_PATH=$BUILDPATH/openssl_bin/$PREFIX/lib/pkgconfig:$BUILDPATH/openpace_bin/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openpace_bin pkg-config --static --libs libeac` $OPENSSL_LIBS"
if ! test -e ${BUILDPATH}/target/$PREFIX/lib/pkgconfig; then
./configure --prefix=$PREFIX \
--sysconfdir=$PREFIX/etc \
--enable-cvcdir=$PREFIX/etc/cvc \
--enable-x509dir=$PREFIX/etc/x509 \
$ENABLE_CRYPTOTOKENKIT \
--disable-notify \
--enable-openssl-secure-malloc=65536 \
--disable-dependency-tracking \
--enable-shared \
--enable-static \
@ -82,7 +92,7 @@ if ! test -e ${BUILDPATH}/target/$PREFIX/lib/pkgconfig; then
make clean
# compile
make -j 2
make -j 4
# copy files
rm -rf ${BUILDPATH}/target
@ -96,7 +106,25 @@ if ! test -e ${BUILDPATH}/target/$PREFIX/lib/pkgconfig; then
./MacOSX/libtool-bundle ${BUILDPATH}/target/$PREFIX/lib/opensc-pkcs11.so ${BUILDPATH}/target/$PREFIX/lib
fi
if test -z "$ENABLE_CRYPTOTOKENKIT"; then
if ! test -e NotificationProxy; then
git clone http://github.com/frankmorgner/NotificationProxy.git
fi
if test -n "${CODE_SIGN_IDENTITY}" -a -n "${DEVELOPMENT_TEAM}"; then
xcodebuild -target NotificationProxy -configuration Release -project NotificationProxy/NotificationProxy.xcodeproj install DSTROOT=$BUILDPATH/target/Library/OpenSC/ \
CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY}" DEVELOPMENT_TEAM="${DEVELOPMENT_TEAM}" OTHER_CODE_SIGN_FLAGS="--timestamp --options=runtime" CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO CODE_SIGN_STYLE=Manual
else
xcodebuild -target NotificationProxy -configuration Release -project NotificationProxy/NotificationProxy.xcodeproj install DSTROOT=$BUILDPATH/target/Library/OpenSC/
fi
mkdir -p "$BUILDPATH/target/Applications/Utilities"
osacompile -o "$BUILDPATH/target/Applications/Utilities/OpenSC Notify.app" "MacOSX/OpenSC_Notify.applescript"
if test -n "${CODE_SIGN_IDENTITY}"; then
codesign --force --sign "${CODE_SIGN_IDENTITY}" --entitlements MacOSX/OpenSC_applescripts.entitlements --deep --timestamp --options runtime "$BUILDPATH/target/Applications/Utilities/OpenSC Notify.app"
fi
# Build OpenSC.tokend when XCode version < 10
if (( $(xcodebuild -version | sed -En 's/Xcode[[:space:]]+([0-9]+)(\.[0-9]*)*/\1/p') < 10 )); then
# Check out OpenSC.tokend, if not already fetched.
if ! test -e OpenSC.tokend; then
git clone http://github.com/OpenSC/OpenSC.tokend.git
@ -106,57 +134,110 @@ if test -z "$ENABLE_CRYPTOTOKENKIT"; then
test -L OpenSC.tokend/build/opensc-src || ln -sf ${BUILDPATH}/src OpenSC.tokend/build/opensc-src
# Build and copy OpenSC.tokend
xcodebuild -target OpenSC -configuration Deployment -project OpenSC.tokend/Tokend.xcodeproj install DSTROOT=${BUILDPATH}/target
#if ! test -e $BUILDPATH/target/Library/Security/tokend/OpenSC.tokend/Contents/Resources/Applications/terminal-notifier.app; then
#if ! test -e terminal-notifier-1.7.1.zip; then
#curl -L https://github.com/julienXX/terminal-notifier/releases/download/1.7.1/terminal-notifier-1.7.1.zip > terminal-notifier-1.7.1.zip
#fi
#if ! test -e terminal-notifier-1.7.1; then
#unzip terminal-notifier-1.7.1.zip
#fi
#mkdir -p $BUILDPATH/target/Library/Security/tokend/OpenSC.tokend/Contents/Resources/Applications
#cp -r terminal-notifier-1.7.1/terminal-notifier.app $BUILDPATH/target/Library/Security/tokend/OpenSC.tokend/Contents/Resources/Applications
#fi
if ! test -e NotificationProxy; then
git clone http://github.com/frankmorgner/NotificationProxy.git
if test -n "${CODE_SIGN_IDENTITY}" -a -n "${DEVELOPMENT_TEAM}"; then
xcodebuild -target OpenSC -configuration Deployment -project OpenSC.tokend/Tokend.xcodeproj install DSTROOT=${BUILDPATH}/target_tokend \
CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY}" DEVELOPMENT_TEAM="${DEVELOPMENT_TEAM}" OTHER_CODE_SIGN_FLAGS="--timestamp --options=runtime" CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO CODE_SIGN_STYLE=Manual
else
xcodebuild -target OpenSC -configuration Deployment -project OpenSC.tokend/Tokend.xcodeproj install DSTROOT=${BUILDPATH}/target_tokend
fi
xcodebuild -target NotificationProxy -configuration Release -project NotificationProxy/NotificationProxy.xcodeproj install DSTROOT=$BUILDPATH/target/Library/Security/tokend/OpenSC.tokend/Contents/Resources/
mkdir -p "$BUILDPATH/target/Applications"
osacompile -o "$BUILDPATH/target/Applications/OpenSC Notify.app" "MacOSX/OpenSC_Notify.applescript"
TOKEND="-tokend"
else
# Check out OpenSCToken, if not already fetched.
if ! test -e OpenSCToken; then
git clone http://github.com/frankmorgner/OpenSCToken.git
fi
# Build and copy OpenSCTokenApp
xcodebuild -target OpenSCTokenApp -configuration Release -project OpenSCToken/OpenSCTokenApp.xcodeproj install DSTROOT=${BUILDPATH}/target
codesign --sign "$SIGNING_IDENTITY" --force --entitlements MacOSX/opensc.entitlements target/Library/OpenSC/bin/*
codesign --sign "$SIGNING_IDENTITY" --force --entitlements MacOSX/opensc.entitlements target/Library/OpenSC/lib/*.dylib
codesign --sign "$SIGNING_IDENTITY" --force --entitlements MacOSX/opensc.entitlements --deep target/Library/OpenSC/lib/opensc-pkcs11.bundle
# https://github.com/OpenSC/OpenSC.tokend/issues/33
mkdir -p ${BUILDPATH}/target_tokend
TOKEND=""
fi
#if ! test -e $BUILDPATH/target/Library/Security/tokend/OpenSC.tokend/Contents/Resources/Applications/terminal-notifier.app; then
#if ! test -e terminal-notifier-1.7.1.zip; then
#curl -L https://github.com/julienXX/terminal-notifier/releases/download/1.7.1/terminal-notifier-1.7.1.zip > terminal-notifier-1.7.1.zip
#fi
#if ! test -e terminal-notifier-1.7.1; then
#unzip terminal-notifier-1.7.1.zip
#fi
#mkdir -p $BUILDPATH/target/Library/Security/tokend/OpenSC.tokend/Contents/Resources/Applications
#cp -r terminal-notifier-1.7.1/terminal-notifier.app $BUILDPATH/target/Library/Security/tokend/OpenSC.tokend/Contents/Resources/Applications
#fi
imagedir=$(mktemp -d)
# Prepare target root
mkdir -p ${BUILDPATH}/target/usr/local/bin
cp MacOSX/opensc-uninstall ${BUILDPATH}/target/usr/local/bin
# Prepare startup root
mkdir -p ${BUILDPATH}/target_startup/Library/LaunchAgents
cp src/tools/org.opensc-project.mac.pkcs11-register.plist ${BUILDPATH}/target_startup/Library/LaunchAgents
cp src/tools/org.opensc-project.mac.opensc-notify.plist ${BUILDPATH}/target_startup/Library/LaunchAgents
# Build OpenSCToken if possible
if test -e OpenSCToken -a -n "${CODE_SIGN_IDENTITY}" -a -n "${DEVELOPMENT_TEAM}"; then
cd OpenSCToken
# make sure OpenSCToken builds with the same dependencies as before
if ! test -e OpenSC; then
git clone --depth=1 file://$PWD/../../OpenSC
else
cd OpenSC && git pull && cd ..
fi
mkdir -p build
if ! test -e build/openssl; then
# build/openssl/lib/libcrypto.a is hardcoded in OpenSCToken
ln -sf $BUILDPATH/openssl_bin/$PREFIX build/openssl
# in OpenSCToken's variant of OpenSC we still use OpenSSL flags from above
fi
if ! test -e build/openpace; then
# build/openpace/lib/libeac.a is hardcoded in OpenSCToken
ln -sf $BUILDPATH/openpace_bin/$PREFIX build/openpace
# in OpenSCToken's variant of OpenSC we still use OpenPACE flags from above
fi
BP=${BUILDPATH}
. ./bootstrap
BUILDPATH=${BP}
xcodebuild -target OpenSCTokenApp -configuration Debug -project OpenSCTokenApp.xcodeproj install DSTROOT=${BUILDPATH}/target_token \
CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY}" DEVELOPMENT_TEAM="${DEVELOPMENT_TEAM}" OTHER_CODE_SIGN_FLAGS="--timestamp --options=runtime" CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO CODE_SIGN_STYLE=Manual
cd ..
COMPONENT_TOKEN="--component-plist MacOSX/target_token.plist"
else
# if no OpenSCToken is checked out, then we create a dummy package
mkdir -p ${BUILDPATH}/target_token
fi
if test -n "${CODE_SIGN_IDENTITY}"; then
for d in ${BUILDPATH}/target/Library/OpenSC/bin ${BUILDPATH}/target/Library/OpenSC/lib
do
# find executable files and run codesign on them
find ${d} -type f -perm +111 -print -exec \
codesign --force --sign "${CODE_SIGN_IDENTITY}" --entitlements MacOSX/OpenSC_binaries.entitlements --deep --timestamp --options runtime {} \;
done
fi
# Build package
pkgbuild --root ${BUILDPATH}/target --scripts MacOSX/scripts --identifier org.opensc-project.mac --version @PACKAGE_VERSION@ --install-location / OpenSC.pkg
pkgbuild --root ${BUILDPATH}/target --component-plist MacOSX/target.plist --scripts MacOSX/scripts --identifier org.opensc-project.mac --version @PACKAGE_VERSION@ --install-location / OpenSC.pkg
pkgbuild --root ${BUILDPATH}/target_tokend --component-plist MacOSX/target_tokend.plist --identifier org.opensc-project.tokend --version @PACKAGE_VERSION@ --install-location / OpenSC-tokend.pkg
pkgbuild --root ${BUILDPATH}/target_token $COMPONENT_TOKEN --identifier org.opensc-project.mac.opensctoken --version @PACKAGE_VERSION@ --install-location / OpenSCToken.pkg
pkgbuild --root ${BUILDPATH}/target_startup --component-plist MacOSX/target_startup.plist --identifier org.opensc-project.startup --version @PACKAGE_VERSION@ --install-location / OpenSC-startup.pkg
# Build product
productbuild --distribution MacOSX/Distribution.xml --package-path . --resources MacOSX/resources "${imagedir}/OpenSC @PACKAGE_VERSION@.pkg"
# Sign installer
if test -n "${INSTALLER_SIGN_IDENTITY}"; then
productsign --sign "${INSTALLER_SIGN_IDENTITY}" "${imagedir}/OpenSC @PACKAGE_VERSION@.pkg" "${BUILDPATH}/OpenSC @PACKAGE_VERSION@.pkg"
mv "${BUILDPATH}/OpenSC @PACKAGE_VERSION@.pkg" "${imagedir}/OpenSC @PACKAGE_VERSION@.pkg"
fi
# Build "Uninstaller"
osacompile -o "${imagedir}/OpenSC Uninstaller.app" "MacOSX/OpenSC_Uninstaller.applescript"
if test -n "${CODE_SIGN_IDENTITY}"; then
codesign --force --sign "${CODE_SIGN_IDENTITY}" --entitlements MacOSX/OpenSC_applescripts.entitlements --deep --timestamp --options runtime "${imagedir}/OpenSC Uninstaller.app"
fi
# Create .dmg
rm -f OpenSC-@PACKAGE_VERSION@.dmg
rm -f OpenSC-@PACKAGE_VERSION@$TOKEND.dmg
i=0
while ! hdiutil create -srcfolder "${imagedir}" -volname "@PACKAGE_NAME@" OpenSC-@PACKAGE_VERSION@.dmg
while ! hdiutil create -srcfolder "${imagedir}" -volname "@PACKAGE_NAME@" -fs JHFS+ OpenSC-@PACKAGE_VERSION@$TOKEND.dmg
do
i=$[$i+1]
if [ $i -gt 2 ]
@ -165,3 +246,6 @@ do
fi
done
rm -rf ${imagedir}
#if [ "$TRAVIS_EVENT_TYPE" != "pull_request" ]; then xcrun altool --notarize-app --file $(pwd)/vorteil_darwin-x86.dmg --username $OSX_NOTARIZE_USERNAME --primary-bundle-id com.vorteil.cli -p $OSX_NOTARIZE_PW -- >> /dev/null; fi;
#if [ "$TRAVIS_EVENT_TYPE" != "pull_request" ]; then for ((i=1;i<=30;i+=1)); do xcrun stapler staple $(pwd)/vorteil_darwin-x86.dmg >> /dev/null; if [ $? = 65 ]; then echo "Waiting for notarization to complete..." && sleep 10; fi; done; fi;

View File

@ -6,9 +6,19 @@ if [ "$(id -u)" != "0" ]; then
exit 1
fi
# Remove symlinks to commands
for file in /Library/OpenSC/bin/*; do
test -L "/usr/local/bin/$(basename $file)" && rm -f "/usr/local/bin/$(basename $file)"
pluginkit -r -i org.opensc-project.mac.opensctoken.OpenSCTokenApp.OpenSCToken
for f in \
/Library/OpenSC/bin/* \
/Library/OpenSC/etc/bash_completion.d/* \
/Library/OpenSC/share/doc/opensc \
/Library/OpenSC/share/man/man1/* \
/Library/OpenSC/share/man/man5/*
do
a=/Library/OpenSC
b=/usr/local
l="${f/$a/$b}"
test -L "$l" && rm -f "$l"
done
# Remove pkcs11 libraries
@ -16,20 +26,25 @@ rm -f /usr/local/lib/opensc-pkcs11.so
rm -f /usr/local/lib/onepin-opensc-pkcs11.so
# Remove installed files
rm -rf /Applications/OpenSCTokenApp.app
rm -rf "/Applications/OpenSC Notify.app"
rm -rf /Applications/Utilities/OpenSCTokenApp.app
rm -rf "/Applications/Utilities/OpenSC Notify.app"
rm -rf /Library/OpenSC
rm -rf /Library/Security/tokend/OpenSC.tokend
rm -f /Library/LaunchAgents/pkcs11-register.plist
rm -f /Library/LaunchAgents/opensc-notify.plist
rm -rf /System/Library/Security/tokend/OpenSC.tokend
if [ -e "/Library/OpenSC/OpenSCTokenApp.app/Contents/PlugIns/OpenSCToken.appex" ]
then
pluginkit -r /Library/OpenSC/OpenSCTokenApp.app/Contents/PlugIns/OpenSCToken.appex
fi
# Unload launchagents
launchctl remove pkcs11-register
launchctl remove opensc-notify
# delete receipts on 10.6+
for file in /var/db/receipts/org.opensc-project.mac.bom /var/db/receipts/org.opensc-project.mac.plist; do
test -f $file && rm -f $file
done
pkgutil --forget org.opensc-project.mac > /dev/null 2>/dev/null
pkgutil --forget org.opensc-project.tokend > /dev/null 2>/dev/null
pkgutil --forget org.opensc-project.mac.opensctoken > /dev/null 2>/dev/null
pkgutil --forget org.opensc-project.startup > /dev/null 2>/dev/null
# remove this script
rm -f /usr/local/bin/opensc-uninstall

View File

@ -1,26 +1,63 @@
#!/bin/bash
cp /Library/OpenSC/lib/opensc-pkcs11.so /usr/local/lib/opensc-pkcs11.so
cp /Library/OpenSC/lib/onepin-opensc-pkcs11.so /usr/local/lib/onepin-opensc-pkcs11.so
if [ -e "/Library/OpenSC/etc/opensc.conf.md5" ]
then
read cs_fromfile file < "/Library/OpenSC/etc/opensc.conf.md5"
cs_calculated=$( md5 -q "/Library/OpenSC/etc/opensc.conf")
if [ "$cs_fromfile" = "$cs_calculated" ]
then
mv /Library/OpenSC/etc/opensc.conf.orig /Library/OpenSC/etc/opensc.conf
md5 -r /Library/OpenSC/etc/opensc.conf > /Library/OpenSC/etc/opensc.conf.md5
fi
else
mv /Library/OpenSC/etc/opensc.conf.orig /Library/OpenSC/etc/opensc.conf
md5 -r /Library/OpenSC/etc/opensc.conf > /Library/OpenSC/etc/opensc.conf.md5
fi
for f in /Library/OpenSC/bin/*
do
ln -sf $f /usr/local/bin
# copy libs to /usr/local/lib
cp /Library/OpenSC/lib/opensc-pkcs11.so \
/Library/OpenSC/lib/onepin-opensc-pkcs11.so \
/usr/local/lib/
# install opensc.conf if it hasn't been locally modified
# shellcheck disable=SC2043
for f in /Library/OpenSC/etc/opensc.conf; do
if [ -e "${f}.md5" ]; then
read -r cs_fromfile _ < "${f}.md5"
cs_calculated="$(md5 -q "${f}")"
if [ "$cs_fromfile" != "$cs_calculated" ]; then
echo "config ${f} was locally modified since last install, skipping" 2>&1
continue
fi
fi
cp "${f}.orig" "$f"
md5 -r "$f" >"${f}.md5"
done
if [ -e "/Library/OpenSC/OpenSCTokenApp.app/Contents/PlugIns/OpenSCToken.appex" ]
then
pluginkit -a /Library/OpenSC/OpenSCTokenApp.app/Contents/PlugIns/OpenSCToken.appex
fi
# symlink other files to /usr/local
for f in \
/Library/OpenSC/bin/* \
/Library/OpenSC/etc/bash_completion.d/* \
/Library/OpenSC/share/doc/*
do
[ -e "$f" ] || continue # keep this or set "shopt -s nullglob"
a=/Library/OpenSC
b=/usr/local
l="${f/$a/$b}" # parameter expansion, returns $f where $a is replaced by $b
mkdir -p "$(dirname "$l")"
ln -sf "$f" "$l"
done
# correct past issue where a literal shell glob character was symlinked
# e.g. /usr/local/share/man/man1/* -> /Library/OpenSC/share/man/man1/*
# maybe remove this step post 2022?
for f in \
'/usr/local/share/man/man1/*' \
'/usr/local/share/man/man5/*'
do
[ -L "$f" ] || continue # skip unless $f is a symlink
t="$(readlink "$f")"
[ -e "$t" ] && continue # skip if the symlink target actually exists
a=/usr/local
b=/Library/OpenSC
[ "$t" = "${f/$a/$b}" ] || continue # skip unless the target is in the corresponding /Library/OpenSC subdirectory
# we can now assume that we originally made $f and can safely remove it
unlink "$f"
done
# register the launch agents
for f in \
/Library/LaunchAgents/org.opensc-project.mac.pkcs11-register.plist \
/Library/LaunchAgents/org.opensc-project.mac.opensc-notify.plist
do
[ -e "$f" ] || continue
/bin/launchctl asuser "$(id -u "$USER")" /bin/launchctl load "$f" || true
done
exit 0

18
MacOSX/target.plist Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>BundleHasStrictIdentifier</key>
<true/>
<key>BundleIsRelocatable</key>
<false/>
<key>BundleIsVersionChecked</key>
<true/>
<key>BundleOverwriteAction</key>
<string>upgrade</string>
<key>RootRelativeBundlePath</key>
<string>Library/OpenSC/Applications/NotificationProxy.app</string>
</dict>
</array>
</plist>

View File

@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.smartcard</key>
<true/>
</dict>
<array/>
</plist>

27
MacOSX/target_token.plist Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>BundleHasStrictIdentifier</key>
<true/>
<key>BundleIsRelocatable</key>
<false/>
<key>BundleIsVersionChecked</key>
<true/>
<key>BundleOverwriteAction</key>
<string>upgrade</string>
<key>ChildBundles</key>
<array>
<dict>
<key>BundleOverwriteAction</key>
<string></string>
<key>RootRelativeBundlePath</key>
<string>Applications/Utilities/OpenSCTokenApp.app/Contents/PlugIns/OpenSCToken.appex</string>
</dict>
</array>
<key>RootRelativeBundlePath</key>
<string>Applications/Utilities/OpenSCTokenApp.app</string>
</dict>
</array>
</plist>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array/>
</plist>

View File

@ -13,12 +13,12 @@ MAINTAINERCLEANFILES = \
$(srcdir)/packaged
EXTRA_DIST = Makefile.mak
SUBDIRS = etc src win32 doc MacOSX
DISTCHECK_CONFIGURE_FLAGS = --with-completiondir=/tmp
SUBDIRS = etc src win32 doc MacOSX tests
dist_noinst_SCRIPTS = bootstrap bootstrap.ci
dist_noinst_DATA = README \
solaris/Makefile solaris/README solaris/checkinstall.in \
solaris/opensc.conf-dist solaris/pkginfo.in solaris/proto \
packaging/debian.templates/changelog \
packaging/debian.templates/compat \
packaging/debian.templates/control \
@ -28,6 +28,10 @@ dist_noinst_DATA = README \
packaging/debian.templates/rules
dist_doc_DATA = NEWS
include $(top_srcdir)/aminclude_static.am
clean-local: code-coverage-clean
distclean-local: code-coverage-dist-clean
Generate-ChangeLog:
rm -f ChangeLog.tmp "$(srcdir)/ChangeLog"
test -n "$(GIT)"

View File

@ -2,5 +2,19 @@ SUBDIRS = etc win32 src
default: all
32:
CALL "C:\Program Files\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
$(MAKE) /f Makefile.mak opensc.msi PLATFORM=x86 OPENPACE_DIR=C:\openpace-Win32_1.0.2
MOVE win32\OpenSC.msi OpenSC_win32.msi
64:
CALL "C:\Program Files\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
$(MAKE) /f Makefile.mak opensc.msi OPENPACE_DIR=C:\openpace-Win64_1.0.2
MOVE win32\OpenSC.msi OpenSC_win64.msi
opensc.msi:
$(MAKE) /f Makefile.mak all OPENSSL_DEF=/DENABLE_OPENSSL OPENPACE_DEF=/DENABLE_OPENPACE"
@cmd /c "cd win32 && $(MAKE) /nologo /f Makefile.mak opensc.msi OPENSSL_DEF=/DENABLE_OPENSSL OPENPACE_DEF=/DENABLE_OPENPACE"
all clean::
@for %i in ( $(SUBDIRS) ) do @cmd /c "cd %i && $(MAKE) /nologo /f Makefile.mak $@"

432
NEWS
View File

@ -1,5 +1,417 @@
NEWS for OpenSC -- History of user visible changes
# New in 0.22.0; 2021-08-10
## General improvements
* Use standard paths for file cache on Linux (#2148) and OSX (#2214)
* Various issues of memory/buffer handling in legacy drivers mostly reported by oss-fuzz and coverity (tcos, oberthur, isoapplet, iasecc, westcos, gpk, flex, dnie, mcrd, authentic, belpic)
* Add threading test to `pkcs11-tool` (#2067)
* Add support to generate generic secret keys (#2140)
* `opensc-explorer`: Print information about LCS (Life cycle status byte) (#2195)
* Add support for Apple's arm64 (M1) binaries, removed TokenD. A seperate installer with TokenD (and without arm64 binaries) will be available (#2179).
* Support for gcc11 and its new strict aliasing rules (#2241, #2260)
* Initial support for building with OpenSSL 3.0 (#2343)
* pkcs15-tool: Write data objects in binary mode (#2324)
* Avoid limited size of log messages (#2352)
## PKCS#11
* Support for ECDSA verification (#2211)
* Support for ECDSA with different SHA hashes (#2190)
* Prevent issues in p11-kit by not returning unexpected return codes (#2207)
* Add support for PKCS#11 3.0: The new interfaces, profile objects and functions (#2096, #2293)
* Standardize the version 2 on 2.20 in the code (#2096)
* Fix CKA_MODIFIABLE and CKA_EXTRACTABLE (#2176)
* Copy arguments of C_Initialize (#2350)
## Minidriver
* Fix RSA-PSS signing (#2234)
## OpenPGP
* Fix DO deletion (#2215)
* Add support for (X)EdDSA keys (#1960)
## IDPrime
* Add support for applet version 3 and fix RSA-PSS mechanisms (#2205)
* Add support for applet version 4 (#2332)
## MyEID
* New configuration option for opensc.conf to disable pkcs1_padding (#2193)
* Add support for ECDSA with different hashes (#2190)
* Enable more mechanisms (#2178)
* Fixed asking for a user pin when formatting a card (#1737)
## IAS/ECC
* Added support for French CPx Healthcare cards (#2217)
## CardOS
* Added ATR for new CardOS 5.4 version (#2296)
# New in 0.21.0; 2020-11-24
## General Improvements
* fixed security problems
* CVE-2020-26570 (6903aebfddc466d966c7b865fae34572bf3ed23e)
* CVE-2020-26571
* CVE-2020-26572 (9d294de90d1cc66956389856e60b6944b27b4817)
* Bump minimal required OpenSSL version to 1.0.1 (#1658)
* Implement basic unit tests for asn1 library, compression and simpletlv parser (#1830)
* Allow generating code coverage
* Improve fuzzing by providing corpus from real cards (#1830)
* Implement support for OAEP encryption
* New separate debug level for PIN commands (d06f23e8)
* Fix handling of card/reader insertion/removal events in pcscd
* Many bugfixes reported by oss-fuzz, coverity and lgtm.com
* Fixes of removed readers handling (#1970)
* Fix Firefox crash because of invalid pcsc context (#2077)
## PKCS#11
* Return CKR_TOKEN_NOT_RECOGNIZED for not recognized cards (#2030)
* Propagate ignore_user_content to PKCS#11 layer not to confuse applications (#2040)
## Minidriver
* Fix check of ATR length (2-to 33 characters inclusive) (#2146)
## MacOS
* Add installer signing for PR and master
* Avoid app bundle relocations after installation
* Move OpenSC to MacOS Utilities folder (#2063)
## OpenSC tools
### pkcs11-tool
* Make SHA256 default for OAEP encryption
* pkcs11-tool: allow using SW tokens (#2113)
### opensc-explorer
* `asn1` accepts offsets and decode records (#2090)
* `cat` accepts records (#2090)
## OpenPGP
* Add new ec curves supported by GNUK (#1853)
* First steps supporting OpenPGP 3.4
* Add support for EC key import (#1821)
## Rutoken
* Add ATR for Rutoken ECP SC NFC (#2122)
## CardOS
* Improve detection of various CardOS 5 configurations (#1987)
## DNIe
* Add new DNIe CA structure for the secure channel (#2109)
## ePass2003
* Improve ECC support (#1859)
* Fixed erase sequence (#2097)
## IAS-ECC (#2070):
* Fixed support for Idemia Cosmo cards with AWP middleware interoperability (previously broken).
* Added support for Idemia Cosmo v8 cards.
* PIN padding settings are now used from PKCS#15 info when available.
* Added PIN-pad support for PIN unblock.
## IDPrime
* New driver for Gemalto IDPrime (only some types) (#1772)
## eDo
* New driver with initial support for Polish eID card (e-dowód, eDO) (#2023)
## MCRD
* Remove unused and broken RSA EstEID support (#2095)
## TCOS
* Add missing encryption certificates (#2083)
## PIV
* Add ATR of DOD Yubikey (#2115)
* fixed PIV global pin bug (#2142)
## CAC1
* Support changing PIN with CAC Alt tokens (#2129)
# New in 0.20.0; 2019-12-29
## General Improvements
* fixed security problems
* CVE-2019-6502 (#1586)
* CVE-2019-15946 (a3fc769)
* CVE-2019-15945 (412a614)
* CVE-2019-19480 (6ce6152284c47ba9b1d4fe8ff9d2e6a3f5ee02c7)
* CVE-2019-19481 (b75c002cfb1fd61cd20ec938ff4937d7b1a94278)
* CVE-2019-19479 (c3f23b836e5a1766c36617fe1da30d22f7b63de2)
* Support RSA-PSS signature mechanisms using RSA-RAW (#1435)
* Added memory locking for secrets (#1491)
* added support for terminal colors (#1534)
* PC/SC driver: Fixed error handling in case of changing (#1537) or removing the card reader (#1615)
* macOS installer
* Add installer option to deselect tokend (#1607)
* Make OpenSCToken available on 10.12+ and the default on 10.15+ (2017626ed237dbdd4683a4b9410fc610618200c5)
* Configuration
* rename `md_read_only` to `read_only` and use it for PKCS#11 and Minidriver (#1467)
* allow global use of ignore_private_certificate (#1623)
* Build Environment
* Bump openssl requirement to 0.9.8 (##1459)
* Added support for fuzzing with AFL (#1580) and libFuzzer/OSS-Fuzz (#1697)
* Added CI tests for simulating GIDS, OpenPGP, PIV, IsoApplet (#1568) and MyEID (#1677) and CAC (#1757)
* Integrate clang-tidy with `make check` (#1673)
* Added support for reproducible builds (#1839)
## PKCS#11
* Implement write protection (CKF_WRITE_PROTECTED) based on the card profile (#1467)
* Added C_WrapKey and C_UnwrapKey implementations (#1393)
* Handle CKA_ALWAYS_AUTHENTICATE when creating key objects. (#1539)
* Truncate long PKCS#11 labels with ... (#1629)
* Fixed recognition of a token when being unplugged and reinserted (#1875)
## Minidriver
* Register for CardOS5 cards (#1750)
* Add support for RSA-PSS (263b945)
## OpenSC tools
* Harmonize the use of option `-r`/`--reader` (#1548)
* `goid-tool`: GoID personalization with fingerprint
* `openpgp-tool`
* replace the options `-L`/` --key-length` with `-t`/`--key-type` (#1508)
* added options `-C`/`--card-info` and `-K`/`--key-info` (#1508)
* `opensc-explorer`
* add command `pin_info` (#1487)
* extend `random` to allow writing to a file (#1487)
* `opensc-minidriver-test.exe`: Tests for Microsoft CryptoAPI (#1510)
* `opensc-notify`: Autostart on Windows
* `pkcs11-register`:
* Auto-configuration of applications for use of OpenSC PKCS#11 (#1644)
* Autostart on Windows, macOS and Linux (#1644)
* `opensc-tool`: Show ATR also for cards not recognized by OpenSC (#1625)
* `pkcs11-spy`:
* parse CKM_AES_GCM
* Add support for CKA_OTP_* and CKM_*_PSS values
* parse EC Derive parameters (#1677)
* `pkcs11-tool`
* Support for signature verification via `--verify` (#1435)
* Add object type `secrkey` for `--type` option (#1575)
* Implement Secret Key write object (#1648)
* Add GOSTR3410-2012 support (#1654)
* Add support for testing CKM_RSA_PKCS_OAEP (#1600)
* Add extractable option to key import (#1674)
* list more key access flags when listing keys (#1653)
* Add support for `CKA_ALLOWED_MECHANISMS` when creating new objects and listing keys (#1628)
* `pkcs15-crypt`: * Handle keys with user consent (#1529)
## CAC1
New separate CAC1 driver using the old CAC specification (#1502)
## CardOS
* Add support for 4K RSA keys in CardOS 5 (#1776)
* Fixed decryption with CardOS 5 (#1867)
## Coolkey
* Enable CoolKey driver to handle 2048-bit keys. (#1532)
## EstEID
* adds support for a minimalistic, small and fast card profile based on IAS-ECC issued since December 2018 (#1635)
## GIDS
* GIDS Decipher fix (#1881)
* Allow RSA 4K support (#1891)
## MICARDO
* Remove long expired EstEID 1.0/1.1 card support (#1470)
## MyEID
* Add support for unwrapping a secret key with an RSA key or secret key (#1393)
* Add support for wrapping a secret key with a secret key (#1393)
* Support for MyEID 4K RSA (#1657)
* Support for OsEID (#1677).
## Gemalto GemSafe
* add new PTeID ATRs (#1683)
* Add support for 4K RSA keys (#1863, #1872)
## OpenPGP
* OpenPGP Card v3 ECC support (#1506)
## Rutoken
* Add Rutoken ECP SC (#1652)
* Add Rutoken Lite (#1728)
## SC-HSM
* Add SmartCard-HSM 4K ATR (#1681)
* Add missing secp384r1 curve parameter (#1696)
## Starcos
* Fixed decipher with 2.3 (#1496)
* Added ATR for 2nd gen. eGK (#1668)
* Added new ATR for 3.5 (#1882)
* Detect and allow Globalplatform PIN encoding (#1882)
## TCOS
* Fix TCOS IDKey support (#1880)
* add encryption certificate for IDKey (#1892)
## Infocamere, Postecert, Cnipa
* Removed profiles (#1584)
## ACS ACOS5
* Remove incomplete acos5 driver (#1622).
# New in 0.19.0; 2018-09-13
## General Improvements
* fixed multiple security problems (out of bound writes/reads, #1447):
* CVE-2018-16391
* CVE-2018-16392
* CVE-2018-16393
* CVE-2018-16418
* CVE-2018-16419
* CVE-2018-16420
* CVE-2018-16421
* CVE-2018-16422
* CVE-2018-16423
* CVE-2018-16424
* CVE-2018-16425
* CVE-2018-16426
* CVE-2018-16427
* Improved documentation:
* New manual page for opensc.conf(5)
* Added several missing switches in manual pages and fixed formatting
* Win32 installer:
* automatically start SCardSvr
* added newer OpenPGP ATRs
* macOS installer: use HFS+ for backward compatibility
* Remove outdated solaris files
* PC/SC driver:
* Workaround OMNIKEY 3x21 and 6121 Smart Card Readers wrongly identified as pinpad readers in macOS
* Workaround cards returning short signatures without leading zeroes
* bash completion
* make location directory configurable
* Use a new correct path by default
* build: support for libressl-2.7+
* Configuration
* Distribute minimal opensc.conf
* `pkcs11_enable_InitToken made` global configuration option
* Modify behavior of `OPENSC_DRIVER` environment variable to restrict driver list instead of forcing one driver and skipping vital parts of configuration
* Removed configuration options `zero_ckaid_for_ca_certs`, `force_card_driver`, `reopen_debug_file`, `paranoid-memory`
* Generalized configuration option `ignored_readers`
* If card initialization fails, continue card detection with other card drivers (#1251)
* Fixed long term card operations on Windows 8 and later (#1043)
* reader-pcsc: allow fixing the length of a PIN
* fixed multithreading issue on Window with OpenPACE OIDs
## PKCS#11
* fixed crash during `C_WaitForSlotEvent` (#1335)
## Minidriver
* Allow cancelling the PIN pad prompt before starting the reader transaction. Whether to start the transaction immediately or not is user-configurable for each application
## OpenSC tools
* `opensc-notify`
* add Exit button to tray icon
* User better description (GenericName) and a generic application icon
* Do not display in the application list
* `pkcs15-tool`
* added support for reading ECDSA ssh keys
* `p11test`
* Filter certificates other than `CKC_X_509`
* `opengpg-tool`
* allow calling -d multiple times
* clarify usage text
## sc-hsm
* Implement RSA PSS
* Add support for SmartCard-HSM 4K (V3.0)
## CAC
* Remove support for CAC1 cards
* Ignore unknown tags in properties buffer
* Use GET PROPERTIES to recognize buffer formats
* Unbreak encoding last tag-len-value in the data objects
* Support HID Alt tokens without CCC
* They present certificates in OIDs of first AID and use other undocumented applets
* Inspect the tokens through the ACA applet and GET ACR APDU
## Coolkey
* Unbreak Get Challenge functionality
* Make uninitialized cards working as expected with ESC
## OpenPGP
* add serial number to card name
* include detailed version into card name
* define & set LCS (lifecycle support) as extended capability
* extend manufacturer list in pkcs15-openpgp.c
* correctly parse hist_bytes
* Make deciphering with AUT-key possible for OpenPGP Card >v3.2 (fixes #1352)
* Add supported algorithms for OpenPGP Card (Fixes #1432)
## Starcos
* added support for 2nd generation eGK (#1451)
## CardOS
* create PIN in MF (`pkcs15init`)
## German ID card
* fixed identifying unknown card as German ID card (#1360)
## PIV
* Context Specific Login Using Pin Pad Reader Fix
* Better Handling of Reset using Discovery Object
# New in 0.18.0; 2018-05-16
## General Improvements
* PKCS#15
* fixed parsing ECC parameters from TokenInfo (#1134)
* Added PKCS#15 emulator for DIN 66291 profile
* Cope with empty serial number in TokenInfo
* Build Environment
* Treat compiler warnings as errors (use `--disable-strict` to avoid)
* MacOS
* optionally use CTK in package builder
* fixed detection of OpenPACE package
* macOS High Sierra: fixed dmg creation
* fixed DNIe UI compatibility
* Windows: Use Dedicated md/pkcs11 installation folders instead of installing to System32/SysWOW64
* fixed (possible) memory leaks for PIV, JPKI, PKCS#11, Minidriver
* fixed many issues reported via compiler warnings, coverity scan and clang's static analyzer
* beautify printed ASN.1 data, add support for ASN.1 time types
* SimpleTLV: Skip correctly two bytes after reading 2b size (#1231)
* added support for `keep_alive` commands for cards with multiple applets to be enabled via `opensc.conf`
* added support for bash completion for arguments that expect filenames
* added keyword `old` for selecting `card_drivers` via `opensc.conf`
* improved documentation manuals for OpenSC tools
* use `leave` as default for `disconnect_action` for PC/SC readers
## PKCS#11
* Make OpenSC PKCS#11 Vendor Defined attributes, mechanisms etc unique
## Minidriver
* added CNS ATR (#1153)
* Add multiple PINs support to minidriver
* protect MD entry points with `CriticalSection`
## Tokend
* Configuration value for not propagating certificates that require user authentication (`ignore_private_certificate`)
## CryptoTokenKit
* Added support for PIN pad
* fixed codesigning of opensc tools
* Added complete support for system integration with https://github.com/frankmorgner/OpenSCToken
## OpenSC Tools
* `cardos-tool`
* List human-readable version for CardOS 5.3
* `pkcs11-tool`
* fixed overwriting digestinfo + hash for RSA-PKCS Signature
* Enable support for RSA-PSS signatures in pkcs11-tool
* Add support for RSA-OAEP
* Fixed #1286
* Add missing pkcs11-tool options to man page
* allow mechanism to be specified in hexadecimal
* fixed default module path on Windows to use opensc-pkcs11.dll
* `pkcs11-spy`
* Add support for RSA-OAEP
* Add support for RSA-PSS
* `pkcs15init`
* Fix rutokenS FCP parsing (#1259)
* `egk-tool`
* Read data from German Health Care Card (Elektronische Gesundheitskarte, eGK)
* `opensc-asn1`
* Parse ASN.1 from files
* `opensc-tool`/`opensc-explorer`
* Allow extended APDUs
## Authentic
* Correctly handle APDUs with more than 256 bytes (#1205)
## Coolkey
* Copy labels from certificate objects to the keys
## Common Access Card
* Fixed infinite reading of certificate
* Added support for Alt token card
## MyEID
* support for RAW RSA signature for 2048 bit keys
## IAS/ECC
* Support for new MinInt agent card
## PIV
* Get cardholder name from the first certificate if token label not specified
* implemented keep alive command (#1256)
* fixed signature creation with `CKA_ALWAYS_AUTHENTICATE` (i.e. PKCS#11 `C_Login(CKU_CONTEXT_SPECIFIC)`)
## CardOS
* fixed card name for CardOS 5
* added ATR `"3b:d2:18:00:81:31:fe:58:c9:02:17"`
* Try forcing `max_send_size` for PSO:DEC
## DNIe
* DNIe: card also supports 1920 bits (#1247)
## GIDS
* Fix GIDS admin authentication
## epass 3000
* Add ECC support
* Fix #1073
* Fix #1115
* Fix buffer underrun in decipher
* Fix #1306
## Starcos
* added serial number for 3.4
* fixed setting key reference for 3.4
* added support for PIN status queries for 3.4
## EstEID
* ECDSA/ECDH token support
* Fix crash when certificate read failed (#1176)
* Cleanup expired EstEID card ATR-s
* Fix reading EstEID certificates with T=0 (#1193)
## OpenPGP
* Added support for PIN logout and status
* factory reset is possible if LCS is supported
* Added support for OpenPGP card V3
* fixed selecting Applet
* implemented keep alive command
* Retrieve OpenPGP applet version from OpenPGP applet on YubiKey token (#1262)
## German ID card
* fixed recognition of newer cards
## SC-HSM
* Don't block generic contactless ATR
* changed default labels of GoID
* added PIN commands for GoID 1.0
## Starcos
* Added Support for Starcos 3.4 and 3.5
## MioCOS
* disabled by default, use `card_drivers = old;` to enable; driver will be removed soon.
## BlueZ PKCS#15 applet
* disabled by default, use `card_drivers = old;` to enable; driver will be removed soon.
# New in 0.17.0; 2017-07-18
## Support for new Cards
* CAC (Common Access Card)
@ -75,7 +487,7 @@ NEWS for OpenSC -- History of user visible changes
* Fixed --id for `C_GenerateKey`, DES and DES3 keygen mechanism (#857)
* Added `--derive-pass-der` option
* Added `--generate-random` option
* Add GOSTR3410 keypair generation
* Add GOSTR3410 key pair generation
* `npa-tool` (new)
* Allows read/write access to EAC tokens
* Allows PIN management for EAC tokens
@ -180,7 +592,7 @@ New in 0.16.0; 2016-05-15
first support for Gids smart card
* dnie
* Feitian PKI card
new ATRs
new ATRs
* IsoApplet
(fixes)
* starcos
@ -203,7 +615,7 @@ New in 0.15.0; 2015-05-11
allow extended length APDUs
accept no output for 'SELECT' MF and 'SELECT' DF_NAME APDUs
fixed sc_driver_version check
adjusted send/receive size accoriding to card capabilities
adjusted send/receive size according to card capabilities
in iso7816 make SELECT agnosting to sc_path_t's aid
* asn1
support multi-bytes tags
@ -323,7 +735,7 @@ New in 0.14.0; 2014-05-31
ECC public key encoding
ECC ecpointQ
* pkcs15init
introduce 'max-unblocks' PIN init parameter
introduce 'max-unblocks' PIN init parameter
keep cert. blob in cert-info data
file 'content' and 'prop-attrs' in the card profile
in profile more AC operations are parsed
@ -345,7 +757,7 @@ New in 0.14.0; 2014-05-31
documentation for --list-token-slots
* default driver
do not send possibly arbitrary APDU-s to an unknown card.
by default 'default' card driver is disabled
by default 'default' card driver is disabled
* sc-hsm
Added support for
persistent EC public keys generated from certificate signing requests
@ -383,7 +795,7 @@ New in 0.14.0; 2014-05-31
* myeid
fixed file-id in myeid.profile
* entersafe
fix a bug when writing public key
fix a bug when writing public key
* EstEID
match card only based on presence of application.
* pteid
@ -483,7 +895,7 @@ New in 0.12.0; 2010-12-22
card initialized by Siemens software. Removed "--split-key" option,
as it is no longer needed.
* Improved debugging support: debug level 3 will show everything
except of ASN1 and card matching debugging (usualy not needed).
except of ASN1 and card matching debugging (usually not needed).
* Massive changes to libopensc. This library is now internal, only
used by opensc-pkcs11.so and command line tools. Header files are
no longer installed, library should not be used by other applications.
@ -498,7 +910,7 @@ New in 0.12.0; 2010-12-22
certificate for card label.
* Possibility to change the default behavior for card resets via
opensc.conf.
New in 0.11.12; 2009-12-18; Andreas Jellinghaus
* Document integer problem in OpenSC and implement workaround
* Improve entersafe profile to support private data objects
@ -529,12 +941,12 @@ New in 0.11.7; 2009-02-26; Andreas Jellinghaus
New in 0.11.6; 2008-08-27; Andreas Jellinghaus
* Improved security fix: don't match for "OpenSC" in the card label.
* New support for Feitian ePass3000 by Weitao Sun.
* GemSafeV1 improved to handle key_ref other than 3 by Douglas E. Engert
* GemSafeV1 improved to handle key_ref other than 3 by Douglas E. Engert
New in 0.11.5; 2008-07-31; Andreas Jellinghaus
* Apply security fix for cardos driver and extend pkcs15-tool to
test cards for the security vulnerability and update them.
* Build system rewritten (NOTICE: configure options was modified).
* Build system rewritten (NOTICE: configure options was modified).
The build system can produce outputs for *NIX, cygwin and native
windows (using mingw).
* ruToken now supported.

View File

@ -4,4 +4,23 @@ Wiki is [available online](https://github.com/OpenSC/OpenSC/wiki)
Please take a look at the documentation before trying to use OpenSC.
[![Travis CI Build Status](https://travis-ci.org/OpenSC/OpenSC.svg)](https://travis-ci.org/OpenSC/OpenSC/branches) [![AppVeyor CI Build Status](https://ci.appveyor.com/api/projects/status/github/OpenSC/OpenSC?branch=master&svg=true)](https://ci.appveyor.com/project/LudovicRousseau/OpenSC/branch/master) [![Coverity Scan Status](https://scan.coverity.com/projects/4026/badge.svg)](https://scan.coverity.com/projects/4026)
[![Linux build](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml/badge.svg)](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml)
[![OSX build](https://github.com/OpenSC/OpenSC/actions/workflows/macos.yml/badge.svg)](https://github.com/OpenSC/OpenSC/actions/workflows/macos.yml)
[![AppVeyor CI Build Status](https://ci.appveyor.com/api/projects/status/github/OpenSC/OpenSC?branch=master&svg=true)](https://ci.appveyor.com/project/LudovicRousseau/OpenSC/branch/master)
[![Coverity Scan Status](https://scan.coverity.com/projects/4026/badge.svg)](https://scan.coverity.com/projects/4026)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/OpenSC/OpenSC.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/OpenSC/OpenSC/context:cpp)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/opensc.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:opensc)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3908/badge)](https://bestpractices.coreinfrastructure.org/projects/3908)
Build and test status of specific cards:
| Cards | Status |
|---------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| CAC | [![CAC](https://gitlab.com/redhat-crypto/OpenSC/badges/cac/pipeline.svg)](https://gitlab.com/redhat-crypto/OpenSC/pipelines) |
| [virt_CACard](https://github.com/Jakuje/virt_cacard) | [![virt_CACard](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml/badge.svg)](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml) |
| [Coolkey](https://github.com/dogtagpki/coolkey/tree/master/applet) | [![Coolkey](https://gitlab.com/redhat-crypto/OpenSC/badges/coolkey/pipeline.svg)](https://gitlab.com/redhat-crypto/OpenSC/pipelines) |
| [PivApplet](https://github.com/arekinath/PivApplet) | [![PIV](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml/badge.svg)](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml) |
| [OpenPGP Applet](https://github.com/Yubico/ykneo-openpgp/) | [![OpenPGP](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml/badge.svg)](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml) |
| [GidsApplet](https://github.com/vletoux/GidsApplet/) | [![GIDS](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml/badge.svg)](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml) |
| [IsoApplet](https://github.com/philipWendland/IsoApplet/) | [![IsoApplet](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml/badge.svg)](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml) |
| [OsEID (MyEID)](https://sourceforge.net/projects/oseid/) | [![OsEID (MyEID)](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml/badge.svg)](https://github.com/OpenSC/OpenSC/actions/workflows/linux.yml) |

23
SECURITY.md Normal file
View File

@ -0,0 +1,23 @@
# Security Policy
## Supported Versions
OpenSC releases are made roughly once a year, unless important security is discovered.
OpenSC does not release micro updates for previously released versions and does not
backport security fixes into them.
| Version | Supported |
| -------- | ------------------ |
| 0.20.0 | :white_check_mark: |
| < 0.20.0 | :x: |
## Reporting a Vulnerability
If you discovered security vulnerability in supported version of OpenSC,
you can either fill an issue in [github](https://github.com/OpenSC/OpenSC/issues)
(note, that these issues are public!) or you can send email to any recently active
project developers frankmorgner(at)gmail.com, deengert(at)gmail.com and/or
jakuje(at)gmail.com .
You can expect update on the issue no later than in two weeks.

View File

@ -1,4 +1,4 @@
version: 0.17.0.{build}
version: 0.22.0.{build}
platform:
- x86
@ -6,12 +6,26 @@ platform:
configuration:
- Release
- Light-Release
- Light
environment:
GH_TOKEN:
secure: aLu3tFc7lRJbotnmnHLx/QruIHc5rLaGm1RttoEdy4QILlPXzVkCZ6loYMz0sfrY
PATH: C:\cygwin\bin;%PATH%
OPENPACE_VER: 1.1.1
ZLIB_VER_DOT: 1.2.11
matrix:
- VSVER: 14
- VSVER: 12
# not compatible with OpenSSL 1.1.1:
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
# VCVARSALL: "%VS120COMNTOOLS%/../../VC/vcvarsall.bat"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat"
DO_PUSH_ARTIFACT: yes
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
VCVARSALL: "%ProgramFiles(x86)%/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat"
# not compatible with WiX 3.11.2:
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
# VCVARSALL: "%ProgramFiles(x86)%/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvarsall.bat"
install:
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
@ -19,23 +33,21 @@ install:
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }
- date /T & time /T
- set PATH=C:\cygwin\bin;%PATH%
- set OPENPACE_VER=1.0.3
- set ZLIB_VER_DOT=1.2.11
- ps: $env:PACKAGE_NAME=(git describe --tags)
- ps: $env:PACKAGE_NAME=(git describe --tags --abbrev=0)
- ps: >-
If ($env:Platform -Match "x86") {
$env:VCVARS_PLATFORM="x86"
$env:OPENSSL_PF="Win32"
$env:ARTIFACT="OpenSC-win32_vs${env:VSVER}-${env:CONFIGURATION}"
$env:ARTIFACT="OpenSC-${env:PACKAGE_NAME}_win32"
} Else {
$env:VCVARS_PLATFORM="amd64"
$env:OPENSSL_PF="Win64"
$env:ARTIFACT="OpenSC-win64_vs${env:VSVER}-${env:CONFIGURATION}"
$env:ARTIFACT="OpenSC-${env:PACKAGE_NAME}_win64"
}
- ps: >-
If (!($env:Configuration -Like "*Light*")) {
$env:NMAKE_EXTRA="OPENSSL_DEF=/DENABLE_OPENSSL ${env:NMAKE_EXTRA}"
If ($env:Configuration -Like "*Light*") {
$env:ARTIFACT+="-Light"
} Else {
$env:NMAKE_EXTRA+=" OPENSSL_DEF=/DENABLE_OPENSSL OPENSSL_DIR=C:\OpenSSL-v111-${env:OPENSSL_PF}"
$env:NMAKE_EXTRA+=" OPENSSL_EXTRA_CFLAGS=/DOPENSSL_SECURE_MALLOC_SIZE=65536"
If (!(Test-Path C:\zlib )) {
appveyor DownloadFile "https://github.com/madler/zlib/archive/v${env:ZLIB_VER_DOT}.zip" -FileName zlib.zip
7z x zlib.zip -oC:\
@ -47,13 +59,12 @@ install:
Rename-Item -path "c:\openpace-${env:OPENPACE_VER}" -newName "openpace"
}
}
If (!(Test-Path cngsdk.msi )) {
appveyor DownloadFile "http://download.microsoft.com/download/2/C/9/2C93059C-0532-42DF-8C24-9AEAFF00768E/cngsdk.msi"
If (!(Test-Path cpdksetup.exe )) {
appveyor DownloadFile "https://download.microsoft.com/download/1/7/6/176909B0-50F2-4DF3-B29B-830A17EA7E38/CPDK_RELEASE_UPDATE/cpdksetup.exe"
}
- ps: $env:VSCOMNTOOLS=(Get-Content ("env:VS" + "$env:VSVER" + "0COMNTOOLS"))
- echo "Using Visual Studio %VSVER%.0 at %VSCOMNTOOLS%"
- call "%VSCOMNTOOLS%\..\..\VC\vcvarsall.bat" %VCVARS_PLATFORM%
- cngsdk.msi /quiet
- echo "Using %APPVEYOR_BUILD_WORKER_IMAGE% with %VCVARSALL%"
- call "%VCVARSALL%" %Platform%
- cpdksetup.exe /quiet
- uname -a
- set
@ -65,43 +76,49 @@ build_script:
xcopy C:\zlib C:\zlib-${env:OPENSSL_PF} /e /i /y /s
cd C:\zlib-${env:OPENSSL_PF}
(Get-Content win32/Makefile.msc).replace('-MD', '-MT') | Set-Content win32/Makefile.msc
If ($env:Platform -Match "x86") {
nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="inffas32.obj match686.obj" zlib.lib
} Else {
nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." OBJA="inffasx64.obj gvmat64.obj inffas8664.obj" zlib.lib
}
nmake /nologo -f win32/Makefile.msc zlib.lib
}
$env:NMAKE_EXTRA="ZLIBSTATIC_DEF=/DENABLE_ZLIB_STATIC ZLIB_INCL_DIR=/IC:\zlib-${env:OPENSSL_PF} ZLIB_LIB=C:\zlib-${env:OPENSSL_PF}\zlib.lib ${env:NMAKE_EXTRA}"
$env:NMAKE_EXTRA+=" ZLIBSTATIC_DEF=/DENABLE_ZLIB_STATIC ZLIB_INCL_DIR=/IC:\zlib-${env:OPENSSL_PF} ZLIB_LIB=C:\zlib-${env:OPENSSL_PF}\zlib.lib"
If (!(Test-Path -Path "C:\openpace-${env:OPENSSL_PF}" )) {
# build libeac.lib as a static library
xcopy C:\openpace C:\openpace-${env:OPENSSL_PF} /e /i /y /s
cd C:\openpace-${env:OPENSSL_PF}\src
# OpenSSL 1.1.0
#cl /IC:\OpenSSL-${env:OPENSSL_PF}\include /I. /DX509DIR=\`"/\`" /DCVCDIR=\`"/\`" /W3 /D_CRT_SECURE_NO_DEPRECATE /DWIN32_LEAN_AND_MEAN /GS /MT /DHAVE_ASN1_STRING_GET0_DATA=1 /DHAVE_DECL_OPENSSL_ZALLOC=1 /DHAVE_DH_GET0_KEY=1 /DHAVE_DH_GET0_PQG=1 /DHAVE_DH_SET0_KEY=1 /DHAVE_DH_SET0_PQG=1 /DHAVE_ECDSA_SIG_GET0=1 /DHAVE_ECDSA_SIG_SET0=1 /DHAVE_EC_KEY_METHOD=1 /DHAVE_RSA_GET0_KEY=1 /DHAVE_RSA_SET0_KEY=1 /c ca_lib.c cv_cert.c cvc_lookup.c x509_lookup.c eac_asn1.c eac.c eac_ca.c eac_dh.c eac_ecdh.c eac_kdf.c eac_lib.c eac_print.c eac_util.c misc.c pace.c pace_lib.c pace_mappings.c ri.c ri_lib.c ta.c ta_lib.c objects.c ssl_compat.c
#cl /nologo /IC:\OpenSSL-v110-${env:OPENSSL_PF}\include /I. /DX509DIR=\`"/\`" /DCVCDIR=\`"/\`" /W3 /D_CRT_SECURE_NO_DEPRECATE /DWIN32_LEAN_AND_MEAN /GS /MT /DHAVE_ASN1_STRING_GET0_DATA=1 /DHAVE_DECL_OPENSSL_ZALLOC=1 /DHAVE_DH_GET0_KEY=1 /DHAVE_DH_GET0_PQG=1 /DHAVE_DH_SET0_KEY=1 /DHAVE_DH_SET0_PQG=1 /DHAVE_ECDSA_SIG_GET0=1 /DHAVE_ECDSA_SIG_SET0=1 /DHAVE_EC_KEY_METHOD=1 /DHAVE_RSA_GET0_KEY=1 /DHAVE_RSA_SET0_KEY=1 /c ca_lib.c cv_cert.c cvc_lookup.c x509_lookup.c eac_asn1.c eac.c eac_ca.c eac_dh.c eac_ecdh.c eac_kdf.c eac_lib.c eac_print.c eac_util.c misc.c pace.c pace_lib.c pace_mappings.c ri.c ri_lib.c ta.c ta_lib.c objects.c ssl_compat.c
# OpenSSL 1.1.1
cl /nologo /IC:\OpenSSL-v111-${env:OPENSSL_PF}\include /I. /DX509DIR=\`"/\`" /DCVCDIR=\`"/\`" /W3 /D_CRT_SECURE_NO_DEPRECATE /DWIN32_LEAN_AND_MEAN /GS /MT /DHAVE_ASN1_STRING_GET0_DATA=1 /DHAVE_DECL_OPENSSL_ZALLOC=1 /DHAVE_DH_GET0_KEY=1 /DHAVE_DH_GET0_PQG=1 /DHAVE_DH_SET0_KEY=1 /DHAVE_DH_SET0_PQG=1 /DHAVE_ECDSA_SIG_GET0=1 /DHAVE_ECDSA_SIG_SET0=1 /DHAVE_EC_KEY_METHOD=1 /DHAVE_RSA_GET0_KEY=1 /DHAVE_RSA_SET0_KEY=1 /DHAVE_EC_POINT_GET_AFFINE_COORDINATES=1 /DHAVE_EC_POINT_SET_AFFINE_COORDINATES=1 /c ca_lib.c cv_cert.c cvc_lookup.c x509_lookup.c eac_asn1.c eac.c eac_ca.c eac_dh.c eac_ecdh.c eac_kdf.c eac_lib.c eac_print.c eac_util.c misc.c pace.c pace_lib.c pace_mappings.c ri.c ri_lib.c ta.c ta_lib.c objects.c ssl_compat.c
# OpenSSL 1.0.2
cl /IC:\OpenSSL-${env:OPENSSL_PF}\include /I. /DX509DIR=\`"/\`" /DCVCDIR=\`"/\`" /W3 /D_CRT_SECURE_NO_DEPRECATE /DWIN32_LEAN_AND_MEAN /GS /MT /c ca_lib.c cv_cert.c cvc_lookup.c x509_lookup.c eac_asn1.c eac.c eac_ca.c eac_dh.c eac_ecdh.c eac_kdf.c eac_lib.c eac_print.c eac_util.c misc.c pace.c pace_lib.c pace_mappings.c ri.c ri_lib.c ta.c ta_lib.c objects.c ssl_compat.c
lib /out:libeac.lib ca_lib.obj cv_cert.obj cvc_lookup.obj x509_lookup.obj eac_asn1.obj eac.obj eac_ca.obj eac_dh.obj eac_ecdh.obj eac_kdf.obj eac_lib.obj eac_print.obj eac_util.obj misc.obj pace.obj pace_lib.obj pace_mappings.obj ri.obj ri_lib.obj ta.obj ta_lib.obj objects.obj ssl_compat.obj
#cl /nologo /IC:\OpenSSL-${env:OPENSSL_PF}\include /I. /DX509DIR=\`"/\`" /DCVCDIR=\`"/\`" /W3 /D_CRT_SECURE_NO_DEPRECATE /DWIN32_LEAN_AND_MEAN /GS /MT /c ca_lib.c cv_cert.c cvc_lookup.c x509_lookup.c eac_asn1.c eac.c eac_ca.c eac_dh.c eac_ecdh.c eac_kdf.c eac_lib.c eac_print.c eac_util.c misc.c pace.c pace_lib.c pace_mappings.c ri.c ri_lib.c ta.c ta_lib.c objects.c ssl_compat.c
lib /nologo /out:libeac.lib ca_lib.obj cv_cert.obj cvc_lookup.obj x509_lookup.obj eac_asn1.obj eac.obj eac_ca.obj eac_dh.obj eac_ecdh.obj eac_kdf.obj eac_lib.obj eac_print.obj eac_util.obj misc.obj pace.obj pace_lib.obj pace_mappings.obj ri.obj ri_lib.obj ta.obj ta_lib.obj objects.obj ssl_compat.obj
cd C:\projects\OpenSC
}
$env:NMAKE_EXTRA="OPENPACE_DEF=/DENABLE_OPENPACE OPENPACE_DIR=C:\openpace-${env:OPENSSL_PF} ${env:NMAKE_EXTRA}"
$env:NMAKE_EXTRA+=" OPENPACE_DEF=/DENABLE_OPENPACE OPENPACE_DIR=C:\openpace-${env:OPENSSL_PF}"
}
- bash -c "exec 0</dev/null && ./bootstrap"
- bash -c "exec 0</dev/null && if [ \"$APPVEYOR_REPO_BRANCH\" == \"master\" -a -z \"$APPVEYOR_PULL_REQUEST_NUMBER\" ]; then ./bootstrap; fi"
- bash -c "exec 0</dev/null && if [ \"$APPVEYOR_REPO_BRANCH\" == \"master\" -a -n \"$APPVEYOR_PULL_REQUEST_NUMBER\" ]; then ./bootstrap.ci -s \"-pr$APPVEYOR_PULL_REQUEST_NUMBER\"; fi"
- bash -c "exec 0</dev/null && if [ \"$APPVEYOR_REPO_BRANCH\" != \"master\" -a -z \"$APPVEYOR_PULL_REQUEST_NUMBER\" ]; then ./bootstrap.ci -s \"-$APPVEYOR_REPO_BRANCH\"; fi"
- bash -c "exec 0</dev/null && if [ \"$APPVEYOR_REPO_BRANCH\" != \"master\" -a -n \"$APPVEYOR_PULL_REQUEST_NUMBER\" ]; then ./bootstrap.ci -s \"-$APPVEYOR_REPO_BRANCH-prAPPVEYOR_PULL_REQUEST_NUMBER\"; fi"
# disable features to speed up the script
- bash -c "exec 0</dev/null && ./configure --disable-openssl --disable-readline --disable-zlib || cat config.log"
- bash -c "make -C etc opensc.conf"
- cp win32/winconfig.h config.h
- bash -c "exec 0</dev/null && ./configure --with-cygwin-native --disable-openssl --disable-readline --disable-zlib || cat config.log"
- bash -c "exec 0</dev/null && rm src/getopt.h"
- nmake /f Makefile.mak %NMAKE_EXTRA%
- cd win32 && nmake /f Makefile.mak %NMAKE_EXTRA% VSVER=%VSVER% OpenSC.msi
- move OpenSC.msi %ARTIFACT%.msi
- appveyor PushArtifact %ARTIFACT%.msi
- cd win32 && nmake /nologo /f Makefile.mak %NMAKE_EXTRA% OpenSC.msi && cd ..
- move win32\OpenSC.msi %ARTIFACT%.msi
# put all pdb files for dump analysis, but this consumes approx 100 MB per build
- md %ARTIFACT%-Debug
- ps: >-
Get-ChildItem -recurse C:\projects\OpenSC -exclude vc*.pdb *.pdb | % {
7z a -tzip ${env:ARTIFACT}-Debug.zip $_.FullName
}
- appveyor PushArtifact %ARTIFACT%.msi
- appveyor PushArtifact %ARTIFACT%-Debug.zip
deploy_script:
# keep in sync with .travis.yml
- bash -c "git config --global user.email 'no-reply@appveyor.com'"
- bash -c "git config --global user.name 'AppVeyor'"
- bash -c "if [ \"$DO_PUSH_ARTIFACT\" = yes -a -z \"$APPVEYOR_PULL_REQUEST_NUMBER\" -a \"$APPVEYOR_REPO_NAME\" = \"OpenSC/OpenSC\" ]; then .github/push_artifacts.sh \"AppVeyor build ${APPVEYOR_BUILD_NUMBER}.${APPVEYOR_JOB_NUMBER}\"; fi"
cache:
- C:\zlib -> appveyor.yml
- C:\zlib-Win32 -> appveyor.yml
@ -109,18 +126,4 @@ cache:
- C:\openpace -> appveyor.yml
- C:\openpace-Win32 -> appveyor.yml
- C:\openpace-Win64 -> appveyor.yml
- cngsdk.msi -> appveyor.yml
deploy:
- provider: GitHub
tag: $(APPVEYOR_REPO_TAG_NAME)
release: OpenSC-$(APPVEYOR_REPO_TAG_NAME)
description: 'release OpenSC $(APPVEYOR_REPO_TAG_NAME)'
auth_token:
secure: NGaTqWohBQa7fgE62rEm2sp9jkv6S9FRc3YEi3T5CpaoyIY6K89FJjqzaoPLr8vj
artifact: /OpenSC-.*\.msi/
draft: false
prerelease: true
on:
branch: /0.16.0-rc.*/ # here branch is release tag
appveyor_repo_tag: true # deploy on tag push only
- cpdksetup.exe -> appveyor.yml

View File

@ -10,19 +10,12 @@ OPTIONS:
-h Show this message
-s Package suffix
-S Use package suffix as 'g' appended with the date of last commit
-r Package version revision
-R Use package version revision as Git commit number from 'git describe' result
-b Package branch
-B Use package branch as current Git branch
EOF
}
SUFFIX=
REVISION=
VERBOSE=
KEEPVERSION=
while getopts “:hs:Sr:RK” OPTION
while getopts “:hs:S” OPTION
do
case $OPTION in
h)
@ -35,12 +28,6 @@ do
S)
SUFFIX=g`git log -1 --pretty=fuller --date=iso | grep CommitDate: | sed -E 's/^CommitDate:\s(.*)/\1/' | sed -E 's/(.*)-(.*)-(.*) (.*):(.*):(.*)\s+.*/\1\2\3\4\5\6/'`
;;
r)
REVISION=$OPTARG
;;
R)
REVISION=`git describe | perl -ne 'print $1 if /^[\.0-9]*-([0-9]*)-g[a-z0-9]*$/;'`
;;
?)
usage
exit
@ -49,31 +36,17 @@ do
done
set -e
set -x
if [ -f Makefile ]; then
make distclean
fi
rm -rf *~ *.cache config.guess config.log config.status config.sub depcomp ltmain.sh version.m4.ci
if [ -n "$SUFFIX" ] || [ -n "$REVISION" ]
if [ -n "$SUFFIX" ]
then
cp -a version.m4 version.m4.tmp
if [ -n "$SUFFIX" ]
then
echo Set package suffix "$SUFFIX"
sed 's/^define(\[PACKAGE_SUFFIX\],\s*\[\([-~]*[0-9a-zA-Z]*\)\])$/define(\[PACKAGE_SUFFIX\], \['$SUFFIX'\])/g' version.m4.tmp > version.m4.ci
cp version.m4.ci version.m4.tmp
fi
if [ -n "$REVISION" ]
then
echo Set package revision "$REVISION"
sed 's/^define(\[PACKAGE_VERSION_REVISION\],\s*\[\([-~]*[0-9a-zA-Z]*\)\])$/define(\[PACKAGE_VERSION_REVISION\], \['$REVISION'\])/g' version.m4.tmp > version.m4.ci
fi
rm -f version.m4.tmp
echo Set package suffix "$SUFFIX"
sed 's/^define(\[PACKAGE_SUFFIX\],\s*\[\([-~]*[0-9a-zA-Z]*\)\])$/define(\[PACKAGE_SUFFIX\], \['$SUFFIX'\])/g' < version.m4 > version.m4.ci
fi
./bootstrap

View File

@ -1,12 +1,13 @@
dnl -*- mode: m4; -*-
AC_PREREQ(2.60)
AC_PREREQ(2.68)
define([PRODUCT_NAME], [OpenSC])
define([PRODUCT_TARNAME], [opensc])
define([PRODUCT_BUGREPORT], [https://github.com/OpenSC/OpenSC/issues])
define([PRODUCT_URL], [https://github.com/OpenSC/OpenSC])
define([PACKAGE_VERSION_MAJOR], [0])
define([PACKAGE_VERSION_MINOR], [18])
define([PACKAGE_VERSION_MINOR], [22])
define([PACKAGE_VERSION_FIX], [0])
define([PACKAGE_SUFFIX], [])
@ -18,14 +19,15 @@ define([VS_FF_PRODUCT_NAME], [OpenSC smartcard framework])
define([VS_FF_PRODUCT_UPDATES], [https://github.com/OpenSC/OpenSC/releases])
define([VS_FF_PRODUCT_URL], [https://github.com/OpenSC/OpenSC])
m4_include(version.m4)
m4_sinclude(version.m4.ci)
AC_INIT([PRODUCT_NAME],[PACKAGE_VERSION_MAJOR.PACKAGE_VERSION_MINOR.PACKAGE_VERSION_FIX[]PACKAGE_SUFFIX],[PRODUCT_BUGREPORT],[PRODUCT_TARNAME])
m4_define([openssl_minimum_version], [1.0.1])
AC_INIT([PRODUCT_NAME],[PACKAGE_VERSION_MAJOR.PACKAGE_VERSION_MINOR.PACKAGE_VERSION_FIX[]PACKAGE_SUFFIX],[PRODUCT_BUGREPORT],[PRODUCT_TARNAME],[PRODUCT_URL])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE(foreign 1.10)
AM_INIT_AUTOMAKE(foreign 1.10 [subdir-objects])
OPENSC_VERSION_MAJOR="PACKAGE_VERSION_MAJOR"
OPENSC_VERSION_MINOR="PACKAGE_VERSION_MINOR"
@ -41,10 +43,10 @@ OPENSC_VS_FF_PRODUCT_URL="VS_FF_PRODUCT_URL"
# LT Version numbers, remember to change them just *before* a release.
# (Code changed: REVISION++)
# (Oldest interface removed: OLDEST++)
# (Oldest interface changed/removed: OLDEST++)
# (Interfaces added: CURRENT++, REVISION=0)
OPENSC_LT_CURRENT="6"
OPENSC_LT_OLDEST="6"
OPENSC_LT_CURRENT="8"
OPENSC_LT_OLDEST="8"
OPENSC_LT_REVISION="0"
OPENSC_LT_AGE="0"
OPENSC_LT_AGE="$((${OPENSC_LT_CURRENT}-${OPENSC_LT_OLDEST}))"
@ -77,7 +79,7 @@ AC_ARG_WITH(
)
if test "${enable_optimization}" = "no"; then
CFLAGS="-O0 -g"
CFLAGS="${CFLAGS} -O0 -g"
fi
dnl Check for some target-specific stuff
@ -104,7 +106,6 @@ case "${host}" in
WIN32="yes"
else
AC_MSG_RESULT([Using cygwin])
CPPFLAGS="${CPPFLAGS} -DCRYPTOKI_FORCE_WIN32"
WIN_LIBPREFIX="cyg"
AC_DEFINE([USE_CYGWIN], [1], [Define if you are on Cygwin])
fi
@ -123,9 +124,6 @@ case "${host}" in
PROFILE_DIR_DEFAULT="\$(pkgdatadir)"
;;
esac
AC_DEFINE_UNQUOTED([DEBUG_FILE], ["${DEBUG_FILE}"], [Debug file])
AC_DEFINE_UNQUOTED([PROFILE_DIR], ["${PROFILE_DIR}"], [Directory of profiles])
AC_DEFINE_UNQUOTED([PROFILE_DIR_DEFAULT], ["${PROFILE_DIR_DEFAULT}"], [Default directory of profiles])
case "${host}" in
*-mingw*)
@ -133,9 +131,20 @@ case "${host}" in
;;
esac
AX_CHECK_COMPILE_FLAG(-Wunknown-warning-option, [have_unknown_warning_option="yes"], [have_unknown_warning_option="no"], [-Werror])
AX_CODE_COVERAGE()
AX_CHECK_COMPILE_FLAG([-Wunknown-warning-option], [have_unknown_warning_option="yes"], [have_unknown_warning_option="no"])
AM_CONDITIONAL([HAVE_UNKNOWN_WARNING_OPTION], [test "${have_unknown_warning_option}" = "yes"])
AC_ARG_ENABLE(
[fuzzing],
[AS_HELP_STRING([--enable-fuzzing],[enable compile of fuzzing tests @<:@disabled@:>@, note that CFLAGS and FUZZING_LIBS should be set accordingly, e.g. to something like CFLAGS="-fsanitize=address,fuzzer" FUZZING_LIBS="-fsanitize=fuzzer"])],
,
[enable_fuzzing="no"]
)
AC_ARG_VAR([FUZZING_LIBS], [linker flags for fuzzing])
AC_ARG_ENABLE(
[strict],
[AS_HELP_STRING([--disable-strict],[disable strict compile mode @<:@enabled@:>@])],
@ -173,11 +182,18 @@ AC_ARG_ENABLE(
AC_ARG_ENABLE(
[openssl],
[AS_HELP_STRING([--enable-openssl],[enable openssl linkage @<:@detect@:>@])],
[AS_HELP_STRING([--enable-openssl],[enable OpenSSL linkage @<:@detect@:>@])],
,
[enable_openssl="detect"]
)
AC_ARG_ENABLE([openssl-secure-malloc],
[AS_HELP_STRING([--openssl-secure-malloc=<SIZE_IN_BYTES>],
[Enable OpenSSL secure memory by specifying its size in bytes, must be a power of 2 @<:@disabled@:>@])],
[], [enable_openssl_secure_malloc=no])
AS_IF([test $enable_openssl_secure_malloc != no],
[AC_DEFINE_UNQUOTED([OPENSSL_SECURE_MALLOC_SIZE],[$enable_openssl_secure_malloc],[Size of OpenSSL secure memory in bytes, must be a power of 2])])
AC_ARG_ENABLE(
[openpace],
[AS_HELP_STRING([--enable-openpace],[enable OpenPACE linkage @<:@detect@:>@])],
@ -255,6 +271,20 @@ AC_ARG_ENABLE(
[enable_notify="detect"]
)
AC_ARG_ENABLE(
[autostart-items],
[AS_HELP_STRING([--enable-autostart-items],[enable autostart items @<:@enabled@:>@])],
,
[enable_autostart="yes"]
)
AC_ARG_ENABLE(
[cmocka],
[AS_HELP_STRING([--enable-cmocka],[Build tests in src/tests/p11test directory @<:@detect@:>@])],
,
[enable_cmocka="detect"]
)
AC_ARG_WITH(
[xsl-stylesheetsdir],
[AS_HELP_STRING([--with-xsl-stylesheetsdir=PATH],[docbook xsl-stylesheets for svn build @<:@detect@:>@])],
@ -262,6 +292,13 @@ AC_ARG_WITH(
[xslstylesheetsdir="detect"]
)
AC_ARG_WITH(
[completiondir],
[AS_HELP_STRING([--with-completiondir=PATH],[Directory of Bash completion @<:@detect@:>@])],
[completiondir="${withval}"],
[completiondir="detect"]
)
AC_ARG_WITH(
[pcsc-provider],
[AS_HELP_STRING([--with-pcsc-provider=PATH],[Path to system pcsc provider @<:@system default@:>@])],
@ -333,7 +370,6 @@ AC_MSG_RESULT([${xslstylesheetsdir}])
AC_MSG_CHECKING([git checkout])
GIT_CHECKOUT="no"
if test -n "${GIT}" -a -d "${srcdir}/.git"; then
AC_DEFINE([HAVE_CONFIG_VERSION_H], [1], [extra version available in config-version.h])
GIT_CHECKOUT="yes"
fi
AC_MSG_RESULT([${GIT_CHECKOUT}])
@ -358,20 +394,19 @@ dnl C Compiler features
AC_C_INLINE
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_ASSERT
AC_CHECK_HEADERS([ \
errno.h fcntl.h stdlib.h \
inttypes.h string.h strings.h \
sys/time.h unistd.h getopt.h sys/mman.h
sys/time.h unistd.h sys/mman.h \
sys/endian.h endian.h
])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_UID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
dnl Checks for library functions.
AC_FUNC_ERROR_AT_LINE
@ -379,9 +414,22 @@ AC_FUNC_STAT
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([ \
getpass gettimeofday getline memset mkdir \
strdup strerror getopt_long getopt_long_only \
strlcpy strlcat strnlen sigaction
strdup strerror memset_s explicit_bzero \
strnlen sigaction
])
# Do not check for strlcpy and strlcat in Linux because it is not implemented
# and autotools can not detect it in AC_CHECK_DECLS because build does not fail
# in this test.
# https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22192
case "${host_os}" in
linux*)
;;
*)
AC_CHECK_DECLS([strlcpy, strlcat], [], [], [[#include <string.h>]])
;;
esac
AC_CHECK_SIZEOF(void *)
if test "${ac_cv_sizeof_void_p}" = 8; then
LIBRARY_BITNESS="64"
@ -511,6 +559,15 @@ if test "${enable_notify}" = "yes"; then
fi
fi
have_cmocka="yes"
PKG_CHECK_MODULES([CMOCKA], [cmocka >= 1.0.1],,[have_cmocka="no"])
AC_CHECK_HEADER([setjmp.h])
AC_CHECK_HEADER([cmocka.h],, [have_cmocka="no"],
[#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
])
AC_ARG_VAR([ZLIB_CFLAGS], [C compiler flags for zlib])
AC_ARG_VAR([ZLIB_LIBS], [linker flags for zlib])
if test -z "${ZLIB_LIBS}"; then
@ -591,21 +648,16 @@ fi
PKG_CHECK_MODULES(
[OPENSSL],
[libcrypto >= 0.9.7],
[libcrypto >= openssl_minimum_version],
[have_openssl="yes"],
[PKG_CHECK_MODULES(
[OPENSSL],
[openssl >= 0.9.7],
[have_openssl="yes"],
[AC_CHECK_LIB(
[crypto],
[RSA_version],
[
have_openssl="yes"
OPENSSL_LIBS="-lcrypto"
],
[have_openssl="no"]
)]
[AC_CHECK_LIB(
[crypto],
[RSA_version],
[
have_openssl="yes"
OPENSSL_LIBS="-lcrypto"
],
[have_openssl="no"]
)]
)
@ -637,6 +689,20 @@ else
OPENSSL_LIBS=""
fi
if test "${enable_cmocka}" = "detect"; then
if test "${have_cmocka}" = "yes" -a "${have_openssl}" = "yes"; then
enable_cmocka="yes"
else
enable_cmocka="no"
fi
fi
if test "${enable_cmocka}" = "yes"; then
if test "${have_cmocka}" != "yes"; then
AC_MSG_ERROR([Tests required, but cmocka is not available])
fi
fi
PKG_CHECK_EXISTS([libeac], [PKG_CHECK_MODULES([OPENPACE], [libeac >= 0.9])],
@ -661,7 +727,7 @@ LIBS="$saved_LIBS"
AC_ARG_ENABLE(cvcdir,
AC_HELP_STRING([--enable-cvcdir=DIR],
AS_HELP_STRING([--enable-cvcdir=DIR],
[directory containing CV certificates (default is determined by libeac)]),
[cvcdir="${enableval}"],
[cvcdir=false])
@ -683,7 +749,7 @@ AC_SUBST(CVCDIR)
AC_DEFINE_UNQUOTED([CVCDIR], ["${CVCDIR}"], [CVC directory])
AC_ARG_ENABLE(x509dir,
AC_HELP_STRING([--enable-x509dir=DIR],
AS_HELP_STRING([--enable-x509dir=DIR],
[directory containing X.509 certificates (default is determined by libeac)]),
[x509dir="${enableval}"],
[x509dir=false])
@ -810,6 +876,14 @@ if test "${enable_cryptotokenkit}" = "yes"; then
AC_DEFINE([ENABLE_CRYPTOTOKENKIT], [1], [Define if CryptoTokenKit is to be enabled])
fi
if test "${completiondir}" = "detect"; then
echo completion ${completiondir}
PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
[completiondir="`pkg-config --variable=completionsdir bash-completion`"],
[completiondir="${sysconfdir}/bash_completion.d"])
fi
AC_SUBST([completiondir])
AC_SUBST(DYN_LIB_EXT)
AC_SUBST(LIBDIR)
@ -833,26 +907,26 @@ if test "${enable_sm}" = "yes"; then
DEFAULT_SM_MODULE="${LIB_PRE}smm-local${DYN_LIB_EXT}"
case "${host}" in
*-mingw*|*-winnt*|*-cygwin*)
DEFAULT_SM_MODULE_PATH="\# module_path = \"\";"
DEFAULT_SM_MODULE_PATH="%PROGRAMFILES%\\\OpenSC Project\\\OpenSC\\\tools"
;;
*)
DEFAULT_SM_MODULE_PATH="module_path = \$(libdir);"
DEFAULT_SM_MODULE_PATH="${libdir}"
;;
esac
AC_DEFINE_UNQUOTED([DEFAULT_SM_MODULE], ["${DEFAULT_SM_MODULE}"], [Default SM module])
AC_DEFINE_UNQUOTED([DEFAULT_SM_MODULE_PATH], ["${DEFAULT_SM_MODULE_PATH}"], [Default SM module path])
fi
if test "${with_pkcs11_provider}" = "detect"; then
if test "${WIN32}" != "yes"; then
DEFAULT_PKCS11_PROVIDER="opensc-pkcs11${DYN_LIB_EXT}"
DEFAULT_PKCS11_PROVIDER="${libdir}/opensc-pkcs11${DYN_LIB_EXT}"
DEFAULT_ONEPIN_PKCS11_PROVIDER="${libdir}/onepin-opensc-pkcs11${DYN_LIB_EXT}"
else
DEFAULT_PKCS11_PROVIDER="%PROGRAMFILES%\\\OpenSC Project\\\OpenSC\\\pkcs11\\\opensc-pkcs11.dll"
DEFAULT_ONEPIN_PKCS11_PROVIDER="%PROGRAMFILES%\\\OpenSC Project\\\OpenSC\\\pkcs11\\\onepin-opensc-pkcs11.dll"
fi
else
DEFAULT_PKCS11_PROVIDER="${with_pkcs11_provider}"
DEFAULT_ONEPIN_PKCS11_PROVIDER="${with_pkcs11_provider}"
fi
AC_DEFINE_UNQUOTED([DEFAULT_PKCS11_PROVIDER], ["${DEFAULT_PKCS11_PROVIDER}"], [Default PKCS11 provider])
if test "${enable_man}" = "detect"; then
if test "${WIN32}" = "yes"; then
@ -871,12 +945,16 @@ if test "${enable_man}" = "yes" -o "${enable_doc}" = "yes"; then
AC_MSG_RESULT([ok])
fi
AC_ARG_VAR([HELP2MAN],
[absolute path to help2man used for man page generation of npa-tool])
AC_PATH_PROG(HELP2MAN, help2man, not found)
AC_ARG_VAR([GENGETOPT],
[absolute path to gengetopt used for command line parsing of npa-tool])
AC_PATH_PROG(GENGETOPT, gengetopt, not found)
AC_ARG_VAR([CLANGTIDY],
[absolute path to clang-tidy used for static code analysis])
AC_PATH_PROG(CLANGTIDY, clang-tidy, not found)
TIDY_CHECKS="-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
AX_FUNC_GETOPT_LONG
#AH_BOTTOM([#include "common/compat_getopt.h"])
OPENSC_FEATURES=""
if test "${enable_thread_locking}" = "yes"; then
@ -963,6 +1041,7 @@ AC_SUBST([OPENSC_LT_OLDEST])
AC_SUBST([WIN_LIBPREFIX])
AC_SUBST([DEFAULT_PCSC_PROVIDER])
AC_SUBST([DEFAULT_PKCS11_PROVIDER])
AC_SUBST([DEFAULT_ONEPIN_PKCS11_PROVIDER])
AC_SUBST([OPTIONAL_ZLIB_CFLAGS])
AC_SUBST([OPTIONAL_ZLIB_LIBS])
AC_SUBST([OPTIONAL_READLINE_CFLAGS])
@ -980,6 +1059,7 @@ AC_SUBST([PROFILE_DIR])
AC_SUBST([PROFILE_DIR_DEFAULT])
AC_SUBST([OPTIONAL_NOTIFY_CFLAGS])
AC_SUBST([OPTIONAL_NOTIFY_LIBS])
AC_SUBST([TIDY_CHECKS])
AM_CONDITIONAL([ENABLE_MAN], [test "${enable_man}" = "yes"])
AM_CONDITIONAL([ENABLE_THREAD_LOCKING], [test "${enable_thread_locking}" = "yes"])
@ -997,21 +1077,28 @@ AM_CONDITIONAL([ENABLE_MINIDRIVER_SETUP_CUSTOMACTION], [test "${enable_minidrive
AM_CONDITIONAL([ENABLE_SM], [test "${enable_sm}" = "yes"])
AM_CONDITIONAL([ENABLE_DNIE_UI], [test "${enable_dnie_ui}" = "yes"])
AM_CONDITIONAL([ENABLE_NPATOOL], [test "${ENABLE_NPATOOL}" = "yes"])
AM_CONDITIONAL([ENABLE_AUTOSTART], [test "${enable_autostart}" = "yes"])
AM_CONDITIONAL([ENABLE_CMOCKA], [test "${enable_cmocka}" = "yes"])
AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = "yes"])
AM_CONDITIONAL([ENABLE_FUZZING], [test "${enable_fuzzing}" = "yes"])
AM_CONDITIONAL([ENABLE_SHARED], [test "${enable_shared}" = "yes"])
AS_IF([test "${enable_shared}" = "yes"], [AC_DEFINE([ENABLE_SHARED], [1], [Enable shared libraries])])
if test "${enable_pedantic}" = "yes"; then
enable_strict="yes";
CFLAGS="${CFLAGS} -pedantic"
CFLAGS="-pedantic ${CFLAGS}"
fi
if test "${enable_strict}" = "yes"; then
CFLAGS="${CFLAGS} -Wall -Wextra -Wno-unused-parameter -Werror"
CFLAGS="-Wall -Wextra -Wno-unused-parameter -Werror -Wstrict-aliasing=2 ${CFLAGS}"
fi
AC_CONFIG_FILES([
Makefile
doc/Makefile
doc/tools/Makefile
doc/files/Makefile
etc/Makefile
tests/Makefile
src/Makefile
src/common/Makefile
src/ui/Makefile
@ -1025,6 +1112,9 @@ AC_CONFIG_FILES([
src/scconf/Makefile
src/tests/Makefile
src/tests/regression/Makefile
src/tests/p11test/Makefile
src/tests/fuzzing/Makefile
src/tests/unittests/Makefile
src/tools/Makefile
src/tools/versioninfo-tools.rc
src/tools/versioninfo-opensc-notify.rc
@ -1043,6 +1133,7 @@ AC_CONFIG_FILES([
MacOSX/Distribution.xml
MacOSX/resources/Welcome.html
])
AC_OUTPUT
cat <<EOF
@ -1065,6 +1156,7 @@ Product URL: ${OPENSC_VS_FF_PRODUCT_URL}
User binaries: $(eval eval eval echo "${bindir}")
Configuration files: $(eval eval eval echo "${sysconfdir}")
Bash completion: ${completiondir}
XSL stylesheets: ${xslstylesheetsdir}
man support: ${enable_man}
@ -1073,6 +1165,7 @@ thread locking support: ${enable_thread_locking}
zlib support: ${enable_zlib}
readline support: ${enable_readline}
OpenSSL support: ${enable_openssl}
OpenSSL secure memory: ${enable_openssl_secure_malloc}
PC/SC support: ${enable_pcsc}
CryptoTokenKit support: ${enable_cryptotokenkit}
OpenCT support: ${enable_openct}
@ -1080,12 +1173,14 @@ CT-API support: ${enable_ctapi}
minidriver support: ${enable_minidriver}
SM support: ${enable_sm}
SM default module: ${DEFAULT_SM_MODULE}
SM default path: $(eval eval eval echo "${DEFAULT_SM_MODULE_PATH}")
DNIe UI support: ${enable_dnie_ui}
Notification support: ${enable_notify}
Debug file: ${DEBUG_FILE}
Code coverage: ${enable_code_coverage}
PC/SC default provider: ${DEFAULT_PCSC_PROVIDER}
PKCS11 default provider: ${DEFAULT_PKCS11_PROVIDER}
PKCS11 default provider: $(eval eval eval echo "${DEFAULT_PKCS11_PROVIDER}")
PKCS11 onepin provider: $(eval eval eval echo "${DEFAULT_ONEPIN_PKCS11_PROVIDER}")
Host: ${host}
Compiler: ${CC}
@ -1108,6 +1203,7 @@ PCSC_CFLAGS: ${PCSC_CFLAGS}
CRYPTOTOKENKIT_CFLAGS: ${CRYPTOTOKENKIT_CFLAGS}
GIO2_CFLAGS: ${GIO2_CFLAGS}
GIO2_LIBS: ${GIO2_LIBS}
FUZZING_LIBS: ${FUZZING_LIBS}
EOF

View File

@ -1,6 +1,6 @@
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
SUBDIRS = tools
SUBDIRS = tools files
dist_noinst_SCRIPTS = html.xsl man.xsl
dist_noinst_DATA = api.css

32
doc/files/Makefile.am Normal file
View File

@ -0,0 +1,32 @@
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
dist_noinst_DATA = pkcs15-profile.5.xml opensc.conf.5.xml.in files.xml
if ENABLE_DOC
html_DATA = files.html
endif
if ENABLE_MAN
man5_MANS = pkcs15-profile.5 opensc.conf.5
endif
opensc.conf.5.xml opensc.conf.5: $(srcdir)/opensc.conf.5.xml.in
@sed \
-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
-e 's|@docdir[@]|$(docdir)|g' \
-e 's|@libdir[@]|$(libdir)|g' \
-e 's|@DYN_LIB_EXT[@]|$(DYN_LIB_EXT)|g' \
-e 's|@DEFAULT_PCSC_PROVIDER[@]|$(DEFAULT_PCSC_PROVIDER)|g' \
-e 's|@PROFILE_DIR_DEFAULT[@]|$(PROFILE_DIR_DEFAULT)|g' \
-e 's|@DEFAULT_SM_MODULE[@]|$(DEFAULT_SM_MODULE)|g' \
< $< > opensc.conf.5.xml
$(AM_V_GEN)$(XSLTPROC) --nonet --path "$(srcdir)/..:$(xslstylesheetsdir)/manpages" --xinclude -o $@ man.xsl opensc.conf.5.xml 2>/dev/null
files.html: $(srcdir)/files.xml $(wildcard $(srcdir)/*.5.xml) opensc.conf.5.xml
$(AM_V_GEN)$(XSLTPROC) --nonet --path "$(builddir):$(srcdir)/..:$(xslstylesheetsdir)/html" --xinclude -o $@ html.xsl $< 2>/dev/null
%.5: $(srcdir)/%.5.xml
$(AM_V_GEN)sed -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' < $< \
| $(XSLTPROC) --nonet --path "$(srcdir)/..:$(xslstylesheetsdir)/manpages" --xinclude -o $@ man.xsl $< 2>/dev/null
clean-local:
-rm -rf $(html_DATA) $(man5_MANS) opensc.conf.5.xml

1151
doc/files/files.html Normal file

File diff suppressed because it is too large Load Diff

10
doc/files/files.xml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<book xmlns:xi="http://www.w3.org/2001/XInclude">
<title>OpenSC Manual Pages: Section 5</title>
<xi:include href="opensc.conf.5.xml"/>
<xi:include href="pkcs15-profile.5.xml"/>
</book>

File diff suppressed because it is too large Load Diff

View File

@ -27,12 +27,12 @@
layout, such as the path of the application DF, various PKCS #15 files within
that directory, and the access conditions on these files. It also defines
general information about PIN, key and certificate objects. Currently, there
is only one such generic profile, <command>pkcs15.profile</command>.
is only one such generic profile, <filename>pkcs15.profile</filename>.
</para>
<para>
The card specific profile contains additional information required during
card intialization, such as location of PIN files, key references etc.
Profiles currently reside in <command>@pkgdatadir@</command>
card initialization, such as location of PIN files, key references etc.
Profiles currently reside in <filename class="directory">@pkgdatadir@</filename>
</para>
</refsect1>

View File

@ -5,6 +5,7 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="docbook.xsl"/>
<xsl:param name="toc.section.depth" select="0"/>
<xsl:param name="generate.consistent.ids" select="1"/>
<xsl:template name="user.head.content">
<style type="text/css">
<xsl:comment>

View File

@ -2,9 +2,6 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
EXTRA_DIST = completion-template
# TODO XXX Uncomment after fixing issue #1267
#TESTS = test-manpage.sh
dist_noinst_DATA = $(wildcard $(srcdir)/*.xml)
if ENABLE_DOC
html_DATA = tools.html
@ -12,35 +9,31 @@ endif
if ENABLE_MAN
man1_MANS = $(patsubst $(srcdir)/%.xml, %, $(wildcard $(srcdir)/*.1.xml))
man5_MANS = $(patsubst $(srcdir)/%.xml, %, $(wildcard $(srcdir)/*.5.xml))
endif
completion_DATA = $(patsubst $(srcdir)/%.1.xml, %, $(wildcard $(srcdir)/*.1.xml))
completiondir = $(sysconfdir)/bash_completion.d
tools.html: $(srcdir)/tools.xml $(wildcard $(srcdir)/*.1.xml) $(wildcard $(srcdir)/*.5.xml)
$(XSLTPROC) --nonet --path "$(srcdir)/..:$(xslstylesheetsdir)/html" --xinclude -o $@ html.xsl $<
tools.html: $(srcdir)/tools.xml $(wildcard $(srcdir)/*.1.xml)
$(AM_V_GEN)$(XSLTPROC) --nonet --path "$(srcdir)/..:$(xslstylesheetsdir)/html" --xinclude -o $@ html.xsl $< 2>/dev/null
%.1: $(srcdir)/%.1.xml
sed -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' < $< \
| $(XSLTPROC) --nonet --path "$(srcdir)/..:$(xslstylesheetsdir)/manpages" --xinclude -o $@ man.xsl $<
%.5: $(srcdir)/%.5.xml
sed -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' < $< \
| $(XSLTPROC) --nonet --path "$(srcdir)/..:$(xslstylesheetsdir)/manpages" --xinclude -o $@ man.xsl $<
$(AM_V_GEN)sed -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' < $< \
| $(XSLTPROC) --nonet --path "$(srcdir)/..:$(xslstylesheetsdir)/manpages" --xinclude -o $@ man.xsl $< 2>/dev/null
%: $(srcdir)/%.1.xml
@echo $< $@
@cat $(srcdir)/completion-template \
$(AM_V_GEN)cat $(srcdir)/completion-template \
| sed "s,ALLOPTS,\
$(shell sed -n 's,.*<option>\([^<]*\)</option>.*,\1,pg' $< \
| sort -u | grep -- '^\-' | tr '\n' ' ')," \
| sed "s,OPTSWITHARGS,\
$(shell sed -n 's,.*<option>\([^<]*\)</option>.*<replaceable>.*,\1,pg' $< \
| sort -u | grep -- '^\-' | tr '\n' '|' | sed 's,|$$,,')," \
| sort -u | grep -- '^\-' | tr '\n' '|' | sed 's,|$$,,' | grep ^ || echo "!*")," \
| sed "s,FILEOPTS,\
$(shell sed -n 's,.*<option>\([^<]*\)</option>.*<replaceable>.*filename.*,\1,pg' $< \
| sort -u | grep -- '^\-' | tr '\n' '|' | sed 's,|$$,,' | grep ^ || echo "!*")," \
| sed "s,PINOPTS,\
$(shell sed -En 's,.*<option>([^<]*)</option>.*<replaceable>\s*(newpin|pin|puk|sopin|sopuk)\s*<.*,\1,pg' $< \
| sort -u | grep -- '^\-' | tr '\n' '|' | sed 's,|$$,,' | grep ^ || echo "!*")," \
| sed "s,MODULEOPTS,\
$(shell sed -n 's,.*<option>\([^<]*\)</option>.*<replaceable>.*mod.*,\1,pg' $< \
| sort -u | grep -- '^\-' | tr '\n' '|' | sed 's,|$$,,' | grep ^ || echo "!*")," \
@ -49,4 +42,4 @@ tools.html: $(srcdir)/tools.xml $(wildcard $(srcdir)/*.1.xml) $(wildcard $(srcdi
> $@
clean-local:
-rm -rf $(html_DATA) $(man1_MANS) $(man5_MANS) $(completion_DATA)
-rm -rf $(html_DATA) $(man1_MANS) $(completion_DATA)

View File

@ -33,13 +33,6 @@ smart cards and similar security tokens based on Siemens Card/OS M4.
<title>Options</title>
<para>
<variablelist>
<varlistentry>
<term>
<option>--card-driver</option> <replaceable>name</replaceable>,
<option>-c</option> <replaceable>name</replaceable></term>
<listitem><para>Use the card driver specified by <replaceable>name</replaceable>.
The default is to auto-detect the correct card driver.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--format</option>,
@ -47,6 +40,13 @@ smart cards and similar security tokens based on Siemens Card/OS M4.
</term>
<listitem><para>Format the card or token.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--help</option>,
<option>-h</option>
</term>
<listitem><para>Print help message on screen.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--info</option>,
@ -56,11 +56,31 @@ smart cards and similar security tokens based on Siemens Card/OS M4.
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>number</replaceable>,
<option>-r</option> <replaceable>number</replaceable>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>Specify the reader number <replaceable>number</replaceable> to use.
The default is reader <literal>0</literal>.</para></listitem>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--startkey</option> <replaceable>arg</replaceable>,
<option>-s</option> <replaceable>arg</replaceable>
</term>
<listitem><para>Specify startkey for format.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--change-startkey</option> <replaceable>arg</replaceable>,
<option>-S</option> <replaceable>arg</replaceable>
</term>
<listitem><para>Change Startkey with given APDU command.</para></listitem>
</varlistentry>
<varlistentry>
<term>
@ -82,4 +102,10 @@ smart cards and similar security tokens based on Siemens Card/OS M4.
</variablelist>
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>cardos-tool</command> was written by
Andreas Jellinghaus <email>aj@dungeon.inka.de</email>.</para>
</refsect1>
</refentry>

View File

@ -3,7 +3,7 @@ _FUNCTION_NAME()
{
COMPREPLY=()
local cur prev split=false
_get_comp_words_by_ref cur prev
_get_comp_words_by_ref -n : cur prev
_split_longopt && split=true
@ -23,6 +23,11 @@ _FUNCTION_NAME()
_filedir
return 0
;;
PINOPTS|--password)
COMPREPLY=( $( compgen -W "$(printenv | cut -d = -f 1 | xargs printf 'env:%s ')" -- $cur ) )
__ltrim_colon_completions "$cur"
return 0
;;
OPTSWITHARGS)
return 0
;;

View File

@ -121,7 +121,8 @@
<varlistentry>
<term>
<option>--read-key</option>
<option>--read-key</option>,
<option>-R</option>
</term>
<listitem><para>Reads a public key from the card, allowing the user to
extract and store or use the public key
@ -130,12 +131,17 @@
<varlistentry>
<term>
<option>--reader</option> <replaceable>num</replaceable>,
<option>-r</option> <replaceable>num</replaceable>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>Forces <command>cryptoflex-tool</command> to use
reader number <replaceable>num</replaceable> for operations. The default
is to use reader number 0, the first reader in the system.</para></listitem>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
@ -156,6 +162,15 @@
<listitem><para>Verifies CHV1 before issuing commands</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--wait</option>,
<option>-w</option>
</term>
<listitem><para>Causes <command>cryptoflex-tool</command> to
wait for a card insertion.</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
@ -170,4 +185,10 @@
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>cryptoflex-tool</command> was written by
Juha Yrjölä <email>juha.yrjola@iki.fi</email>.</para>
</refsect1>
</refentry>

View File

@ -52,7 +52,7 @@
<option>-a</option>
</term>
<listitem><para>Displays every available information.
This command is equivalent to -d -i -s</para></listitem>
This command is equivalent to -d -i -V -s</para></listitem>
</varlistentry>
<varlistentry>
<term>
@ -68,34 +68,44 @@
<option>-V</option>
</term>
<listitem><para>Show DNIe sw version.
Displays sofware version for in-card DNIe OS</para></listitem>
Displays software version for in-card DNIe OS</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--pin</option> <replaceable>pin</replaceable>,
<option>-p</option> <replaceable>pin</replaceable>
</term>
<listitem><para>Specify the user pin <replaceable>pin</replaceable> to use.
If set to env:<replaceable>VARIABLE</replaceable>, the
value of the environment variable
<replaceable>VARIABLE</replaceable> is used.
The default is do not enter pin</para></listitem>
<listitem>
<para>
These options can be used to specify the PIN value
on the command line. If the value is set to
<literal>env:</literal><replaceable>VARIABLE</replaceable>, the value
of the specified environment variable is used. By default,
the code is prompted on the command line if needed.
</para>
<para>
Note that on most operation systems, any user can
display the command line of any process on the
system using utilities such as
<command>ps(1)</command>. Therefore, you should prefer
passing the codes via an environment variable
on an unsecured system.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>number</replaceable>,
<option>-r</option> <replaceable>number</replaceable>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>Specify the reader <replaceable>number</replaceable> to use.
The default is reader 0.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--driver</option> <replaceable>driver</replaceable>,
<option>-c</option> <replaceable>driver</replaceable>
</term>
<listitem><para>Specify the card driver <replaceable>driver</replaceable> to use.
Default is use driver from configuration file, or auto-detect if absent</para></listitem>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
@ -118,10 +128,6 @@ to enable debug output in the opensc library.</para></listitem>
</para>
</refsect1>
<refsect1>
<title>See also</title>
<para>opensc(7)</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>dnie-tool</command> was written by

115
doc/tools/egk-tool.1.xml Normal file
View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<refentry id="egk-tool">
<refmeta>
<refentrytitle>egk-tool</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="productname">OpenSC</refmiscinfo>
<refmiscinfo class="manual">OpenSC Tools</refmiscinfo>
<refmiscinfo class="source">opensc</refmiscinfo>
</refmeta>
<refnamediv>
<refname>egk-tool</refname>
<refpurpose>displays information on the German electronic health card (elektronische Gesundheitskarte, <abbrev>eGK</abbrev>)
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>egk-tool</command>
<arg choice="opt"><replaceable class="option">OPTIONS</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
The <command>egk-tool</command> utility is used to display information stored on the German elektronic health card (elektronische Gesundheitskarte, <abbrev>eGK</abbrev>).
</para>
</refsect1>
<refsect1>
<title>Options</title>
<para>
<variablelist>
<varlistentry>
<term>
<option>--help</option>,
<option>-h</option></term>
<listitem><para>Print help and exit.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--version</option>,
<option>-V</option></term>
<listitem><para>Print version and exit.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--verbose</option>,
<option>-v</option>
</term>
<listitem><para>
Causes <command>egk-tool</command> to be more verbose.
Specify this flag several times to be more verbose.
</para></listitem>
</varlistentry>
</variablelist>
</para>
<refsect2>
<title>Health Care Application (<abbrev>HCA</abbrev>)</title>
<variablelist>
<varlistentry>
<term><option>--pd</option></term>
<listitem><para>
Show 'Persönliche Versicherungsdaten' (XML).
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--vd</option></term>
<listitem><para>
Show 'Allgemeine Versicherungsdaten' (XML).
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--gvd</option></term>
<listitem><para>
Show 'Geschützte Versicherungsdaten' (XML).
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--vsd-status</option></term>
<listitem><para>
Show 'Versichertenstammdaten-Status'.
</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>egk-tool</command> was written by
Frank Morgner <email>frankmorgner@gmail.com</email>.</para>
</refsect1>
<!--
<refsect1>
<title>Reporting Bugs</title>
<para>Report bugs to <ulink url="@PACKAGE_BUGREPORT@">@PACKAGE_BUGREPORT@</ulink>.</para>
</refsect1>
-->
</refentry>

View File

@ -66,12 +66,17 @@
<varlistentry>
<term>
<option>--reader</option> <replaceable>num</replaceable>,
<option>-r</option> <replaceable>num</replaceable>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>
Use the given reader. The default is the first reader with a card.
</para></listitem>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>

View File

@ -46,9 +46,25 @@
</varlistentry>
<varlistentry>
<term>
<option>--pin</option> <replaceable>argument</replaceable>
<option>--pin</option> <replaceable>pin</replaceable>
</term>
<listitem><para>Define user PIN.</para></listitem>
<listitem>
<para>
This option can be used to specify the PIN value
on the command line. If the value is set to
<literal>env:</literal><replaceable>VARIABLE</replaceable>, the value
of the specified environment variable is used. By default,
the code is prompted on the command line if needed.
</para>
<para>
Note that on most operation systems, any user can
display the command line of any process on the
system using utilities such as
<command>ps(1)</command>. Therefore, you should prefer
passing the codes via an environment variable
on an unsecured system.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
@ -75,15 +91,21 @@
<term>
<option>--new-admin-key</option> <replaceable>argument</replaceable>
</term>
<listitem><para>Define the new adminastrator key.</para></listitem>
<listitem><para>Define the new administrator key.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>argument</replaceable>,
<option>-r</option> <replaceable>argument</replaceable>
</term>
<listitem><para>Uses reader number
<replaceable>argument</replaceable>.</para></listitem>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>argument</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
@ -114,4 +136,10 @@
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>gids-tool</command> was written by
Vincent Le Toux <email>vincent.letoux@mysmartlogon.com</email>.</para>
</refsect1>
</refentry>

126
doc/tools/goid-tool.1.xml Normal file
View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<refentry id="goid-tool">
<refmeta>
<refentrytitle>goid-tool</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="productname">OpenSC</refmiscinfo>
<refmiscinfo class="manual">OpenSC Tools</refmiscinfo>
<refmiscinfo class="source">opensc</refmiscinfo>
</refmeta>
<refnamediv>
<refname>goid-tool</refname>
<refpurpose>???</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>goid-tool</command>
<arg choice="opt"><replaceable class="option">OPTIONS</replaceable></arg>
<arg><replaceable class="option">mode</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
The <command>goid-tool</command> utility can be used from
the command line to ???
</para>
</refsect1>
<refsect1>
<title>Options</title>
<para>
<variablelist>
<varlistentry>
<term>
<option>--help</option>,
<option>-h</option>
</term>
<listitem><para>Print help message on screen.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--version</option>,
<option>-V</option>
</term>
<listitem><para>Print the OpenSC package release version.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>string</replaceable>,
<option>-r</option> <replaceable>string</replaceable>
</term>
<listitem><para>
Specify the number of the reader to use. By default, the
first reader with present card is used. If
the argument is an ATR, the reader with a
matching card will be chosen.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--verbose</option>,
<option>-v</option>
</term>
<listitem><para>
Cause <command>goid-tool</command> to be
more verbose. Use it multiple times to be even more
verbose.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--verify-pin</option>,
<option>-p</option>
</term>
<listitem><para>
Verify PIN.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--verify-bio</option>,
<option>-b</option>
</term>
<listitem><para>
Verify finger print.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--verify-pin-or-bio</option>
</term>
<listitem><para>
Verify PIN or finger print (user's choice).
</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<!-- TODO modes -->
<refsect1>
<title>See also</title>
<para>
<citerefentry>
<refentrytitle>pkcs11-tool</refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>
<citerefentry>
<refentrytitle>opensc.conf</refentrytitle>
<manvolnum>5</manvolnum>
</citerefentry>
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>pkcs11-register</command> was written by
Frank Morgner <email>frankmorgner@gmail.com</email>.</para>
</refsect1>
</refentry>

View File

@ -34,10 +34,16 @@
<variablelist>
<varlistentry>
<term>
<option>--reader</option> <replaceable>number</replaceable>,
<option>--reader</option> <replaceable>arg</replaceable>,
</term>
<listitem><para>Specify the reader number <replaceable>number</replaceable> to use.
The default is reader <literal>0</literal>.</para></listitem>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
@ -78,4 +84,10 @@
</variablelist>
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>iasecc-tool</command> was written by
Viktor Tarasov <email>viktor.tarasov@gmail.com</email>.</para>
</refsect1>
</refentry>

View File

@ -43,38 +43,45 @@
</varlistentry>
<varlistentry>
<term>
<option>--pin</option> <replaceable>pin-value</replaceable>,
<option>-p</option> <replaceable>pin-value</replaceable>
<option>--pin</option> <replaceable>pin</replaceable>,
<option>-p</option> <replaceable>pin</replaceable>
</term>
<listitem><para>Specifies the current value of the global PIN.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--puk</option> <replaceable>pin-value</replaceable>,
<option>-u</option> <replaceable>pin-value</replaceable>
<option>--puk</option> <replaceable>pin</replaceable>,
<option>-u</option> <replaceable>pin</replaceable>
</term>
<listitem><para>Specifies the current value of the global PUK.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--pin0</option> <replaceable>pin-value</replaceable>,
<option>-0</option> <replaceable>pin-value</replaceable>
<option>--pin0</option> <replaceable>pin</replaceable>,
<option>-0</option> <replaceable>pin</replaceable>
</term>
<listitem><para>Specifies the current value of the local PIN0 (aka local PIN).</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--pin1</option> <replaceable>pin-value</replaceable>,
<option>-1</option> <replaceable>pin-value</replaceable>
<option>--pin1</option> <replaceable>pin</replaceable>,
<option>-1</option> <replaceable>pin</replaceable>
</term>
<listitem><para>Specifies the current value of the local PIN1 (aka local PUK).</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>number</replaceable>,
<option>-r</option> <replaceable>number</replaceable>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>Use smart card in specified reader. Default is reader 0.</para></listitem>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
@ -91,7 +98,7 @@
<title>PIN format</title>
<para>With the <option>-p</option>, <option>-u</option>, <option>-0</option> or the <option>-1</option>
one of the cards pins may be specified. You may use plain ascii-strings (i.e. 123456) or a hex-string
(i.e. 31:32:33:34:35:36). A hex-string must consists of exacly n 2-digit hexnumbers separated by n-1 colons.
(i.e. 31:32:33:34:35:36). A hex-string must consist of exactly n 2-digit hexnumbers separated by n-1 colons.
Otherwise it will be interpreted as an ascii string. For example :12:34: and 1:2:3:4 are both pins of
length 7, while 12:34 and 01:02:03:04 are pins of length 2 and 4.</para>
</refsect1>
@ -112,7 +119,7 @@
current value of your global PIN. </para>
<para>For most of the commands that <command>netkey-tool</command> can execute, you have
to specify one pin. One notable exeption is the <command>nullpin</command> command, but
to specify one pin. One notable exception is the <command>nullpin</command> command, but
this command can only be executed once in the lifetime of a NetKey E4 card.</para>
<para>
@ -140,8 +147,14 @@
</varlistentry>
<varlistentry>
<term>
<command>change</command> { <parameter>pin</parameter> | <parameter>puk</parameter> |
<parameter>pin0</parameter> | <parameter>pin1</parameter> } <replaceable>new-pin</replaceable>
<command>change</command>
<group choice="req">
<arg choice="plain">pin</arg>
<arg choice="plain">puk</arg>
<arg choice="plain">pin0</arg>
<arg choice="plain">pin1</arg>
</group>
<replaceable>new-pin</replaceable>
</term>
<listitem><para>This changes the value of the specified pin to the given new value.
You must specify either the current value of the pin or another pin to be able to do
@ -154,13 +167,18 @@
</term>
<listitem><para>This command can be executed only if the global PIN of your card is
in nullpin-state. There's no way to return back to nullpin-state once you have changed
your global PIN. You don't need a pin to execute the nullpin-command. After a succesfull
your global PIN. You don't need a pin to execute the nullpin-command. After a successful
nullpin-command <command>netkey-tool</command> will display your cards initial
PUK-value.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>unblock</command> { <parameter>pin</parameter> | <parameter>pin0</parameter> | <parameter>pin1</parameter> }
<command>unblock</command>
<group choice="req">
<arg choice="plain">pin</arg>
<arg choice="plain">pin0</arg>
<arg choice="plain">pin1</arg>
</group>
</term>
<listitem><para>This unblocks the specified pin. You must specify another pin
to be able to do this and if you don't specify a correct one,

440
doc/tools/npa-tool.1.xml Normal file
View File

@ -0,0 +1,440 @@
<?xml version="1.0" encoding="UTF-8"?>
<refentry id="npa-tool">
<refmeta>
<refentrytitle>npa-tool</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="productname">OpenSC</refmiscinfo>
<refmiscinfo class="manual">OpenSC Tools</refmiscinfo>
<refmiscinfo class="source">opensc</refmiscinfo>
</refmeta>
<refnamediv>
<refname>npa-tool</refname>
<refpurpose>displays information on the German eID card (neuer Personalausweis, <abbrev>nPA</abbrev>).
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>npa-tool</command>
<arg choice="opt"><replaceable class="option">OPTIONS</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
The <command>npa-tool</command> utility is used to display information
stored on the German eID card (neuer Personalausweis, <abbrev>nPA</abbrev>),
and to perform some write and verification operations.
</para>
</refsect1>
<refsect1>
<title>Options</title>
<para>
<variablelist>
<varlistentry>
<term>
<option>--help</option>,
<option>-h</option></term>
<listitem><para>Print help and exit.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--version</option>,
<option>-V</option></term>
<listitem><para>Print version and exit.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--verbose</option>,
<option>-v</option>
</term>
<listitem><para>
Causes <command>npa-tool</command> to be more verbose.
Specify this flag several times to be more verbose.
</para></listitem>
</varlistentry>
</variablelist>
</para>
<refsect2>
<title>Password Authenticated Connection Establishment (<abbrev>PACE</abbrev>)</title>
<variablelist>
<varlistentry>
<term>
<option>--pin</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>,
<option>-p</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>
</term>
<listitem><para>
Run <abbrev>PACE</abbrev> with (transport) eID-PIN.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--puk</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>,
<option>-u</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>
</term>
<listitem><para>
Run <abbrev>PACE</abbrev> with PUK.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--can</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>,
<option>-c</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>
</term>
<listitem><para>
Run <abbrev>PACE</abbrev> with Card Access Number (<abbrev>CAN</abbrev>).
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--mrz</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>,
<option>-m</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>
</term>
<listitem><para>
Run <abbrev>PACE</abbrev> with Machine Readable Zone (<abbrev>MRZ</abbrev>).
Enter the <abbrev>MRZ</abbrev> without newlines.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--env</option></term>
<listitem><para>
Specify whether to use environment variables <envar>PIN</envar>,
<envar>PUK</envar>, <envar>CAN</envar>, <envar>MRZ</envar>,
and <envar>NEWPIN</envar>.
You may want to clean your environment before enabling this.
(default=off)
</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
<title>PIN management</title>
<variablelist>
<varlistentry>
<term>
<option>--new-pin</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>,
<option>-N</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>
</term>
<listitem><para>
Install a new PIN.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--resume</option>,
<option>-R</option>
</term>
<listitem><para>
Resume eID-PIN (uses <abbrev>CAN</abbrev> to activate last retry).
(default=off)
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--unblock</option>,
<option>-U</option>
</term>
<listitem><para>
Unblock PIN (uses PUK to activate three more retries).
(default=off)
</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
<title>Terminal Authentication (<abbrev>TA</abbrev>) and Chip Authentication (<abbrev>CA</abbrev>)</title>
<variablelist>
<varlistentry>
<term>
<option>--cv-certificate</option> <replaceable>FILENAME</replaceable>,
<option>-C</option> <replaceable>FILENAME</replaceable>
</term>
<listitem><para>
Specify Card Verifiable (<abbrev>CV</abbrev>) certificate
to create a certificate chain.
The option can be given multiple times, in which case the
order is important.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--cert-desc</option> <replaceable>HEX_STRING</replaceable></term>
<listitem><para>
Certificate description to show for Terminal Authentication.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--chat</option> <replaceable>HEX_STRING</replaceable></term>
<listitem><para>
Specify the Card Holder Authorization Template
(<abbrev>CHAT</abbrev>) to use.
If not given, it defaults to the terminal's CHAT.
Use <literal>7F4C0E060904007F000703010203530103</literal>
to trigger EAC on the CAT-C (Komfortleser).
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--auxiliary-data</option> <replaceable>HEX_STRING</replaceable>,
<option>-A</option> <replaceable>HEX_STRING</replaceable>
</term>
<listitem><para>
Specify the terminal's auxiliary data.
If not given, the default is determined by verification
of validity, age and community ID.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--private-key</option> <replaceable>FILENAME</replaceable>,
<option>-P</option> <replaceable>FILENAME</replaceable>
</term>
<listitem><para>
Specify the terminal's private key.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--cvc-dir</option> <replaceable>DIRECTORY</replaceable></term>
<listitem><para>
Specify where to look for the certificate of the
Country Verifying Certification Authority
(<abbrev>CVCA</abbrev>).
If not given, it defaults to
<filename class="directory">/home/fm/.local/etc/eac/cvc</filename>.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--x509-dir</option> <replaceable>DIRECTORY</replaceable></term>
<listitem><para>
Specify where to look for the X.509 certificate.
If not given, it defaults to
<filename class="directory">/home/fm/.local/etc/eac/x509</filename>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--disable-ta-checks</option></term>
<listitem><para>
Disable checking the validity period of CV certificates.
(default=off)
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--disable-ca-checks</option></term>
<listitem><para>
Disable passive authentication. (default=off)
</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
<title>Read and write data groups</title>
<variablelist>
<varlistentry>
<term><option>--read-dg1</option></term>
<listitem><para>Read data group 1: Document Type.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg2</option></term>
<listitem><para>Read data group 2: Issuing State.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg3</option></term>
<listitem><para>Read data group 3: Date of Expiry.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg4</option></term>
<listitem><para>Read data group 4: Given Name(s).</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg5</option></term>
<listitem><para>Read data group 5: Family Name.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg6</option></term>
<listitem><para>Read data group 6: Religious/Artistic Name.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg7</option></term>
<listitem><para>Read data group 7: Academic Title.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg8</option></term>
<listitem><para>Read data group 8: Date of Birth.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg9</option></term>
<listitem><para>Read data group 9: Place of Birth.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg10</option></term>
<listitem><para>Read data group 10: Nationality.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg11</option></term>
<listitem><para>Read data group 11: Sex.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg12</option></term>
<listitem><para>Read data group 12: Optional Data.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg13</option></term>
<listitem><para>Read data group 13: Birth Name.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg14</option></term>
<listitem><para>Read data group 14.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg15</option></term>
<listitem><para>Read data group 15.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg16</option></term>
<listitem><para>Read data group 16.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg17</option></term>
<listitem><para>Read data group 17: Normal Place of Residence.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg18</option></term>
<listitem><para>Read data group 18: Community ID.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg19</option></term>
<listitem><para>Read data group 19: Residence Permit I.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg20</option></term>
<listitem><para>Read data group 20: Residence Permit II.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--read-dg21</option></term>
<listitem><para>Read data group 21: Optional Data.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--write-dg17</option> <replaceable>HEX_STRING</replaceable></term>
<listitem><para>Write data group 17: Normal Place of Residence.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--write-dg18</option> <replaceable>HEX_STRING</replaceable></term>
<listitem><para>Write data group 18: Community ID.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--write-dg19</option> <replaceable>HEX_STRING</replaceable></term>
<listitem><para>Write data group 19: Residence Permit I.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--write-dg20</option> <replaceable>HEX_STRING</replaceable></term>
<listitem><para>Write data group 20: Residence Permit II.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--write-dg21</option> <replaceable>HEX_STRING</replaceable></term>
<listitem><para>Write data group 21: Optional Data.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
<title>Verification of validity, age and community ID</title>
<variablelist>
<varlistentry>
<term><option>--verify-validity</option> <replaceable>YYYYMMDD</replaceable></term>
<listitem><para>
Verify chip's validity with a reference date.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--older-than</option> <replaceable>YYYYMMDD</replaceable></term>
<listitem><para>
Verify age with a reference date.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--verify-community</option> <replaceable>HEX_STRING</replaceable></term>
<listitem><para>
Verify community ID with a reference ID.
</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
<title>Special options, not always useful</title>
<variablelist>
<varlistentry>
<term>
<option>--break</option>,
<option>-b</option>
</term>
<listitem><para>
Brute force PIN, CAN or PUK.
Use together with options <option>-p</option>,
<option>-a</option>, or <option>-u</option>.
(default=off)
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--translate</option> <replaceable>FILENAME</replaceable>,
<option>-t</option> <replaceable>FILENAME</replaceable>
</term>
<listitem><para>
Specify the file with APDUs of HEX_STRINGs to send
through the secure channel.
(default=`stdin')
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--tr-03110v201</option></term>
<listitem><para>
Force compliance to BSI TR-03110 version 2.01. (default=off)
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--disable-all-checks</option></term>
<listitem><para>
Disable all checking of fly-by-data. (default=off)
</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>npa-tool</command> was written by
Frank Morgner <email>frankmorgner@gmail.com</email>.</para>
</refsect1>
<!--
<refsect1>
<title>Reporting Bugs</title>
<para>Report bugs to <ulink url="@PACKAGE_BUGREPORT@">@PACKAGE_BUGREPORT@</ulink>.</para>
</refsect1>
-->
</refentry>

View File

@ -38,13 +38,76 @@
<title>Options</title>
<para>
<variablelist>
<varlistentry>
<term>
<option>--card-info</option>,
<option>-C</option>
</term>
<listitem><para>
Show card information.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--del-key</option> <replaceable>arg</replaceable>
</term>
<listitem><para>
Delete key indicated by <replaceable>arg</replaceable>.
<replaceable>arg</replaceable> can be <literal>1</literal>,
<literal>2</literal>, <literal>3</literal>, or
<literal>all</literal>.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--do</option> <replaceable>arg</replaceable>,
<option>-d</option> <replaceable>arg</replaceable>
</term>
<listitem><para>
Dump private data object (<abbrev>DO</abbrev>)
indicated by <replaceable>arg</replaceable>.
<replaceable>arg</replaceable> can be in the form
<replaceable>x</replaceable>,
<literal>10</literal><replaceable>x</replaceable>, or
<literal>010</literal><replaceable>x</replaceable>
to access <literal>DO 010</literal><replaceable>x</replaceable>,
where <replaceable>x</replaceable> is <literal>1</literal>,
<literal>2</literal>, <literal>3</literal>, or
<literal>4</literal>.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--erase</option>,
<option>-E</option>
</term>
<listitem><para>
Erase (i.e. reset) the card.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--exec</option> <replaceable>prog</replaceable>,
<option>-x</option> <replaceable>prog</replaceable>
</term>
<listitem><para>
Execute the given program with data in environment variables.
Execute the given program with data in environment variables.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--gen-key</option> <replaceable>arg</replaceable>,
<option>-G</option> <replaceable>arg</replaceable>
</term>
<listitem><para>
Generate key with the ID given as <replaceable>arg</replaceable>.
<replaceable>arg</replaceable> can be one of <literal>1</literal>,
<literal>2</literal>, or <literal>3</literal>.
</para></listitem>
</varlistentry>
@ -54,7 +117,65 @@
<option>-h</option>
</term>
<listitem><para>
Print help message on screen.
Print help message on screen.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--key-info</option>,
<option>-K</option>
</term>
<listitem><para>
Show information of keys on the card.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--key-type</option> <replaceable>keytype</replaceable>,
<option>-t</option> <replaceable>keytype</replaceable>
</term>
<listitem><para>
Specify the type of the key to be generated.
Supported values for <replaceable>keytype</replaceable> are
<literal>rsa</literal> for RSA with 2048 bits,
<literal>rsa</literal><replaceable>LENGTH</replaceable>
for RSA with a bit length of <replaceable>LENGTH</replaceable>.
If not given, it defaults to <literal>rsa2048</literal>.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--pin</option> <replaceable>pin</replaceable>
</term>
<listitem>
<para>
This option can be used to specify the PIN value
on the command line. If the value is set to
<literal>env:</literal><replaceable>VARIABLE</replaceable>, the value
of the specified environment variable is used. By default,
the code is prompted on the command line if needed.
</para>
<para>
Note that on most operation systems, any user can
display the command line of any process on the
system using utilities such as
<command>ps(1)</command>. Therefore, you should prefer
passing the codes via an environment variable
on an unsecured system.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--pretty</option>
</term>
<listitem><para>
Print values in pretty format.
</para></listitem>
</varlistentry>
@ -63,16 +184,20 @@
<option>--raw</option>
</term>
<listitem><para>
Print values in raw format, as they are stored on the card.
Print values in raw format, as they are stored on the card.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--pretty</option>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>
Print values in pretty format.
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para></listitem>
</varlistentry>
@ -82,17 +207,7 @@
<option>-U</option>
</term>
<listitem><para>
Show card holder information.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>num</replaceable>,
<option>-r</option> <replaceable>num</replaceable>
</term>
<listitem><para>
Use the given reader. The default is the first reader with a card.
Show card holder information.
</para></listitem>
</varlistentry>
@ -100,49 +215,9 @@
<term>
<option>--verify</option> <replaceable>pintype</replaceable>
</term>
<listitem>
<para>
<listitem><para>
Verify PIN (CHV1, CHV2 or CHV3).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--pin</option> <replaceable>string</replaceable>
</term>
<listitem>
<para>
The PIN text to verify. If set to
env:<replaceable>VARIABLE</replaceable>, the value of
the environment variable
<replaceable>VARIABLE</replaceable> is used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--gen-key</option> <replaceable>ID</replaceable>,
<option>-G</option> <replaceable>ID</replaceable>
</term>
<listitem>
<para>
Generate key. Specify key ID (1, 2 or 3) to generate.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--key-length</option> <replaceable>bitlength</replaceable>,
<option>-L</option> <replaceable>bitlength</replaceable>
</term>
<listitem>
<para>
Length (default 2048 bit) of the key to be generated.
</para>
</listitem>
</para></listitem>
</varlistentry>
<varlistentry>
@ -151,7 +226,7 @@
<option>-V</option>
</term>
<listitem><para>
Print the version of the utility and exit.
Print the version of the utility and exit.
</para></listitem>
</varlistentry>
@ -161,7 +236,7 @@
<option>-v</option>
</term>
<listitem><para>
Verbose operation. Use several times to enable debug output.
Verbose operation. Use several times to enable debug output.
</para></listitem>
</varlistentry>
@ -171,10 +246,9 @@
<option>-w</option>
</term>
<listitem><para>
Wait for a card to be inserted.
Wait for a card to be inserted.
</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<refentry id="opensc-asn1">
<refmeta>
<refentrytitle>opensc-asn1</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="productname">OpenSC</refmiscinfo>
<refmiscinfo class="manual">OpenSC Tools</refmiscinfo>
<refmiscinfo class="source">opensc</refmiscinfo>
</refmeta>
<refnamediv>
<refname>opensc-asn1</refname>
<refpurpose>parse ASN.1 data
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>opensc-asn1</command>
<arg choice="opt"><replaceable class="option">OPTIONS</replaceable></arg>
<arg choice="opt"><replaceable class="option">FILES</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
The <command>opensc-asn1</command> utility is used to parse ASN.1 data.
</para>
</refsect1>
<refsect1>
<title>Options</title>
<para>
<variablelist>
<varlistentry>
<term>
<option>--help</option>,
<option>-h</option></term>
<listitem><para>Print help and exit.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--version</option>,
<option>-V</option></term>
<listitem><para>Print version and exit.</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>opensc-asn1</command> was written by
Frank Morgner <email>frankmorgner@gmail.com</email>.</para>
</refsect1>
<!--
<refsect1>
<title>Reporting Bugs</title>
<para>Report bugs to <ulink url="@PACKAGE_BUGREPORT@">@PACKAGE_BUGREPORT@</ulink>.</para>
</refsect1>
-->
</refentry>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<refentry id="opensc-notify">
<refmeta>
<refentrytitle>opensc-notify</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="productname">OpenSC</refmiscinfo>
<refmiscinfo class="manual">OpenSC Tools</refmiscinfo>
<refmiscinfo class="source">opensc</refmiscinfo>
</refmeta>
<refnamediv>
<refname>opensc-notify</refname>
<refpurpose> monitor smart card events and send notifications
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>opensc-notify</command>
<arg choice="opt"><replaceable class="option">OPTIONS</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
The <command>opensc-notify</command> utility is used to
monitor smart card events and send the appropriate notification.
</para>
</refsect1>
<refsect1>
<title>Options</title>
<para>
<variablelist>
<varlistentry>
<term>
<option>--help</option>,
<option>-h</option></term>
<listitem><para>Print help and exit.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--version</option>,
<option>-V</option></term>
<listitem><para>Print version and exit.</para></listitem>
</varlistentry>
</variablelist>
</para>
<refsect2>
<title>Mode: customized</title>
<para>
Send customized notifications.
</para>
<variablelist>
<varlistentry>
<term>
<option>--title</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>,
<option>-t</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>
</term>
<listitem><para>
Specify the title of the notification.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--message</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>,
<option>-m</option> <arg choice="opt"><replaceable>STRING</replaceable></arg>
</term>
<listitem><para>
Specify the main text of the notification.
</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
<title>Mode: standard</title>
<para>
Manually send standard notifications.
</para>
<variablelist>
<varlistentry>
<term>
<option>--notify-card-inserted</option>,
<option>-I</option></term>
<listitem><para>
See <parameter>notify_card_inserted</parameter>
in <filename>opensc.conf</filename> (default=off).
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--notify-card-removed</option>,
<option>-R</option></term>
<listitem><para>
See <parameter>notify_card_removed</parameter>
in <filename>opensc.conf</filename> (default=off).
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--notify-pin-good</option>,
<option>-G</option></term>
<listitem><para>
See <parameter>notify_pin_good</parameter>
in <filename>opensc.conf</filename> (default=off).
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--notify-pin-bad</option>,
<option>-B</option></term>
<listitem><para>
See <parameter>notify_pin_bad</parameter>
in <filename>opensc.conf</filename> (default=off).
</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>opensc-notify</command> was written by
Frank Morgner <email>frankmorgner@gmail.com</email>.</para>
</refsect1>
<!--
<refsect1>
<title>Reporting Bugs</title>
<para>Report bugs to <ulink url="@PACKAGE_BUGREPORT@">@PACKAGE_BUGREPORT@</ulink>.</para>
</refsect1>
-->
</refentry>

View File

@ -35,7 +35,7 @@
<variablelist>
<varlistentry>
<term>
<option>--version</option>,
<option>--version</option>
</term>
<listitem><para>Print the OpenSC package release version.</para></listitem>
</varlistentry>
@ -52,8 +52,18 @@
<option>--card-driver</option> <replaceable>driver</replaceable>,
<option>-c</option> <replaceable>driver</replaceable>
</term>
<listitem><para>Use the given card driver.
The default is auto-detected.</para></listitem>
<listitem><para>
Use the given card driver.
The default is to auto-detect the correct card driver.
The literal value <literal>?</literal> lists
all available card drivers.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--list-algorithms</option>,
</term>
<listitem><para>Lists algorithms supported by card</para></listitem>
</varlistentry>
<varlistentry>
<term>
@ -92,18 +102,39 @@
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>num</replaceable>,
<option>-r</option> <replaceable>num</replaceable>
<option>--get-conf-entry</option> <replaceable>conf</replaceable>,
<option>-G</option> <replaceable>conf</replaceable>
</term>
<listitem><para>Use the given reader number.
The default is <literal>0</literal>, the first reader in the system.</para></listitem>
<listitem><para>Get configuration key, format: section:name:key</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reset</option>[=<replaceable>type</replaceable>],
<option>--set-conf-entry</option> <replaceable>conf</replaceable>,
<option>-S</option> <replaceable>conf</replaceable>
</term>
<listitem><para>Set configuration key, format: section:name:key:value</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reset</option> <arg choice="opt"><replaceable>type</replaceable></arg>,
</term>
<listitem><para>Resets the card in reader.
The default reset type is <literal>cold</literal>, but warm reset is also possible.</para></listitem>
The default reset type is <literal>cold</literal>,
but <literal>warm</literal> reset is also possible.</para></listitem>
</varlistentry>
<varlistentry>
<term>
@ -149,4 +180,10 @@
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>opensc-tool</command> was written by
Juha Yrjölä <email>juha.yrjola@iki.fi</email>.</para>
</refsect1>
</refentry>

View File

@ -24,7 +24,7 @@
<para>
The <command>piv-tool</command> utility can be used from the command line to perform
miscellaneous smart card operations on a HSPD-12 PIV smart card as defined in NIST 800-73-3.
It is intened for use with test cards only. It can be used to load objects, and generate
It is intended for use with test cards only. It can be used to load objects, and generate
key pairs, as well as send arbitrary APDU commands to a card after having authenticated
to the card using the card key provided by the card vendor.
</para>
@ -53,15 +53,18 @@
<option>--admin</option> <replaceable>argument</replaceable>,
<option>-A</option> <replaceable>argument</replaceable>
</term>
<listitem><para>Authenticate to the card using a 2DES or 3DES key.
<listitem><para>Authenticate to the card using a 2DES, 3DES or AES key.
The <replaceable>argument</replaceable> of the form
<synopsis> {<literal>A</literal>|<literal>M</literal>}<literal>:</literal><replaceable>ref</replaceable><literal>:</literal><replaceable>alg</replaceable></synopsis>
is required, were <literal>A</literal> uses "EXTERNAL AUTHENTICATION"
and <literal>M</literal> uses "MUTUAL AUTHENTICATION".
<replaceable>ref</replaceable> is normally <literal>9B</literal>,
and <replaceable>alg</replaceable> is <literal>03</literal> for 3DES.
The key is provided by the card vendor, and the environment variable
<varname>PIV_EXT_AUTH_KEY</varname> must point to a text file containing
and <replaceable>alg</replaceable> is <literal>03</literal> for 3DES,
<literal>01</literal> for 2DES, <literal>08</literal> for AES-128,
<literal>0A</literal> for AES-192 or <literal>0C</literal> for AES-256.
The key is provided by the card vendor. The environment variable
<varname>PIV_EXT_AUTH_KEY</varname> must point to either a binary file
matching the length of the key or a text file containing
the key in the format:
<code>XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX</code>
</para></listitem>
@ -94,7 +97,7 @@
<varlistentry>
<term>
<option>--cert</option> <replaceable>ref</replaceable>,
<option>-s</option> <replaceable>ref</replaceable>
<option>-C</option> <replaceable>ref</replaceable>
</term>
<listitem><para>Load a certificate onto the card.
<replaceable>ref</replaceable> is <literal>9A</literal>,
@ -151,19 +154,17 @@
<varlistentry>
<term>
<option>--reader</option> <replaceable>num</replaceable>,
<option>-r</option> <replaceable>num</replaceable>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>Use the given reader number. The default is
<literal>0</literal>, the first reader in the system.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--card-driver</option> <replaceable>driver</replaceable>,
<option>-c</option> <replaceable>driver</replaceable>
</term>
<listitem><para>Use the given card driver.
The default is auto-detected.</para></listitem>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
@ -195,4 +196,10 @@
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>piv-tool</command> was written by
Douglas E. Engert <email>deengert@gmail.com</email>.</para>
</refsect1>
</refentry>

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<refentry id="pkcs11-register">
<refmeta>
<refentrytitle>pkcs11-register</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="productname">OpenSC</refmiscinfo>
<refmiscinfo class="manual">OpenSC Tools</refmiscinfo>
<refmiscinfo class="source">opensc</refmiscinfo>
</refmeta>
<refnamediv>
<refname>pkcs11-register</refname>
<refpurpose>Simple tool to install PKCS#11 modules to known applications.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>pkcs11-register</command>
<arg choice="opt"><replaceable class="option">OPTIONS</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
The <command>pkcs11-register</command> utility can be used from
the command line to register PKCS#11 modules to various applications
</para>
</refsect1>
<refsect1>
<title>Options</title>
<para>
<variablelist>
<varlistentry>
<term>
<option>--help</option>,
<option>-h</option>
</term>
<listitem><para>Print help message on screen.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--version</option>,
<option>-V</option>
</term>
<listitem><para>Print the OpenSC package release version.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--module</option> <replaceable>filename</replaceable>,
<option>-m</option> <replaceable>filename</replaceable>
</term>
<listitem><para>
Path to the PKCS#11 module to load. The default
is OpenSC PKCS#11 module.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--skip-chrome</option>
</term>
<listitem><para>
Don't install module for Chrome browser. By default,
the tool attempts to install the module for Chrome
browser.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--skip-firefox</option>
</term>
<listitem><para>
Don't install module for Firefox browser. By default,
the tool attempts to install the module for Firefox
browser.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--skip-thunderbird</option>
</term>
<listitem><para>
Don't install module for Thunderbird mail client.
By default, the tool attempts to install the module
for Thunderbird mail client.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--skip-seamonkey</option>
</term>
<listitem><para>
Don't install module for Seamonkey. By default,
the tool attempts to install the module Seamonkey.
</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1>
<title>See also</title>
<para>
<citerefentry>
<refentrytitle>pkcs11-tool</refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>
<citerefentry>
<refentrytitle>opensc.conf</refentrytitle>
<manvolnum>5</manvolnum>
</citerefentry>
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>pkcs11-register</command> was written by
Frank Morgner <email>frankmorgner@gmail.com</email>.</para>
</refsect1>
</refentry>

View File

@ -77,9 +77,9 @@
</term>
<listitem>
<para>
Specify hash algorithm used with RSA-PKCS-PSS signature or RSA-OAEP decryption.
Allowed values are "SHA-1", "SHA256", "SHA384", "SHA512", and some tokens may
also allow "SHA224". Default is "SHA-1".
Specify hash algorithm used with RSA-PKCS-PSS signature or RSA-OAEP decryption.
Allowed values are "SHA-1", "SHA256", "SHA384", "SHA512", and some tokens may
also allow "SHA224". Default is "SHA-1".
</para>
<para>
Note that the input to RSA-PKCS-PSS has to be of the size equal to
@ -146,7 +146,9 @@
<term>
<option>--key-type</option> <replaceable>specification</replaceable>
</term>
<listitem><para>Specify the type and length of the key to create, for example rsa:1024 or EC:prime256v1.</para></listitem>
<listitem><para>Specify the type and length (bytes if symmetric) of the key to create,
for example RSA:1024, EC:prime256v1, GOSTR3410-2012-256:B,
DES:8, DES3:24, AES:16 or GENERIC:64.</para></listitem>
</varlistentry>
<varlistentry>
@ -170,6 +172,13 @@
<listitem><para>Specify 'derive' key usage flag (EC only).</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--usage-wrap</option>
</term>
<listitem><para>Specify 'wrap' key usage flag.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--label</option> <replaceable>name</replaceable>,
@ -212,6 +221,13 @@
<listitem><para>List slots with tokens.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--list-interfaces</option>
</term>
<listitem><para>List interfaces of PKCS #11 3.0 library.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--login</option>,
@ -266,7 +282,7 @@
<option>--moz-cert</option> <replaceable>filename</replaceable>,
<option>-z</option> <replaceable>filename</replaceable>
</term>
<listitem><para>Test a Mozilla-like keypair generation
<listitem><para>Test a Mozilla-like key pair generation
and certificate request. Specify the <replaceable>filename</replaceable>
to the certificate file.</para></listitem>
</varlistentry>
@ -319,6 +335,13 @@
<listitem><para>Set the CKA_SENSITIVE attribute (object cannot be revealed in plaintext).</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--extractable</option>
</term>
<listitem><para>Set the CKA_EXTRACTABLE attribute (object can be extracted)</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--set-id</option> <replaceable>id</replaceable>,
@ -396,6 +419,29 @@
<listitem><para>Specify the index of the slot to use.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--object-index</option> <replaceable>index</replaceable>
</term>
<listitem><para>Specify the index of the object to use.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--use-locking</option>
</term>
<listitem><para>Tell pkcs11 module it should use OS thread locking.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--test-threads</option> <replaceable>options</replaceable>
</term>
<listitem><para>Test a pkcs11 module's thread implication. (See source code).
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--token-label</option> <replaceable>label</replaceable>
@ -444,6 +490,26 @@
viewable after a login).</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--always-auth</option>
</term>
<listitem><para>Set the CKA_ALWAYS_AUTHENTICATE attribute to a private key object.
If set, the user has to supply the PIN for each use (sign or decrypt) with the key.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--allowed-mechanisms</option> <replaceable>mechanisms</replaceable>
</term>
<listitem><para>Sets the CKA_ALLOWED_MECHANISMS attribute
to a key objects when importing an object or generating
a keys. The argument accepts comma-separated list of
algorithmsm, that can be used with the given key.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--test-ec</option>
@ -466,8 +532,9 @@
<option>-y</option> <replaceable>type</replaceable>
</term>
<listitem><para>Specify the type of object to operate on.
Examples are <literal>cert</literal>, <literal>privkey</literal>
and <literal>pubkey</literal>.</para></listitem>
Valid value are <literal>cert</literal>, <literal>privkey</literal>,
<literal>pubkey</literal>, <literal>secrkey</literal>
and <literal>data</literal>.</para></listitem>
</varlistentry>
<varlistentry>
@ -481,6 +548,13 @@
non-zero number.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--verify</option>,
</term>
<listitem><para>Verify signature of some data.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--read-object</option>,
@ -530,6 +604,13 @@
<option>--type</option> cert/privkey/pubkey).</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--signature-file</option> <replaceable>filename</replaceable>
</term>
<listitem><para>The path to the signature file for signature verification</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--signature-format</option> <replaceable>format</replaceable>
@ -545,7 +626,7 @@
</term>
<listitem><para>Write a key or certificate object to the token.
<replaceable>filename</replaceable> points to the DER-encoded certificate or key file.
</para></listitem>
</para></listitem>
</varlistentry>
<varlistentry>
@ -553,7 +634,16 @@
<option>--generate-random</option> <replaceable>num</replaceable>
</term>
<listitem><para>Get <replaceable>num</replaceable> bytes of random data.
</para></listitem>
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--allow-sw</option>
</term>
<listitem><para>Allow using software mechanisms that do not have the CKF_HW flag set.
May be required when using software tokens and emulators.
</para></listitem>
</varlistentry>
</variablelist>
@ -568,9 +658,9 @@
To read the certificate with ID <replaceable>KEY_ID</replaceable>
in DER format from smart card:
<programlisting>pkcs11-tool --read-object --id KEY_ID --type cert --outfile cert.der</programlisting>
<programlisting>pkcs11-tool --read-object --id KEY_ID --type cert --output-file cert.der</programlisting>
To convert the certificate in DER formato to PEM format, use OpenSSL
To convert the certificate in DER format to PEM format, use OpenSSL
tools:
<programlisting>openssl x509 -inform DER -in cert.der -outform PEM > cert.pem</programlisting>
@ -581,4 +671,10 @@
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>pkcs11-tool</command> was written by
Olaf Kirch <email>okir@suse.de</email>.</para>
</refsect1>
</refentry>

View File

@ -129,22 +129,31 @@
<varlistentry>
<term>
<option>--reader</option> <replaceable>N</replaceable>,
<option>-r</option> <replaceable>N</replaceable>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>Selects the <replaceable>N</replaceable>-th smart
card reader configured by the system. If unspecified,
<command>pkcs15-crypt</command> will use the first reader
found.</para></listitem>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--md5</option>
<option>--sha-1</option>
<option>--sha-224</option>
<option>--sha-256</option>
<option>--sha-384</option>
<option>--sha-512</option>
</term>
<listitem><para>This option tells <command>pkcs15-crypt</command>
that the input file is the result of an SHA1 hash operation,
rather than an MD5 hash. Again, the data must be in binary
<listitem><para>These options tell <command>pkcs15-crypt</command>
that the input file is the result of the specified hash operation.
By default, an MD5 hash is expected. Again, the data must be in binary
representation.</para></listitem>
</varlistentry>
@ -174,9 +183,18 @@
</term>
<listitem><para>When signing with ECDSA key this option indicates
to <command>pkcs15-crypt</command> the signature output format.
Possible values are 'rs'(default) -- two concatanated
Possible values are 'rs'(default) -- two concatenated
integers (PKCS#11), 'sequence' or 'openssl' -- DER encoded sequence
of two integeres (OpenSSL).</para></listitem>
of two integers (OpenSSL).</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--wait</option>,
<option>-w</option>
</term>
<listitem><para>Causes <command>pkcs15-crypt</command> to
wait for a card insertion.</para></listitem>
</varlistentry>
<varlistentry>
@ -206,4 +224,10 @@
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>pkcs15-crypt</command> was written by
Juha Yrjölä <email>juha.yrjola@iki.fi</email>.</para>
</refsect1>
</refentry>

View File

@ -136,11 +136,12 @@
<command>pkcs15-init --generate-key " keyspec " --auth-id " nn</command>
</para>
<para>
where <replaceable>keyspec</replaceable> describes the algorithm and length of the
key to be created, such as <literal>rsa/512</literal>. This will create a 512 bit
RSA key. Currently, only RSA key generation is supported. Note that cards
usually support just a few different key lengths. Almost all cards will support
512 and 1024 bit keys, some will support 768 or 2048 as well.
where <replaceable>keyspec</replaceable> describes the algorithm and the parameters
of the key to be created. For example, <literal>rsa:2048</literal> generates a RSA key
with 2048-bit modulus. If you are generating an EC key, the curve designation must
be specified, for example <literal>ec:prime256v1</literal>. For symmetric key,
the length of key is specified in bytes, for example <literal>AES:32</literal>
or <literal>DES3:24</literal>.
</para>
<para>
<replaceable>nn</replaceable> is the ID of a user PIN installed previously,
@ -148,7 +149,7 @@
</para>
<para>
In addition to storing the private portion of the key on the card,
<command>pkcs15-init</command> will also store the the public portion of the
<command>pkcs15-init</command> will also store the public portion of the
key as a PKCS #15 public key object.
</para>
</refsect2>
@ -165,16 +166,16 @@
</para>
<para>
In addition to storing the private portion of the key on the card,
<command>pkcs15-init</command> will also store the the public portion of the
<command>pkcs15-init</command> will also store the public portion of the
key as a PKCS #15 public key object.
</para>
<para>
Note that usage of <option>--id</option> option in the <command>pkcs15-init</command>
commands to generate or to import a new key is deprecated.
Better practice is to let the middleware to derive the identifier from the key material.
(SHA1(modulus) for RSA, SHA1(pub) for DSA, ...).
This allows easily set up relation between 'related' objects
(private/public keys and certificates).
commands to generate or to import a new key is deprecated.
Better practice is to let the middleware to derive the identifier from the key material.
(SHA1(modulus) for RSA, SHA1(pub) for DSA, ...).
This allows easily set up relation between 'related' objects
(private/public keys and certificates).
</para>
<para>
In addition to the PEM key file format, <command>pkcs15-init</command> also
@ -242,7 +243,7 @@
you would use
</para>
<para>
<command>pkcs15-init --store-secret-key /dev/urandom --secret-key-algorithm aes/256 --auth-id 01</command>
<command>pkcs15-init --store-secret-key /dev/urandom --secret-key-algorithm aes:256 --auth-id 01</command>
</para>
<para>
By default a random ID is generated for the secret key. You may specify an ID
@ -255,12 +256,12 @@
<title>Options</title>
<para>
<variablelist>
<varlistentry>
<term>
<option>--version</option>,
</term>
<listitem><para>Print the OpenSC package release version.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--version</option>,
</term>
<listitem><para>Print the OpenSC package release version.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--card-profile</option> <replaceable>name</replaceable>,
@ -287,6 +288,17 @@
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--serial</option> <replaceable>SERIAL</replaceable>
</term>
<listitem>
<para>
Specify the serial number of the card.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--erase-card</option>,
@ -301,6 +313,18 @@
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--erase-application</option> <replaceable>AID</replaceable>
</term>
<listitem>
<para>
This will erase the application with the application identifier
<replaceable>AID</replaceable>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--generate-key</option> <replaceable>keyspec</replaceable>,
@ -309,62 +333,53 @@
<listitem>
<para>
Tells the card to generate new key and store it on the card.
<replaceable>keyspec</replaceable> consists of an algorithm name
(currently, the only supported name is <option>RSA</option>),
optionally followed by a slash and the length of the key in bits.
<replaceable>keyspec</replaceable> consists of an algorithm name,
optionally followed by a colon ":", slash "/" or hyphen "-" and
the parameters of the key to be created.
It is a good idea to specify the key ID along with this command,
using the <option>id</option> option, otherwise an intrinsic ID
will be calculated from the key material. Look the description of
the 'pkcs15-id-style' attribut in the 'pkcs15.profile' for the details
about the algorithm used to calculate intrinsic ID.
For the multi-application cards the target PKCS#15 application can be
specified by the hexadecimal AID value of the <option>aid</option> option.
will be calculated from the key material. Look the description of
the 'pkcs15-id-style' attribute in the 'pkcs15.profile' for the details
about the algorithm used to calculate intrinsic ID.
For the multi-application cards the target PKCS#15 application can be
specified by the hexadecimal AID value of the <option>aid</option> option.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--options-file</option> <replaceable>filename</replaceable>
<option>--pin</option> <replaceable>pin</replaceable>,
<option>--puk</option> <replaceable>puk</replaceable>,
<option>--so-pin</option> <replaceable>sopin</replaceable>,
<option>--so-puk</option> <replaceable>sopuk</replaceable>
</term>
<listitem>
<para>
Tells <command>pkcs15-init</command> to read additional options
from <replaceable>filename</replaceable>. The file is supposed to
contain one long option per line, without the leading dashes,
for instance:
<programlisting>
pin frank
puk zappa
</programlisting>
These options can be used to specify the PIN/PUK values
on the command line. If the value is set to
<literal>env:</literal><replaceable>VARIABLE</replaceable>, the value
of the specified environment variable is used. By default,
the code is prompted on the command line if needed.
</para>
<para>
You can specify <option>--options-file</option> several times.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--pin</option>,
<option>--puk</option>
<option>--so-pin</option>,
<option>--so-puk</option>,
</term>
<listitem>
<para>
These options can be used to specify PIN/PUK values
on the command line. If set to
env:<replaceable>VARIABLE</replaceable>, the value
of the environment variable
<replaceable>VARIABLE</replaceable> is used. Note
that on most operation systems, any user can
Note that on most operation systems, any user can
display the command line of any process on the
system using utilities such as
<command>ps(1)</command>. Therefore, you should use
these options only on a secured system, or in an
options file specified with
<option>--options-file</option>.
<command>ps(1)</command>. Therefore, you should prefer
passing the codes via an environment variable
on an unsecured system.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--no-so-pin</option>,
</term>
<listitem>
<para>
Do not install a SO PIN, and do not prompt for it.
</para>
</listitem>
</varlistentry>
@ -403,7 +418,7 @@
<listitem>
<para>
<replaceable>keyspec</replaceable> describes the algorithm and length of the
key to be created or downloaded, such as <literal>aes/256</literal>.
key to be created or downloaded, such as <literal>aes:256</literal>.
This will create a 256 bit AES key.
</para>
</listitem>
@ -419,13 +434,25 @@
Tells <command>pkcs15-init</command> to store the certificate given
in <option>filename</option> on the card, creating a certificate
object with the ID specified via the <option>--id</option> option.
Without supplied ID an intrisic ID will be calculated from the
certificate's public key. Look the description of the 'pkcs15-id-style'
attribut in the 'pkcs15.profile' for the details
about the algorithm used to calculate intrinsic ID.
Without supplied ID an intrinsic ID will be calculated from the
certificate's public key. Look the description of the 'pkcs15-id-style'
attribute in the 'pkcs15.profile' for the details
about the algorithm used to calculate intrinsic ID.
The file is assumed to contain the PEM encoded certificate.
For the multi-application cards the target application can be specified
by the hexadecimal AID value of the <option>aid</option> option.
For the multi-application cards the target application can be specified
by the hexadecimal AID value of the <option>aid</option> option.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--store-pin</option>,
<option>-P</option>
</term>
<listitem>
<para>
Store a new PIN/PUK on the card.
</para>
</listitem>
</varlistentry>
@ -459,11 +486,11 @@
formats can be specified using <option>--format</option>.
It is a good idea to specify the key ID along with this command,
using the <option>--id</option> option, otherwise an intrinsic ID
will be calculated from the key material. Look the description of
the 'pkcs15-id-style' attribut in the 'pkcs15.profile' for the details
about the algorithm used to calculate intrinsic ID.
For the multi-application cards the target PKCS#15 application can be
specified by the hexadecimal AID value of the <option>aid</option> option.
will be calculated from the key material. Look the description of
the 'pkcs15-id-style' attribute in the 'pkcs15.profile' for the details
about the algorithm used to calculate intrinsic ID.
For the multi-application cards the target PKCS#15 application can be
specified by the hexadecimal AID value of the <option>aid</option> option.
</para>
</listitem>
</varlistentry>
@ -478,6 +505,8 @@
secret key to the card. The file is assumed to contain the raw key.
They key type should be specified with <option>--secret-key-algorithm</option>
option.
</para>
<para>
You may additionally specify the key ID along with this command,
using the <option>--id</option> option, otherwise a random ID is generated.
For the multi-application cards the target PKCS#15 application can be
@ -486,6 +515,18 @@
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--store-data</option> <replaceable>filename</replaceable>,
<option>-W</option> <replaceable>filename</replaceable>
</term>
<listitem>
<para>
Store a data object.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--update-certificate</option> <replaceable>filename</replaceable>,
@ -495,11 +536,62 @@
<para>
Tells <command>pkcs15-init</command> to update the certificate
object with the ID specified via the <option>--id</option> option
with the certificate in <option>filename</option>.
with the certificate in <replaceable>filename</replaceable>.
The file is assumed to contain a PEM encoded certificate.
</para>
<para>Pay extra attention when updating mail decryption certificates, as
missing certificates can render e-mail messages unreadable!
missing certificates can render e-mail messages unreadable!
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--delete-objects</option> <replaceable>arg</replaceable>,
<option>-D</option> <replaceable>arg</replaceable>
</term>
<listitem>
<para>
Tells <command>pkcs15-init</command> to delete the
specified object. <replaceable>arg</replaceable>
is comma-separated list containing any of
<literal>privkey</literal>, <literal>pubkey</literal>,
<literal>secrkey</literal>, <literal>cert</literal>,
<literal>chain</literal> or <literal>data</literal>.
</para>
<para>
When <literal>data</literal> is specified, an
-<option>--application-id</option> must also be
specified, in the other cases an
<option>--id</option> must also be specified
</para>
<para>
When <literal>chain</literal> is specified, the
certificate chain starting with the cert with
specified ID will be deleted, until there's a CA
certificate that certifies another cert on the card
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--change-attributes</option> <replaceable>arg</replaceable>,
<option>-A</option> <replaceable>arg</replaceable>
</term>
<listitem>
<para>
Tells <command>pkcs15-init</command> to change the
specified attribute. <replaceable>arg</replaceable>
is either <literal>privkey</literal>,
<literal>pubkey</literal>, <literal>secrkey</literal>,
<literal>cert</literal> or <literal>data</literal>.
You also have to specify the <option>--id</option>
of the object.
For now, you can only change the <option>--label</option>, e.g:
<programlisting>
pkcs15-init -A cert --id 45 -a 1 --label Jim
</programlisting>
</para>
</listitem>
</varlistentry>
@ -517,6 +609,35 @@
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--sanity-check</option>,
<option>-T</option>
</term>
<listitem>
<para>
Tells <command>pkcs15-init</command> to perform a
card specific sanity check and possibly update
procedure.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--verbose</option>,
@ -530,6 +651,15 @@
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--wait</option>,
<option>-w</option>
</term>
<listitem><para>Causes <command>pkcs15-init</command> to
wait for a card insertion.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--use-pinpad</option>
@ -537,6 +667,241 @@
<listitem><para>Do not prompt the user; if no PINs supplied, pinpad will be used.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--puk-id</option> <replaceable>ID</replaceable>
</term>
<listitem>
<para>
Specify ID of PUK to use/create
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--puk-label</option> <replaceable>LABEL</replaceable>
</term>
<listitem>
<para>
Specify label of PUK
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--public-key-label</option> <replaceable>LABEL</replaceable>
</term>
<listitem>
<para>
Specify public key label (use with <option>--generate-key</option>)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--cert-label</option> <replaceable>LABEL</replaceable>
</term>
<listitem>
<para>
Specify user cert label (use with <option>--store-private-key</option>)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--application-name</option> <replaceable>arg</replaceable>
</term>
<listitem>
<para>
Specify application name of data object (use with <option>--store-data-object</option>)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--aid</option> <replaceable>AID</replaceable>
</term>
<listitem>
<para>
Specify AID of the on-card PKCS#15 application to be binded to (in hexadecimal form)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--output-file</option> <replaceable>filename</replaceable>
<option>-o</option> <replaceable>filename</replaceable>,
</term>
<listitem>
<para>
Output public portion of generated key to file
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--passphrase</option> <replaceable>PASSPHRASE</replaceable>
</term>
<listitem>
<para>
Specify passphrase for unlocking secret key
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--authority</option>
</term>
<listitem>
<para>
Mark certificate as a CA certificate
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--key-usage</option> <replaceable>arg</replaceable>
<option>-u</option> <replaceable>arg</replaceable>,
</term>
<listitem>
<para>
Specifies the X.509 key usage.
<replaceable>arg</replaceable> is comma-separated
list containing any of
<literal>digitalSignature</literal>,
<literal>nonRepudiation</literal>,
<literal>keyEncipherment</literal>,
<literal>dataEncipherment</literal>,
<literal>keyAgreement</literal>,
<literal>keyCertSign</literal>,
<literal>cRLSign</literal>. Abbreviated names are
allowed if unique (e.g.
<literal>dataEnc</literal>).
</para>
<para>
The alias <literal>sign</literal> is equivalent to
<literal>digitalSignature,keyCertSign,cRLSign</literal>
</para>
<para>
The alias <literal>decrypt</literal> is equivalent to
<literal>keyEncipherment,dataEncipherment</literal>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--finalize</option>
<option>-F</option>,
</term>
<listitem>
<para>
Finish initialization phase of the smart card
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--update-last-update</option>
</term>
<listitem>
<para>
Update 'lastUpdate' attribute of tokenInfo
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--ignore-ca-certificates</option>
</term>
<listitem>
<para>
When storing PKCS#12 ignore CA certificates
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--update-existing</option>
</term>
<listitem>
<para>
Store or update existing certificate
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--extractable</option>
</term>
<listitem>
<para>
Private key stored as an extractable key
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--user-consent</option> <replaceable>arg</replaceable>
</term>
<listitem>
<para>
Specify user-consent. <replaceable>arg</replaceable> is an integer value.
If > 0, the value specifies how many times the
object can be accessed before a new authentication is required.
If zero, the object does not require re-authentication.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--insecure</option>
</term>
<listitem>
<para>
Insecure mode: do not require a PIN for private key
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--md-container-guid</option> <replaceable>GUID</replaceable>
</term>
<listitem>
<para>
For a new key specify GUID for a MD container
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--help</option>
<option>-h</option>,
</term>
<listitem>
<para>
Display help message
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
@ -551,4 +916,10 @@
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>pkcs15-init</command> was written by
Olaf Kirch <email>okir@suse.de</email>.</para>
</refsect1>
</refentry>

View File

@ -52,8 +52,8 @@
<varlistentry>
<term>
<option>--auth-id</option> <replaceable>pin</replaceable>,
<option>-a</option> <replaceable>pin</replaceable>
<option>--auth-id</option> <replaceable>id</replaceable>,
<option>-a</option> <replaceable>id</replaceable>
</term>
<listitem><para>Specifies the auth id of the PIN to use for the
operation. This is useful with the --change-pin operation.</para></listitem>
@ -75,11 +75,18 @@
<listitem><para>List all card objects.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--list-info</option>
</term>
<listitem><para>List card objects.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--list-applications</option>
</term>
<listitem><para>List the on-card PKCS#15 applications</para></listitem>
<listitem><para>List the on-card PKCS#15 applications.</para></listitem>
</varlistentry>
<varlistentry>
@ -115,6 +122,18 @@
In such a case the <option>--verify-pin</option> option has to be used.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--list-secret-keys</option>
</term>
<listitem><para>List all secret (symmetric) keys stored on the token. General
information about each secret key is listed (eg. key name, id and
algorithm). Actual secret key values are not displayed.
For some cards the PKCS#15 attributes of the private keys are protected for reading
and need the authentication with the User PIN.
In such a case the <option>--verify-pin</option> option has to be used.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--list-pins</option>
@ -190,8 +209,7 @@
<varlistentry>
<term>
<option>--read-certificate</option> <replaceable>cert</replaceable>,
<option>-r</option> <replaceable>cert</replaceable>
<option>--read-certificate</option> <replaceable>cert</replaceable>
</term>
<listitem><para>Reads the certificate with the given id.</para></listitem>
</varlistentry>
@ -243,11 +261,32 @@
<varlistentry>
<term>
<option>--reader</option> <replaceable>num</replaceable>
<option>--test-update</option>,
<option>-T</option>,
</term>
<listitem><para>Forces <command>pkcs15-tool</command> to use reader
number <replaceable>num</replaceable> for operations. The default is to use
reader number 0, the first reader in the system.</para></listitem>
<listitem><para>Test if the card needs a security update</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--update</option>,
<option>-U</option>,
</term>
<listitem><para>Update the card with a security update</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--reader</option> <replaceable>arg</replaceable>
</term>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
@ -269,6 +308,38 @@
in the OpenSC library.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--pin</option> <replaceable>pin</replaceable>,
<option>--new-pin</option> <replaceable>newpin</replaceable>
<option>--puk</option> <replaceable>puk</replaceable>
</term>
<listitem>
<para>
These options can be used to specify the PIN/PUK values
on the command line. If the value is set to
<literal>env:</literal><replaceable>VARIABLE</replaceable>, the value
of the specified environment variable is used. By default,
the code is prompted on the command line if needed.
</para>
<para>
Note that on most operation systems, any user can
display the command line of any process on the
system using utilities such as
<command>ps(1)</command>. Therefore, you should prefer
passing the codes via an environment variable
on an unsecured system.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--new-pin</option> <replaceable>pin</replaceable>
</term>
<listitem><para>Specify New PIN (when changing or unblocking)</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--verify-pin</option>
@ -277,6 +348,23 @@
(without 'auth-id' the first non-SO, non-Unblock PIN will be verified)</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--test-session-pin</option>
</term>
<listitem><para>Equivalent to <option>--verify-pin</option>
with additional session PIN generation</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--wait</option>,
<option>-w</option>
</term>
<listitem><para>Causes <command>pkcs15-tool</command> to
wait for a card insertion.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--use-pinpad</option>
@ -302,4 +390,10 @@
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>pkcs15-tool</command> was written by
Juha Yrjölä <email>juha.yrjola@iki.fi</email>.</para>
</refsect1>
</refentry>

View File

@ -120,26 +120,25 @@
<varlistentry>
<term>
<option>--so-pin</option> <replaceable>value</replaceable>
<option>--pin</option> <replaceable>pin</replaceable>,
<option>--so-pin</option> <replaceable>sopin</replaceable>,
</term>
<listitem>
<para>Define SO-PIN for initialization. If set to
env:<replaceable>VARIABLE</replaceable>, the value of
the environment variable
<replaceable>VARIABLE</replaceable> is used.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--pin</option> <replaceable>value</replaceable>
</term>
<listitem>
<para>Define user PIN for initialization, wrap or
unwrap operation. If set to
env:<replaceable>VARIABLE</replaceable>, the value of
the environment variable
<replaceable>VARIABLE</replaceable> is used.</para>
<para>
These options can be used to specify the PIN values
on the command line. If the value is set to
<literal>env:</literal><replaceable>VARIABLE</replaceable>, the value
of the specified environment variable is used. By default,
the code is prompted on the command line if needed.
</para>
<para>
Note that on most operation systems, any user can
display the command line of any process on the
system using utilities such as
<command>ps(1)</command>. Therefore, you should prefer
passing the codes via an environment variable
on an unsecured system.
</para>
</listitem>
</varlistentry>
@ -151,7 +150,25 @@
<para>Define number of PIN retries for user PIN during initialization. Default is 3.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--bio-server1</option> <replaceable>value</replaceable>
</term>
<listitem>
<para>The hexadecimal AID of of the biometric server for template 1. Switches on the use of the user PIN as session PIN.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--bio-server2</option> <replaceable>value</replaceable>
</term>
<listitem>
<para>The hexadecimal AID of of the biometric server for template 2. Switches on the use of the user PIN as session PIN.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--password</option> <replaceable>value</replaceable>
@ -201,11 +218,17 @@
<varlistentry>
<term>
<option>--reader</option> <replaceable>num</replaceable>,
<option>-r</option> <replaceable>num</replaceable>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>Use the given reader number. The default is
<literal>0</literal>, the first reader in the system.</para></listitem>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
@ -257,4 +280,10 @@
</para>
</refsect1>
<refsect1>
<title>Authors</title>
<para><command>sc-hsm-tool</command> was written by
Andreas Schwier <email>andreas.schwier@cardcontact.de</email>.</para>
</refsect1>
</refentry>

View File

@ -1,17 +0,0 @@
#!/bin/bash
SOURCE_PATH=../../
# find all the manual pages in src/tools
TOOLS=`find "${SOURCE_PATH}/doc/tools" -name "*.1.xml" | sed -E -e "s|.*/([a-z0-9-]*).*|\1|"`
ALL=1
for T in $TOOLS; do
SWITCHES=`${SOURCE_PATH}/src/tools/${T} 2>&1 | awk '{if (match($0,"--[a-zA-Z0-9-]*",a) != 0) print a[0]} {if (match($0," -[a-zA-Z0-9]",a) != 0) print a[0]}'`
for S in $SWITCHES; do
grep -q -- "$S" ${SOURCE_PATH}/doc/tools/${T}.1.xml || { echo "${T}: missing switch $S"; ALL=0; };
done
done
if [ "$ALL" = 0 ]; then
echo "Not all the switches in help are documented in manual pages"
exit 1;
fi

2632
doc/tools/tools.html Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,33 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<book xmlns:xi="http://www.w3.org/2001/XInclude">
<title>OpenSC</title>
<reference>
<referenceinfo>
<title>OpenSC tools</title>
</referenceinfo>
<xi:include href="eidenv.1.xml"/>
<xi:include href="cardos-tool.1.xml"/>
<xi:include href="cryptoflex-tool.1.xml"/>
<xi:include href="netkey-tool.1.xml"/>
<xi:include href="openpgp-tool.1.xml"/>
<xi:include href="iasecc-tool.1.xml"/>
<xi:include href="opensc-tool.1.xml"/>
<xi:include href="opensc-explorer.1.xml"/>
<xi:include href="piv-tool.1.xml"/>
<xi:include href="pkcs11-tool.1.xml"/>
<xi:include href="pkcs15-crypt.1.xml"/>
<xi:include href="pkcs15-tool.1.xml"/>
<xi:include href="pkcs15-init.1.xml"/>
<xi:include href="westcos-tool.1.xml"/>
</reference>
<title>OpenSC Manual Pages: Section 1</title>
<reference>
<referenceinfo>
<title>OpenSC file formats</title>
</referenceinfo>
<xi:include href="pkcs15-profile.5.xml"/>
</reference>
<xi:include href="cardos-tool.1.xml"/>
<xi:include href="cryptoflex-tool.1.xml"/>
<xi:include href="dnie-tool.1.xml"/>
<xi:include href="egk-tool.1.xml"/>
<xi:include href="eidenv.1.xml"/>
<xi:include href="gids-tool.1.xml"/>
<xi:include href="iasecc-tool.1.xml"/>
<xi:include href="netkey-tool.1.xml"/>
<xi:include href="npa-tool.1.xml"/>
<xi:include href="openpgp-tool.1.xml"/>
<xi:include href="opensc-asn1.1.xml"/>
<xi:include href="opensc-explorer.1.xml"/>
<xi:include href="opensc-notify.1.xml"/>
<xi:include href="opensc-tool.1.xml"/>
<xi:include href="piv-tool.1.xml"/>
<xi:include href="pkcs11-tool.1.xml"/>
<xi:include href="pkcs15-crypt.1.xml"/>
<xi:include href="pkcs15-init.1.xml"/>
<xi:include href="pkcs15-tool.1.xml"/>
<xi:include href="sc-hsm-tool.1.xml"/>
<xi:include href="westcos-tool.1.xml"/>
</book>

View File

@ -62,8 +62,8 @@
<listitem><para>Finalize the card. Once finalized the default key is
invalidated, so PIN and PUK cannot be changed anymore without user
authentication.</para>
<para>Warning, un-finalized are insecure because PIN can be changed
without user authentication (knowledge of default key
<para>Warning, un-finalized cards are insecure because the PIN can be
changed without user authentication (knowledge of default key
is enough).</para></listitem>
</varlistentry>
@ -73,8 +73,8 @@
<option>-g</option>
</term>
<listitem><para>Generate a private key on the card. The card must not have
been finalized and a PIN must be installed (ie. the file for ithe PIN must
havei been created, see option <option>-i</option>).
been finalized and a PIN must be installed (i.e. the file for the PIN must
have been created, see option <option>-i</option>).
By default the key length is 1536 bits. User authentication is required for
this operation. </para></listitem>
</varlistentry>
@ -115,25 +115,28 @@
<varlistentry>
<term>
<option>--pin-value</option> <replaceable>value</replaceable>,
<option>-x</option> <replaceable>value</replaceable>
<option>--pin-value</option> <replaceable>pin</replaceable>,
<option>-x</option> <replaceable>pin</replaceable>
<option>--puk-value</option> <replaceable>puk</replaceable>,
<option>-y</option> <replaceable>puk</replaceable>
</term>
<listitem><para>Set value of PIN. If set to
env:<replaceable>VARIABLE</replaceable>, the value of
the environment variable
<replaceable>VARIABLE</replaceable> is used.</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--puk-value</option> <replaceable>value</replaceable>,
<option>-y</option> <replaceable>value</replaceable>
</term>
<listitem><para>set value of PUK (or value of new PIN for change PIN
command see <option>-n</option>). If set to
env:<replaceable>VARIABLE</replaceable>, the value of
the environment variable
<replaceable>VARIABLE</replaceable> is used.</para></listitem>
<listitem>
<para>
These options can be used to specify the PIN/PUK values
on the command line. If the value is set to
<literal>env:</literal><replaceable>VARIABLE</replaceable>, the value
of the specified environment variable is used. By default,
the code is prompted on the command line if needed.
</para>
<para>
Note that on most operation systems, any user can
display the command line of any process on the
system using utilities such as
<command>ps(1)</command>. Therefore, you should prefer
passing the codes via an environment variable
on an unsecured system.
</para>
</listitem>
</varlistentry>
<varlistentry>
@ -148,12 +151,17 @@
<varlistentry>
<term>
<option>--reader</option> <replaceable>num</replaceable>,
<option>-r</option> <replaceable>num</replaceable>
<option>--reader</option> <replaceable>arg</replaceable>,
<option>-r</option> <replaceable>arg</replaceable>
</term>
<listitem><para>
Use the given reader. The default is the first reader with a card.
</para></listitem>
<listitem>
<para>
Number of the reader to use. By default, the first
reader with a present card is used. If
<replaceable>arg</replaceable> is an ATR, the
reader with a matching card will be chosen.
</para>
</listitem>
</varlistentry>
<varlistentry>
@ -167,6 +175,7 @@
<varlistentry>
<term>
<option>--verbose</option>
<option>-v</option>
</term>
<listitem><para>Causes <command>westcos-tool</command> to be more

BIN
etc/DESCHSMCVCA00001 Normal file

Binary file not shown.

View File

@ -1,23 +1,23 @@
CV_CERTS = DESRCACC100001
CV_CERTS = DESRCACC100001 DESCHSMCVCA00001
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
DISTCLEANFILES = opensc.conf
DISTCLEANFILES = opensc.conf.example
EXTRA_DIST = $(CV_CERTS) Makefile.mak
SUFFIXES = .in
dist_noinst_DATA = opensc.conf.in
nodist_noinst_DATA = opensc.conf
dist_noinst_DATA = opensc.conf opensc.conf.example.in
nodist_noinst_DATA = opensc.conf.example
# Make sure we build this every time
# as there is no dependency for this.
# Can be removed if MSVC is not requried.
# Can be removed if MSVC is not required.
force:
opensc.conf: opensc.conf.in force
opensc.conf.example: opensc.conf.example.in force
.in:
@sed \
$(AM_V_GEN)sed \
-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
-e 's|@DEBUG_FILE[@]|$(DEBUG_FILE)|g' \
-e 's|@DEFAULT_PCSC_PROVIDER[@]|$(DEFAULT_PCSC_PROVIDER)|g' \
@ -30,16 +30,19 @@ opensc.conf: opensc.conf.in force
-e 's|@PROFILE_DIR_DEFAULT[@]|$(PROFILE_DIR_DEFAULT)|g' \
< $< > $@
install-exec-hook: opensc.conf
install-exec-hook: opensc.conf.example
$(MKDIR_P) "$(DESTDIR)$(sysconfdir)"
if [ -f "$(DESTDIR)$(sysconfdir)/opensc.conf" ]; then \
$(INSTALL_DATA) opensc.conf "$(DESTDIR)$(sysconfdir)/opensc.conf.new"; \
$(INSTALL_DATA) $(srcdir)/opensc.conf "$(DESTDIR)$(sysconfdir)/opensc.conf.new"; \
else \
$(INSTALL_DATA) opensc.conf "$(DESTDIR)$(sysconfdir)/opensc.conf"; \
$(INSTALL_DATA) $(srcdir)/opensc.conf "$(DESTDIR)$(sysconfdir)/opensc.conf"; \
fi
$(MKDIR_P) "$(DESTDIR)$(docdir)"
$(INSTALL_DATA) opensc.conf.example "$(DESTDIR)$(docdir)/opensc.conf";
uninstall-hook: opensc.conf
uninstall-hook: opensc.conf.example
rm -f "$(DESTDIR)$(sysconfdir)/opensc.conf.new" "$(DESTDIR)$(sysconfdir)/opensc.conf"
rm -f "$(DESTDIR)$(docdir)/opensc.conf"
if ENABLE_OPENPACE
install-data-local:

7
etc/opensc.conf Normal file
View File

@ -0,0 +1,7 @@
app default {
# debug = 3;
# debug_file = opensc-debug.txt;
framework pkcs15 {
# use_file_caching = true;
}
}

View File

@ -21,41 +21,31 @@ app default {
#
# debug_file = @DEBUG_FILE@
# Reopen debug file at the every debug message.
#
# For Windows it's forced to 'true'. The reason is that
# in Windows file handles can not be shared between DLL-s,
# each DLL has a separate file handle table.
#
# Default: false
# reopen_debug_file = true;
# PKCS#15 initialization / personalization
# profiles directory for pkcs15-init.
# Default: @PROFILE_DIR_DEFAULT@
#
# profile_dir = @PROFILE_DIR@;
# Paranoid memory allocation.
#
# If set to 'true', then refuse to continue when locking of non-pageable
# memory fails. This can cause subtle failures but is more secure when
# you have a swap disk.
# Default: false
#
# paranoid_memory = false;
# Dsiable pop-ups of built-in GUI
# Disable pop-ups of built-in GUI
#
# Default: false
# disable_popups = true;
# Enable default card driver
# Default card driver is explicitely enabled for the 'opensc-explorer' and 'opensc-tool'.
# Default card driver is explicitly enabled for the 'opensc-explorer' and 'opensc-tool'.
#
# Default: false
# enable_default_driver = true;
# List of readers to ignore
# If any of the strings listed below is matched in a reader name (case
# sensitive, partial matching possible), the reader is ignored by OpenSC.
# Use `opensc-tool --list-readers` to see all currently connected readers.
#
# Default: empty
# ignored_readers = "CardMan 1021", "SPR 532";
# CT-API module configuration.
reader_driver ctapi {
# module @LIBDIR@@LIB_PRE@towitoko@DYN_LIB_EXT@ {
@ -103,6 +93,12 @@ app default {
# Default: true
# enable_pinpad = false;
#
# Some pinpad readers can only handle one exact length of the PIN.
# fixed_pinlength sets this value so that OpenSC expands the padding to
# this length.
# Default: 0 (i.e. not fixed)
# fixed_pinlength = 6;
#
# Detect reader capabilities with escape commands (wrapped APDUs with
# CLA=0xFF as defined by PC/SC pt. 3 and BSI TR-03119, e.g. for getting
# the UID, escaped PIN commands and the reader's firmware version)
@ -147,7 +143,7 @@ app default {
# statically linked drivers that may be removed in the future.
#
# A special value of 'internal' will load all
# statically linked drivers. If an unknown (ie. not
# statically linked drivers. If an unknown (i.e. not
# internal) driver is supplied, a separate configuration
# configuration block has to be written for the driver.
# Default: internal
@ -178,7 +174,7 @@ app default {
# QES is only possible with a Comfort Reader (CAT-K), which holds a
# cryptographic key to authenticate itself as signature terminal (ST).
# We usually will use the reader's capability to sign the data.
# However, during developement you may specify soft certificates and
# However, during development you may specify soft certificates and
# keys for a ST below.
# The following example EAC PKI can be found in vicc's example data:
# https://github.com/frankmorgner/vsmartcard/tree/master/virtualsmartcard/npa-example-data
@ -188,15 +184,6 @@ app default {
#st_key = ZZSTTERM00001.pkcs8;
}
# Force using specific card driver
#
# If this option is present, OpenSC will use the supplied
# driver with all inserted cards.
#
# Default: autodetect
#
# force_card_driver = customcos;
# Configuration block for DNIe
#
# Card DNIe has an option to show an extra warning before
@ -215,6 +202,15 @@ app default {
# user_consent_app = "/usr/bin/pinentry";
}
card_driver edo {
# CAN is required to establish connection
# with the card. It might be overridden by
# EDO_CAN environment variable. Currently,
# it is not possible to set it in any other way.
#
#can = 123456;
}
# In addition to the built-in list of known cards in the
# card driver, you can configure a new card for the driver
# using the card_atr block. The goal is to centralize
@ -276,10 +272,6 @@ app default {
#
# flags = "rng", "keep_alive", "0x80000000";
# Enable pkcs11 initialization.
# Default: no
# pkcs11_enable_InitToken = yes;
#
# Context: PKCS#15 emulation layer
#
@ -299,10 +291,10 @@ app default {
# Context: minidriver
#
# md_read_only: Mark card as read/only card in Minidriver/BaseCSP interface (Default: false)
# read_only: Mark card as read/only card in Minidriver/BaseCSP interface (Default: false)
# md_supports_X509_enrollment: Indicate X509 enrollment support at Minidriver/BaseCSP interface (Default: false)
# md_guid_as_id: Use the GUID generated for the key as id in the PKCS#15 structure (Default: false - auto generated)
# md_guid_as_label: Use the GUID generated for the key as label in the PKCS#15 structure (Default: false - no label set)
# md_guid_as_id: Use the GUID generated for the key as id in the PKCS#15 structure (Default: false, i.e. auto generated)
# md_guid_as_label: Use the GUID generated for the key as label in the PKCS#15 structure (Default: false, i.e. no label set)
# md_supports_container_key_gen: Card allows generating key pairs on the card (Default: false)
# md_supports_container_key_import: Card allows importing private keys (Default: false)
#
@ -330,21 +322,18 @@ app default {
# Default: "Please enter your PIN to unblock the user PIN on the PINPAD."
# md_pinpad_dlg_content_admin = "Content Admin";
#
# Content of the PIN pad dialog after pressing "Cancel", when the reader doesn't respond to SCardCancel
# md_pinpad_dlg_content_cancel = "Content Cancel";
#
# Expanded information of the PIN pad dialog
# Default: "This window will be closed automatically after the PIN has been submitted on the PINPAD (timeout typically after 30 seconds)."
# md_pinpad_dlg_expanded = "Expanded Information";
#
# Expanded information of the PIN pad dialog after pressing "Cancel", when the reader doesn't respond to SCardCancel
# Default: "Some readers only support canceling the operation on the PIN pad. Press Cancel or remove the card."
# md_pinpad_dlg_expanded_cancel = "Expanded Information Cancel";
#
# Allow the user to cancel the PIN pad dialog
# Allow the user to cancel the PIN pad dialog by not immediately requesting the PIN on the PIN pad
# Default: false
# md_pinpad_dlg_enable_cancel = true;
#
# Content of the verification of the PIN pad dialog
# Default: "Automatically request PIN immediately on PIN-Pad"
# md_pinpad_dlg_verification = "Verification";
#
# Time in seconds for the progress bar of the PIN pad dialog to tick. "0" removes the progress bar.
# Default: 30
# md_pinpad_dlg_timeout = 0;
@ -399,19 +388,6 @@ app default {
flags = "keep_alive";
}
# Micardo driver sometimes only play together with T=0
# In theory only the 'cold' ATR should be specified, as T=0 will
# be the preferred protocol once you boot it up with T=0, but be
# paranoid.
#
# D-Trust cards are also based on micardo and need T=0 for some reason
card_atr 3b:ff:94:00:ff:80:b1:fe:45:1f:03:00:68:d2:76:00:00:28:ff:05:1e:31:80:00:90:00:23 {
force_protocol = t0;
}
card_atr 3b:ff:11:00:ff:80:b1:fe:45:1f:03:00:68:d2:76:00:00:28:ff:05:1e:31:80:00:90:00:a6 {
force_protocol = t0;
}
# Oberthur's AuthentIC v3.2.2
card_atr 3B:DD:18:00:81:31:FE:45:80:F9:A0:00:00:00:77:01:00:70:0A:90:00:8B {
type = 11100;
@ -429,7 +405,7 @@ app default {
name = "Gemalto MultiApp IAS/ECC v1.0.1";
secure_messaging = local_gemalto_iam;
# secure_messaging = local_adele;
md_read_only = false;
read_only = false;
md_supports_X509_enrollment = true;
}
card_atr 3B:7F:96:00:00:00:31:B8:64:40:70:14:10:73:94:01:80:82:90:00 {
@ -437,7 +413,7 @@ app default {
driver = "iasecc";
name = "Gemalto MultiApp IAS/ECC v1.0.1";
secure_messaging = local_gemalto_iam;
md_read_only = false;
read_only = false;
md_supports_X509_enrollment = true;
}
#card_atr 3B:DD:18:00:81:31:FE:45:80:F9:A0:00:00:00:77:01:08:00:07:90:00:FE {
@ -456,7 +432,7 @@ app default {
# type = 25005;
# driver = "iasecc";
# name = "Morpho MI IAS/ECC v1.0.1";
# md_read_only = false;
# read_only = false;
# md_supports_X509_enrollment = true;
# secure_messaging = local_morpho_mi;
#}
@ -464,7 +440,7 @@ app default {
type = 25004;
driver = "iasecc";
name = "Amos IAS/ECC v1.0.1";
md_read_only = false;
read_only = false;
md_supports_X509_enrollment = true;
secure_messaging = local_amos;
}
@ -472,7 +448,7 @@ app default {
type = 25004;
driver = "iasecc";
name = "Amos IAS/ECC v1.0.1";
md_read_only = false;
read_only = false;
md_supports_X509_enrollment = true;
secure_messaging = local_amos_eid;
}
@ -480,7 +456,7 @@ app default {
# SmartCard-HSM with contact-based interface or USB-Stick
card_atr 3B:FE:18:00:00:81:31:FE:45:80:31:81:54:48:53:4D:31:73:80:21:40:81:07:FA {
driver = "sc-hsm";
md_read_only = false;
read_only = false;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -489,7 +465,16 @@ app default {
# SmartCard-HSM with contact-less interface
card_atr 3B:8E:80:01:80:31:81:54:48:53:4D:31:73:80:21:40:81:07:18 {
driver = "sc-hsm";
md_read_only = false;
read_only = false;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
}
# SmartCard-HSM 4k with contact-based interface or USB-Stick
card_atr 3b:de:18:ff:81:91:fe:1f:c3:80:31:81:54:48:53:4d:31:73:80:21:40:81:07:1c {
driver = "sc-hsm";
read_only = false;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -498,7 +483,7 @@ app default {
# SmartCard-HSM with fingerprint sensor and PIN pad
card_atr 3B:80:80:01:01 {
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -507,8 +492,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -524,7 +507,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -533,8 +516,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -549,7 +530,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -558,8 +539,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -574,7 +553,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00:00:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -583,8 +562,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -599,7 +576,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00:00:00:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -608,8 +585,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -624,7 +599,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00:00:00:00:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -633,8 +608,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -649,7 +622,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00:00:00:00:00:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -658,8 +631,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -674,7 +645,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00:00:00:00:00:00:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -683,8 +654,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -699,7 +668,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00:00:00:00:00:00:00:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -708,8 +677,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -724,7 +691,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00:00:00:00:00:00:00:00:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -733,8 +700,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -750,7 +715,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00:00:00:00:00:00:00:00:00:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -759,8 +724,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -776,7 +739,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00:00:00:00:00:00:00:00:00:00:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -785,8 +748,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -802,7 +763,7 @@ app default {
atrmask = "FF:FF:FF:FF:FF:FF:FF:FF:00:00:00:00:00:00:00:00:00:00:00:00";
driver = "sc-hsm";
force_protocol = "t1";
md_read_only = false;
read_only = true;
md_supports_X509_enrollment = true;
md_supports_container_key_gen = true;
md_guid_as_label = true;
@ -811,8 +772,6 @@ app default {
md_pinpad_dlg_content_user_sign = "Bitte verifizieren Sie Ihren Fingarabdruck oder Ihre PIN für die digitale Signatur auf der Karte.";
md_pinpad_dlg_content_admin = "Bitte geben Sie Ihre PIN zum Entsperren der Nutzer-PIN auf dem PIN-Pad ein.";
md_pinpad_dlg_expanded = "Dieses Fenster wird automatisch geschlossen, wenn die PIN oder der Fingerabdruck verifiziert wurde (Timeout nach 30 Sekunden). Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen.";
md_pinpad_dlg_expanded_cancel = "Die Karte unterstützt das Abbrechen ausschließlich am PIN-Pad. Nutzen Sie das PIN-Pad, um die Eingabe abzubrechen oder entfernen Sie die Karte.";
md_pinpad_dlg_allow_cancel = false;
md_pinpad_dlg_timeout = 30;
notify_card_inserted = "GoID erkannt";
notify_card_inserted_text = "";
@ -827,8 +786,8 @@ app default {
# name of external SM module
# module_name = @DEFAULT_SM_MODULE@;
# directory with external SM module
# Default: defined by windows register
@DEFAULT_SM_MODULE_PATH@
# Default: @DEFAULT_SM_MODULE_PATH@
# module_path = @DEFAULT_SM_MODULE_PATH@;
# specific data to tune the module initialization
# module_data = "Here can be your SM module init data";
@ -851,7 +810,7 @@ app default {
secure_messaging local_gemalto_iam {
module_name = @DEFAULT_SM_MODULE@;
@DEFAULT_SM_MODULE_PATH@
# module_path = @DEFAULT_SM_MODULE_PATH@;
# module_data = "";
type = acl; # transmit, acl
@ -870,7 +829,7 @@ app default {
secure_messaging local_amos {
module_name = @DEFAULT_SM_MODULE@;
@DEFAULT_SM_MODULE_PATH@
# module_path = @DEFAULT_SM_MODULE_PATH@;
# module_data = "";
mode = acl;
ifd_serial = "11:22:33:44:55:66:77:88";
@ -880,7 +839,7 @@ app default {
secure_messaging local_amos_eid {
module_name = @DEFAULT_SM_MODULE@;
@DEFAULT_SM_MODULE_PATH@
# module_path = @DEFAULT_SM_MODULE_PATH@;
# module_data = "";
mode = acl;
ifd_serial = "11:22:33:44:55:66:77:88";
@ -890,7 +849,7 @@ app default {
secure_messaging local_adele {
module_name = @DEFAULT_SM_MODULE@;
@DEFAULT_SM_MODULE_PATH@
# module_path = @DEFAULT_SM_MODULE_PATH@;
# module_data = "";
type = acl; # transmit, acl
@ -920,11 +879,10 @@ app default {
# Whether to use the cache files in the user's
# home directory.
#
# At the moment you have to 'teach' the card
# to the system by running command: pkcs15-tool -L
# Note: If caching is done by a system process, caching may be placed
# inaccessible from the user account. Use a global caching directory if
# you wish to share the cached information.
#
# WARNING: Caching shouldn't be used in setuid root
# applications.
# Default: false
# use_file_caching = true;
#
@ -933,7 +891,7 @@ app default {
# (with certificate check) where $HOME is not set
# Default: path in user home
# file_cache_dir = /var/lib/opensc/cache
#
# Use PIN caching?
# Default: true
# use_pin_caching = false;
@ -945,8 +903,15 @@ app default {
# Older PKCS#11 applications not supporting CKA_ALWAYS_AUTHENTICATE
# may need to set this to get signatures to work with some cards.
# Default: false
# It is recommended to enable also use_pin_caching to allow OpenSC
# to pass the pin to the card when needed.
# pin_cache_ignore_user_consent = true;
#
# How to handle a PIN-protected certificate
# Valid values: protect, declassify, ignore.
# Default: ignore in tokend, protect otherwise
# private_certificate = declassify;
# Enable pkcs15 emulation.
# Default: yes
# enable_pkcs15_emulation = no;
@ -964,7 +929,7 @@ app default {
# enable_builtin_emulation = no;
#
# List of the builtin pkcs15 emulators to test
# Default: esteid, openpgp, tcos, starcert, itacns, infocamere, postecert, actalis, atrust-acos, gemsafeGPK, gemsafeV1, tccardos, PIV-II;
# Default: esteid, openpgp, tcos, starcert, itacns, actalis, atrust-acos, gemsafeGPK, gemsafeV1, tccardos, PIV-II;
# builtin_emulators = openpgp;
# additional settings per driver
@ -978,12 +943,16 @@ app default {
# module = @LIBDIR@@LIB_PRE@p15emu_custom@DYN_LIB_EXT@;
# }
# Enable initialization and card recognition in PKCS#11 layer.
# Default: no
# pkcs11_enable_InitToken = yes;
# some additional application parameters:
# - type (generic, protected) used to distinguish the common access application
# and application for which authentication to perform some operation cannot be
# obtained with the common procedures (ex. object creation protected by secure messaging).
# Used by PKCS#11 module configurated to expose restricted number of slots.
# (for ex. configurated to expose only User PIN slot, User and Sign PINs slots, ...)
# Used by PKCS#11 module configured to expose restricted number of slots.
# (for ex. configured to expose only User PIN slot, User and Sign PINs slots, ...)
#
# - disable: do not expose application in PKCS15 framework
# default 'false'
@ -1028,15 +997,6 @@ app opensc-pkcs11 {
# (max_virtual_slots/slots_per_card) limits the number of readers
# that can be used on the system. Default is then 16/4=4 readers.
# Normally, the pkcs11 module will create
# the full number of slots defined above by
# num_slots. If there are fewer pins/keys on
# the card, the remaining keys will be empty
# (and you will be able to create new objects
# within them).
# Default: true
# hide_empty_tokens = false;
# By default, the OpenSC PKCS#11 module will not lock your card
# once you authenticate to the card via C_Login.
#
@ -1071,7 +1031,7 @@ app opensc-pkcs11 {
# abusing an existing login or they may logout unnoticed.
#
# With this setting enabled the login state of the token is tracked and
# cached (including the PIN). Every transaction is preceeded by
# cached (including the PIN). Every transaction is preceded by
# restoring the login state. After every transaction a logout is
# performed. This setting by default also enables `lock_login` (see
# above) to disable access for other applications during the atomic
@ -1105,7 +1065,7 @@ app opensc-pkcs11 {
# init_pin_in_so_session: C_InitPIN() in CKU_SO logged session:
# User PIN 'UNBLOCK' is protected by SOPIN. (PUK == SOPIN).
# # Actually this style works only for the PKCS15 contents without SOPIN.
# # For those with SOPIN, this mode will be usefull for the cards without
# # For those with SOPIN, this mode will be useful for the cards without
# # modes 00 and 01 of ISO command 'RESET RETRY COUNTER'. --vt
#
# Default: none
@ -1120,26 +1080,11 @@ app opensc-pkcs11 {
# Default: false
# create_puk_slot = true;
# Report as 'zero' the CKA_ID attribute of CA certificate
# For the unknown reason the middleware of the manufacturer of gemalto (axalto, gemplus)
# card reports as '0' the CKA_ID of CA cartificates.
# Maybe someone else will need it. (Would be nice to know who and what for -- VTA)
#
# Default: false
# zero_ckaid_for_ca_certs = true;
# List of readers to ignore
# If any of the strings listed below is matched (case sensitive) in a reader name,
# the reader is ignored by the PKCS#11 module.
#
# Default: empty
# ignored_readers = "CardMan 1021", "SPR 532";
# Symbolic names of PINs for which slots are created
# Card can contain more then one PINs or more then one on-card application with
# its own PINs. Normally, to access all of them with the PKCS#11 API a slot has to be
# created for all of them. Many slots could be ennoying for some of widely used application,
# like FireFox. This configuration parameter allows to select the PIN(s)
# like FireFox. This configuration parameter allows one to select the PIN(s)
# for which PKCS#11 slot will be created.
# Actually recognised following symbolic names:
# 'user', 'sign', 'all'

View File

@ -0,0 +1,32 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_ac_append_to_file.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_AC_APPEND_TO_FILE([FILE],[DATA])
#
# DESCRIPTION
#
# Appends the specified data to the specified Autoconf is run. If you want
# to append to a file when configure is run use AX_APPEND_TO_FILE instead.
#
# LICENSE
#
# Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 10
AC_DEFUN([AX_AC_APPEND_TO_FILE],[
AC_REQUIRE([AX_FILE_ESCAPES])
m4_esyscmd(
AX_FILE_ESCAPES
[
printf "%s" "$2" >> "$1"
])
])

32
m4/ax_ac_print_to_file.m4 Normal file
View File

@ -0,0 +1,32 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_ac_print_to_file.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_AC_PRINT_TO_FILE([FILE],[DATA])
#
# DESCRIPTION
#
# Writes the specified data to the specified file when Autoconf is run. If
# you want to print to a file when configure is run use AX_PRINT_TO_FILE
# instead.
#
# LICENSE
#
# Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 10
AC_DEFUN([AX_AC_PRINT_TO_FILE],[
m4_esyscmd(
AC_REQUIRE([AX_FILE_ESCAPES])
[
printf "%s" "$2" > "$1"
])
])

View File

@ -0,0 +1,28 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_add_am_macro_static.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_ADD_AM_MACRO_STATIC([RULE])
#
# DESCRIPTION
#
# Adds the specified rule to $AMINCLUDE.
#
# LICENSE
#
# Copyright (c) 2009 Tom Howard <tomhoward@users.sf.net>
# Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 8
AC_DEFUN([AX_ADD_AM_MACRO_STATIC],[
AC_REQUIRE([AX_AM_MACROS_STATIC])
AX_AC_APPEND_TO_FILE(AMINCLUDE_STATIC,[$1])
])

38
m4/ax_am_macros_static.m4 Normal file
View File

@ -0,0 +1,38 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_am_macros_static.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_AM_MACROS_STATIC
#
# DESCRIPTION
#
# Adds support for macros that create Automake rules. You must manually
# add the following line
#
# include $(top_srcdir)/aminclude_static.am
#
# to your Makefile.am files.
#
# LICENSE
#
# Copyright (c) 2009 Tom Howard <tomhoward@users.sf.net>
# Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 11
AC_DEFUN([AMINCLUDE_STATIC],[aminclude_static.am])
AC_DEFUN([AX_AM_MACROS_STATIC],
[
AX_AC_PRINT_TO_FILE(AMINCLUDE_STATIC,[
# ]AMINCLUDE_STATIC[ generated automatically by Autoconf
# from AX_AM_MACROS_STATIC on ]m4_esyscmd([LC_ALL=C date])[
])
])

95
m4/ax_check_gnu_make.m4 Normal file
View File

@ -0,0 +1,95 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_GNU_MAKE([run-if-true],[run-if-false])
#
# DESCRIPTION
#
# This macro searches for a GNU version of make. If a match is found:
#
# * The makefile variable `ifGNUmake' is set to the empty string, otherwise
# it is set to "#". This is useful for including a special features in a
# Makefile, which cannot be handled by other versions of make.
# * The makefile variable `ifnGNUmake' is set to #, otherwise
# it is set to the empty string. This is useful for including a special
# features in a Makefile, which can be handled
# by other versions of make or to specify else like clause.
# * The variable `_cv_gnu_make_command` is set to the command to invoke
# GNU make if it exists, the empty string otherwise.
# * The variable `ax_cv_gnu_make_command` is set to the command to invoke
# GNU make by copying `_cv_gnu_make_command`, otherwise it is unset.
# * If GNU Make is found, its version is extracted from the output of
# `make --version` as the last field of a record of space-separated
# columns and saved into the variable `ax_check_gnu_make_version`.
# * Additionally if GNU Make is found, run shell code run-if-true
# else run shell code run-if-false.
#
# Here is an example of its use:
#
# Makefile.in might contain:
#
# # A failsafe way of putting a dependency rule into a makefile
# $(DEPEND):
# $(CC) -MM $(srcdir)/*.c > $(DEPEND)
#
# @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
# @ifGNUmake@ include $(DEPEND)
# @ifGNUmake@ else
# fallback code
# @ifGNUmake@ endif
#
# Then configure.in would normally contain:
#
# AX_CHECK_GNU_MAKE()
# AC_OUTPUT(Makefile)
#
# Then perhaps to cause gnu make to override any other make, we could do
# something like this (note that GNU make always looks for GNUmakefile
# first):
#
# if ! test x$_cv_gnu_make_command = x ; then
# mv Makefile GNUmakefile
# echo .DEFAULT: > Makefile ;
# echo \ $_cv_gnu_make_command \$@ >> Makefile;
# fi
#
# Then, if any (well almost any) other make is called, and GNU make also
# exists, then the other make wraps the GNU make.
#
# LICENSE
#
# Copyright (c) 2008 John Darrington <j.darrington@elvis.murdoch.edu.au>
# Copyright (c) 2015 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 12
AC_DEFUN([AX_CHECK_GNU_MAKE],dnl
[AC_PROG_AWK
AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl
_cv_gnu_make_command="" ;
dnl Search all the common names for GNU make
for a in "$MAKE" make gmake gnumake ; do
if test -z "$a" ; then continue ; fi ;
if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then
_cv_gnu_make_command=$a ;
AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make")
ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }')
break ;
fi
done ;])
dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise
AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])], [AS_VAR_SET([ifGNUmake], [""])])
AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifnGNUmake], [""])], [AS_VAR_SET([ifnGNUmake], ["#"])])
AS_VAR_IF([_cv_gnu_make_command], [""], [AS_UNSET(ax_cv_gnu_make_command)], [AS_VAR_SET([ax_cv_gnu_make_command], [${_cv_gnu_make_command}])])
AS_VAR_IF([_cv_gnu_make_command], [""],[$2],[$1])
AC_SUBST([ifGNUmake])
AC_SUBST([ifnGNUmake])
])

272
m4/ax_code_coverage.m4 Normal file
View File

@ -0,0 +1,272 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_code_coverage.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CODE_COVERAGE()
#
# DESCRIPTION
#
# Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS,
# CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LIBS which should be included
# in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LIBADD variables of every
# build target (program or library) which should be built with code
# coverage support. Also add rules using AX_ADD_AM_MACRO_STATIC; and
# $enable_code_coverage which can be used in subsequent configure output.
# CODE_COVERAGE_ENABLED is defined and substituted, and corresponds to the
# value of the --enable-code-coverage option, which defaults to being
# disabled.
#
# Test also for gcov program and create GCOV variable that could be
# substituted.
#
# Note that all optimization flags in CFLAGS must be disabled when code
# coverage is enabled.
#
# Usage example:
#
# configure.ac:
#
# AX_CODE_COVERAGE
#
# Makefile.am:
#
# include $(top_srcdir)/aminclude_static.am
#
# my_program_LIBS = ... $(CODE_COVERAGE_LIBS) ...
# my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ...
# my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ...
# my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ...
#
# clean-local: code-coverage-clean
# distclean-local: code-coverage-dist-clean
#
# This results in a "check-code-coverage" rule being added to any
# Makefile.am which do "include $(top_srcdir)/aminclude_static.am"
# (assuming the module has been configured with --enable-code-coverage).
# Running `make check-code-coverage` in that directory will run the
# module's test suite (`make check`) and build a code coverage report
# detailing the code which was touched, then print the URI for the report.
#
# This code was derived from Makefile.decl in GLib, originally licensed
# under LGPLv2.1+.
#
# LICENSE
#
# Copyright (c) 2012, 2016 Philip Withnall
# Copyright (c) 2012 Xan Lopez
# Copyright (c) 2012 Christian Persch
# Copyright (c) 2012 Paolo Borelli
# Copyright (c) 2012 Dan Winship
# Copyright (c) 2015,2018 Bastien ROUCARIES
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#serial 32
m4_define(_AX_CODE_COVERAGE_RULES,[
AX_ADD_AM_MACRO_STATIC([
# Code coverage
#
# Optional:
# - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting.
# Multiple directories may be specified, separated by whitespace.
# (Default: \$(top_builddir))
# - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated
# by lcov for code coverage. (Default:
# \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage.info)
# - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage
# reports to be created. (Default:
# \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage)
# - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage,
# set to 0 to disable it and leave empty to stay with the default.
# (Default: empty)
# - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov
# instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
# - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov
# instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
# - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov
# - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the
# collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
# - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov
# instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
# - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering
# lcov instance. (Default: empty)
# - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov
# instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
# - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the
# genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
# - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml
# instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)
# - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore
#
# The generated report will be titled using the \$(PACKAGE_NAME) and
# \$(PACKAGE_VERSION). In order to add the current git hash to the title,
# use the git-version-gen script, available online.
# Optional variables
# run only on top dir
if CODE_COVERAGE_ENABLED
ifeq (\$(abs_builddir), \$(abs_top_builddir))
CODE_COVERAGE_DIRECTORY ?= \$(top_builddir)
CODE_COVERAGE_OUTPUT_FILE ?= \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage.info
CODE_COVERAGE_OUTPUT_DIRECTORY ?= \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage
CODE_COVERAGE_BRANCH_COVERAGE ?=
CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= \$(if \$(CODE_COVERAGE_BRANCH_COVERAGE),\
--rc lcov_branch_coverage=\$(CODE_COVERAGE_BRANCH_COVERAGE))
CODE_COVERAGE_LCOV_SHOPTS ?= \$(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool \"\$(GCOV)\"
CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= \$(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
CODE_COVERAGE_LCOV_OPTIONS ?= \$(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?=
CODE_COVERAGE_LCOV_RMOPTS ?= \$(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\
\$(if \$(CODE_COVERAGE_BRANCH_COVERAGE),\
--rc genhtml_branch_coverage=\$(CODE_COVERAGE_BRANCH_COVERAGE))
CODE_COVERAGE_GENHTML_OPTIONS ?= \$(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)
CODE_COVERAGE_IGNORE_PATTERN ?=
GITIGNOREFILES = \$(GITIGNOREFILES) \$(CODE_COVERAGE_OUTPUT_FILE) \$(CODE_COVERAGE_OUTPUT_DIRECTORY)
code_coverage_v_lcov_cap = \$(code_coverage_v_lcov_cap_\$(V))
code_coverage_v_lcov_cap_ = \$(code_coverage_v_lcov_cap_\$(AM_DEFAULT_VERBOSITY))
code_coverage_v_lcov_cap_0 = @echo \" LCOV --capture\" \$(CODE_COVERAGE_OUTPUT_FILE);
code_coverage_v_lcov_ign = \$(code_coverage_v_lcov_ign_\$(V))
code_coverage_v_lcov_ign_ = \$(code_coverage_v_lcov_ign_\$(AM_DEFAULT_VERBOSITY))
code_coverage_v_lcov_ign_0 = @echo \" LCOV --remove /tmp/*\" \$(CODE_COVERAGE_IGNORE_PATTERN);
code_coverage_v_genhtml = \$(code_coverage_v_genhtml_\$(V))
code_coverage_v_genhtml_ = \$(code_coverage_v_genhtml_\$(AM_DEFAULT_VERBOSITY))
code_coverage_v_genhtml_0 = @echo \" GEN \" \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\";
code_coverage_quiet = \$(code_coverage_quiet_\$(V))
code_coverage_quiet_ = \$(code_coverage_quiet_\$(AM_DEFAULT_VERBOSITY))
code_coverage_quiet_0 = --quiet
# sanitizes the test-name: replaces with underscores: dashes and dots
code_coverage_sanitize = \$(subst -,_,\$(subst .,_,\$(1)))
# Use recursive makes in order to ignore errors during check
check-code-coverage:
-\$(AM_V_at)\$(MAKE) \$(AM_MAKEFLAGS) -k check
\$(AM_V_at)\$(MAKE) \$(AM_MAKEFLAGS) code-coverage-capture
# Capture code coverage data
code-coverage-capture: code-coverage-capture-hook
\$(code_coverage_v_lcov_cap)\$(LCOV) \$(code_coverage_quiet) \$(addprefix --directory ,\$(CODE_COVERAGE_DIRECTORY)) --capture --output-file \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" --test-name \"\$(call code_coverage_sanitize,\$(PACKAGE_NAME)-\$(PACKAGE_VERSION))\" --no-checksum --compat-libtool \$(CODE_COVERAGE_LCOV_SHOPTS) \$(CODE_COVERAGE_LCOV_OPTIONS)
\$(code_coverage_v_lcov_ign)\$(LCOV) \$(code_coverage_quiet) \$(addprefix --directory ,\$(CODE_COVERAGE_DIRECTORY)) --remove \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \"/tmp/*\" \$(CODE_COVERAGE_IGNORE_PATTERN) --output-file \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \$(CODE_COVERAGE_LCOV_SHOPTS) \$(CODE_COVERAGE_LCOV_RMOPTS)
-@rm -f \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\"
\$(code_coverage_v_genhtml)LANG=C \$(GENHTML) \$(code_coverage_quiet) \$(addprefix --prefix ,\$(CODE_COVERAGE_DIRECTORY)) --output-directory \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\" --title \"\$(PACKAGE_NAME)-\$(PACKAGE_VERSION) Code Coverage\" --legend --show-details \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \$(CODE_COVERAGE_GENHTML_OPTIONS)
@echo \"file://\$(abs_builddir)/\$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html\"
code-coverage-clean:
-\$(LCOV) --directory \$(top_builddir) -z
-rm -rf \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\"
-find . \\( -name \"*.gcda\" -o -name \"*.gcno\" -o -name \"*.gcov\" \\) -delete
code-coverage-dist-clean:
A][M_DISTCHECK_CONFIGURE_FLAGS = \$(A][M_DISTCHECK_CONFIGURE_FLAGS) --disable-code-coverage
else # ifneq (\$(abs_builddir), \$(abs_top_builddir))
check-code-coverage:
code-coverage-capture: code-coverage-capture-hook
code-coverage-clean:
code-coverage-dist-clean:
endif # ifeq (\$(abs_builddir), \$(abs_top_builddir))
else #! CODE_COVERAGE_ENABLED
# Use recursive makes in order to ignore errors during check
check-code-coverage:
@echo \"Need to reconfigure with --enable-code-coverage\"
# Capture code coverage data
code-coverage-capture: code-coverage-capture-hook
@echo \"Need to reconfigure with --enable-code-coverage\"
code-coverage-clean:
code-coverage-dist-clean:
endif #CODE_COVERAGE_ENABLED
# Hook rule executed before code-coverage-capture, overridable by the user
code-coverage-capture-hook:
.PHONY: check-code-coverage code-coverage-capture code-coverage-dist-clean code-coverage-clean code-coverage-capture-hook
])
])
AC_DEFUN([_AX_CODE_COVERAGE_ENABLED],[
AX_CHECK_GNU_MAKE([],[AC_MSG_ERROR([not using GNU make that is needed for coverage])])
AC_REQUIRE([AX_ADD_AM_MACRO_STATIC])
# check for gcov
AC_CHECK_TOOL([GCOV],
[$_AX_CODE_COVERAGE_GCOV_PROG_WITH],
[:])
AS_IF([test "X$GCOV" = "X:"],
[AC_MSG_ERROR([gcov is needed to do coverage])])
AC_SUBST([GCOV])
dnl Check if gcc is being used
AS_IF([ test "$GCC" = "no" ], [
AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage])
])
AC_CHECK_PROG([LCOV], [lcov], [lcov])
AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
AS_IF([ test x"$LCOV" = x ], [
AC_MSG_ERROR([To enable code coverage reporting you must have lcov installed])
])
AS_IF([ test x"$GENHTML" = x ], [
AC_MSG_ERROR([Could not find genhtml from the lcov package])
])
dnl Build the code coverage flags
dnl Define CODE_COVERAGE_LDFLAGS for backwards compatibility
CODE_COVERAGE_CPPFLAGS="-DNDEBUG"
CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
CODE_COVERAGE_LIBS="-lgcov"
AC_SUBST([CODE_COVERAGE_CPPFLAGS])
AC_SUBST([CODE_COVERAGE_CFLAGS])
AC_SUBST([CODE_COVERAGE_CXXFLAGS])
AC_SUBST([CODE_COVERAGE_LIBS])
])
AC_DEFUN([AX_CODE_COVERAGE],[
dnl Check for --enable-code-coverage
# allow to override gcov location
AC_ARG_WITH([gcov],
[AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])],
[_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov],
[_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov])
AC_MSG_CHECKING([whether to build with code coverage support])
AC_ARG_ENABLE([code-coverage],
AS_HELP_STRING([--enable-code-coverage],
[Whether to enable code coverage support]),,
enable_code_coverage=no)
AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test "x$enable_code_coverage" = xyes])
AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage])
AC_MSG_RESULT($enable_code_coverage)
AS_IF([ test "x$enable_code_coverage" = xyes ], [
_AX_CODE_COVERAGE_ENABLED
])
_AX_CODE_COVERAGE_RULES
])

30
m4/ax_file_escapes.m4 Normal file
View File

@ -0,0 +1,30 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_file_escapes.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_FILE_ESCAPES
#
# DESCRIPTION
#
# Writes the specified data to the specified file.
#
# LICENSE
#
# Copyright (c) 2008 Tom Howard <tomhoward@users.sf.net>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 8
AC_DEFUN([AX_FILE_ESCAPES],[
AX_DOLLAR="\$"
AX_SRB="\\135"
AX_SLB="\\133"
AX_BS="\\\\"
AX_DQ="\""
])

View File

@ -0,0 +1,62 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_func_getopt_long.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_FUNC_GETOPT_LONG
#
# DESCRIPTION
#
# Check for getopt_long support.
#
# This assume that the standard getopt.h file (from GNU libc) is available
# as src/common/compat_getopt.h. If needed, this file will be linked as getopt.h, but
# we want to default to the system's getopt.h file. (See
# http://sources.redhat.com/ml/automake/2000-09/msg00041.html for an
# explanation about why using the system's getopt.h file is important.)
#
# LICENSE
#
# Copyright (c) 2008 Alexandre Duret-Lutz <adl@gnu.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 6
AU_ALIAS([ADL_FUNC_GETOPT_LONG], [AX_FUNC_GETOPT_LONG])
AC_DEFUN([AX_FUNC_GETOPT_LONG],
[AC_PREREQ(2.49)dnl
# clean out junk possibly left behind by a previous configuration
rm -f src/getopt.h
# Check for getopt_long support
AC_CHECK_HEADERS([getopt.h])
AC_CHECK_FUNCS([getopt_long],,
[# FreeBSD has a gnugetopt library for this
AC_CHECK_LIB([gnugetopt],[getopt_long],[AC_DEFINE([HAVE_GETOPT_LONG])],
[# use the OpenSC replacement
AC_CONFIG_LINKS([src/getopt.h:src/common/compat_getopt.h])])])])

View File

@ -1,39 +0,0 @@
PACKAGE=OSCopensc
PACKAGE_NAME=opensc
VERSION=CVS
PWD=pwd
CONFIGURE_PREFIX=$(PWD:sh)/..
CONFIGURE=${CONFIGURE_PREFIX}/configure
CONFIGURE_ARGS=--prefix=/usr --sysconfdir=/etc/opensc --mandir=/usr/share/man --enable-pcsc --enable-openct
CONFIG_GUESS=${CONFIGURE_PREFIX}/config.guess
UNAME_ARCH=/usr/bin/uname -p
PLATFORM = $(CONFIG_GUESS:sh)
ARCH = $(UNAME_ARCH:sh)
build:
@echo "Setup platform specific build directory build-${PLATFORM}"
mkdir -p build-${PLATFORM}
( cd build-${PLATFORM}; CC=cc PCSC_CFLAGS=-I/usr/include/smartcard ${CONFIGURE} ${CONFIGURE_ARGS}; make )
dist:
@echo "Setup platform specific dist directory dist-${PLATFORM}"
mkdir -p dist-${PLATFORM}
@echo "Performing Installing in dist directory"
( cd build-${PLATFORM}; make DESTDIR=`pwd`/../dist-${PLATFORM} install )
package:
@echo "Setup package meta files"
-cp proto dist-${PLATFORM}
-sed "s|@ARCH@|${ARCH}|" <checkinstall.in >dist-${PLATFORM}/checkinstall
-sed -e "s|@ARCH@|${ARCH}|" \
-e "s|@VERSION@|${VERSION}|" \
-e "s|@PACKAGE@|${PACKAGE}|" \
-e "s|@PACKAGE_NAME@|${PACKAGE_NAME}|" \
<pkginfo.in >dist-${PLATFORM}/pkginfo
mkdir -p dist-${PLATFORM}/etc/opensc
-cp opensc.conf-dist dist-${PLATFORM}/etc/opensc/opensc.conf
@echo "Creating package"
( \
cd dist-${PLATFORM}; \
pkgmk -o -r . -d . -f proto; \
pkgtrans -s . ../OSCopensc-${VERSION}-${PLATFORM}.pkg ${PACKAGE} \
)

View File

@ -1,13 +0,0 @@
Creating an installable package for Solaris 10
==============================================
The files in this directory are an attempt to ease
the building of opensc packages for Solaris 10.
The basic steps to create a Solaris 10 package are:
# make build
# make dist
# make package
NOTE: If you are using the GNU compiler you will
need to adjust the Makefile accordingly.

View File

@ -1,9 +0,0 @@
#!/bin/sh
expected_platform="@ARCH@"
platform=`uname -p`
if [ ${platform} != ${expected_platform} ]; then
echo "This package must be installed on ${expected_platform}"
exit 1
fi
exit 0

View File

@ -1,286 +0,0 @@
# Configuration file for OpenSC
# Example configuration file
# NOTE: All key-value pairs must be terminated by a semicolon.
# Default values for any application
# These can be overrided by an application
# specific configuration block.
app default {
# Amount of debug info to print
#
# A greater value means more debug info.
# Default: 0
#
debug = 0;
# The file to which debug output will be written
#
# A special value of 'stdout' is recognized.
# Default: stdout
#
# debug_file = /tmp/opensc-debug.log;
# The file to which errors will be written
#
# A special value of 'stderr' is recognized.
# Default: stderr
#
# error_file = /tmp/opensc-errors.log;
# Where to find the *.profile files for pkcs15init;
profile_dir = /usr/share/opensc;
# What reader drivers to load at start-up
#
# A special value of 'internal' will load all
# statically linked drivers. If an unknown (ie. not
# internal) driver is supplied, a separate configuration
# configuration block has to be written for the driver.
# Default: internal
# NOTE: if "internal" keyword is used, must be the
# last entry in reader_drivers list
#
reader_drivers = openct, pcsc, ctapi;
reader_driver ctapi {
# module /usr/local/towitoko/lib/libtowitoko.so {
# CT-API ports:
# 0..3 COM1..4
# 4 Printer
# 5 Modem
# 6..7 LPT1..2
# ports = 0;
# }
}
# Define parameters specific to your readers.
# The following section shows definitions for PC/SC readers,
# but the same set of variables are applicatable to ctapi and
# openct readers, simply by using "reader_driver ctapi" and
# "reader_driver openct", respectively.
reader_driver pcsc {
# Whether to transform some APDU's from one case to another
# Possible values:
# none: Don't transform any APDU's
# case4as3: For T=0, send a case 4 APDU as case 3,
# (no Lc byte) the card will send back
# a 61xx SW, and we will follow up with a
# GetResponse command
# The SCM SCR111, Sun SCF, and e-gate readers
# seem to require this.
# case1as2: For T=0, send a case 1 APDU as case 2.
# (append an Le byte of 0)
# The Sun SCF and e-gate readers seem to
# require this
# case1as2_always: for any T=0/1, send a case 1 APDU as
# case 2.
# The Sun SCF reader may require this
# Default: none
#
apdu_masquerade = none;
#
# This sets the maximum send and receive sizes.
# Some IFD handlers do not properly handle APDUs with
# large lc or le bytes.
#
max_send_size = 252;
max_recv_size = 252;
#
# EXPERIMENTAL: Enable CCID pinpad support
# implemented (at least) in the libccid driver.
#use_ccid_pin_cmd = true;
}
# What card drivers to load at start-up
#
# A special value of 'internal' will load all
# statically linked drivers. If an unknown (ie. not
# internal) driver is supplied, a separate configuration
# configuration block has to be written for the driver.
# Default: internal
# NOTE: When "internal" keyword is used, must be last entry
#
# card_drivers = customcos, internal;
# Card driver configuration blocks.
# For all drivers, you can specify ATRs of cards that
# should be handled by this driver (in addition to the
# list of compiled-in ATRs).
#
# The supported internal card driver names are
# flex Cryptoflex/Multiflex
# setcos Setec
# etoken Aladdin eToken and other CardOS based cards
# gpk GPK 4K/8K/16K
# mcrd MICARDO 2.1
# miocos MioCOS 1.1
# openpgp OpenPGP card
# tcos TCOS 2.0
# emv EMV compatible cards
# GPK card driver additional ATR entry:
card_driver gpk {
# atr = 00:11:22;
}
# For card drivers loaded from an external shared library/DLL,
# you need to specify the path name of the module
#
# card_driver customcos {
# The location of the driver library
# module = /usr/lib/opensc/drivers/card_customcos.so;
# atr = 00:11:22:33:44;
# atr = 55:66:77:88:99:aa:bb;
# }
# Force using specific card driver
#
# If this option is present, OpenSC will use the supplied
# driver with all inserted cards.
#
# Default: autodetect
#
# force_card_driver = miocos;
# Below are the framework specific configuration blocks.
# PKCS #15
framework pkcs15 {
# Whether to use the cache files in the user's
# home directory.
#
# At the moment you have to 'teach' the card to the
# system by:
# pkcs15-tool -L
#
# WARNING: Caching shouldn't be used in setuid root
# applications.
# Default: false
#
use_caching = true;
# Enable pkcs15 emulation
# Default: yes
enable_pkcs15_emulation = yes;
# Try pkcs15 emulation code first (before the normal
# pkcs15 processing).
# Default: no
try_emulation_first = no;
# Enable builtin emulators
# Default: yes
enable_builtin_emulation = yes;
# list of the builtin pkcs15 emulators to test
# possible values: esteid, openpgp, netkey, netkey,
# starcert, infocamere, postecert
builtin_emulators = esteid, openpgp, netkey, netkey, starcert, infocamere, postecert;
# additional pkcs15 emulators (dynamic or builtin with
# a different atr etc.)
# emulate foo {
# module = builtin;
# atr = 11:22:33:44;
#}
}
# Estonian ID card and Micardo driver currently play together with T=0 only.
# In theory only the 'cold' ATR should be specified, as T=0 will be the preferred
# protocol once you boot it up with T=0, but be paranoid.
# Generic format: card_atr <hex encoded ATR (case-sensitive!)>
# Only parameter currently understood is force_protocol
card_atr 3b:6e:00:ff:45:73:74:45:49:44:20:76:65:72:20:31:2e:30 {
force_protocol = t0;
}
card_atr 3b:fe:94:00:ff:80:b1:fa:45:1f:03:45:73:74:45:49:44:20:76:65:72:20:31:2e:30:43 {
force_protocol = t0;
}
}
# For applications that use SCAM (pam_opensc, sia_opensc)
app scam {
framework pkcs15 {
use_caching = false;
}
}
# Parameters for the OpenSC PKCS11 module
app opensc-pkcs11 {
pkcs11 {
# Maxmimum number of slots per smart card.
# If the card has fewer keys than defined here,
# the remaining number of slots will be empty.
#
# Note that there is currently a compile time
# maximum on the overall number of slots
# the pkcs11 module is able to handle.
num_slots = 4;
# Normally, the pkcs11 module will create
# the full number of slots defined above by
# num_slots. If there are fewer pins/keys on
# the card, the remaining keys will be empty
# (and you will be able to create new objects
# within them).
#
# Set this option to true to hide these empty
# slots.
hide_empty_tokens = true;
# By default, the OpenSC PKCS#11 module will
# try to lock this card once you have authenticated
# to the card via C_Login. This is done so that no
# other user can connect to the card and perform
# crypto operations (which may be possible because
# you have already authenticated with the card).
#
# However, this also means that no other application
# that _you_ run can use the card until your application
# has done a C_Logout or C_Finalize. In the case of
# Netscape or Mozilla, this does not happen until
# you exit the browser.
lock_login = true;
# Normally, the pkcs11 module will not cache PINs
# presented via C_Login. However, some cards
# may not work properly with OpenSC; for instance
# when you have two keys on your card that get
# stored in two different directories.
#
# In this case, you can turn on PIN caching by setting
# cache_pins = true
#
# Default: false
cache_pins = false;
# Set this value to false if you want to enfore on-card
# keypair generation
#
# Default: true
soft_keygen_allowed = true;
}
}
# Parameters for the OpenSC PKCS11-Spy module, that logs all the
# communication between a pkcs11 module and it's calling application:
# app <--> pkcs11-spy <--> pkcs11 module
app pkcs11-spy {
spy {
# Where to log to.
#
# By default, the value of the PKCS11SPY_OUTPUT environment
# variable is used. And if that one isn't defined: stderr
# is used.
#
#output = /tmp/pkcs11-spy.log;
# Which PKCS11 module to load.
#
# By default, the value of the PKCS11SPY environment
# variable is used. And if that one isn't defined,
# opensc-pkcs11.so is used.
#
#module = opensc-pkcs11.so;
}
}

View File

@ -1,12 +0,0 @@
PKG="OSCopensc"
NAME="opensc"
VERSION="@VERSION@"
ARCH="@ARCH@"
CLASSES="none"
CATEGORY="drivers"
VENDOR="WW"
PSTAMP="26thFeb2005"
EMAIL="william@wanders.org"
ISTATES="S s 1 2 3"
RSTATES="S s 1 2 3"
BASEDIR="/"

View File

@ -1,118 +0,0 @@
d none usr 0755 root sys
d none usr/share 0755 root other
d none usr/share/man 0755 root other
d none usr/share/man/man1 0755 root other
f none usr/share/man/man1/pkcs15-crypt.1 0644 root other
f none usr/share/man/man1/pkcs15-init.1 0644 root other
f none usr/share/man/man1/cryptoflex-tool.1 0644 root other
f none usr/share/man/man1/opensc-config.1 0644 root other
f none usr/share/man/man1/opensc-explorer.1 0644 root other
f none usr/share/man/man1/opensc-tool.1 0644 root other
f none usr/share/man/man1/pkcs15-tool.1 0644 root other
f none usr/share/man/man1/pkcs11-tool.1 0644 root other
f none usr/share/man/man1/cardos-info.1 0644 root other
d none usr/share/man/man3 0755 root other
f none usr/share/man/man3/sc_connect_card.3 0644 root other
f none usr/share/man/man3/sc_detect_card_presence.3 0644 root other
f none usr/share/man/man3/sc_disconnect_card.3 0644 root other
f none usr/share/man/man3/sc_establish_context.3 0644 root other
f none usr/share/man/man3/sc_file.3 0644 root other
f none usr/share/man/man3/sc_file_free.3 0644 root other
f none usr/share/man/man3/sc_file_new.3 0644 root other
f none usr/share/man/man3/sc_list_files.3 0644 root other
f none usr/share/man/man3/sc_lock.3 0644 root other
f none usr/share/man/man3/sc_read_binary.3 0644 root other
f none usr/share/man/man3/sc_read_record.3 0644 root other
f none usr/share/man/man3/sc_release_context.3 0644 root other
f none usr/share/man/man3/sc_select_file.3 0644 root other
f none usr/share/man/man3/sc_pkcs15_compute_signature.3 0644 root other
d none usr/share/man/man5 0755 root other
f none usr/share/man/man5/pkcs15-profile.5 0644 root other
d none usr/share/man/man7 0755 root other
f none usr/share/man/man7/opensc.7 0644 root other
f none usr/share/man/man7/pkcs15.7 0644 root other
d none usr/share/opensc 0755 root other
f none usr/share/opensc/opensc.conf.example 0644 root other
f none usr/share/opensc/cyberflex.profile 0644 root other
f none usr/share/opensc/flex.profile 0644 root other
f none usr/share/opensc/gpk.profile 0644 root other
f none usr/share/opensc/miocos.profile 0644 root other
f none usr/share/opensc/etoken.profile 0644 root other
f none usr/share/opensc/jcop.profile 0644 root other
f none usr/share/opensc/oberthur.profile 0644 root other
f none usr/share/opensc/starcos.profile 0644 root other
f none usr/share/opensc/pkcs15.profile 0644 root other
d none usr/lib 0755 root bin
s none usr/lib/libscconf.so.0=libscconf.so.0.0.9
f none usr/lib/libscconf.so.0.0.9 0755 root bin
s none usr/lib/libscconf.so=libscconf.so.0.0.9
f none usr/lib/libscconf.la 0755 root bin
f none usr/lib/libscconf.a 0644 root bin
s none usr/lib/libopensc.so.0=libopensc.so.0.0.9
f none usr/lib/libopensc.so.0.0.9 0755 root bin
s none usr/lib/libopensc.so=libopensc.so.0.0.9
d none usr/lib/pkgconfig 0755 root bin
f none usr/lib/pkgconfig/libopensc.pc 0644 root bin
f none usr/lib/pkgconfig/libpkcs15init.pc 0644 root bin
f none usr/lib/pkgconfig/libscconf.pc 0644 root bin
f none usr/lib/libopensc.la 0755 root bin
f none usr/lib/libopensc.a 0644 root bin
d none usr/lib/pkcs11 0755 root bin
s none usr/lib/pkcs11/libpkcs11.so.0=libpkcs11.so.0.0.9
f none usr/lib/pkcs11/opensc-pkcs11.so 0755 root bin
f none usr/lib/pkcs11/opensc-pkcs11.la 0755 root bin
f none usr/lib/pkcs11/opensc-pkcs11.a 0644 root bin
f none usr/lib/pkcs11/libpkcs11.so.0.0.9 0755 root bin
s none usr/lib/pkcs11/libpkcs11.so=libpkcs11.so.0.0.9
f none usr/lib/pkcs11/libpkcs11.la 0755 root bin
f none usr/lib/pkcs11/libpkcs11.a 0644 root bin
f none usr/lib/pkcs11/pkcs11-spy.so 0755 root bin
f none usr/lib/pkcs11/pkcs11-spy.la 0755 root bin
f none usr/lib/pkcs11/pkcs11-spy.a 0644 root bin
f none usr/lib/libpkcs15init.so.0.0.9 0755 root bin
s none usr/lib/libpkcs15init.so.0=libpkcs15init.so.0.0.9
s none usr/lib/libpkcs15init.so=libpkcs15init.so.0.0.9
f none usr/lib/libpkcs15init.la 0755 root bin
f none usr/lib/libpkcs15init.a 0644 root bin
d none usr/lib/opensc 0755 root bin
f none usr/lib/opensc/engine_opensc.so 0755 root bin
f none usr/lib/opensc/engine_opensc.la 0755 root bin
f none usr/lib/opensc/engine_opensc.a 0644 root bin
f none usr/lib/opensc/engine_pkcs11.so 0755 root bin
f none usr/lib/opensc/engine_pkcs11.la 0755 root bin
f none usr/lib/opensc/engine_pkcs11.a 0644 root bin
d none usr/include 0755 root bin
d none usr/include/opensc 0755 root bin
d none usr/include/opensc/rsaref 0755 root bin
f none usr/include/opensc/rsaref/pkcs11.h 0644 root bin
f none usr/include/opensc/rsaref/pkcs11f.h 0644 root bin
f none usr/include/opensc/rsaref/pkcs11t.h 0644 root bin
f none usr/include/opensc/rsaref/unix.h 0644 root bin
f none usr/include/opensc/rsaref/win32.h 0644 root bin
f none usr/include/opensc/scconf.h 0644 root bin
f none usr/include/opensc/opensc.h 0644 root bin
f none usr/include/opensc/pkcs15.h 0644 root bin
f none usr/include/opensc/cardctl.h 0644 root bin
f none usr/include/opensc/asn1.h 0644 root bin
f none usr/include/opensc/log.h 0644 root bin
f none usr/include/opensc/ui.h 0644 root bin
f none usr/include/opensc/errors.h 0644 root bin
f none usr/include/opensc/types.h 0644 root bin
f none usr/include/opensc/pkcs15-init.h 0644 root bin
f none usr/include/opensc/pkcs11.h 0644 root bin
d none usr/bin 0755 root bin
f none usr/bin/opensc-config 0755 root bin
f none usr/bin/opensc-tool 0755 root bin
f none usr/bin/opensc-explorer 0755 root bin
f none usr/bin/pkcs15-tool 0755 root bin
f none usr/bin/pkcs15-crypt 0755 root bin
f none usr/bin/pkcs11-tool 0755 root bin
f none usr/bin/cardos-info 0755 root bin
f none usr/bin/eidenv 0755 root bin
f none usr/bin/cryptoflex-tool 0755 root bin
f none usr/bin/pkcs15-init 0755 root bin
d none etc 0755 root sys
d none etc/opensc 0755 root sys
f none etc/opensc/opensc.conf 0644 root sys
i checkinstall=checkinstall
i pkginfo=pkginfo

View File

@ -3,7 +3,7 @@ EXTRA_DIST = Makefile.mak
# Order IS important
SUBDIRS = common scconf ui pkcs15init sm \
libopensc pkcs11 tools tests minidriver
libopensc pkcs11 tools minidriver tests
if ENABLE_SM
SUBDIRS += smm

View File

@ -1,7 +1,7 @@
TOPDIR = ..
SUBDIRS = common scconf ui sm pkcs15init \
libopensc pkcs11 tools tests
libopensc pkcs11 tools
default: all
@ -15,6 +15,16 @@ SUBDIRS = $(SUBDIRS) minidriver
SUBDIRS = $(SUBDIRS) smm
!ENDIF
all clean::
!IF "$(TESTS_DEF)" == "/DENABLE_TESTS"
SUBDIRS = $(SUBDIRS) tests
!ENDIF
all::
copy /y common\compat_getopt.h getopt.h
@for %i in ( $(SUBDIRS) ) do \
@cmd /c "cd %i && $(MAKE) /nologo /f Makefile.mak $@"
clean::
@for %i in ( $(SUBDIRS) ) do \
@cmd /c "cd %i && $(MAKE) /nologo /f Makefile.mak $@"
del /Q getopt.h

View File

@ -8,10 +8,29 @@ dist_noinst_DATA = \
LICENSE.compat_getopt compat_getopt.txt \
compat_getopt_main.c \
README.compat_strlcpy compat_strlcpy.3
noinst_HEADERS = compat_strlcat.h compat_strlcpy.h compat_strnlen.h compat_getpass.h compat_getopt.h simclist.h libpkcs11.h libscdl.h
AM_CPPFLAGS = -I$(top_srcdir)/src
libcompat_la_SOURCES = \
compat_dummy.c \
compat_strlcat.c \
compat_strlcpy.c \
compat_strnlen.c \
compat_getpass.c \
compat_getopt.c \
compat_report_rangecheckfailure.c \
compat___iob_func.c \
simclist.c
compat_getopt_main_LDADD = libcompat.la
libpkcs11_la_SOURCES = libpkcs11.c
libscdl_la_SOURCES = libscdl.c
TIDY_FLAGS = $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
TIDY_FILES = \
compat_dummy.c \
compat_strlcat.h compat_strlcat.c \
compat_strlcpy.h compat_strlcpy.c \
@ -20,10 +39,8 @@ libcompat_la_SOURCES = \
compat_getopt.h compat_getopt.c \
compat_report_rangecheckfailure.c \
compat___iob_func.c \
simclist.c simclist.h
simclist.c simclist.h \
libpkcs11.c libscdl.c
compat_getopt_main_LDADD = libcompat.la
libpkcs11_la_SOURCES = libpkcs11.c libpkcs11.h
libscdl_la_SOURCES = libscdl.c libscdl.h
check-local:
if [ -x "$(CLANGTIDY)" ]; then clang-tidy -config='' --checks='$(TIDY_CHECKS)' -header-filter=.* $(addprefix $(srcdir)/,$(TIDY_FILES)) -- $(TIDY_FLAGS); fi

View File

@ -94,14 +94,14 @@ WHY RE-INVENT THE WHEEL?
========================
I re-implemented getopt, getopt_long, and getopt_long_only because
there were noticable bugs in several versions of the GNU
there were noticeable bugs in several versions of the GNU
implementations, and because the GNU versions aren't always available
on some systems (*BSD, for example.) Other systems don't include any
sort of standard argument parser (Win32 with Microsoft tools, for
example, has no getopt.)
These should do all the expected Unix- and GNU-style argument
parsing, including permution, bunching, long options with single or
parsing, including permutation, bunching, long options with single or
double dashes (double dashes are required if you use
my_getopt_long,) and optional arguments for both long and short
options. A word with double dashes all by themselves halts argument
@ -112,11 +112,11 @@ separated by '='.
As with the GNU versions, a '+' prefix to the short option
specification (or the POSIXLY_CORRECT environment variable) disables
permution, a '-' prefix to the short option specification returns 1
permutation, a '-' prefix to the short option specification returns 1
for non-options, ':' after a short option indicates a required
argument, and '::' after a short option specification indicates an
optional argument (which must appear in the same word.) If you'd like
to recieve ':' instead of '?' for missing option arguments, prefix the
to receive ':' instead of '?' for missing option arguments, prefix the
short option specification with ':'.
The original intent was to re-implement the documented behavior of

Some files were not shown because too many files have changed in this diff Show More