1/*
2 * Copyright (c) 2006-2011 Christian Plattner. All rights reserved.
3 * Please refer to the LICENSE.txt for licensing details.
4 */
5package ch.ethz.ssh2.packets;
6
7import java.io.IOException;
8
9import java.math.BigInteger;
10
11/**
12 * PacketKexDhGexGroup.
13 *
14 * @author Christian Plattner
15 * @version 2.50, 03/15/10
16 */
17public class PacketKexDhGexGroup
18{
19	byte[] payload;
20
21	BigInteger p;
22	BigInteger g;
23
24	public PacketKexDhGexGroup(byte payload[], int off, int len) throws IOException
25	{
26		this.payload = new byte[len];
27		System.arraycopy(payload, off, this.payload, 0, len);
28
29		TypesReader tr = new TypesReader(payload, off, len);
30
31		int packet_type = tr.readByte();
32
33		if (packet_type != Packets.SSH_MSG_KEX_DH_GEX_GROUP)
34			throw new IllegalArgumentException(
35					"This is not a SSH_MSG_KEX_DH_GEX_GROUP! (" + packet_type
36							+ ")");
37
38		p = tr.readMPINT();
39		g = tr.readMPINT();
40
41		if (tr.remain() != 0)
42			throw new IOException("PADDING IN SSH_MSG_KEX_DH_GEX_GROUP!");
43	}
44
45	public BigInteger getG()
46	{
47		return g;
48	}
49
50	public BigInteger getP()
51	{
52		return p;
53	}
54}
55