JDK-8322974 : KEM.getInstance() should check if a 3rd-party security provider is signed
  • Type: CSR
  • Component: security-libs
  • Sub-Component: javax.crypto
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 21-pool,22,23
  • Submitted: 2024-01-03
  • Updated: 2024-07-11
  • Resolved: 2024-01-11
Related Reports
CSR :  
Description
Summary
-------

Update the `getInstance` method for `KEM` to check if a 3rd-party security provider is signed.

Problem
-------

Like other JCE service classes (`Cipher`, `Mac`, `KeyAgreement`, etc), the `KEM` service is able to generate `SecretKey`s that can be used in encryption and decryption. As always, such services, when implemented in a 3rd-party security provider, require the provider to reside in a signed JAR file.

See [the requirement][1] in the Java SE Security Guide.

Solution
--------

Update the `KEM::getInstance` methods to check whether the 3rd-party security provider is signed.

Precisely, if `KEM.getInstance(alg)` (without a provider argument) is called, the implementations in unsigned 3rd-party security providers will be ignored. If there is no signed 3rd-party security providers or JDK builtin providers that provide this KEM algorithm, a `NoSuchAlgorithmException` will be thrown. If `KEM.getInstance(alg, p)` (with a `Provider` argument) is called and the provider is an unsigned 3rd-party security provider, a `SecurityException` will be thrown indicating that the provider cannot be authenticated by JCE. If `KEM.getInstance(alg, "P")` (with a `String` argument as the registered provider's name) is called and the provider is an unsigned 3rd-party security provider, a `NoSuchProviderException` will be thrown indicating that the provider cannot be authenticated by JCE. 

This is consistent with most other existing JCE service classes.

OpenJDK source code does not require 3rd party JCE providers to be signed, but does support a framework (by extending internal APIs) for vendors to optionally add support for it, as Oracle JDK does.

Specification
-------------

The Java SE Security Guide will be updated to include KEM in the existing list of JCE service classes. See https://bugs.openjdk.org/browse/JDK-8322973 for detailed changes.

  [1]: https://docs.oracle.com/en/java/javase/21/security/howtoimplaprovider.html#GUID-AEE5234F-24F1-4899-B490-C79F0C2D8D59
Comments
[~mbaesken] JEP 452 added the KEM API in JDK 21, it doesn't exist in JDK 17. However, there is a maintenance release of JSR 392 (the JSR for Java SE 17) in flight that includes KEM in the proposed update so this may be why there are some JBS issues.
11-07-2024

Hi Joe, should 17 be added to the CSR ? Looking at https://bugs.openjdk.org/browse/JDK-8322971 this went already into 17 so I guess 17 should be also a fix version here ?
11-07-2024

Moving to Approved.
11-01-2024

Moving to Provisional, not Approved.
09-01-2024