1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package java.security.spec; 19 20import java.math.BigInteger; 21 22import org.apache.harmony.security.internal.nls.Messages; 23 24/** 25 * The parameters specifying an Elliptic Curve (EC) private key. 26 */ 27public class ECPrivateKeySpec implements KeySpec { 28 // Private value associated with this key 29 private final BigInteger s; 30 // Elliptic Curve domain parameters associated with this key 31 private final ECParameterSpec params; 32 33 /** 34 * Creates a new {@code ECPrivateKeySpec} with the specified private value 35 * {@code S} and parameter specification. 36 * 37 * @param s 38 * the private value {@code S}. 39 * @param params 40 * the domain parameter specification. 41 */ 42 public ECPrivateKeySpec(BigInteger s, ECParameterSpec params) { 43 this.s = s; 44 this.params = params; 45 // throw NullPointerException if s or params is null 46 if (this.s == null) { 47 throw new NullPointerException(Messages.getString("security.83", "s")); //$NON-NLS-1$ //$NON-NLS-2$ 48 } 49 if (this.params == null) { 50 throw new NullPointerException(Messages.getString("security.83", "params")); //$NON-NLS-1$ //$NON-NLS-2$ 51 } 52 } 53 54 /** 55 * Returns the domain parameter specification. 56 * 57 * @return the domain parameter specification. 58 */ 59 public ECParameterSpec getParams() { 60 return params; 61 } 62 63 /** 64 * Returns the private value {@code S}. 65 * 66 * @return the private value {@code S}. 67 */ 68 public BigInteger getS() { 69 return s; 70 } 71} 72