comparison src/com/trilead/ssh2/packets/PacketNewKeys.java @ 0:0ce5cc452d02

initial version
author Carl Byington <carl@five-ten-sg.com>
date Thu, 22 May 2014 10:41:19 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0ce5cc452d02
1 package com.trilead.ssh2.packets;
2
3 import java.io.IOException;
4
5 /**
6 * PacketNewKeys.
7 *
8 * @author Christian Plattner, plattner@trilead.com
9 * @version $Id: PacketNewKeys.java,v 1.1 2007/10/15 12:49:55 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) throws IOException {
18 this.payload = new byte[len];
19 System.arraycopy(payload, off, this.payload, 0, len);
20 TypesReader tr = new TypesReader(payload, off, len);
21 int packet_type = tr.readByte();
22
23 if (packet_type != Packets.SSH_MSG_NEWKEYS)
24 throw new IOException("This is not a SSH_MSG_NEWKEYS! ("
25 + packet_type + ")");
26
27 if (tr.remain() != 0)
28 throw new IOException("Padding in SSH_MSG_NEWKEYS packet!");
29 }
30
31 public byte[] getPayload() {
32 if (payload == null) {
33 TypesWriter tw = new TypesWriter();
34 tw.writeByte(Packets.SSH_MSG_NEWKEYS);
35 payload = tw.getBytes();
36 }
37
38 return payload;
39 }
40 }