// Path: lib/src/main/java/com/google/capillary/Config.java
// public final class Config {
// 
//   /**
//    * Initializes the Capillary library.
//    *
//    * <p>This should be called before using any functionality provided by Capillary.
//    *
//    * @throws GeneralSecurityException if the initialization fails.
//    */
//   public static void initialize() throws GeneralSecurityException {
//     com.google.crypto.tink.Config.register(SignatureConfig.TINK_1_1_0);
//     com.google.crypto.tink.Config.register(AeadConfig.TINK_1_1_0);
//   }
// }
// 
// Path: lib/src/main/java/com/google/capillary/NoSuchKeyException.java
// public final class NoSuchKeyException extends CapillaryException {
// 
//   /**
//    * Creates a new {@link NoSuchKeyException} object.
//    *
//    * @param msg the exception message.
//    */
//   public NoSuchKeyException(String msg) {
//     super(msg);
//   }
// }


import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.google.capillary.Config;
import com.google.capillary.NoSuchKeyException;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
        IntegrationTest.class.getResourceAsStream("verification_key.dat")) {
      rsaEcdsaKeyManager =
          RsaEcdsaKeyManager.getInstance(context, KEYCHAIN_ID, senderVerificationKey);
    }
    webPushKeyManager = WebPushKeyManager.getInstance(context, KEYCHAIN_ID);
    TestUtils.clearKeyStore();
  }

  @Test
  public void testRsaEcdsaGenerateKeys() throws GeneralSecurityException {
    testGenerateKeys(rsaEcdsaKeyManager);
  }

  @Test
  public void testWebPushGenerateKeys() throws GeneralSecurityException {
    testGenerateKeys(webPushKeyManager);
  }

  private void testGenerateKeys(KeyManager keyManager) throws GeneralSecurityException {
    KeyStore keyStore = Utils.getInstance().loadKeyStore();

    assertEquals(0, keyStore.size());

    keyManager.rawGenerateKeyPair(true);
    keyManager.rawGenerateKeyPair(false);

    assertEquals(2, keyStore.size());
  }

  @Test
// Path: lib/src/main/java/com/google/capillary/Config.java
// public final class Config {
// 
//   /**
//    * Initializes the Capillary library.
//    *
//    * <p>This should be called before using any functionality provided by Capillary.
//    *
//    * @throws GeneralSecurityException if the initialization fails.
//    */
//   public static void initialize() throws GeneralSecurityException {
//     com.google.crypto.tink.Config.register(SignatureConfig.TINK_1_1_0);
//     com.google.crypto.tink.Config.register(AeadConfig.TINK_1_1_0);
//   }
// }
// 
// Path: lib/src/main/java/com/google/capillary/NoSuchKeyException.java
// public final class NoSuchKeyException extends CapillaryException {
// 
//   /**
//    * Creates a new {@link NoSuchKeyException} object.
//    *
//    * @param msg the exception message.
//    */
//   public NoSuchKeyException(String msg) {
//     super(msg);
//   }
// }


// Path: lib-android/src/androidTest/java/com/google/capillary/android/KeyManagerImplAndroidTest.java
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.google.capillary.Config;
import com.google.capillary.NoSuchKeyException;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import java.security.KeyStore;

        IntegrationTest.class.getResourceAsStream("verification_key.dat")) {
      rsaEcdsaKeyManager =
          RsaEcdsaKeyManager.getInstance(context, KEYCHAIN_ID, senderVerificationKey);
    }
    webPushKeyManager = WebPushKeyManager.getInstance(context, KEYCHAIN_ID);
    TestUtils.clearKeyStore();
  }

  @Test
  public void testRsaEcdsaGenerateKeys() throws GeneralSecurityException {
    testGenerateKeys(rsaEcdsaKeyManager);
  }

  @Test
  public void testWebPushGenerateKeys() throws GeneralSecurityException {
    testGenerateKeys(webPushKeyManager);
  }

  private void testGenerateKeys(KeyManager keyManager) throws GeneralSecurityException {
    KeyStore keyStore = Utils.getInstance().loadKeyStore();

    assertEquals(0, keyStore.size());

    keyManager.rawGenerateKeyPair(true);
    keyManager.rawGenerateKeyPair(false);

    assertEquals(2, keyStore.size());
  }

  @Test
  public void testRsaEcdsaGetPublicKey() throws GeneralSecurityException, NoSuchKeyException {