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 javax.crypto.spec; 19 20import java.math.BigInteger; 21import java.security.spec.KeySpec; 22 23/** 24 * The key specification for a Diffie-Hellman public key. 25 */ 26public class DHPublicKeySpec implements KeySpec { 27 28 private final BigInteger y; 29 private final BigInteger p; 30 private final BigInteger g; 31 32 /** 33 * Creates a new <code>DHPublicKeySpec</code> instance with the specified 34 * <i>public value</i> <code>y</code>, the <i>prime modulus</i> 35 * <code>p</code> and the <i>base generator</i> <code>g</code>. 36 * 37 * @param y 38 * the public value. 39 * @param p 40 * the prime modulus. 41 * @param g 42 * the base generator. 43 */ 44 public DHPublicKeySpec(BigInteger y, BigInteger p, BigInteger g) { 45 this.y = y; 46 this.p = p; 47 this.g = g; 48 } 49 50 /** 51 * Returns the <i>public value</i> <code>y</code>. 52 * 53 * @return the public value <code>y</code>. 54 */ 55 public BigInteger getY() { 56 return y; 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