public static byte[] calculateHashValue(String host, Factory<? extends Mac> factory, byte[] salt) throws Exception { return calculateHashValue(host, factory.create(), salt); }
public static byte[] calculateHashValue(String host, int port, Factory<? extends Mac> factory, byte[] salt) throws Exception { return calculateHashValue(host, port, factory.create(), salt); }
/** * Checks if the host matches the hash * * @param host The host name/address - ignored if {@code null}/empty * @param port The access port - ignored if non-positive or SSH default * @return {@code true} if host matches the hash * @throws RuntimeException If entry not properly initialized */ public boolean isHostMatch(String host, int port) { if (GenericUtils.isEmpty(host)) { return false; } try { byte[] expected = getDigestValue(); byte[] actual = calculateHashValue(host, port, getDigester(), getSaltValue()); return Arrays.equals(expected, actual); } catch (Throwable t) { if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new RuntimeSshException("Failed (" + t.getClass().getSimpleName() + ")" + " to calculate hash value: " + t.getMessage(), t); } }
/** * Checks if the host matches the hash * * @param host The host name/address - ignored if {@code null}/empty * @return {@code true} if host matches the hash * @throws RuntimeException If entry not properly initialized */ public boolean isHostMatch(String host) { if (GenericUtils.isEmpty(host)) { return false; } try { byte[] expected = getDigestValue(); byte[] actual = calculateHashValue(host, getDigester(), getSaltValue()); return Arrays.equals(expected, actual); } catch (Throwable t) { if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new RuntimeSshException("Failed (" + t.getClass().getSimpleName() + ")" + " to calculate hash value: " + t.getMessage(), t); } }
rnd.fill(salt); byte[] digestValue = KnownHostHashValue.calculateHashValue(hostIdentity.getHostName(), mac, salt); KnownHostHashValue.append(sb, digester, salt, digestValue); } else {
KnownHostHashValue.calculateHashValue( hostIdentity.getHostName(), hostIdentity.getPort(), mac, salt); KnownHostHashValue.append(sb, digester, salt, digestValue);