Package ch.ethz.ssh2.crypto.digest

Examples of ch.ethz.ssh2.crypto.digest.SHA1


    catch (IOException e)
    {
      return false;
    }

    SHA1 sha1 = new SHA1();

    if (salt.length != sha1.getDigestLength())
      return false;

    byte[] dig = hmacSha1Hash(salt, hostname);

    for (int i = 0; i < dig.length; i++)
View Full Code Here


    {
      dig = new MD5();
    }
    else if ("sha1".equals(type))
    {
      dig = new SHA1();
    }
    else
      throw new IllegalArgumentException("Unknown hash type " + type);

    if ("ssh-rsa".equals(keyType))
View Full Code Here

   * @param hostname
   * @return the hashed representation, e.g., "|1|cDhrv7zwEUV3k71CEPHnhHZezhA=|Xo+2y6rUXo2OIWRAYhBOIijbJMA="
   */
  public static final String createHashedHostname(String hostname)
  {
    SHA1 sha1 = new SHA1();

    byte[] salt = new byte[sha1.getDigestLength()];

    new SecureRandom().nextBytes(salt);

    byte[] hash = hmacSha1Hash(salt, hostname);

View Full Code Here

    return new String("|1|" + base64_salt + "|" + base64_hash);
  }

  private static final byte[] hmacSha1Hash(byte[] salt, String hostname)
  {
    SHA1 sha1 = new SHA1();

    if (salt.length != sha1.getDigestLength())
      throw new IllegalArgumentException("Salt has wrong length (" + salt.length + ")");

    HMAC hmac = new HMAC(sha1, salt, salt.length);

    hmac.update(hostname.getBytes());
View Full Code Here

    catch (IOException e)
    {
      return false;
    }

    SHA1 sha1 = new SHA1();

    if (salt.length != sha1.getDigestLength())
      return false;

    byte[] dig = hmacSha1Hash(salt, hostname);

    for (int i = 0; i < dig.length; i++)
View Full Code Here

    {
      dig = new MD5();
    }
    else if ("sha1".equals(type))
    {
      dig = new SHA1();
    }
    else
      throw new IllegalArgumentException("Unknown hash type " + type);

    if ("ssh-rsa".equals(keyType))
View Full Code Here

   * @param hostname
   * @return the hashed representation, e.g., "|1|cDhrv7zwEUV3k71CEPHnhHZezhA=|Xo+2y6rUXo2OIWRAYhBOIijbJMA="
   */
  public static final String createHashedHostname(String hostname)
  {
    SHA1 sha1 = new SHA1();

    byte[] salt = new byte[sha1.getDigestLength()];

    new SecureRandom().nextBytes(salt);

    byte[] hash = hmacSha1Hash(salt, hostname);

View Full Code Here

    return new String("|1|" + base64_salt + "|" + base64_hash);
  }

  private static final byte[] hmacSha1Hash(byte[] salt, String hostname)
  {
    SHA1 sha1 = new SHA1();

    if (salt.length != sha1.getDigestLength())
      throw new IllegalArgumentException("Salt has wrong length (" + salt.length + ")");

    HMAC hmac = new HMAC(sha1, salt, salt.length);

    hmac.update(StringEncoder.GetBytes(hostname));
View Full Code Here

    catch (IOException e)
    {
      return false;
    }

    SHA1 sha1 = new SHA1();

    if (salt.length != sha1.getDigestLength())
      return false;

    byte[] dig = hmacSha1Hash(salt, hostname);

    for (int i = 0; i < dig.length; i++)
View Full Code Here

    {
      dig = new MD5();
    }
    else if ("sha1".equals(type))
    {
      dig = new SHA1();
    }
    else
      throw new IllegalArgumentException("Unknown hash type " + type);

    if ("ssh-rsa".equals(keyType))
View Full Code Here

TOP

Related Classes of ch.ethz.ssh2.crypto.digest.SHA1

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.