1 /* |
1 /* |
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
26 package java.security.spec; |
26 package java.security.spec; |
27 |
27 |
28 import java.math.BigInteger; |
28 import java.math.BigInteger; |
29 |
29 |
30 /** |
30 /** |
31 * This class specifies an RSA private key, as defined in the PKCS#1 |
31 * This class specifies an RSA private key, as defined in the |
32 * standard, using the Chinese Remainder Theorem (CRT) information values for |
32 * <a href="https://tools.ietf.org/rfc/rfc8017.txt">PKCS#1 v2.2</a> standard, |
33 * efficiency. |
33 * using the Chinese Remainder Theorem (CRT) information values for efficiency. |
34 * |
34 * |
35 * @author Jan Luehe |
35 * @author Jan Luehe |
36 * @since 1.2 |
36 * @since 1.2 |
37 * |
37 * |
38 * |
38 * |
51 private final BigInteger primeQ; |
51 private final BigInteger primeQ; |
52 private final BigInteger primeExponentP; |
52 private final BigInteger primeExponentP; |
53 private final BigInteger primeExponentQ; |
53 private final BigInteger primeExponentQ; |
54 private final BigInteger crtCoefficient; |
54 private final BigInteger crtCoefficient; |
55 |
55 |
56 |
|
57 |
|
58 /** |
56 /** |
59 * Creates a new {@code RSAPrivateCrtKeySpec} |
57 * Creates a new {@code RSAPrivateCrtKeySpec}. |
60 * given the modulus, publicExponent, privateExponent, |
|
61 * primeP, primeQ, primeExponentP, primeExponentQ, and |
|
62 * crtCoefficient as defined in PKCS#1. |
|
63 * |
58 * |
64 * @param modulus the modulus n |
59 * @param modulus the modulus n |
65 * @param publicExponent the public exponent e |
60 * @param publicExponent the public exponent e |
66 * @param privateExponent the private exponent d |
61 * @param privateExponent the private exponent d |
67 * @param primeP the prime factor p of n |
62 * @param primeP the prime factor p of n |
77 BigInteger primeP, |
72 BigInteger primeP, |
78 BigInteger primeQ, |
73 BigInteger primeQ, |
79 BigInteger primeExponentP, |
74 BigInteger primeExponentP, |
80 BigInteger primeExponentQ, |
75 BigInteger primeExponentQ, |
81 BigInteger crtCoefficient) { |
76 BigInteger crtCoefficient) { |
82 super(modulus, privateExponent); |
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); |
83 this.publicExponent = publicExponent; |
107 this.publicExponent = publicExponent; |
84 this.primeP = primeP; |
108 this.primeP = primeP; |
85 this.primeQ = primeQ; |
109 this.primeQ = primeQ; |
86 this.primeExponentP = primeExponentP; |
110 this.primeExponentP = primeExponentP; |
87 this.primeExponentQ = primeExponentQ; |
111 this.primeExponentQ = primeExponentQ; |