jdk/src/java.base/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 18552 jdk/src/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java@005e115dc6ee
child 45434 4582657c7260
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18552
005e115dc6ee 8017326: Cleanup of the javadoc <code> tag in java.security.spec
juh
parents: 5506
diff changeset
     2
 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.security.spec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.math.BigInteger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * This class specifies an RSA private key, as defined in the PKCS#1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * standard, using the Chinese Remainder Theorem (CRT) information values for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * efficiency.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @author Jan Luehe
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @see java.security.Key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @see java.security.KeyFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @see KeySpec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @see PKCS8EncodedKeySpec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @see RSAPrivateKeySpec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @see RSAPublicKeySpec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private final BigInteger publicExponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private final BigInteger primeP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private final BigInteger primeQ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private final BigInteger primeExponentP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private final BigInteger primeExponentQ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private final BigInteger crtCoefficient;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
   /**
18552
005e115dc6ee 8017326: Cleanup of the javadoc <code> tag in java.security.spec
juh
parents: 5506
diff changeset
    58
    * Creates a new {@code RSAPrivateCrtKeySpec}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    * given the modulus, publicExponent, privateExponent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    * primeP, primeQ, primeExponentP, primeExponentQ, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    * crtCoefficient as defined in PKCS#1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    * @param modulus the modulus n
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    * @param publicExponent the public exponent e
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    * @param privateExponent the private exponent d
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    * @param primeP the prime factor p of n
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    * @param primeQ the prime factor q of n
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    * @param primeExponentP this is d mod (p-1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    * @param primeExponentQ this is d mod (q-1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    * @param crtCoefficient the Chinese Remainder Theorem
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    * coefficient q-1 mod p
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public RSAPrivateCrtKeySpec(BigInteger modulus,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                                BigInteger publicExponent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                                BigInteger privateExponent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                                BigInteger primeP,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                                BigInteger primeQ,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                                BigInteger primeExponentP,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                                BigInteger primeExponentQ,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                                BigInteger crtCoefficient) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        super(modulus, privateExponent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        this.publicExponent = publicExponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        this.primeP = primeP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        this.primeQ = primeQ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        this.primeExponentP = primeExponentP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        this.primeExponentQ = primeExponentQ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        this.crtCoefficient = crtCoefficient;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * Returns the public exponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @return the public exponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public BigInteger getPublicExponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        return this.publicExponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Returns the primeP.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @return the primeP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public BigInteger getPrimeP() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        return this.primeP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * Returns the primeQ.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @return the primeQ
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    public BigInteger getPrimeQ() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        return this.primeQ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * Returns the primeExponentP.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @return the primeExponentP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public BigInteger getPrimeExponentP() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        return this.primeExponentP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Returns the primeExponentQ.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @return the primeExponentQ
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    public BigInteger getPrimeExponentQ() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        return this.primeExponentQ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Returns the crtCoefficient.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @return the crtCoefficient
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public BigInteger getCrtCoefficient() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return this.crtCoefficient;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
}