01: package ch.ethz.ssh2.packets;
02:
03: import java.io.IOException;
04:
05: /**
06: * PacketNewKeys.
07: *
08: * @author Christian Plattner, plattner@inf.ethz.ch
09: * @version $Id: PacketNewKeys.java,v 1.2 2005/08/24 17:54:09 cplattne Exp $
10: */
11: public class PacketNewKeys {
12: byte[] payload;
13:
14: public PacketNewKeys() {
15: }
16:
17: public PacketNewKeys(byte payload[], int off, int len)
18: throws IOException {
19: this .payload = new byte[len];
20: System.arraycopy(payload, off, this .payload, 0, len);
21:
22: TypesReader tr = new TypesReader(payload, off, len);
23:
24: int packet_type = tr.readByte();
25:
26: if (packet_type != Packets.SSH_MSG_NEWKEYS)
27: throw new IOException("This is not a SSH_MSG_NEWKEYS! ("
28: + packet_type + ")");
29:
30: if (tr.remain() != 0)
31: throw new IOException("Padding in SSH_MSG_NEWKEYS packet!");
32: }
33:
34: public byte[] getPayload() {
35: if (payload == null) {
36: TypesWriter tw = new TypesWriter();
37: tw.writeByte(Packets.SSH_MSG_NEWKEYS);
38: payload = tw.getBytes();
39: }
40: return payload;
41: }
42: }
|