author | wetmore |
Fri, 11 May 2018 15:53:12 -0700 | |
branch | JDK-8145252-TLS13-branch |
changeset 56542 | 56aaa6cb3693 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
56542 | 2 |
* Copyright (c) 1998, 2018, 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 java.security.spec; |
|
27 |
||
28 |
import java.math.BigInteger; |
|
29 |
||
30 |
/** |
|
56542 | 31 |
* This class specifies an RSA private key, as defined in the |
32 |
* <a href="https://tools.ietf.org/rfc/rfc8017.txt">PKCS#1 v2.2</a> standard, |
|
33 |
* using the Chinese Remainder Theorem (CRT) information values for efficiency. |
|
2 | 34 |
* |
35 |
* @author Jan Luehe |
|
45434
4582657c7260
8181082: class-level since tag issues in java.base & java.datatransfer module
mli
parents:
25859
diff
changeset
|
36 |
* @since 1.2 |
2 | 37 |
* |
38 |
* |
|
39 |
* @see java.security.Key |
|
40 |
* @see java.security.KeyFactory |
|
41 |
* @see KeySpec |
|
42 |
* @see PKCS8EncodedKeySpec |
|
43 |
* @see RSAPrivateKeySpec |
|
44 |
* @see RSAPublicKeySpec |
|
45 |
*/ |
|
46 |
||
47 |
public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { |
|
48 |
||
49 |
private final BigInteger publicExponent; |
|
50 |
private final BigInteger primeP; |
|
51 |
private final BigInteger primeQ; |
|
52 |
private final BigInteger primeExponentP; |
|
53 |
private final BigInteger primeExponentQ; |
|
54 |
private final BigInteger crtCoefficient; |
|
55 |
||
56 |
/** |
|
56542 | 57 |
* Creates a new {@code RSAPrivateCrtKeySpec}. |
2 | 58 |
* |
59 |
* @param modulus the modulus n |
|
60 |
* @param publicExponent the public exponent e |
|
61 |
* @param privateExponent the private exponent d |
|
62 |
* @param primeP the prime factor p of n |
|
63 |
* @param primeQ the prime factor q of n |
|
64 |
* @param primeExponentP this is d mod (p-1) |
|
65 |
* @param primeExponentQ this is d mod (q-1) |
|
66 |
* @param crtCoefficient the Chinese Remainder Theorem |
|
67 |
* coefficient q-1 mod p |
|
68 |
*/ |
|
69 |
public RSAPrivateCrtKeySpec(BigInteger modulus, |
|
70 |
BigInteger publicExponent, |
|
71 |
BigInteger privateExponent, |
|
72 |
BigInteger primeP, |
|
73 |
BigInteger primeQ, |
|
74 |
BigInteger primeExponentP, |
|
75 |
BigInteger primeExponentQ, |
|
76 |
BigInteger crtCoefficient) { |
|
56542 | 77 |
this(modulus, publicExponent, privateExponent, primeP, primeQ, |
78 |
primeExponentP, primeExponentQ, crtCoefficient, null); |
|
79 |
} |
|
80 |
||
81 |
/** |
|
82 |
* Creates a new {@code RSAPrivateCrtKeySpec} with additional |
|
83 |
* key parameters. |
|
84 |
* |
|
85 |
* @param modulus the modulus n |
|
86 |
* @param publicExponent the public exponent e |
|
87 |
* @param privateExponent the private exponent d |
|
88 |
* @param primeP the prime factor p of n |
|
89 |
* @param primeQ the prime factor q of n |
|
90 |
* @param primeExponentP this is d mod (p-1) |
|
91 |
* @param primeExponentQ this is d mod (q-1) |
|
92 |
* @param crtCoefficient the Chinese Remainder Theorem |
|
93 |
* coefficient q-1 mod p |
|
94 |
* @param keyParams the parameters associated with key |
|
95 |
* @since 11 |
|
96 |
*/ |
|
97 |
public RSAPrivateCrtKeySpec(BigInteger modulus, |
|
98 |
BigInteger publicExponent, |
|
99 |
BigInteger privateExponent, |
|
100 |
BigInteger primeP, |
|
101 |
BigInteger primeQ, |
|
102 |
BigInteger primeExponentP, |
|
103 |
BigInteger primeExponentQ, |
|
104 |
BigInteger crtCoefficient, |
|
105 |
AlgorithmParameterSpec keyParams) { |
|
106 |
super(modulus, privateExponent, keyParams); |
|
2 | 107 |
this.publicExponent = publicExponent; |
108 |
this.primeP = primeP; |
|
109 |
this.primeQ = primeQ; |
|
110 |
this.primeExponentP = primeExponentP; |
|
111 |
this.primeExponentQ = primeExponentQ; |
|
112 |
this.crtCoefficient = crtCoefficient; |
|
113 |
} |
|
114 |
||
115 |
/** |
|
116 |
* Returns the public exponent. |
|
117 |
* |
|
118 |
* @return the public exponent |
|
119 |
*/ |
|
120 |
public BigInteger getPublicExponent() { |
|
121 |
return this.publicExponent; |
|
122 |
} |
|
123 |
||
124 |
/** |
|
125 |
* Returns the primeP. |
|
126 |
||
127 |
* @return the primeP |
|
128 |
*/ |
|
129 |
public BigInteger getPrimeP() { |
|
130 |
return this.primeP; |
|
131 |
} |
|
132 |
||
133 |
/** |
|
134 |
* Returns the primeQ. |
|
135 |
* |
|
136 |
* @return the primeQ |
|
137 |
*/ |
|
138 |
public BigInteger getPrimeQ() { |
|
139 |
return this.primeQ; |
|
140 |
} |
|
141 |
||
142 |
/** |
|
143 |
* Returns the primeExponentP. |
|
144 |
* |
|
145 |
* @return the primeExponentP |
|
146 |
*/ |
|
147 |
public BigInteger getPrimeExponentP() { |
|
148 |
return this.primeExponentP; |
|
149 |
} |
|
150 |
||
151 |
/** |
|
152 |
* Returns the primeExponentQ. |
|
153 |
* |
|
154 |
* @return the primeExponentQ |
|
155 |
*/ |
|
156 |
public BigInteger getPrimeExponentQ() { |
|
157 |
return this.primeExponentQ; |
|
158 |
} |
|
159 |
||
160 |
/** |
|
161 |
* Returns the crtCoefficient. |
|
162 |
* |
|
163 |
* @return the crtCoefficient |
|
164 |
*/ |
|
165 |
public BigInteger getCrtCoefficient() { |
|
166 |
return this.crtCoefficient; |
|
167 |
} |
|
168 |
} |