26 package sun.security.util; |
26 package sun.security.util; |
27 |
27 |
28 import java.io.IOException; |
28 import java.io.IOException; |
29 import java.security.*; |
29 import java.security.*; |
30 import java.security.spec.*; |
30 import java.security.spec.*; |
31 import sun.security.util.ObjectIdentifier; |
|
32 import sun.security.x509.AlgorithmId; |
|
33 import sun.security.rsa.RSAUtil; |
31 import sun.security.rsa.RSAUtil; |
34 |
32 |
35 /** |
33 /** |
36 * Utility class for Signature related operations. Currently used by various |
34 * Utility class for Signature related operations. Currently used by various |
37 * internal PKI classes such as sun.security.x509.X509CertImpl, |
35 * internal PKI classes such as sun.security.x509.X509CertImpl, |
84 |
82 |
85 // Special method for setting the specified parameter bytes into the |
83 // Special method for setting the specified parameter bytes into the |
86 // specified Signature object as signature parameters. |
84 // specified Signature object as signature parameters. |
87 public static void specialSetParameter(Signature sig, byte[] paramBytes) |
85 public static void specialSetParameter(Signature sig, byte[] paramBytes) |
88 throws InvalidAlgorithmParameterException, ProviderException { |
86 throws InvalidAlgorithmParameterException, ProviderException { |
89 |
|
90 AlgorithmParameters params = null; |
|
91 if (paramBytes != null) { |
87 if (paramBytes != null) { |
92 String sigName = sig.getAlgorithm(); |
88 String sigName = sig.getAlgorithm(); |
93 params = createAlgorithmParameters(sigName, paramBytes); |
89 AlgorithmParameters params = |
|
90 createAlgorithmParameters(sigName, paramBytes); |
|
91 specialSetParameter(sig, params); |
94 } |
92 } |
95 specialSetParameter(sig, params); |
|
96 } |
93 } |
97 |
94 |
98 // Special method for setting the specified AlgorithmParameter object |
95 // Special method for setting the specified AlgorithmParameter object |
99 // into the specified Signature object as signature parameters. |
96 // into the specified Signature object as signature parameters. |
100 public static void specialSetParameter(Signature sig, |
97 public static void specialSetParameter(Signature sig, |
101 AlgorithmParameters params) |
98 AlgorithmParameters params) |
102 throws InvalidAlgorithmParameterException, ProviderException { |
99 throws InvalidAlgorithmParameterException, ProviderException { |
103 |
|
104 String sigName = sig.getAlgorithm(); |
|
105 if (params != null) { |
100 if (params != null) { |
|
101 String sigName = sig.getAlgorithm(); |
106 sig.setParameter(getParamSpec(sigName, params)); |
102 sig.setParameter(getParamSpec(sigName, params)); |
107 } else { |
|
108 try { |
|
109 sig.setParameter(null); |
|
110 } catch (UnsupportedOperationException e) { |
|
111 // ignore for maintaining backward compatibility |
|
112 } |
|
113 } |
103 } |
114 } |
104 } |
115 } |
105 } |