1 /* |
1 /* |
2 * Copyright (c) 1998, 2001, 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 |
42 * @see RSAPrivateCrtKeySpec |
42 * @see RSAPrivateCrtKeySpec |
43 */ |
43 */ |
44 |
44 |
45 public class RSAPrivateKeySpec implements KeySpec { |
45 public class RSAPrivateKeySpec implements KeySpec { |
46 |
46 |
47 private BigInteger modulus; |
47 private final BigInteger modulus; |
48 private BigInteger privateExponent; |
48 private final BigInteger privateExponent; |
|
49 private final AlgorithmParameterSpec params; |
49 |
50 |
50 /** |
51 /** |
51 * Creates a new RSAPrivateKeySpec. |
52 * Creates a new RSAPrivateKeySpec. |
52 * |
53 * |
53 * @param modulus the modulus |
54 * @param modulus the modulus |
54 * @param privateExponent the private exponent |
55 * @param privateExponent the private exponent |
55 */ |
56 */ |
56 public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent) { |
57 public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent) { |
|
58 this(modulus, privateExponent, null); |
|
59 } |
|
60 |
|
61 /** |
|
62 * Creates a new RSAPrivateKeySpec with additional key parameters. |
|
63 * |
|
64 * @param modulus the modulus |
|
65 * @param privateExponent the private exponent |
|
66 * @param params the parameters associated with this key, may be null |
|
67 * @since 11 |
|
68 */ |
|
69 public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent, |
|
70 AlgorithmParameterSpec params) { |
57 this.modulus = modulus; |
71 this.modulus = modulus; |
58 this.privateExponent = privateExponent; |
72 this.privateExponent = privateExponent; |
|
73 this.params = params; |
59 } |
74 } |
60 |
75 |
61 /** |
76 /** |
62 * Returns the modulus. |
77 * Returns the modulus. |
63 * |
78 * |
73 * @return the private exponent |
88 * @return the private exponent |
74 */ |
89 */ |
75 public BigInteger getPrivateExponent() { |
90 public BigInteger getPrivateExponent() { |
76 return this.privateExponent; |
91 return this.privateExponent; |
77 } |
92 } |
|
93 |
|
94 /** |
|
95 * Returns the parameters associated with this key, may be null if not |
|
96 * present. |
|
97 * |
|
98 * @return the parameters associated with this key |
|
99 * @since 11 |
|
100 */ |
|
101 public AlgorithmParameterSpec getParams() { |
|
102 return this.params; |
|
103 } |
78 } |
104 } |