-
Bug
-
Resolution: Fixed
-
P4
-
17.0.10, 21, 23
-
b08
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8351239 | 21.0.8 | Sorna Sarathi | P4 | Resolved | Fixed | master |
After JDK-8271566, the CKA_MODULUS and CKA_PRIVATE_EXPONENT attributes were added to the list passed to Java's C_GetAttributeValue wrapper when determining if a private RSA key is CRT or non-CRT [1]. The rationale was to make a single query and have both CKA_MODULUS and CKA_PRIVATE_EXPONENT available beforehand, avoiding a potential second query later. Most PKCS #11 tokens benefit from this saving.
Contrary to the native C_GetAttributeValue PKCS #11 API, its Java counterpart does not return any attribute value if there is an error in one of the attributes queried (e.g. if CKR_ATTRIBUTE_TYPE_INVALID is returned) [2]. If a non-CRT key is created in a token (pre PKCS #11 2.40), the query including all attributes will fail and CKA_MODULUS and CKA_PRIVATE_EXPONENT will not be available. An error will be thrown here [3].
This bug was reported by Bob Du (IBM).
--
[1] - https://git.openjdk.org/jdk/blob/jdk-24%2B6/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java#L568
[2] - https://git.openjdk.org/jdk/blob/jdk-24%2B6/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_objmgmt.c#L252
[3] - https://git.openjdk.org/jdk/blob/jdk-24%2B6/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java#L594
Contrary to the native C_GetAttributeValue PKCS #11 API, its Java counterpart does not return any attribute value if there is an error in one of the attributes queried (e.g. if CKR_ATTRIBUTE_TYPE_INVALID is returned) [2]. If a non-CRT key is created in a token (pre PKCS #11 2.40), the query including all attributes will fail and CKA_MODULUS and CKA_PRIVATE_EXPONENT will not be available. An error will be thrown here [3].
This bug was reported by Bob Du (IBM).
--
[1] - https://git.openjdk.org/jdk/blob/jdk-24%2B6/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java#L568
[2] - https://git.openjdk.org/jdk/blob/jdk-24%2B6/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_objmgmt.c#L252
[3] - https://git.openjdk.org/jdk/blob/jdk-24%2B6/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java#L594
- backported by
-
JDK-8351239 Failure when creating non-CRT RSA private keys in SunPKCS11
-
- Resolved
-
- relates to
-
JDK-8271566 DSA signature length value is not accurate in P11Signature
-
- Resolved
-
- links to
-
Commit(master) openjdk/jdk21u-dev/e48995f4
-
Commit(master) openjdk/jdk/3251eea1
-
Review(master) openjdk/jdk17u-dev/2979
-
Review(master) openjdk/jdk21u-dev/1021
-
Review(master) openjdk/jdk23u/130
-
Review(master) openjdk/jdk/20204
(3 links to)