27 |
27 |
28 import java.security.*; |
28 import java.security.*; |
29 import java.security.interfaces.ECPrivateKey; |
29 import java.security.interfaces.ECPrivateKey; |
30 import java.security.spec.AlgorithmParameterSpec; |
30 import java.security.spec.AlgorithmParameterSpec; |
31 import java.security.spec.ECParameterSpec; |
31 import java.security.spec.ECParameterSpec; |
|
32 import java.security.spec.MGF1ParameterSpec; |
32 import java.security.spec.PSSParameterSpec; |
33 import java.security.spec.PSSParameterSpec; |
33 import java.util.ArrayList; |
34 import java.util.ArrayList; |
34 import java.util.Arrays; |
35 import java.util.Arrays; |
35 import java.util.Collection; |
36 import java.util.Collection; |
36 import java.util.Collections; |
37 import java.util.Collections; |
142 private final String algorithm; // signature algorithm |
143 private final String algorithm; // signature algorithm |
143 final String keyAlgorithm; // signature key algorithm |
144 final String keyAlgorithm; // signature key algorithm |
144 private final AlgorithmParameterSpec signAlgParameter; |
145 private final AlgorithmParameterSpec signAlgParameter; |
145 private final NamedGroup namedGroup; // associated named group |
146 private final NamedGroup namedGroup; // associated named group |
146 |
147 |
147 // The minial required key size in bits. |
148 // The minimal required key size in bits. |
148 // |
149 // |
149 // Only need to check RSA algorithm at present. RSA keys of 512 bits |
150 // Only need to check RSA algorithm at present. RSA keys of 512 bits |
150 // have been shown to be practically breakable, it does not make much |
151 // have been shown to be practically breakable, it does not make much |
151 // sense to use the strong hash algorithm for keys whose key size less |
152 // sense to use the strong hash algorithm for keys whose key size less |
152 // than 512 bits. So it is not necessary to caculate the minial |
153 // than 512 bits. So it is not necessary to calculate the minimal |
153 // required key size exactly for a hash algorithm. |
154 // required key size exactly for a hash algorithm. |
154 final int minimalKeySize; |
155 final int minimalKeySize; |
155 final List<ProtocolVersion> supportedProtocols; |
156 final List<ProtocolVersion> supportedProtocols; |
156 |
157 |
157 // Some signature schemes are supported in different versions for handshake |
158 // Some signature schemes are supported in different versions for handshake |
178 final boolean isAvailable; |
179 final boolean isAvailable; |
179 |
180 |
180 SigAlgParamSpec(String hash, int saltLength) { |
181 SigAlgParamSpec(String hash, int saltLength) { |
181 // See RFC 8017 |
182 // See RFC 8017 |
182 PSSParameterSpec pssParamSpec = |
183 PSSParameterSpec pssParamSpec = |
183 new PSSParameterSpec(hash, "MGF1", null, saltLength, 1); |
184 new PSSParameterSpec(hash, "MGF1", |
|
185 new MGF1ParameterSpec(hash), saltLength, 1); |
184 |
186 |
185 boolean mediator = true; |
187 boolean mediator = true; |
186 try { |
188 try { |
187 Signature signer = JsseJce.getSignature("RSASSA-PSS"); |
189 Signature signer = JsseJce.getSignature("RSASSA-PSS"); |
188 signer.setParameter(pssParamSpec); |
190 signer.setParameter(pssParamSpec); |