Blame SOURCES/jdk8251117-rh1860990-pkcs11_key_length.patch

5781ba
# HG changeset patch
5781ba
# User mbalao
5781ba
# Date 1596572361 10800
5781ba
#      Tue Aug 04 17:19:21 2020 -0300
5781ba
# Node ID d8a0513b92ee262d4e64c1e13d43e1b3f3e5c5d5
5781ba
# Parent  a259b5b1bc7cc4dd0d8fa19e8bdbf96a4e76224f
5781ba
8251117: Cannot check P11Key size in P11Cipher and P11AEADCipher
5781ba
Reviewed-by: andrew
5781ba
Contributed-by: zzambers@redhat.com
5781ba
5781ba
diff --git openjdk.orig/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java openjdk/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java
5781ba
--- openjdk.orig/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java
5781ba
+++ openjdk/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java
5781ba
@@ -345,7 +345,9 @@
5781ba
             SecureRandom random)
5781ba
             throws InvalidKeyException, InvalidAlgorithmParameterException {
5781ba
         reset(true);
5781ba
-        if (fixedKeySize != -1 && key.getEncoded().length != fixedKeySize) {
5781ba
+        if (fixedKeySize != -1 &&
5781ba
+                ((key instanceof P11Key) ? ((P11Key) key).length() >> 3 :
5781ba
+                            key.getEncoded().length) != fixedKeySize) {
5781ba
             throw new InvalidKeyException("Key size is invalid");
5781ba
         }
5781ba
         switch (opmode) {