Package ch.ethz.ssh2.crypto.digest

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


      Session sess = conn.openSession();

      sess.execCommand("uname -a && date && uptime && who");

      InputStream stdout = new StreamGobbler(sess.getStdout());

      BufferedReader br = new BufferedReader(new InputStreamReader(stdout));

      System.out.println("Here is some information about the remote host:");
View Full Code Here


      objSSHSession = this.getSshConnection().openSession();
      logger.debug("Executing command " + checkShellCommand);
      objSSHSession.execCommand(checkShellCommand);

      logger.debug("output to stdout for remote command: " + checkShellCommand);
      ipsStdOut = new StreamGobbler(objSSHSession.getStdout());
      ipsStdErr = new StreamGobbler(objSSHSession.getStderr());
      BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(ipsStdOut));
      String stdOut = "";
      while (true) {
        String line = stdoutReader.readLine();
        if (line == null)
View Full Code Here

      this.getSshSession().execCommand(strCmd);

      logger.info("output to stdout for remote command: " + strCmd);

      ipsStdOut = new StreamGobbler(this.getSshSession().getStdout());
      ipsStdErr = new StreamGobbler(this.getSshSession().getStderr());
      BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(ipsStdOut));
      strbStdoutOutput = new StringBuffer();
      while (true) {
        String line = stdoutReader.readLine();
        if (line == null)
View Full Code Here

        {
            String message = "Cannot execute remote command: " + command;
            throw new CommandAbortedException( message, message );
        }

        InputStream stdout = new StreamGobbler( session.getStdout() );
        InputStream stderr = new StreamGobbler( session.getStderr() );
        stderrReader = new BufferedReader( new InputStreamReader( stderr ) );
        setInputStream( new LoggedDataInputStream( stdout ) );
        setOutputStream( new LoggedDataOutputStream( session.getStdin() ) );
    }
View Full Code Here

  public static boolean verifySignature(byte[] message, DSASignature ds, DSAPublicKey dpk) throws IOException
  {
    /* Inspired by Bouncycastle's DSASigner class */

    SHA1 md = new SHA1();
    md.update(message);
    byte[] sha_message = new byte[md.getDigestLength()];
    md.digest(sha_message);

    BigInteger m = new BigInteger(1, sha_message);

    BigInteger r = ds.getR();
    BigInteger s = ds.getS();
View Full Code Here

    return v.equals(r);
  }

  public static DSASignature generateSignature(byte[] message, DSAPrivateKey pk, SecureRandom rnd)
  {
    SHA1 md = new SHA1();
    md.update(message);
    byte[] sha_message = new byte[md.getDigestLength()];
    md.digest(sha_message);

    BigInteger m = new BigInteger(1, sha_message);
    BigInteger k;
    int qBitLength = pk.getQ().bitLength();
View Full Code Here

    return tw.getBytes();
  }

  public static RSASignature generateSignature(byte[] message, RSAPrivateKey pk) throws IOException
  {
    SHA1 md = new SHA1();
    md.update(message);
    byte[] sha_message = new byte[md.getDigestLength()];
    md.digest(sha_message);

    byte[] der_header = new byte[] { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00,
        0x04, 0x14 };

    int rsa_block_len = (pk.getN().bitLength() + 7) / 8;
View Full Code Here

    return new RSASignature(s);
  }

  public static boolean verifySignature(byte[] message, RSASignature ds, RSAPublicKey dpk) throws IOException
  {
    SHA1 md = new SHA1();
    md.update(message);
    byte[] sha_message = new byte[md.getDigestLength()];
    md.digest(sha_message);

    BigInteger n = dpk.getN();
    BigInteger e = dpk.getE();
    BigInteger s = ds.getS();
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

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.