Commit Graph

7435 Commits

Author SHA1 Message Date
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