-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b06
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8297459 | 17.0.6 | Andrew Hughes | P4 | Resolved | Fixed | b05 |
JDK-8303956 | 11.0.20 | Zdenek Zambersky | P4 | Resolved | Fixed | b01 |
JDK-8304653 | openjdk8u382 | Zdenek Zambersky | P4 | Resolved | Fixed | b01 |
Exception:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 32
at java.base/java.util.Arrays.rangeCheck(Arrays.java:725)
at java.base/java.util.Arrays.fill(Arrays.java:3308)
at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher$PKCS5Padding.setPaddingBytes(P11Cipher.java:96)
at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.implDoFinal(P11Cipher.java:813)
at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:585)
at java.base/javax.crypto.Cipher.doFinal(Cipher.java:2417)
...
Details:
This problems happens when reqBlockUpdates is true and implUpdate, which does not end on block boundary, is performed followed by final implUpdate, which ends exactly on block boundary. In that case final implUpdate fills padBuffer and then just returns. [1] Following implDoFinal then tries to add padding and throws OOB exception. Problem is, that in this case (input is multiple of block size) whole padding block should be added, but there is no space for it in padBuffer causing OOB exception.
Solution:
Solution is to detect this case (implDoFinal is called with full padBuffer) and to perform additional C_EncryptUpdate to free up padBuffer so that padBuffer can than be used to add whole new padding block.
[1] https://github.com/openjdk/jdk/blob/master/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Cipher.java#L622
- backported by
-
JDK-8297459 P11Cipher should not throw out of bounds exception during padding
- Resolved
-
JDK-8303956 P11Cipher should not throw out of bounds exception during padding
- Resolved
-
JDK-8304653 P11Cipher should not throw out of bounds exception during padding
- Resolved
- links to
-
Commit openjdk/jdk8u-dev/ae6405fe
-
Commit openjdk/jdk11u-dev/7d899197
-
Commit openjdk/jdk17u-dev/2f7e673f
-
Commit openjdk/jdk/3e60e828
-
Review openjdk/jdk8u-dev/287
-
Review openjdk/jdk11u-dev/1786
-
Review openjdk/jdk17u-dev/706
-
Review openjdk/jdk/9310