1 7 8 package java.security.spec; 9 10 import java.math.BigInteger ; 11 import java.security.spec.MGF1ParameterSpec ; 12 13 60 61 public class PSSParameterSpec implements AlgorithmParameterSpec { 62 63 private String mdName = "SHA-1"; 64 private String mgfName = "MGF1"; 65 private AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1; 66 private int saltLen = 20; 67 private int trailerField = 1; 68 69 72 public static final PSSParameterSpec DEFAULT = new PSSParameterSpec (); 73 74 78 private PSSParameterSpec() { 79 } 80 81 101 public PSSParameterSpec(String mdName, String mgfName, 102 AlgorithmParameterSpec mgfSpec, 103 int saltLen, int trailerField) { 104 if (mdName == null) { 105 throw new NullPointerException ("digest algorithm is null"); 106 } 107 if (mgfName == null) { 108 throw new NullPointerException ("mask generation function " + 109 "algorithm is null"); 110 } 111 if (saltLen < 0) { 112 throw new IllegalArgumentException ("negative saltLen value: " + 113 saltLen); 114 } 115 if (trailerField < 0) { 116 throw new IllegalArgumentException ("negative trailerField: " + 117 trailerField); 118 } 119 this.mdName = mdName; 120 this.mgfName = mgfName; 121 this.mgfSpec = mgfSpec; 122 this.saltLen = saltLen; 123 this.trailerField = trailerField; 124 } 125 126 136 public PSSParameterSpec(int saltLen) { 137 if (saltLen < 0) { 138 throw new IllegalArgumentException ("negative saltLen value: " + 139 saltLen); 140 } 141 this.saltLen = saltLen; 142 } 143 144 150 public String getDigestAlgorithm() { 151 return mdName; 152 } 153 154 161 public String getMGFAlgorithm() { 162 return mgfName; 163 } 164 165 171 public AlgorithmParameterSpec getMGFParameters() { 172 return mgfSpec; 173 } 174 175 180 public int getSaltLength() { 181 return saltLen; 182 } 183 184 190 public int getTrailerField() { 191 return trailerField; 192 } 193 } 194 | Popular Tags |