author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58519 | 6e017b301287 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
57950
4612a3cfb927
8229999: Apply java.io.Serial annotations to security types in java.base
darcy
parents:
50918
diff
changeset
|
2 |
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.security.rsa; |
|
27 |
||
28 |
import java.io.IOException; |
|
29 |
import java.math.BigInteger; |
|
30 |
||
31 |
import java.security.*; |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
32 |
import java.security.spec.*; |
2 | 33 |
import java.security.interfaces.*; |
34 |
||
35 |
import sun.security.util.*; |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
36 |
|
2 | 37 |
import sun.security.x509.AlgorithmId; |
38 |
import sun.security.pkcs.PKCS8Key; |
|
39 |
||
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
40 |
import static sun.security.rsa.RSAUtil.KeyType; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
41 |
|
2 | 42 |
/** |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
43 |
* RSA private key implementation for "RSA", "RSASSA-PSS" algorithms in CRT form. |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
44 |
* For non-CRT private keys, see RSAPrivateKeyImpl. We need separate classes |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
45 |
* to ensure correct behavior in instanceof checks, etc. |
2 | 46 |
* |
47 |
* Note: RSA keys must be at least 512 bits long |
|
48 |
* |
|
49 |
* @see RSAPrivateKeyImpl |
|
50 |
* @see RSAKeyFactory |
|
51 |
* |
|
52 |
* @since 1.5 |
|
53 |
* @author Andreas Sterbenz |
|
54 |
*/ |
|
55 |
public final class RSAPrivateCrtKeyImpl |
|
56 |
extends PKCS8Key implements RSAPrivateCrtKey { |
|
57 |
||
57950
4612a3cfb927
8229999: Apply java.io.Serial annotations to security types in java.base
darcy
parents:
50918
diff
changeset
|
58 |
@java.io.Serial |
2 | 59 |
private static final long serialVersionUID = -1326088454257084918L; |
60 |
||
61 |
private BigInteger n; // modulus |
|
62 |
private BigInteger e; // public exponent |
|
63 |
private BigInteger d; // private exponent |
|
64 |
private BigInteger p; // prime p |
|
65 |
private BigInteger q; // prime q |
|
66 |
private BigInteger pe; // prime exponent p |
|
67 |
private BigInteger qe; // prime exponent q |
|
68 |
private BigInteger coeff; // CRT coeffcient |
|
69 |
||
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
70 |
// Optional parameters associated with this RSA key |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
71 |
// specified in the encoding of its AlgorithmId. |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
72 |
// Must be null for "RSA" keys. |
58519
6e017b301287
8231262: Suppress warnings on non-serializable instance fields in security libs serializable classes
darcy
parents:
57950
diff
changeset
|
73 |
@SuppressWarnings("serial") // Not statically typed as Serializable |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
74 |
private AlgorithmParameterSpec keyParams; |
2 | 75 |
|
76 |
/** |
|
77 |
* Generate a new key from its encoding. Returns a CRT key if possible |
|
78 |
* and a non-CRT key otherwise. Used by RSAKeyFactory. |
|
79 |
*/ |
|
80 |
public static RSAPrivateKey newKey(byte[] encoded) |
|
81 |
throws InvalidKeyException { |
|
82 |
RSAPrivateCrtKeyImpl key = new RSAPrivateCrtKeyImpl(encoded); |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
83 |
// check all CRT-specific components are available, if any one |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
84 |
// missing, return a non-CRT key instead |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
85 |
if ((key.getPublicExponent().signum() == 0) || |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
86 |
(key.getPrimeExponentP().signum() == 0) || |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
87 |
(key.getPrimeExponentQ().signum() == 0) || |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
88 |
(key.getPrimeP().signum() == 0) || |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
89 |
(key.getPrimeQ().signum() == 0) || |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
90 |
(key.getCrtCoefficient().signum() == 0)) { |
2 | 91 |
return new RSAPrivateKeyImpl( |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
92 |
key.algid, |
2 | 93 |
key.getModulus(), |
94 |
key.getPrivateExponent() |
|
95 |
); |
|
96 |
} else { |
|
97 |
return key; |
|
98 |
} |
|
99 |
} |
|
100 |
||
101 |
/** |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
102 |
* Generate a new key from the specified type and components. |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
103 |
* Returns a CRT key if possible and a non-CRT key otherwise. |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
104 |
* Used by SunPKCS11 provider. |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
105 |
*/ |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
106 |
public static RSAPrivateKey newKey(KeyType type, |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
107 |
AlgorithmParameterSpec params, |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
108 |
BigInteger n, BigInteger e, BigInteger d, |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
109 |
BigInteger p, BigInteger q, BigInteger pe, BigInteger qe, |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
110 |
BigInteger coeff) throws InvalidKeyException { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
111 |
RSAPrivateKey key; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
112 |
AlgorithmId rsaId = RSAUtil.createAlgorithmId(type, params); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
113 |
if ((e.signum() == 0) || (p.signum() == 0) || |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
114 |
(q.signum() == 0) || (pe.signum() == 0) || |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
115 |
(qe.signum() == 0) || (coeff.signum() == 0)) { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
116 |
// if any component is missing, return a non-CRT key |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
117 |
return new RSAPrivateKeyImpl(rsaId, n, d); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
118 |
} else { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
119 |
return new RSAPrivateCrtKeyImpl(rsaId, n, e, d, |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
120 |
p, q, pe, qe, coeff); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
121 |
} |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
122 |
} |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
123 |
|
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
124 |
/** |
2 | 125 |
* Construct a key from its encoding. Called from newKey above. |
126 |
*/ |
|
127 |
RSAPrivateCrtKeyImpl(byte[] encoded) throws InvalidKeyException { |
|
50918
ebff24bd9302
8205720: KeyFactory#getKeySpec and translateKey thorws NullPointerException with Invalid key
valeriep
parents:
50204
diff
changeset
|
128 |
if (encoded == null || encoded.length == 0) { |
ebff24bd9302
8205720: KeyFactory#getKeySpec and translateKey thorws NullPointerException with Invalid key
valeriep
parents:
50204
diff
changeset
|
129 |
throw new InvalidKeyException("Missing key encoding"); |
ebff24bd9302
8205720: KeyFactory#getKeySpec and translateKey thorws NullPointerException with Invalid key
valeriep
parents:
50204
diff
changeset
|
130 |
} |
ebff24bd9302
8205720: KeyFactory#getKeySpec and translateKey thorws NullPointerException with Invalid key
valeriep
parents:
50204
diff
changeset
|
131 |
|
2 | 132 |
decode(encoded); |
2596 | 133 |
RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e); |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
134 |
try { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
135 |
// this will check the validity of params |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
136 |
this.keyParams = RSAUtil.getParamSpec(algid); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
137 |
} catch (ProviderException e) { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
138 |
throw new InvalidKeyException(e); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
139 |
} |
2 | 140 |
} |
141 |
||
142 |
/** |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
143 |
* Construct a RSA key from its components. Used by the |
2 | 144 |
* RSAKeyFactory and the RSAKeyPairGenerator. |
145 |
*/ |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
146 |
RSAPrivateCrtKeyImpl(AlgorithmId rsaId, |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
147 |
BigInteger n, BigInteger e, BigInteger d, |
2 | 148 |
BigInteger p, BigInteger q, BigInteger pe, BigInteger qe, |
149 |
BigInteger coeff) throws InvalidKeyException { |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
150 |
RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e); |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
151 |
|
2 | 152 |
this.n = n; |
153 |
this.e = e; |
|
154 |
this.d = d; |
|
155 |
this.p = p; |
|
156 |
this.q = q; |
|
157 |
this.pe = pe; |
|
158 |
this.qe = qe; |
|
159 |
this.coeff = coeff; |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
160 |
this.keyParams = RSAUtil.getParamSpec(rsaId); |
2596 | 161 |
|
2 | 162 |
// generate the encoding |
163 |
algid = rsaId; |
|
164 |
try { |
|
165 |
DerOutputStream out = new DerOutputStream(); |
|
166 |
out.putInteger(0); // version must be 0 |
|
167 |
out.putInteger(n); |
|
168 |
out.putInteger(e); |
|
169 |
out.putInteger(d); |
|
170 |
out.putInteger(p); |
|
171 |
out.putInteger(q); |
|
172 |
out.putInteger(pe); |
|
173 |
out.putInteger(qe); |
|
174 |
out.putInteger(coeff); |
|
175 |
DerValue val = |
|
176 |
new DerValue(DerValue.tag_Sequence, out.toByteArray()); |
|
177 |
key = val.toByteArray(); |
|
178 |
} catch (IOException exc) { |
|
179 |
// should never occur |
|
180 |
throw new InvalidKeyException(exc); |
|
181 |
} |
|
182 |
} |
|
183 |
||
184 |
// see JCA doc |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
185 |
@Override |
2 | 186 |
public String getAlgorithm() { |
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
187 |
return algid.getName(); |
2 | 188 |
} |
189 |
||
190 |
// see JCA doc |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
191 |
@Override |
2 | 192 |
public BigInteger getModulus() { |
193 |
return n; |
|
194 |
} |
|
195 |
||
196 |
// see JCA doc |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
197 |
@Override |
2 | 198 |
public BigInteger getPublicExponent() { |
199 |
return e; |
|
200 |
} |
|
201 |
||
202 |
// see JCA doc |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
203 |
@Override |
2 | 204 |
public BigInteger getPrivateExponent() { |
205 |
return d; |
|
206 |
} |
|
207 |
||
208 |
// see JCA doc |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
209 |
@Override |
2 | 210 |
public BigInteger getPrimeP() { |
211 |
return p; |
|
212 |
} |
|
213 |
||
214 |
// see JCA doc |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
215 |
@Override |
2 | 216 |
public BigInteger getPrimeQ() { |
217 |
return q; |
|
218 |
} |
|
219 |
||
220 |
// see JCA doc |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
221 |
@Override |
2 | 222 |
public BigInteger getPrimeExponentP() { |
223 |
return pe; |
|
224 |
} |
|
225 |
||
226 |
// see JCA doc |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
227 |
@Override |
2 | 228 |
public BigInteger getPrimeExponentQ() { |
229 |
return qe; |
|
230 |
} |
|
231 |
||
232 |
// see JCA doc |
|
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
233 |
@Override |
2 | 234 |
public BigInteger getCrtCoefficient() { |
235 |
return coeff; |
|
236 |
} |
|
237 |
||
50204
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
238 |
// see JCA doc |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
239 |
@Override |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
240 |
public AlgorithmParameterSpec getParams() { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
241 |
return keyParams; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
242 |
} |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
243 |
|
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
244 |
// return a string representation of this key for debugging |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
245 |
@Override |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
246 |
public String toString() { |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
247 |
return "SunRsaSign " + getAlgorithm() + " private CRT key, " + n.bitLength() |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
248 |
+ " bits" + "\n params: " + keyParams + "\n modulus: " + n |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
249 |
+ "\n private exponent: " + d; |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
250 |
} |
3195a713e24d
8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
47216
diff
changeset
|
251 |
|
2 | 252 |
/** |
253 |
* Parse the key. Called by PKCS8Key. |
|
254 |
*/ |
|
255 |
protected void parseKeyBits() throws InvalidKeyException { |
|
256 |
try { |
|
257 |
DerInputStream in = new DerInputStream(key); |
|
258 |
DerValue derValue = in.getDerValue(); |
|
259 |
if (derValue.tag != DerValue.tag_Sequence) { |
|
260 |
throw new IOException("Not a SEQUENCE"); |
|
261 |
} |
|
262 |
DerInputStream data = derValue.data; |
|
263 |
int version = data.getInteger(); |
|
264 |
if (version != 0) { |
|
265 |
throw new IOException("Version must be 0"); |
|
266 |
} |
|
44260
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
267 |
|
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
268 |
/* |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
269 |
* Some implementations do not correctly encode ASN.1 INTEGER values |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
270 |
* in 2's complement format, resulting in a negative integer when |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
271 |
* decoded. Correct the error by converting it to a positive integer. |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
272 |
* |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
273 |
* See CR 6255949 |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
274 |
*/ |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
275 |
n = data.getPositiveBigInteger(); |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
276 |
e = data.getPositiveBigInteger(); |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
277 |
d = data.getPositiveBigInteger(); |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
278 |
p = data.getPositiveBigInteger(); |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
279 |
q = data.getPositiveBigInteger(); |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
280 |
pe = data.getPositiveBigInteger(); |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
281 |
qe = data.getPositiveBigInteger(); |
dd947f766e11
8175251: Failed to load RSA private key from pkcs12
valeriep
parents:
32649
diff
changeset
|
282 |
coeff = data.getPositiveBigInteger(); |
2 | 283 |
if (derValue.data.available() != 0) { |
284 |
throw new IOException("Extra data available"); |
|
285 |
} |
|
286 |
} catch (IOException e) { |
|
287 |
throw new InvalidKeyException("Invalid RSA private key", e); |
|
288 |
} |
|
289 |
} |
|
290 |
} |