All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.ethz.ssh2.DHGexParameters Maven / Gradle / Ivy


package ch.ethz.ssh2;

/**
 * A DHGexParameters object can be used to specify parameters for
 * the diffie-hellman group exchange. Default values are 1024, 1024 and 4096.
 * All values have to be >= 1024 and <= 8192. min_group_len <=
 * pref_group_len <= max_group_len.
 * 
 * @author Christian Plattner, [email protected]
 * @version $Id: DHGexParameters.java,v 1.2 2005/08/11 17:34:19 cplattne Exp $
 */

public class DHGexParameters
{
	private int min_group_len = 1024;
	private int pref_group_len = 1024;
	private int max_group_len = 4096;

	private static final int min_allowed = 1024;
	private static final int max_allowed = 8192;

	public DHGexParameters()
	{
	}

	public DHGexParameters(int min_group_len, int pref_group_len, int max_group_len)
	{
		if ((min_group_len < min_allowed) || (min_group_len > max_allowed))
			throw new IllegalArgumentException("min_group_len out of range!");

		if ((pref_group_len < min_allowed) || (pref_group_len > max_allowed))
			throw new IllegalArgumentException("pref_group_len out of range!");

		if ((max_group_len < min_allowed) || (max_group_len > max_allowed))
			throw new IllegalArgumentException("max_group_len out of range!");

		if ((pref_group_len < min_group_len) || (pref_group_len > max_group_len))
			throw new IllegalArgumentException("pref_group_len is incompatible with min and max!");

		if (max_group_len < min_group_len)
			throw new IllegalArgumentException("max_group_len must not be smaller than min_group_len!");

		this.min_group_len = min_group_len;
		this.pref_group_len = pref_group_len;
		this.max_group_len = max_group_len;
	}

	public int getMax_group_len()
	{
		return max_group_len;
	}

	public int getMin_group_len()
	{
		return min_group_len;
	}

	public int getPref_group_len()
	{
		return pref_group_len;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy