From 733c19350c7cd423bfc2982e4c5b6378fd82ad69 Mon Sep 17 00:00:00 2001 From: David Solin Date: Tue, 23 Aug 2016 17:40:00 -0500 Subject: [PATCH] Un-break PKCS5 (I inadvertently over-simplified setting the salt length). --- .../net/schmizz/sshj/userauth/keyprovider/PKCS5KeyFile.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/schmizz/sshj/userauth/keyprovider/PKCS5KeyFile.java b/src/main/java/net/schmizz/sshj/userauth/keyprovider/PKCS5KeyFile.java index 2964ecbb..8652c36f 100644 --- a/src/main/java/net/schmizz/sshj/userauth/keyprovider/PKCS5KeyFile.java +++ b/src/main/java/net/schmizz/sshj/userauth/keyprovider/PKCS5KeyFile.java @@ -183,7 +183,7 @@ public class PKCS5KeyFile } else { throw new FormatException("Not a supported algorithm: " + algorithm); } - iv = Arrays.copyOfRange(DatatypeConverter.parseHexBinary(line.substring(ptr+1)), 0, Math.min(cipher.getIVSize(), 8)); + iv = Arrays.copyOfRange(DatatypeConverter.parseHexBinary(line.substring(ptr+1)), 0, cipher.getIVSize()); } } else if (line.length() > 0) { sb.append(line); @@ -261,7 +261,7 @@ public class PKCS5KeyFile md5.update(tmp, 0, tmp.length); } md5.update(passphrase, 0, passphrase.length); - md5.update(iv, 0, iv.length); + md5.update(iv, 0, iv.length > 8 ? 8 : iv.length); tmp = md5.digest(); System.arraycopy(tmp, 0, hn, i, tmp.length); i += tmp.length;