comparison src/ch/ethz/ssh2/DHGexParameters.java @ 307:071eccdff8ea ganymed

fix java formatting
author Carl Byington <carl@five-ten-sg.com>
date Wed, 30 Jul 2014 14:16:58 -0700
parents 91a31873c42a
children
comparison
equal deleted inserted replaced
305:d2b303406d63 307:071eccdff8ea
9 * the diffie-hellman group exchange. 9 * the diffie-hellman group exchange.
10 * <p> 10 * <p>
11 * Depending on which constructor is used, either the use of a 11 * Depending on which constructor is used, either the use of a
12 * <code>SSH_MSG_KEX_DH_GEX_REQUEST</code> or <code>SSH_MSG_KEX_DH_GEX_REQUEST_OLD</code> 12 * <code>SSH_MSG_KEX_DH_GEX_REQUEST</code> or <code>SSH_MSG_KEX_DH_GEX_REQUEST_OLD</code>
13 * can be forced. 13 * can be forced.
14 * 14 *
15 * @see Connection#setDHGexParameters(DHGexParameters) 15 * @see Connection#setDHGexParameters(DHGexParameters)
16 * @author Christian Plattner 16 * @author Christian Plattner
17 * @version 2.50, 03/15/10 17 * @version 2.50, 03/15/10
18 */ 18 */
19 19
20 public class DHGexParameters 20 public class DHGexParameters {
21 { 21 private final int min_group_len;
22 private final int min_group_len; 22 private final int pref_group_len;
23 private final int pref_group_len; 23 private final int max_group_len;
24 private final int max_group_len;
25 24
26 private static final int MIN_ALLOWED = 1024; 25 private static final int MIN_ALLOWED = 1024;
27 private static final int MAX_ALLOWED = 8192; 26 private static final int MAX_ALLOWED = 8192;
28 27
29 /** 28 /**
30 * Same as calling {@link #DHGexParameters(int, int, int) DHGexParameters(1024, 1024, 4096)}. 29 * Same as calling {@link #DHGexParameters(int, int, int) DHGexParameters(1024, 1024, 4096)}.
31 * This is also the default used by the Connection class. 30 * This is also the default used by the Connection class.
32 * 31 *
33 */ 32 */
34 public DHGexParameters() 33 public DHGexParameters() {
35 { 34 this(1024, 1024, 4096);
36 this(1024, 1024, 4096); 35 }
37 }
38 36
39 /** 37 /**
40 * This constructor can be used to force the sending of a 38 * This constructor can be used to force the sending of a
41 * <code>SSH_MSG_KEX_DH_GEX_REQUEST_OLD</code> request. 39 * <code>SSH_MSG_KEX_DH_GEX_REQUEST_OLD</code> request.
42 * Internally, the minimum and maximum group lengths will 40 * Internally, the minimum and maximum group lengths will
43 * be set to zero. 41 * be set to zero.
44 * 42 *
45 * @param pref_group_len has to be &gt= 1024 and &lt;= 8192 43 * @param pref_group_len has to be &gt= 1024 and &lt;= 8192
46 */ 44 */
47 public DHGexParameters(int pref_group_len) 45 public DHGexParameters(int pref_group_len) {
48 { 46 if ((pref_group_len < MIN_ALLOWED) || (pref_group_len > MAX_ALLOWED))
49 if ((pref_group_len < MIN_ALLOWED) || (pref_group_len > MAX_ALLOWED)) 47 throw new IllegalArgumentException("pref_group_len out of range!");
50 throw new IllegalArgumentException("pref_group_len out of range!");
51 48
52 this.pref_group_len = pref_group_len; 49 this.pref_group_len = pref_group_len;
53 this.min_group_len = 0; 50 this.min_group_len = 0;
54 this.max_group_len = 0; 51 this.max_group_len = 0;
55 } 52 }
56 53
57 /** 54 /**
58 * This constructor can be used to force the sending of a 55 * This constructor can be used to force the sending of a
59 * <code>SSH_MSG_KEX_DH_GEX_REQUEST</code> request. 56 * <code>SSH_MSG_KEX_DH_GEX_REQUEST</code> request.
60 * <p> 57 * <p>
61 * Note: older OpenSSH servers don't understand this request, in which 58 * Note: older OpenSSH servers don't understand this request, in which
62 * case you should use the {@link #DHGexParameters(int)} constructor. 59 * case you should use the {@link #DHGexParameters(int)} constructor.
63 * <p> 60 * <p>
64 * All values have to be &gt= 1024 and &lt;= 8192. Furthermore, 61 * All values have to be &gt= 1024 and &lt;= 8192. Furthermore,
65 * min_group_len &lt;= pref_group_len &lt;= max_group_len. 62 * min_group_len &lt;= pref_group_len &lt;= max_group_len.
66 * 63 *
67 * @param min_group_len 64 * @param min_group_len
68 * @param pref_group_len 65 * @param pref_group_len
69 * @param max_group_len 66 * @param max_group_len
70 */ 67 */
71 public DHGexParameters(int min_group_len, int pref_group_len, int max_group_len) 68 public DHGexParameters(int min_group_len, int pref_group_len, int max_group_len) {
72 { 69 if ((min_group_len < MIN_ALLOWED) || (min_group_len > MAX_ALLOWED))
73 if ((min_group_len < MIN_ALLOWED) || (min_group_len > MAX_ALLOWED)) 70 throw new IllegalArgumentException("min_group_len out of range!");
74 throw new IllegalArgumentException("min_group_len out of range!");
75 71
76 if ((pref_group_len < MIN_ALLOWED) || (pref_group_len > MAX_ALLOWED)) 72 if ((pref_group_len < MIN_ALLOWED) || (pref_group_len > MAX_ALLOWED))
77 throw new IllegalArgumentException("pref_group_len out of range!"); 73 throw new IllegalArgumentException("pref_group_len out of range!");
78 74
79 if ((max_group_len < MIN_ALLOWED) || (max_group_len > MAX_ALLOWED)) 75 if ((max_group_len < MIN_ALLOWED) || (max_group_len > MAX_ALLOWED))
80 throw new IllegalArgumentException("max_group_len out of range!"); 76 throw new IllegalArgumentException("max_group_len out of range!");
81 77
82 if ((pref_group_len < min_group_len) || (pref_group_len > max_group_len)) 78 if ((pref_group_len < min_group_len) || (pref_group_len > max_group_len))
83 throw new IllegalArgumentException("pref_group_len is incompatible with min and max!"); 79 throw new IllegalArgumentException("pref_group_len is incompatible with min and max!");
84 80
85 if (max_group_len < min_group_len) 81 if (max_group_len < min_group_len)
86 throw new IllegalArgumentException("max_group_len must not be smaller than min_group_len!"); 82 throw new IllegalArgumentException("max_group_len must not be smaller than min_group_len!");
87 83
88 this.min_group_len = min_group_len; 84 this.min_group_len = min_group_len;
89 this.pref_group_len = pref_group_len; 85 this.pref_group_len = pref_group_len;
90 this.max_group_len = max_group_len; 86 this.max_group_len = max_group_len;
91 } 87 }
92 88
93 /** 89 /**
94 * Get the maximum group length. 90 * Get the maximum group length.
95 * 91 *
96 * @return the maximum group length, may be <code>zero</code> if 92 * @return the maximum group length, may be <code>zero</code> if
97 * SSH_MSG_KEX_DH_GEX_REQUEST_OLD should be requested 93 * SSH_MSG_KEX_DH_GEX_REQUEST_OLD should be requested
98 */ 94 */
99 public int getMax_group_len() 95 public int getMax_group_len() {
100 { 96 return max_group_len;
101 return max_group_len; 97 }
102 }
103 98
104 /** 99 /**
105 * Get the minimum group length. 100 * Get the minimum group length.
106 * 101 *
107 * @return minimum group length, may be <code>zero</code> if 102 * @return minimum group length, may be <code>zero</code> if
108 * SSH_MSG_KEX_DH_GEX_REQUEST_OLD should be requested 103 * SSH_MSG_KEX_DH_GEX_REQUEST_OLD should be requested
109 */ 104 */
110 public int getMin_group_len() 105 public int getMin_group_len() {
111 { 106 return min_group_len;
112 return min_group_len; 107 }
113 }
114 108
115 /** 109 /**
116 * Get the preferred group length. 110 * Get the preferred group length.
117 * 111 *
118 * @return the preferred group length 112 * @return the preferred group length
119 */ 113 */
120 public int getPref_group_len() 114 public int getPref_group_len() {
121 { 115 return pref_group_len;
122 return pref_group_len; 116 }
123 }
124 } 117 }