Package ch.ethz.ssh2.packets

Examples of ch.ethz.ssh2.packets.PacketKexInit


    this.state = state;
  }

  public 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.local_dsa_key = nextKEXdsakey;
        kxs.local_rsa_key = nextKEXrsakey;
        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.remoteKEX.getKexParameters(), kxs.localKEX.getKexParameters());

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


    {
      kxs = new KexState();
      kxs.local_dsa_key = dsa;
      kxs.local_rsa_key = rsa;
      kxs.dhgexParameters = nextKEXdhgexParameters;
      kxs.localKEX = new PacketKexInit(nextKEXcryptoWishList, rnd);
      tm.sendKexMessage(kxs.localKEX.getPayload());
    }
  }
View Full Code Here

  }

 
  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

    this.state = state;
  }

  public 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.local_dsa_key = nextKEXdsakey;
        kxs.local_rsa_key = nextKEXrsakey;
        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.remoteKEX.getKexParameters(), kxs.localKEX.getKexParameters());

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

    {
      kxs = new KexState();
      kxs.local_dsa_key = dsa;
      kxs.local_rsa_key = rsa;
      kxs.dhgexParameters = nextKEXdhgexParameters;
      kxs.localKEX = new PacketKexInit(nextKEXcryptoWishList, rnd);
      tm.sendKexMessage(kxs.localKEX.getPayload());
    }
  }
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

        return true;
      }

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

        remainingMethods = puf.getAuthThatCanContinue();
        isPartialSuccess = puf.isPartialSuccess();

        return false;
      }

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

TOP

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

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.