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 1881999 - 8025 error code when creating subCAs
Summary: 8025 error code when creating subCAs
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: nss
Version: 8.3
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: rc
: 8.0
Assignee: nss-nspr-maint
QA Contact: Ivan Nikolchev
URL:
Whiteboard:
Depends On:
Blocks: 1977412 1985061
TreeView+ depends on / blocked
 
Reported: 2020-09-23 14:53 UTC by François Cami
Modified: 2022-01-13 16:12 UTC (History)
5 users (show)

Fixed In Version: nss-3.67.0-4.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
: 1977412 1985061 (view as bug list)
Environment:
Last Closed: 2021-12-16 11:54:57 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker CRYPTO-5884 0 None None None 2021-12-16 12:06:59 UTC

Comment 2 Alex Scheel 2020-09-23 16:28:21 UTC
I believe this is a race condition in NSS.

See this reproducer here: https://github.com/cipherboy/jss/blob/reproduce-1881999/org/mozilla/jss/tests/LWCAFailure.java

Change count to 10 on line 68, build JSS via https://github.com/dogtagpki/jss/blob/master/docs/building.md#in-source-build and then run via `cd build && ./run_test.sh org.mozilla.jss.tests.LWCAFailure`.

(I've added 1000 to see if it is reproducible via serial Key Gen. So far it hasn't after a couple hundred keygen attempts. So I'm inclined to believe race condition.)



This successfully reproduces the failure after sufficient (random) time:

org.mozilla.jss.crypto.TokenException: Keypair Generation failed on token with error: -8025 : 
Exception in thread "Thread-8" java.lang.RuntimeException: Keypair Generation failed on token with error: -8025 : 
	at org.mozilla.jss.tests.LWCAFailure$Smasher.run(LWCAFailure.java:63)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.mozilla.jss.crypto.TokenException: Keypair Generation failed on token with error: -8025 : 
	at org.mozilla.jss.pkcs11.PK11KeyPairGenerator.generateRSAKeyPairWithOpFlags(Native Method)
	at org.mozilla.jss.pkcs11.PK11KeyPairGenerator.generateKeyPair(PK11KeyPairGenerator.java:502)
	at org.mozilla.jss.crypto.KeyPairGenerator.genKeyPair(KeyPairGenerator.java:50)
	at org.mozilla.jss.tests.LWCAFailure.createSubCA(LWCAFailure.java:49)
	at org.mozilla.jss.tests.LWCAFailure$Smasher.run(LWCAFailure.java:59)
	... 1 more

It is (subjectively) faster to reproduce on NSS @ 3.53 (in RHEL 8.3) than it is in NSS @ 3.56 (in Fedora 32 currently). 

I do not know yet how to trigger this in a reliable fashion other than brute-forcing parallel keygen and waiting for it to fail.



My suggestion is we turn this over to the crypto/NSS team to see if they have any thoughts.

Comment 3 Alex Scheel 2020-09-23 16:33:52 UTC
For context, the relevant JSS function (generateRSAKeyPairWithOpFlags) is fairly trivial:

JNIEXPORT jobject JNICALL
Java_org_mozilla_jss_pkcs11_PK11KeyPairGenerator_generateRSAKeyPairWithOpFlags
  (JNIEnv *env, jobject this, jobject token, jint keySize, jlong publicExponent,
    jboolean temporary, jint sensitive, jint extractable,
    jint op_flags, jint op_flags_mask)
{
    PK11RSAGenParams params;

    PR_ASSERT(env!=NULL && this!=NULL && token!=NULL);

    /**************************************************
     * setup parameters
     *************************************************/
    params.keySizeInBits = keySize;
    params.pe = publicExponent;

    return PK11KeyPairGeneratorWithOpFlags(env, this, token, CKM_RSA_PKCS_KEY_PAIR_GEN,
     &params, temporary, sensitive, extractable, op_flags, op_flags_mask);
}


At the time it is called (and this executes), we've initialized NSS a while ago (because we've successfully generated keys $count times earlier). So the race condition must happen in the PK11 code somewhere.


The question is why is this failure in NSS... now :-)

Comment 4 Alex Scheel 2020-09-23 16:38:02 UTC
Sorry, PK11KeyPairGeneratorWithOpFlags is actually a JSS function. It calls JSS's JSS_PK11_generateKeyPairWithOpFlags and keysToKeyPair.

So, we call the following two PK11 functions:

 - PK11_Authenticate (should be a no-op if token is already logged in, which it is since we authed earlier).
 - PK11_GenerateKeyPairWithOpFlags

No JSS method returns SEC_ERROR_PKCS11_GENERAL_ERROR, so it is one of these two functions (or the interaction thereof). 

Guess the next step is a C reproducer without JSS.


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