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