/** * @param d The {@link Digest} instance - ignored if {@code null} * @return The matching {@link org.apache.sshd.common.digest.BuiltinDigests} whose algorithm matches * (case <U>insensitive</U>) the digets's algorithm - {@code null} if no match */ public static BuiltinDigests fromDigest(Digest d) { return fromAlgorithm((d == null) ? null : d.getAlgorithm()); }
/** * @param f The {@link Factory} to create the {@link Digest} to use * @param s The {@link String} to digest - ignored if {@code null}/empty, * otherwise its UTF-8 representation is used as input for the fingerprint * @return The fingerprint - {@code null} if {@code null}/empty input * @throws Exception If failed to calculate the digest * @see #getFingerPrint(Digest, String, Charset) */ public static String getFingerPrint(Factory<? extends Digest> f, String s) throws Exception { return getFingerPrint(f, s, StandardCharsets.UTF_8); }
@Override public final Digest create() { return new BaseDigest(getAlgorithm(), getBlockSize()); }
@Override public int hashCode() { synchronized (this) { if (h == 0) { h = Objects.hashCode(getAlgorithm()) + getBlockSize(); if (h == 0) { h = 1; } } } return h; }
@Override // see https://tools.ietf.org/html/rfc4253#page-23 public boolean isSupported() { return SecurityUtils.isDHOakelyGroupSupported(1024) && BuiltinDigests.sha1.isSupported(); } },
/** * @return The {@link Digest} to use when hashing the curve's parameters */ public final Digest getDigestForParams() { return digestFactory.create(); }
BuiltinDigests(String factoryName, String algorithm, int blockSize) { this.factoryName = factoryName; this.algorithm = algorithm; this.blockSize = blockSize; /* * This can be done once since in order to change the support the JVM * needs to be stopped, some unlimited-strength files need be installed * and then the JVM re-started. Therefore, the answer is not going to * change while the JVM is running */ this.supported = DigestUtils.checkSupported(algorithm); }
/** * @param algo The algorithm to find - ignored if {@code null}/empty * @return The matching {@link org.apache.sshd.common.digest.BuiltinDigests} whose algorithm matches * (case <U>insensitive</U>) the provided name - {@code null} if no match */ public static BuiltinDigests fromAlgorithm(String algo) { return DigestUtils.findFactoryByAlgorithm(algo, String.CASE_INSENSITIVE_ORDER, VALUES); }
@Override public final String toString() { return getName(); }
@Override public final Digest create() { return new BaseDigest(getAlgorithm(), getBlockSize()); }
/** * @param d The {@link Digest} instance - ignored if {@code null} * @return The matching {@link org.apache.sshd.common.digest.BuiltinDigests} whose algorithm matches * (case <U>insensitive</U>) the digets's algorithm - {@code null} if no match */ public static BuiltinDigests fromDigest(Digest d) { return fromAlgorithm((d == null) ? null : d.getAlgorithm()); }
@Override // see https://tools.ietf.org/html/rfc4253#page-23 public boolean isSupported() { return SecurityUtils.isDHOakelyGroupSupported(2048) && BuiltinDigests.sha256.isSupported(); } },
/** * @param d The {@link Digest} to use * @param s The {@link String} to digest - ignored if {@code null}/empty, * otherwise its UTF-8 representation is used as input for the fingerprint * @return The fingerprint - {@code null} if {@code null}/empty input * @throws Exception If failed to calculate the digest * @see #getFingerPrint(Digest, String, Charset) */ public static String getFingerPrint(Digest d, String s) throws Exception { return getFingerPrint(d, s, StandardCharsets.UTF_8); }
/** * @return The {@link Digest} to use when hashing the curve's parameters */ public final Digest getDigestForParams() { return digestFactory.create(); }
BuiltinDigests(String factoryName, String algorithm, int blockSize) { this.factoryName = factoryName; this.algorithm = algorithm; this.blockSize = blockSize; /* * This can be done once since in order to change the support the JVM * needs to be stopped, some unlimited-strength files need be installed * and then the JVM re-started. Therefore, the answer is not going to * change while the JVM is running */ this.supported = DigestUtils.checkSupported(algorithm); }
/** * @param algo The algorithm to find - ignored if {@code null}/empty * @return The matching {@link org.apache.sshd.common.digest.BuiltinDigests} whose algorithm matches * (case <U>insensitive</U>) the provided name - {@code null} if no match */ public static BuiltinDigests fromAlgorithm(String algo) { return DigestUtils.findFactoryByAlgorithm(algo, String.CASE_INSENSITIVE_ORDER, VALUES); }
@Override public final String toString() { return getName(); }
@Override public boolean isSupported() { // avoid "Prime size must be multiple of 64, and can only range from 512 to 2048 (inclusive)" return SecurityUtils.isDHGroupExchangeSupported() && BuiltinDigests.sha1.isSupported(); } },
/** * @param d The {@link Digest} to use * @param s The {@link String} to digest - ignored if {@code null}/empty, * otherwise its UTF-8 representation is used as input for the fingerprint * @return The fingerprint - {@code null} if {@code null}/empty input * @throws Exception If failed to calculate the digest * @see #getFingerPrint(Digest, String, Charset) */ public static String getFingerPrint(Digest d, String s) throws Exception { return getFingerPrint(d, s, StandardCharsets.UTF_8); }
/** * @param f The {@link Factory} to create the {@link Digest} to use * @param s The {@link String} to digest - ignored if {@code null}/empty, * otherwise its UTF-8 representation is used as input for the fingerprint * @return The fingerprint - {@code null} if {@code null}/empty input * @throws Exception If failed to calculate the digest * @see #getFingerPrint(Digest, String, Charset) */ public static String getFingerPrint(Factory<? extends Digest> f, String s) throws Exception { return getFingerPrint(f, s, StandardCharsets.UTF_8); }