Home | History | Annotate | Download | only in spec
      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 java.security.spec;
     19 
     20 import java.math.BigInteger;
     21 
     22 /**
     23  * The key specification of a RSA private key.
     24  * <p>
     25  * Defined in the <a
     26  * href="http://www.rsa.com/rsalabs/pubs/PKCS/html/pkcs-1.html">PKCS #1 v2.1</a>
     27  * standard
     28  */
     29 public class RSAPrivateKeySpec implements KeySpec {
     30     // Modulus
     31     private final BigInteger modulus;
     32     // Private Exponent
     33     private final BigInteger privateExponent;
     34 
     35     /**
     36      * Creates a new {@code RSAPrivateKeySpec} with the specified modulus and
     37      * private exponent.
     38      *
     39      * @param modulus
     40      *            the modulus {@code n}.
     41      * @param privateExponent
     42      *            the private exponent {@code e}
     43      */
     44     public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent) {
     45         this.modulus = modulus;
     46         this.privateExponent = privateExponent;
     47     }
     48 
     49     /**
     50      * Returns the modulus {@code n}.
     51      *
     52      * @return the modulus {@code n}.
     53      */
     54     public BigInteger getModulus() {
     55         return modulus;
     56     }
     57 
     58     /**
     59      * Returns the private exponent {@code e}.
     60      *
     61      * @return the private exponent {@code e}.
     62      */
     63     public BigInteger getPrivateExponent() {
     64         return privateExponent;
     65     }
     66 }
     67