-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b24
Both `PKCS8Key::<init>(byte[])` and `X509::decode(byte[])` wrap the input bytes into a `ByteArrayInputStream` and then parse it. This means if there are any extra bytes after the end of the key they will not be detected and the key parsing succeeds.
This can be demonstrated with
```
KeyFactory.getInstance("EC").generatePublic(new X509EncodedKeySpec(Arrays.copyOf(
KeyPairGenerator.getInstance("EC").generateKeyPair().getPublic().getEncoded(), 1000)));
```
This can be demonstrated with
```
KeyFactory.getInstance("EC").generatePublic(new X509EncodedKeySpec(Arrays.copyOf(
KeyPairGenerator.getInstance("EC").generateKeyPair().getPublic().getEncoded(), 1000)));
```
- relates to
-
JDK-8319937 KeyFactory.generatePublic throws if spec decoded from input with extra bytes
- Closed