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