Home | History | Annotate | Download | only in interfaces
      1 /*
      2  * Copyright (C) 2007 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package tests.security.interfaces;
     17 
     18 import junit.framework.TestCase;
     19 
     20 import java.security.KeyFactory;
     21 import java.security.interfaces.RSAPrivateCrtKey;
     22 
     23 public class RSAPrivateCrtKeyTest extends TestCase {
     24 
     25     RSAPrivateCrtKey key = null;
     26 
     27     protected void setUp() throws Exception {
     28         super.setUp();
     29         KeyFactory gen = KeyFactory.getInstance("RSA");
     30         key = (RSAPrivateCrtKey) gen.generatePrivate(Util.rsaCrtParam);
     31     }
     32 
     33     /**
     34      * java.security.interfaces.RSAPrivateCrtKey
     35      * #getCrtCoefficient()
     36      */
     37     public void test_getCrtCoefficient() {
     38         assertEquals("invalid CRT coefficient",
     39                 Util.rsaCrtParam.getCrtCoefficient(), key.getCrtCoefficient());
     40     }
     41 
     42     /**
     43      * java.security.interfaces.RSAPrivateCrtKey
     44      * #getPrimeExponentP()
     45      */
     46     public void test_getPrimeExponentP() {
     47         assertEquals("invalid prime exponent P",
     48                 Util.rsaCrtParam.getPrimeExponentP(), key.getPrimeExponentP());
     49     }
     50 
     51     /**
     52      * java.security.interfaces.RSAPrivateCrtKey
     53      * #getPrimeExponentQ()
     54      */
     55     public void test_getPrimeExponentQ() {
     56         assertEquals("invalid prime exponent Q",
     57                 Util.rsaCrtParam.getPrimeExponentQ(), key.getPrimeExponentQ());
     58     }
     59 
     60     /**
     61      * java.security.interfaces.RSAPrivateCrtKey
     62      * #getPrimeP()
     63      */
     64     public void test_getPrimeP() {
     65         assertEquals("invalid prime P",
     66                 Util.rsaCrtParam.getPrimeP(), key.getPrimeP());
     67     }
     68 
     69     /**
     70      * java.security.interfaces.RSAPrivateCrtKey
     71      * #getPrimeQ()
     72      */
     73     public void test_getPrimeQ() {
     74         assertEquals("invalid prime Q",
     75                 Util.rsaCrtParam.getPrimeQ(), key.getPrimeQ());
     76     }
     77 
     78     /**
     79      * java.security.interfaces.RSAPrivateCrtKey
     80      * #getPublicExponent()
     81      */
     82     public void test_getPublicExponent() {
     83         assertEquals("invalid public exponent",
     84                 Util.rsaCrtParam.getPublicExponent(), key.getPublicExponent());
     85     }
     86 
     87     protected void tearDown() throws Exception {
     88         key = null;
     89         super.tearDown();
     90     }
     91 }
     92