Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8251117: Cannot check P11Key size in P11Cipher and P11AEADCipher
Reviewed-by: valeriep
  • Loading branch information
zzambers authored and martinuy committed Aug 4, 2020
1 parent 88297c1 commit 16075ea2551d20a92013516323ae056a9e13a10b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
@@ -280,7 +280,9 @@ private void implInit(int opmode, Key key, byte[] iv, int tagLen,
SecureRandom sr)
throws InvalidKeyException, InvalidAlgorithmParameterException {
reset(true);
if (fixedKeySize != -1 && key.getEncoded().length != fixedKeySize) {
if (fixedKeySize != -1 &&
((key instanceof P11Key) ? ((P11Key) key).length() >> 3 :
key.getEncoded().length) != fixedKeySize) {
throw new InvalidKeyException("Key size is invalid");
}
P11Key newKey = P11SecretKeyFactory.convertKey(token, key, ALGO);
@@ -345,7 +345,9 @@ private void implInit(int opmode, Key key, byte[] iv,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
reset(true);
if (fixedKeySize != -1 && key.getEncoded().length != fixedKeySize) {
if (fixedKeySize != -1 &&
((key instanceof P11Key) ? ((P11Key) key).length() >> 3 :
key.getEncoded().length) != fixedKeySize) {
throw new InvalidKeyException("Key size is invalid");
}
switch (opmode) {

0 comments on commit 16075ea

Please sign in to comment.