Home | History | Annotate | Download | only in packets
      1 /*
      2  * Copyright (c) 2006-2011 Christian Plattner. All rights reserved.
      3  * Please refer to the LICENSE.txt for licensing details.
      4  */
      5 package ch.ethz.ssh2.packets;
      6 
      7 import java.io.IOException;
      8 
      9 /**
     10  * PacketNewKeys.
     11  *
     12  * @author Christian Plattner
     13  * @version 2.50, 03/15/10
     14  */
     15 public class PacketNewKeys
     16 {
     17 	byte[] payload;
     18 
     19 	public PacketNewKeys()
     20 	{
     21 	}
     22 
     23 	public PacketNewKeys(byte payload[], int off, int len) throws IOException
     24 	{
     25 		this.payload = new byte[len];
     26 		System.arraycopy(payload, off, this.payload, 0, len);
     27 
     28 		TypesReader tr = new TypesReader(payload, off, len);
     29 
     30 		int packet_type = tr.readByte();
     31 
     32 		if (packet_type != Packets.SSH_MSG_NEWKEYS)
     33 			throw new IOException("This is not a SSH_MSG_NEWKEYS! ("
     34 					+ packet_type + ")");
     35 
     36 		if (tr.remain() != 0)
     37 			throw new IOException("Padding in SSH_MSG_NEWKEYS packet!");
     38 	}
     39 
     40 	public byte[] getPayload()
     41 	{
     42 		if (payload == null)
     43 		{
     44 			TypesWriter tw = new TypesWriter();
     45 			tw.writeByte(Packets.SSH_MSG_NEWKEYS);
     46 			payload = tw.getBytes();
     47 		}
     48 		return payload;
     49 	}
     50 }
     51