1 /* 2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.security.spec; 27 28 import java.math.BigInteger; 29 import java.security.spec.AlgorithmParameterSpec; 30 31 /** 32 * This class specifies the set of parameters used to generate an RSA 33 * key pair. 34 * 35 * @author Jan Luehe 36 * 37 * @see java.security.KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec) 38 * 39 * @since 1.3 40 */ 41 42 public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec { 43 44 private int keysize; 45 private BigInteger publicExponent; 46 private AlgorithmParameterSpec keyParams; 47 48 /** 49 * The public-exponent value F0 = 3. 50 */ 51 public static final BigInteger F0 = BigInteger.valueOf(3); 52 53 /** 54 * The public exponent-value F4 = 65537. 55 */ 56 public static final BigInteger F4 = BigInteger.valueOf(65537); 57 58 /** 59 * Constructs a new {@code RSAKeyGenParameterSpec} object from the 60 * given keysize, public-exponent value, and null key parameters. 61 * 62 * @param keysize the modulus size (specified in number of bits) 63 * @param publicExponent the public exponent 64 */ RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent)65 public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent) { 66 this(keysize, publicExponent, null); 67 } 68 69 /** 70 * Constructs a new {@code RSAKeyGenParameterSpec} object from the 71 * given keysize, public-exponent value, and key parameters. 72 * 73 * @param keysize the modulus size (specified in number of bits) 74 * @param publicExponent the public exponent 75 * @param keyParams the key parameters, may be null 76 * @since 11 77 */ RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent, AlgorithmParameterSpec keyParams)78 public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent, 79 AlgorithmParameterSpec keyParams) { 80 this.keysize = keysize; 81 this.publicExponent = publicExponent; 82 this.keyParams = keyParams; 83 } 84 85 /** 86 * Returns the keysize. 87 * 88 * @return the keysize. 89 */ getKeysize()90 public int getKeysize() { 91 return keysize; 92 } 93 94 /** 95 * Returns the public-exponent value. 96 * 97 * @return the public-exponent value. 98 */ getPublicExponent()99 public BigInteger getPublicExponent() { 100 return publicExponent; 101 } 102 103 /** 104 * Returns the parameters to be associated with key. 105 * 106 * @return the associated parameters, may be null if 107 * not present 108 * @since 11 109 */ getKeyParams()110 public AlgorithmParameterSpec getKeyParams() { 111 return keyParams; 112 } 113 } 114