001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * @author Vladimir N. Molotkov
020: * @version $Revision$
021: */package java.security.spec;
022:
023: import java.math.BigInteger;
024:
025: import org.apache.harmony.security.internal.nls.Messages;
026:
027: /**
028: * @com.intel.drl.spec_ref
029: *
030: */
031: public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec {
032: // Public Exponent
033: private final BigInteger publicExponent;
034: // Prime P
035: private final BigInteger primeP;
036: // Prime Q
037: private final BigInteger primeQ;
038: // Prime Exponent P
039: private final BigInteger primeExponentP;
040: // Prime Exponent Q
041: private final BigInteger primeExponentQ;
042: // CRT Coefficient
043: private final BigInteger crtCoefficient;
044: // Other Prime Info
045: private final RSAOtherPrimeInfo[] otherPrimeInfo;
046:
047: /**
048: * @com.intel.drl.spec_ref
049: */
050: public RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
051: BigInteger publicExponent, BigInteger privateExponent,
052: BigInteger primeP, BigInteger primeQ,
053: BigInteger primeExponentP, BigInteger primeExponentQ,
054: BigInteger crtCoefficient,
055: RSAOtherPrimeInfo[] otherPrimeInfo) {
056:
057: super (modulus, privateExponent);
058:
059: // Perform checks specified
060: if (modulus == null) {
061: throw new NullPointerException(Messages.getString(
062: "security.83", "modulus")); //$NON-NLS-1$ //$NON-NLS-2$
063: }
064: if (privateExponent == null) {
065: throw new NullPointerException(Messages.getString(
066: "security.83", "privateExponent")); //$NON-NLS-1$ //$NON-NLS-2$
067: }
068: if (publicExponent == null) {
069: throw new NullPointerException(Messages.getString(
070: "security.83", "publicExponent")); //$NON-NLS-1$ //$NON-NLS-2$
071: }
072: if (primeP == null) {
073: throw new NullPointerException(Messages.getString(
074: "security.83", "primeP")); //$NON-NLS-1$ //$NON-NLS-2$
075: }
076: if (primeQ == null) {
077: throw new NullPointerException(Messages.getString(
078: "security.83", "primeQ")); //$NON-NLS-1$ //$NON-NLS-2$
079: }
080: if (primeExponentP == null) {
081: throw new NullPointerException(Messages.getString(
082: "security.83", "primeExponentP")); //$NON-NLS-1$ //$NON-NLS-2$
083: }
084: if (primeExponentQ == null) {
085: throw new NullPointerException(Messages.getString(
086: "security.83", "primeExponentQ")); //$NON-NLS-1$ //$NON-NLS-2$
087: }
088: if (crtCoefficient == null) {
089: throw new NullPointerException(Messages.getString(
090: "security.83", "crtCoefficient")); //$NON-NLS-1$ //$NON-NLS-2$
091: }
092:
093: if (otherPrimeInfo != null) {
094: if (otherPrimeInfo.length == 0) {
095: throw new IllegalArgumentException(Messages
096: .getString("security.85")); //$NON-NLS-1$
097: }
098: // Clone array to prevent subsequent modification
099: this .otherPrimeInfo = new RSAOtherPrimeInfo[otherPrimeInfo.length];
100: System.arraycopy(otherPrimeInfo, 0, this .otherPrimeInfo, 0,
101: this .otherPrimeInfo.length);
102: } else {
103: this .otherPrimeInfo = null;
104: }
105: this .publicExponent = publicExponent;
106: this .primeP = primeP;
107: this .primeQ = primeQ;
108: this .primeExponentP = primeExponentP;
109: this .primeExponentQ = primeExponentQ;
110: this .crtCoefficient = crtCoefficient;
111: }
112:
113: /**
114: * @com.intel.drl.spec_ref
115: */
116: public BigInteger getCrtCoefficient() {
117: return crtCoefficient;
118: }
119:
120: /**
121: * @com.intel.drl.spec_ref
122: */
123: public RSAOtherPrimeInfo[] getOtherPrimeInfo() {
124: // Clone array (if not null) to prevent subsequent modification
125: if (otherPrimeInfo == null) {
126: return null;
127: } else {
128: RSAOtherPrimeInfo[] ret = new RSAOtherPrimeInfo[otherPrimeInfo.length];
129: System.arraycopy(otherPrimeInfo, 0, ret, 0, ret.length);
130: return ret;
131: }
132: }
133:
134: /**
135: * @com.intel.drl.spec_ref
136: */
137: public BigInteger getPrimeExponentP() {
138: return primeExponentP;
139: }
140:
141: /**
142: * @com.intel.drl.spec_ref
143: */
144: public BigInteger getPrimeExponentQ() {
145: return primeExponentQ;
146: }
147:
148: /**
149: * @com.intel.drl.spec_ref
150: */
151: public BigInteger getPrimeP() {
152: return primeP;
153: }
154:
155: /**
156: * @com.intel.drl.spec_ref
157: */
158: public BigInteger getPrimeQ() {
159: return primeQ;
160: }
161:
162: /**
163: * @com.intel.drl.spec_ref
164: */
165: public BigInteger getPublicExponent() {
166: return publicExponent;
167: }
168: }
|