@Override public void init() { try { md = SecurityUtils.getMessageDigest(algorithm); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } }
@Override public boolean verify(String hostname, int port, PublicKey key) { MessageDigest digest; try { digest = SecurityUtils.getMessageDigest(digestAlgorithm); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } digest.update(new Buffer.PlainBuffer().putPublicKey(key).getCompactData()); byte[] digestData = digest.digest(); return Arrays.equals(fingerprintData, digestData); }
/** * Computes the fingerprint for a public key, in the standard SSH format, e.g. "4b:69:6c:72:6f:79:20:77:61:73:20:68:65:72:65:21" * * @param key the public key * @return the fingerprint * @see <a href="http://tools.ietf.org/html/draft-friedl-secsh-fingerprint-00">specification</a> */ public static String getFingerprint(PublicKey key) { MessageDigest md5; try { md5 = getMessageDigest("MD5"); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } md5.update(new Buffer.PlainBuffer().putPublicKey(key).getCompactData()); final String undelimited = ByteArrayUtils.toHex(md5.digest()); assert undelimited.length() == 32 : "md5 contract"; StringBuilder fp = new StringBuilder(undelimited.substring(0, 2)); for (int i = 2; i <= undelimited.length() - 2; i += 2) fp.append(":").append(undelimited.substring(i, i + 2)); return fp.toString(); }
@Override public void init() { try { md = SecurityUtils.getMessageDigest(algorithm); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } }
@Override public void init() { try { md = SecurityUtils.getMessageDigest(algorithm); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } }
@Override public boolean verify(String hostname, int port, PublicKey key) { MessageDigest digest; try { digest = SecurityUtils.getMessageDigest(digestAlgorithm); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } digest.update(new Buffer.PlainBuffer().putPublicKey(key).getCompactData()); byte[] digestData = digest.digest(); return Arrays.equals(fingerprintData, digestData); }
/** * Computes the fingerprint for a public key, in the standard SSH format, e.g. "4b:69:6c:72:6f:79:20:77:61:73:20:68:65:72:65:21" * * @param key the public key * @return the fingerprint * @see <a href="http://tools.ietf.org/html/draft-friedl-secsh-fingerprint-00">specification</a> */ public static String getFingerprint(PublicKey key) { MessageDigest md5; try { md5 = getMessageDigest("MD5"); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } md5.update(new Buffer.PlainBuffer().putPublicKey(key).getCompactData()); final String undelimited = ByteArrayUtils.toHex(md5.digest()); assert undelimited.length() == 32 : "md5 contract"; StringBuilder fp = new StringBuilder(undelimited.substring(0, 2)); for (int i = 2; i <= undelimited.length() - 2; i += 2) fp.append(":").append(undelimited.substring(i, i + 2)); return fp.toString(); }
/** * Computes the fingerprint for a public key, in the standard SSH format, e.g. "4b:69:6c:72:6f:79:20:77:61:73:20:68:65:72:65:21" * * @param key the public key * * @return the fingerprint * * @see <a href="http://tools.ietf.org/html/draft-friedl-secsh-fingerprint-00">specification</a> */ public static String getFingerprint(PublicKey key) { MessageDigest md5; try { md5 = getMessageDigest("MD5"); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } md5.update(new Buffer.PlainBuffer().putPublicKey(key).getCompactData()); final String undelimited = ByteArrayUtils.toHex(md5.digest()); assert undelimited.length() == 32 : "md5 contract"; StringBuilder fp = new StringBuilder(undelimited.substring(0, 2)); for (int i = 2; i <= undelimited.length() - 2; i += 2) fp.append(":").append(undelimited.substring(i, i + 2)); return fp.toString(); }