1 2 package ch.ethz.ssh2; 3 4 16 17 public class DHGexParameters 18 { 19 private final int min_group_len; 20 private final int pref_group_len; 21 private final int max_group_len; 22 23 private static final int MIN_ALLOWED = 1024; 24 private static final int MAX_ALLOWED = 8192; 25 26 31 public DHGexParameters() 32 { 33 this(1024, 1024, 4096); 34 } 35 36 44 public DHGexParameters(int pref_group_len) 45 { 46 if ((pref_group_len < MIN_ALLOWED) || (pref_group_len > MAX_ALLOWED)) 47 throw new IllegalArgumentException ("pref_group_len out of range!"); 48 49 this.pref_group_len = pref_group_len; 50 this.min_group_len = 0; 51 this.max_group_len = 0; 52 } 53 54 68 public DHGexParameters(int min_group_len, int pref_group_len, int max_group_len) 69 { 70 if ((min_group_len < MIN_ALLOWED) || (min_group_len > MAX_ALLOWED)) 71 throw new IllegalArgumentException ("min_group_len out of range!"); 72 73 if ((pref_group_len < MIN_ALLOWED) || (pref_group_len > MAX_ALLOWED)) 74 throw new IllegalArgumentException ("pref_group_len out of range!"); 75 76 if ((max_group_len < MIN_ALLOWED) || (max_group_len > MAX_ALLOWED)) 77 throw new IllegalArgumentException ("max_group_len out of range!"); 78 79 if ((pref_group_len < min_group_len) || (pref_group_len > max_group_len)) 80 throw new IllegalArgumentException ("pref_group_len is incompatible with min and max!"); 81 82 if (max_group_len < min_group_len) 83 throw new IllegalArgumentException ("max_group_len must not be smaller than min_group_len!"); 84 85 this.min_group_len = min_group_len; 86 this.pref_group_len = pref_group_len; 87 this.max_group_len = max_group_len; 88 } 89 90 96 public int getMax_group_len() 97 { 98 return max_group_len; 99 } 100 101 107 public int getMin_group_len() 108 { 109 return min_group_len; 110 } 111 112 117 public int getPref_group_len() 118 { 119 return pref_group_len; 120 } 121 } 122 | Popular Tags |