@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()); }
/** * @param factory The {@link org.apache.sshd.common.NamedFactory} for the cipher - ignored if {@code null} * @return The matching {@link org.apache.sshd.common.digest.BuiltinDigests} whose factory name matches * (case <U>insensitive</U>) the digest factory name * @see #fromFactoryName(String) */ public static BuiltinDigests fromFactory(NamedFactory<? extends Digest> factory) { if (factory == null) { return null; } else { return fromFactoryName(factory.getName()); } }
@Override // see https://tools.ietf.org/html/rfc4253#page-23 public boolean isSupported() { return SecurityUtils.isDHOakelyGroupSupported(1024) && BuiltinDigests.sha1.isSupported(); } },
protected byte[] doMD5Hash(int id, Path path, long startOffset, long length, byte[] quickCheckHash) throws Exception { ValidateUtils.checkTrue(startOffset >= 0L, "Invalid start offset: %d", startOffset); ValidateUtils.checkTrue(length > 0L, "Invalid length: %d", length); if (!BuiltinDigests.md5.isSupported()) { throw new UnsupportedOperationException(BuiltinDigests.md5.getAlgorithm() + " hash not supported"); Digest digest = BuiltinDigests.md5.create(); digest.init(); digest = BuiltinDigests.md5.create(); digest.init(); digest.update(digestBuf, 0, readLen);
expectedFactory = BuiltinDigests.fromFactoryName(name); if (expectedFactory == null) { return new SimpleImmutableEntry<>(false, getFingerPrint(d, key)); boolean matches = BuiltinDigests.md5.getName().equals(expectedFactory.getName())
/** * @param d The {@link Digest} to use * @param buf The data buffer to be fingerprint-ed * @param offset The offset of the data in the buffer * @param len The length of data - ignored if non-positive * @return The fingerprint - {@code null} if non-positive length * @throws Exception If failed to calculate the fingerprint * @see #getRawFingerprint(Digest, byte[], int, int) */ public static String getFingerPrint(Digest d, byte[] buf, int offset, int len) throws Exception { if (len <= 0) { return null; } byte[] data = getRawFingerprint(d, buf, offset, len); String algo = d.getAlgorithm(); if (BuiltinDigests.md5.getAlgorithm().equals(algo)) { return algo + ":" + BufferUtils.toHex(':', data).toLowerCase(); } Base64.Encoder encoder = Base64.getEncoder(); return algo.replace("-", "").toUpperCase() + ":" + encoder.encodeToString(data).replaceAll("=", ""); }
@Override public final String toString() { return getName(); }
/** * @param s The {@link Enum}'s name - ignored if {@code null}/empty * @return The matching {@link org.apache.sshd.common.digest.BuiltinDigests} whose {@link Enum#name()} matches * (case <U>insensitive</U>) the provided argument - {@code null} if no match */ public static BuiltinDigests fromString(String s) { if (GenericUtils.isEmpty(s)) { return null; } for (BuiltinDigests c : VALUES) { if (s.equalsIgnoreCase(c.name())) { return c; } } return null; }
@Override // see https://tools.ietf.org/html/rfc4253#page-23 public boolean isSupported() { return SecurityUtils.isDHOakelyGroupSupported(2048) && BuiltinDigests.sha256.isSupported(); } },
expectedFactory = BuiltinDigests.fromFactoryName(name); if (expectedFactory == null) { return new SimpleImmutableEntry<>(false, getFingerPrint(d, key)); boolean matches = BuiltinDigests.md5.getName().equals(expectedFactory.getName())
/** * @param d The {@link Digest} to use * @param buf The data buffer to be fingerprint-ed * @param offset The offset of the data in the buffer * @param len The length of data - ignored if non-positive * @return The fingerprint - {@code null} if non-positive length * @throws Exception If failed to calculate the fingerprint * @see #getRawFingerprint(Digest, byte[], int, int) */ public static String getFingerPrint(Digest d, byte[] buf, int offset, int len) throws Exception { if (len <= 0) { return null; } byte[] data = getRawFingerprint(d, buf, offset, len); String algo = d.getAlgorithm(); if (BuiltinDigests.md5.getAlgorithm().equals(algo)) { return algo + ":" + BufferUtils.toHex(':', data).toLowerCase(); } Base64.Encoder encoder = Base64.getEncoder(); return algo.replace("-", "").toUpperCase() + ":" + encoder.encodeToString(data).replaceAll("=", ""); }
@Override public final String toString() { return getName(); }
/** * @param s The {@link Enum}'s name - ignored if {@code null}/empty * @return The matching {@link org.apache.sshd.common.digest.BuiltinDigests} whose {@link Enum#name()} matches * (case <U>insensitive</U>) the provided argument - {@code null} if no match */ public static BuiltinDigests fromString(String s) { if (GenericUtils.isEmpty(s)) { return null; } for (BuiltinDigests c : VALUES) { if (s.equalsIgnoreCase(c.name())) { return c; } } return null; }
@Override // see https://tools.ietf.org/html/rfc4253#page-23 public boolean isSupported() { return SecurityUtils.isDHOakelyGroupSupported(8192) && BuiltinDigests.sha512.isSupported(); } },
@Override public final Digest create() { return new BaseDigest(getAlgorithm(), getBlockSize()); }
MessageDigest hash = SecurityUtils.getMessageDigest(BuiltinDigests.sha1.getAlgorithm()); byte[] stateValue = {0, 0, 0, 0}; byte[] passBytes = passphrase.getBytes(StandardCharsets.UTF_8);
/** * @param factory The {@link org.apache.sshd.common.NamedFactory} for the cipher - ignored if {@code null} * @return The matching {@link org.apache.sshd.common.digest.BuiltinDigests} whose factory name matches * (case <U>insensitive</U>) the digest factory name * @see #fromFactoryName(String) */ public static BuiltinDigests fromFactory(NamedFactory<? extends Digest> factory) { if (factory == null) { return null; } else { return fromFactoryName(factory.getName()); } }
/** * @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 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(); } },