RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1775673 - RSA-PKCS-PSS signatures do not seem to work with PIV Cards
Summary: RSA-PKCS-PSS signatures do not seem to work with PIV Cards
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: opensc
Version: 8.4
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: rc
: 8.0
Assignee: Jakub Jelen
QA Contact: PKI QE
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-11-22 14:49 UTC by Jakub Jelen
Modified: 2023-05-13 08:57 UTC (History)
2 users (show)

Fixed In Version: opensc-0.19.0-7.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-28 16:52:15 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-30104 0 None None None 2023-05-13 08:57:56 UTC
Red Hat Product Errata RHEA-2020:1843 0 None None None 2020-04-28 16:52:20 UTC

Description Jakub Jelen 2019-11-22 14:49:29 UTC
Description of problem:
The explicitly hashed SHA*-RSA-PKCS-PSS mechanisms as tested in bug #1595626, works fine, but it looks like the implicit hashes used in RSA-PKCS-PSS seems to be failing with PIV cards.

Version-Release number of selected component (if applicable):
opensc-0.19.0-6.el8.x86_64

How reproducible: deterministic


[root@sec-eng-opensc-2 test]# pkcs11-tool -s --id 04 -p 123456 -m RSA-PKCS-PSS --hash-algorithm SHA256 --mgf MGF1-SHA256  --input-file data.sha256 --output-file data.sig
Using slot 0 with a present token (0x0)
Using signature algorithm RSA-PKCS-PSS
PSS parameters: hashAlg=SHA256, mgf=MGF1-SHA256, salt_len=32 B
error: PKCS11 function C_SignFinal failed: rv = CKR_TOKEN_NOT_RECOGNIZED (0xe1)
Aborting.


Actual results:
fails to provide signature

Expected results:
provides signature

Additional info:
Identified while testing TLS client authetnication in TLS 1.3 with wget or gnutls-client.

I remember there was quite a bunch of fixes upstream related to PSS since last release so I would propose to rebase to the soon-to-be-released opensc 0.20.0 and improve the automated tests to make sure we do not break these essential use cases.

Comment 1 Jakub Jelen 2019-11-22 16:34:08 UTC
Interestingly enough, it looks like the same works for me with current Fedora package.

It also works with opensc-0.19.0-5.el8.x86_64 (RHEL 8.1 package) so it is some regression in the latest update, which I accidentally hit.

Adding acks and triage and I will investigate it further as it needs to get fixed.

Comment 2 Jakub Jelen 2019-11-22 17:01:50 UTC
The fix addressing this issue is available now in the upstream PR with the other IDPrime changes (adding support for OAEP modes supported by this card).

https://github.com/OpenSC/OpenSC/commit/6593dc9b

I will provide a new build fixing this issue as soon as I will get acks. Asha?

Comment 5 Sneha Veeranki 2020-01-13 18:49:58 UTC
Tested as below following the test steps from https://bugzilla.redhat.com/show_bug.cgi?id=1595626#c11 
Jakub Jelen, please let me know if this looks alright.

# cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.2 Beta (Ootpa)

# rpm -qa opensc
opensc-0.19.0-7.el8.x86_64

[root@xxx ~]# pkcs11-tool --id 02 -s -p 123456 -m SHA1-RSA-PKCS-PSS --module /usr/lib64/opensc-pkcs11.so --input-file data --output-file data.sig
Using slot 0 with a present token (0x0)
Using signature algorithm SHA1-RSA-PKCS-PSS
PSS parameters: hashAlg=SHA-1, mgf=MGF1-SHA1, salt_len=20 B

[root@xxx ~]# pkcs11-tool -r -p 123456 --id 02 --type pubkey --module /usr/lib64/opensc-pkcs11.so > 02.der
Using slot 0 with a present token (0x0)

[root@xxx ~]# openssl rsa -inform DER -outform PEM -in 02.der -pubin > 02.pub
writing RSA key

[root@xxx ~]# cat 02.pub
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4Pr2EKgurc0OKhqDqqOX
IlFl60FQB5z4d+8r2T61d0uDcZ0KP15q+WtNmR7vviQLazascc3B7XLe+2BAcGn8
Y4cU7nmaSWxFJf8Z5RH01SbYgfmimJgOX4ADznk1JPMvepQENHAPkK5uJlXKz+w4
5SRjQ4UM6kF4Mg4RTZtfztnxwv/G0V4hqyRQLbwJCmy8u2vptrzpglaG8TVe4iOO
dghxLOzq3Mj5frgM3CDWQNCQ/nZGVrMvOSJndSboMXZUr6ulUyB8f8YDCI1tamdq
J8OKLeVx3N8lnBuz1dCRX6oXXPkRzBgzmXAmF3uMLrl4nUQlXdgRVO8jSg7baMqc
pQIDAQAB
-----END PUBLIC KEY-----

[root@xxx ~]# openssl dgst -verify 02.pub -sha1 -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:-1 -signature data.sig data
Verified OK

Comment 6 Jakub Jelen 2020-01-14 08:51:48 UTC
Looks good to me. You should be able to try this with opensc-0.19.0-6.el8.x86_64 and the same steps should fail, but I do not think it is mandatory now.

Comment 9 errata-xmlrpc 2020-04-28 16:52:15 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2020:1843


Note You need to log in before you can comment on or make changes to this bug.