273
|
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 import ch.ethz.ssh2.PacketFormatException;
|
|
10 import ch.ethz.ssh2.PacketTypeException;
|
|
11
|
|
12 /**
|
|
13 * @author Christian Plattner
|
|
14 * @version $Id: PacketNewKeys.java 160 2014-05-01 14:30:26Z dkocher@sudo.ch $
|
|
15 */
|
|
16 public final class PacketNewKeys {
|
|
17 private final byte[] payload;
|
|
18
|
|
19 public PacketNewKeys() {
|
|
20 TypesWriter tw = new TypesWriter();
|
|
21 tw.writeByte(Packets.SSH_MSG_NEWKEYS);
|
|
22 payload = tw.getBytes();
|
|
23 }
|
|
24
|
|
25 public PacketNewKeys(byte payload[]) throws IOException {
|
|
26 this.payload = payload;
|
|
27 TypesReader tr = new TypesReader(payload);
|
|
28 int packet_type = tr.readByte();
|
|
29
|
307
|
30 if (packet_type != Packets.SSH_MSG_NEWKEYS) {
|
273
|
31 throw new PacketTypeException(packet_type);
|
|
32 }
|
307
|
33
|
|
34 if (tr.remain() != 0) {
|
273
|
35 throw new PacketFormatException(String.format("Padding in %s", Packets.getMessageName(packet_type)));
|
|
36 }
|
|
37 }
|
|
38
|
|
39 public byte[] getPayload() {
|
|
40 return payload;
|
|
41 }
|
|
42 }
|