Bug 820684 - certutil support for EC on HSMs - need to call PK11_GenerateKeyPairWithOpFlags()
Summary: certutil support for EC on HSMs - need to call PK11_GenerateKeyPairWithOpFlags()
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: nss
Version: 5.9
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Elio Maldonado Batiz
QA Contact: Aleš Mareček
URL:
Whiteboard:
Depends On:
Blocks: 820695 910580
TreeView+ depends on / blocked
 
Reported: 2012-05-10 16:59 UTC by Christina Fu
Modified: 2015-05-06 11:08 UTC (History)
10 users (show)

Fixed In Version: nss-3.13.5-8.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-01-08 07:38:52 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
a java tool that can do this (14.70 KB, text/plain)
2012-07-24 19:32 UTC, Christina Fu
no flags Details
Adds ability to specify opFlags and attrFlags in certutil (8.46 KB, patch)
2012-07-25 00:13 UTC, Bob Relyea
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Mozilla Foundation 783579 0 None None None 2012-08-17 16:00:52 UTC
Red Hat Product Errata RHBA-2013:0081 0 normal SHIPPED_LIVE nss and nspr bug fix and enhancement update 2013-01-07 15:26:55 UTC

Description Christina Fu 2012-05-10 16:59:01 UTC
Description of problem:
When attached to an nethsm to generate EC key pairs, certutil fails with the following error:
certutil: unable to generate key(s)
: security library: received bad data.

Version-Release number of selected component (if applicable):
nss-3.12.10

How reproducible:
always

Steps to Reproduce:
1. Install Thales nethsm Connect per HSM vendor instruction; attach nethsm on client:
   modutil -dbdir . -nocertdb -add nfast -libfile /opt/nfast/toolkits/pkcs11/libcknfast.so
2. create password file and random file (e.g. cfu_pwfile, cfu_ran)
3. generate EC CSR with certutil:
  certutil -d . -h NHSM6000-OCS -f cfu_pwfile -R -s "cn=Christian Fu ECC test" -k ec -q nistp256 -a -z cfu_ran> cfu.csr
  
Actual results:
certutil: unable to generate key(s)
: security library: received bad data.

Expected results:
should work (it works for certicom)

Additional info:
Further investigation shows that certutil calls PK11_GenerateKeyPair() with hardcoded isSensitive flag set to true.  I think to get it to work we need to call PK11_GenerateKeyPairWithOpFlags() as what I did with JSS for our Java based subsystems so we can pass in the values that will enable nethsm to work.  I also know that lunasa would need a different set of values for isSensitive and extractability. 
I think certutil should expose "temporary", "sensitive", "extractable" and the op flags and mask. in order to support various hsms.

Comment 1 RHEL Program Management 2012-06-12 01:32:46 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 7 Kai Engert (:kaie) (inactive account) 2012-07-24 15:55:04 UTC
This is the kind of bug that needs work to be done at the upstream project.

I would like to ask that you please file an enhancement request at bugzilla.mozilla.org and add a reference here to that new upstream bug.

And someone needs to contribute a patch.

Christina, I believe you already understand what needs to be done,
would you like to propose a patch in an upstream bug?

I think this issue hasn't yet been worked on, so it won't make rhel 5.9, it needs to be moved forward to a future release.

Comment 8 Kai Engert (:kaie) (inactive account) 2012-07-24 15:56:30 UTC
Please get the patch done first, only afterwards does it make sense to request new flags. You'll probably want to target 5.9.z after that's done.

Comment 9 Christina Fu 2012-07-24 19:32:48 UTC
Created attachment 600161 [details]
a java tool that can do this

This is a java tool that can generate EC pkcs10 requests.  It's converted from an RSA tool PKCS10Client, and it's a bit hacky.

Comment 10 Bob Relyea 2012-07-25 00:13:20 UTC
Created attachment 600184 [details]
Adds ability to specify opFlags and attrFlags in certutil

Here's the patch I wrote do do this.

Christina, you'll still have to play with the flags, something like:

Certutil -R ..... --keyAttrFlags token,private

Comment 12 Christina Fu 2012-08-15 23:37:44 UTC
Verification failed.

It seems both "extractable" and "unextractable" are treated as "extractable" and yield the same result ...

Here was what I did :

=====

[pkiuserecc5@glyph alias]$ certutil -d . -h "NHSM6000-OCS" -f passwd -R --keyAttrFlags "token,private,sensitive,unextractable" --keyOpFlagsOff derive -s "cn=cfutestHSM" -k ec -q nistp256 -a -z passwd > cfutestHSM.req
parsing flags <derive>
parsing flags <token,private,sensitive,unextractable>


Generating key.  This may take a few moments...

2012-08-09 07:58:41 [10136] t306c570d462b0000: pkcs11-sam: 000008cd Application error: Key type CKK_EC
2012-08-09 07:58:41 [10136] t306c570d462b0000: pkcs11-sam: 000008cd Application error: Insecure key should be marked as such; set CKNFAST_OVERRIDE_SECURITY_ASSURANCES=explicitness to allow extractable but sensititive
certutil: unable to generate key(s)
: security library: received bad data.

=====
[pkiuserecc5@glyph alias]$ certutil -d . -h "NHSM6000-OCS" -f passwd -R --keyAttrFlags "token,private,sensitive,extractable" --keyOpFlagsOff derive -s "cn=cfutestHSM" -k ec -q nistp256 -a -z passwd > cfutestHSM.req
parsing flags <derive>
parsing flags <token,private,sensitive,extractable>


Generating key.  This may take a few moments...

2012-08-09 07:59:52 [10137] t308ceed17f2b0000: pkcs11-sam: 000008cd Application error: Key type CKK_EC
2012-08-09 07:59:52 [10137] t308ceed17f2b0000: pkcs11-sam: 000008cd Application error: Insecure key should be marked as such; set CKNFAST_OVERRIDE_SECURITY_ASSURANCES=explicitness to allow extractable but sensititive
certutil: unable to generate key(s)
: security library: received bad data.

Comment 20 errata-xmlrpc 2013-01-08 07:38:52 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.

http://rhn.redhat.com/errata/RHBA-2013-0081.html


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