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 ECParameterSpec implements AlgorithmParameterSpec {
032: // Elliptic curve for which this is parameter
033: private final EllipticCurve curve;
034: // Distinguished point on the elliptic curve called generator or base point
035: private final ECPoint generator;
036: // Order of the generator
037: private final BigInteger order;
038: // Cofactor
039: private final int cofactor;
040:
041: /**
042: * @com.intel.drl.spec_ref
043: */
044: public ECParameterSpec(EllipticCurve curve, ECPoint generator,
045: BigInteger order, int cofactor) {
046: this .curve = curve;
047: this .generator = generator;
048: this .order = order;
049: this .cofactor = cofactor;
050: // throw NullPointerException if curve, generator or order is null
051: if (this .curve == null) {
052: throw new NullPointerException(Messages.getString(
053: "security.83", "curve")); //$NON-NLS-1$ //$NON-NLS-2$
054: }
055: if (this .generator == null) {
056: throw new NullPointerException(Messages.getString(
057: "security.83", "generator")); //$NON-NLS-1$ //$NON-NLS-2$
058: }
059: if (this .order == null) {
060: throw new NullPointerException(Messages.getString(
061: "security.83", "order")); //$NON-NLS-1$ //$NON-NLS-2$
062: }
063: // throw IllegalArgumentException if order or cofactor is not positive
064: if (!(this .order.compareTo(BigInteger.ZERO) > 0)) {
065: throw new IllegalArgumentException(Messages.getString(
066: "security.86", "order")); //$NON-NLS-1$ //$NON-NLS-2$
067: }
068: if (!(this .cofactor > 0)) {
069: throw new IllegalArgumentException(Messages.getString(
070: "security.86", "cofactor")); //$NON-NLS-1$ //$NON-NLS-2$
071: }
072: }
073:
074: /**
075: * @com.intel.drl.spec_ref
076: */
077: public int getCofactor() {
078: return cofactor;
079: }
080:
081: /**
082: * @com.intel.drl.spec_ref
083: */
084: public EllipticCurve getCurve() {
085: return curve;
086: }
087:
088: /**
089: * @com.intel.drl.spec_ref
090: */
091: public ECPoint getGenerator() {
092: return generator;
093: }
094:
095: /**
096: * @com.intel.drl.spec_ref
097: */
098: public BigInteger getOrder() {
099: return order;
100: }
101: }
|