Blame SOURCES/jdk8251117-rh1860990-pkcs11_key_length.patch

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