RFR: 8263404: RsaPrivateKeySpec is always recognized as RSAPrivateCrtKeySpec in RSAKeyFactory.engineGetKeySpec [v2]

Ziyi Luo luoziyi at openjdk.java.net
Fri Mar 12 22:00:18 UTC 2021


> This is a P2 regression introduced by JDK-8254717.
> 
> In `RSAKeyFactory.engineGetKeySpec`, when the key is a RSA key and the KeySpec is RSAPrivateKeySpec or RSAPrivateCrtKeySpec. The method behavior is described as follow:
> 
> X-axis: type of `keySpec`
> Y-axis: type of `key`
> 
> Before JDK-8254717:
> 
> |  | RSAPrivateKeySpec.class | RSAPrivateCrtKeySpec.class |
> |--|--|--|
> | RSAPrivateKey | Return RSAPrivateKeySpec  | Throw `InvalidKeySpecException` |
> | RSAPrivateCrtKey | Return RSAPrivateKeySpec | Return RSAPrivateKeyCrtSpec |
> 
> After JDK-8254717 (Green check is what we want to fix, red cross is the regression):
> 
> |  | RSAPrivateKeySpec.class | RSAPrivateCrtKeySpec.class |
> |--|--|--|
> | RSAPrivateKey | Throw `InvalidKeySpecException` ❌  | Throw `InvalidKeySpecException` |
> | RSAPrivateCrtKey | Return RSAPrivateKeyCrtSpec ✅ | Return RSAPrivateKeyCrtSpec |
> 
> This commit fixes the regression.
> 
> 
> ### Tests
> 
> * Jtreg: All tests under `java/security`, `sun/security`, `javax/crypto` passed
> * JCK: All JCK-16 (I do not have jCK-17)tests under `api/java_security` passed

Ziyi Luo has updated the pull request incrementally with one additional commit since the last revision:

  Add one test case for the regression fixed by 8263404

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/2949/files
  - new: https://git.openjdk.java.net/jdk/pull/2949/files/0ebb72d0..e9a76978

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=2949&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=2949&range=00-01

  Stats: 62 lines in 1 file changed: 61 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2949.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2949/head:pull/2949

PR: https://git.openjdk.java.net/jdk/pull/2949


More information about the security-dev mailing list