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 18 package javax.crypto.spec; 19 20 import java.math.BigInteger; 21 import java.security.spec.KeySpec; 22 23 /** 24 * The key specification for a Diffie-Hellman private key. 25 */ 26 public class DHPrivateKeySpec implements KeySpec { 27 28 private final BigInteger x; 29 private final BigInteger p; 30 private final BigInteger g; 31 32 /** 33 * Creates a new <code>DHPrivateKeySpec</code> with the specified <i>private 34 * value</i> <code>x</code>. <i>prime modulus</i> <code>p</code> and <i>base 35 * generator</i> <code>g</code>. 36 * 37 * @param x 38 * the private value. 39 * @param p 40 * the prime modulus. 41 * @param g 42 * the base generator. 43 */ 44 public DHPrivateKeySpec(BigInteger x, BigInteger p, BigInteger g) { 45 this.x = x; 46 this.p = p; 47 this.g = g; 48 } 49 50 /** 51 * Returns the <i>private value</i> <code>x</code>. 52 * 53 * @return the private value <code>x</code>. 54 */ 55 public BigInteger getX() { 56 return x; 57 } 58 59 /** 60 * Returns the <i>prime modulus</i> <code>p</code>. 61 * 62 * @return the prime modulus <code>p</code>. 63 */ 64 public BigInteger getP() { 65 return p; 66 } 67 68 /** 69 * Returns the <i>base generator</i> <code>g</code>. 70 * 71 * @return the base generator <code>g</code>. 72 */ 73 public BigInteger getG() { 74 return g; 75 } 76 } 77 78