On Fri, 25 Jul 2025 23:39:54 GMT, Valerie Peng <[email protected]> wrote:
> This PR is for clarifying the `NoSuchAlgorithmException` and > `NoSuchPaddingException` for the `Cipher.getInstance(String transformation, > Provider provider)` and `Cipher.getInstance(String transformation, String > provider)` methods. > > As stated in `javax.crypto.CipherSpi` class, provider has the flexibility to > register their implementations through various sub-transformations. As a > result, depending on how the providers register the implementation, it may > lead to `NoSuchAlgorithmException` or `NoSuchPaddingException`. For example, > the provider A registers to support "AES/CBC/PKCS5Padding" vs provider B > registers to support "AES" (but would only accept "CBC" and "PKCS5Padding" as > the valid input for setting mode and padding). Calling > `Cipher.getInstance(...)` with "AES/CBC/NoPadding" against provider A and B > would lead to `NoSuchAlgorithmException` and `NoSuchPaddingException`. This > javadoc update hope to make it clear. > > Thanks in advance for the review~ > Valerie This pull request has now been integrated. Changeset: 5c596e2a Author: Valerie Peng <[email protected]> URL: https://git.openjdk.org/jdk/commit/5c596e2a9599e1e0eb9ec845f1b6e0e7b59f186a Stats: 56 lines in 2 files changed: 13 ins; 2 del; 41 mod 8360463: Ambiguity in Cipher.getInstance() specification between NoSuchAlgorithmException and NoSuchPaddingException Reviewed-by: mullan ------------- PR: https://git.openjdk.org/jdk/pull/26489
