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 /**
     19 * @author Vladimir N. Molotkov
     20 * @version $Revision$
     21 */
     22 
     23 package tests.security.spec;
     24 
     25 import junit.framework.TestCase;
     26 
     27 import java.math.BigInteger;
     28 import java.security.spec.AlgorithmParameterSpec;
     29 import java.security.spec.RSAKeyGenParameterSpec;
     30 
     31 /**
     32  * Tests for <code>RSAKeyGenParameterSpec</code> class fields and methods.
     33  *
     34  */
     35 public class RSAKeyGenParameterSpecTest extends TestCase {
     36 
     37     /**
     38      * Test for <code>RSAKeyGenParameterSpec(int,BigInteger)</code> ctor
     39      * Assertion: constructs <code>RSAKeyGenParameterSpec</code>
     40      * object using valid parameters
     41      */
     42     public final void testRSAKeyGenParameterSpec() {
     43         AlgorithmParameterSpec aps =
     44             new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L));
     45         assertTrue(aps instanceof RSAKeyGenParameterSpec);
     46     }
     47 
     48     /**
     49      * Test for <code>getKeySize()</code> method<br>
     50      * Assertion: returns key size value
     51      */
     52     public final void testGetKeysize() {
     53         RSAKeyGenParameterSpec rkgps =
     54             new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L));
     55         assertEquals(512, rkgps.getKeysize());
     56     }
     57 
     58     /**
     59      * Test for <code>getPublicExponent()</code> method<br>
     60      * Assertion: returns public exponent value
     61      */
     62     public final void testGetPublicExponent() {
     63         RSAKeyGenParameterSpec rkgps =
     64             new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L));
     65         assertEquals(0, rkgps.getPublicExponent().intValue());
     66     }
     67 
     68     /**
     69      * Test for <code>F0</code> field<br>
     70      * Assertion: the public exponent value F0 = 3
     71      */
     72     public final void testF0Value() {
     73         assertEquals(3, RSAKeyGenParameterSpec.F0.intValue());
     74     }
     75 
     76     /**
     77      * Test for <code>F4</code> field<br>
     78      * Assertion: the public exponent value F0 = 65537
     79      */
     80     public final void testF4Value() {
     81         assertEquals(65537, RSAKeyGenParameterSpec.F4.intValue());
     82     }
     83 
     84 }
     85