Package ch.ethz.ssh2.packets

Examples of ch.ethz.ssh2.packets.PacketKexDhGexReply


        return;
      }

      if (kxs.state == 2)
      {
        PacketKexDhGexReply dhgexrpl = new PacketKexDhGexReply(msg, 0, msglen);

        kxs.remote_hostkey = dhgexrpl.getHostKey();

        if (verifier != null)
        {
          boolean vres = false;

          try
          {
            vres = verifier.verifyServerHostKey(hostname, port, kxs.np.server_host_key_algo, kxs.remote_hostkey);
          }
          catch (Exception e)
          {
            throw (IOException) new IOException(
                "The server hostkey was not accepted by the verifier callback.").initCause(e);
          }

          if (vres == false)
            throw new IOException("The server hostkey was not accepted by the verifier callback");
        }

        kxs.dhgx.setF(dhgexrpl.getF());

        try
        {
          kxs.H = kxs.dhgx.calculateH(csh.getClientString(), csh.getServerString(),
              kxs.localKEX.getPayload(), kxs.remoteKEX.getPayload(), dhgexrpl.getHostKey(),
              kxs.dhgexParameters);
        }
        catch (IllegalArgumentException e)
        {
          throw (IOException) new IOException("KEX error.").initCause(e);
        }

        boolean res = verifySignature(dhgexrpl.getSignature(), kxs.remote_hostkey);

        if (res == false)
          throw new IOException("Hostkey signature sent by remote is wrong!");

        kxs.K = kxs.dhgx.getK();
View Full Code Here


          tm.sendKexMessage(dhgexreq.getPayload());

        }
        else
        {
          PacketKexDhGexRequest dhgexreq = new PacketKexDhGexRequest(kxs.dhgexParameters);
          tm.sendKexMessage(dhgexreq.getPayload());
        }
        kxs.state = 1;
        return;
      }
View Full Code Here

      if (kxs.np.kex_algo.equals("diffie-hellman-group-exchange-sha1"))
      {
        if (kxs.dhgexParameters.getMin_group_len() == 0)
        {
          PacketKexDhGexRequestOld dhgexreq = new PacketKexDhGexRequestOld(kxs.dhgexParameters);
          tm.sendKexMessage(dhgexreq.getPayload());

        }
        else
        {
          PacketKexDhGexRequest dhgexreq = new PacketKexDhGexRequest(kxs.dhgexParameters);
          tm.sendKexMessage(dhgexreq.getPayload());
        }
        kxs.state = 1;
        return;
      }
View Full Code Here

    if (kxs == null)
    {
      kxs = new KexState();

      kxs.dhgexParameters = nextKEXdhgexParameters;
      PacketKexInit kp = new PacketKexInit(nextKEXcryptoWishList, rnd);
      kxs.localKEX = kp;
      tm.sendKexMessage(kp.getPayload());
    }
  }
View Full Code Here

    throw new IOException("Unknown server host key algorithm '" + kxs.np.server_host_key_algo + "'");
  }

  public synchronized void handleMessage(byte[] msg, int msglen) throws IOException
  {
    PacketKexInit kip;

    if (msg == null)
    {
      synchronized (accessLock)
      {
        connectionClosed = true;
        accessLock.notifyAll();
        return;
      }
    }

    if ((kxs == null) && (msg[0] != Packets.SSH_MSG_KEXINIT))
      throw new IOException("Unexpected KEX message (type " + msg[0] + ")");

    if (ignore_next_kex_packet)
    {
      ignore_next_kex_packet = false;
      return;
    }

    if (msg[0] == Packets.SSH_MSG_KEXINIT)
    {
      if ((kxs != null) && (kxs.state != 0))
        throw new IOException("Unexpected SSH_MSG_KEXINIT message during on-going kex exchange!");

      if (kxs == null)
      {
        /*
         * Ah, OK, peer wants to do KEX. Let's be nice and play
         * together.
         */
        kxs = new KexState();
        kxs.dhgexParameters = nextKEXdhgexParameters;
        kip = new PacketKexInit(nextKEXcryptoWishList, rnd);
        kxs.localKEX = kip;
        tm.sendKexMessage(kip.getPayload());
      }

      kip = new PacketKexInit(msg, 0, msglen);
      kxs.remoteKEX = kip;

      kxs.np = mergeKexParameters(kxs.localKEX.getKexParameters(), kxs.remoteKEX.getKexParameters());

      if (kxs.np == null)
View Full Code Here

    establishKeyMaterial();

    /* Tell the other side that we start using the new material */

    PacketNewKeys ign = new PacketNewKeys();
    tm.sendKexMessage(ign.getPayload());

    BlockCipher cbc;
    MAC mac;

    try
View Full Code Here

      PacketUserauthRequestNone urn = new PacketUserauthRequestNone("ssh-connection", user);
      tm.sendMessage(urn.getPayload());

      byte[] msg = getNextMessage();
      new PacketServiceAccept(msg, 0, msg.length);
      msg = getNextMessage();

      initDone = true;

      if (msg[0] == Packets.SSH_MSG_USERAUTH_SUCCESS)
View Full Code Here

  {
    if (initDone == false)
    {
      tm.registerMessageHandler(this, 0, 255);

      PacketServiceRequest sr = new PacketServiceRequest("ssh-userauth");
      tm.sendMessage(sr.getPayload());

      PacketUserauthRequestNone urn = new PacketUserauthRequestNone("ssh-connection", user);
      tm.sendMessage(urn.getPayload());

      byte[] msg = getNextMessage();
View Full Code Here

      byte[] msg = deQueue();

      if (msg[0] != Packets.SSH_MSG_USERAUTH_BANNER)
        return msg;

      PacketUserauthBanner sb = new PacketUserauthBanner(msg, 0, msg.length);

      banner = sb.getBanner();
    }
  }
View Full Code Here

        return true;
      }

      if (msg[0] == Packets.SSH_MSG_USERAUTH_FAILURE)
      {
        PacketUserauthFailure puf = new PacketUserauthFailure(msg, 0, msg.length);

        remainingMethods = puf.getAuthThatCanContinue();
        isPartialSuccess = puf.isPartialSuccess();
        return false;
      }

      throw new IOException("Unexpected SSH message (type " + msg[0] + ")");
    }
View Full Code Here

TOP

Related Classes of ch.ethz.ssh2.packets.PacketKexDhGexReply

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.