Home | History | Annotate | Download | only in wycheproof
      1 /*
      2  * Copyright (C) 2017 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 
     17 package android.libcore.cts.wycheproof;
     18 
     19 import com.android.org.conscrypt.OpenSSLProvider;
     20 import com.google.security.wycheproof.AesGcmTest;
     21 import com.google.security.wycheproof.BasicTest;
     22 import com.google.security.wycheproof.CipherInputStreamTest;
     23 import com.google.security.wycheproof.CipherOutputStreamTest;
     24 import com.google.security.wycheproof.EcKeyTest;
     25 import com.google.security.wycheproof.EcdhTest;
     26 import com.google.security.wycheproof.EcdsaTest;
     27 import com.google.security.wycheproof.RsaEncryptionTest;
     28 import com.google.security.wycheproof.RsaKeyTest;
     29 import com.google.security.wycheproof.RsaSignatureTest;
     30 import com.google.security.wycheproof.TestUtil;
     31 import com.google.security.wycheproof.WycheproofRunner;
     32 import com.google.security.wycheproof.WycheproofRunner.Fast;
     33 import com.google.security.wycheproof.WycheproofRunner.Provider;
     34 import com.google.security.wycheproof.WycheproofRunner.ProviderType;
     35 
     36 import org.junit.AfterClass;
     37 import org.junit.BeforeClass;
     38 import org.junit.runner.RunWith;
     39 import org.junit.runners.Suite.SuiteClasses;
     40 
     41 import java.security.Security;
     42 import java.util.ArrayList;
     43 import java.util.Arrays;
     44 import java.util.List;
     45 
     46 /**
     47  * Checks that our Conscrypt provider properly implements all its functionality.
     48  */
     49 @RunWith(WycheproofRunner.class)
     50 @SuiteClasses({
     51         AesGcmTest.class,
     52         BasicTest.class,
     53         CipherInputStreamTest.class,
     54         CipherOutputStreamTest.class,
     55         EcKeyTest.class,
     56         EcdhTest.class,
     57         EcdsaTest.class,
     58         RsaEncryptionTest.class,
     59         RsaKeyTest.class,
     60         RsaSignatureTest.class
     61 })
     62 @Provider(ProviderType.CONSCRYPT)
     63 @Fast
     64 public final class ConscryptTest {
     65 
     66     private static final List<java.security.Provider> previousProviders = new ArrayList<>();
     67 
     68     @BeforeClass
     69     public static void setUp() throws Exception {
     70         previousProviders.clear();
     71         previousProviders.addAll(Arrays.asList(Security.getProviders()));
     72         TestUtil.installOnlyThisProvider(new OpenSSLProvider());
     73     }
     74 
     75     @AfterClass
     76     public static void tearDown() throws Exception {
     77         for (java.security.Provider p : Security.getProviders()) {
     78             Security.removeProvider(p.getName());
     79         }
     80         for (java.security.Provider p : previousProviders) {
     81             Security.addProvider(p);
     82         }
     83     }
     84 }
     85