Search in sources :

Example 6 with SignerConfig

use of com.android.apksig.SigningCertificateLineage.SignerConfig in project apksig by venshine.

the class SigningCertificateLineageTest method testFirstRotationContainsExpectedSigners.

@Test
public void testFirstRotationContainsExpectedSigners() throws Exception {
    SigningCertificateLineage lineage = createLineageWithSignersFromResources(FIRST_RSA_2048_SIGNER_RESOURCE_NAME, SECOND_RSA_2048_SIGNER_RESOURCE_NAME);
    assertLineageContainsExpectedSigners(lineage, mSigners);
    SignerConfig unknownSigner = Resources.toLineageSignerConfig(getClass(), THIRD_RSA_2048_SIGNER_RESOURCE_NAME);
    assertFalse("The signer " + unknownSigner.getCertificate().getSubjectDN() + " should not be in the lineage", lineage.isSignerInLineage(unknownSigner));
}
Also used : SignerConfig(com.android.apksig.SigningCertificateLineage.SignerConfig) Test(org.junit.Test)

Example 7 with SignerConfig

use of com.android.apksig.SigningCertificateLineage.SignerConfig in project apksig by venshine.

the class SigningCertificateLineageTest method getSignerConfigFromResources.

private static SignerConfig getSignerConfigFromResources(String resourcePrefix) throws Exception {
    PrivateKey privateKey = Resources.toPrivateKey(SigningCertificateLineageTest.class, resourcePrefix + ".pk8");
    X509Certificate cert = Resources.toCertificate(SigningCertificateLineageTest.class, resourcePrefix + ".x509.pem");
    return new SignerConfig.Builder(privateKey, cert).build();
}
Also used : PrivateKey(java.security.PrivateKey) SignerConfig(com.android.apksig.SigningCertificateLineage.SignerConfig) X509Certificate(java.security.cert.X509Certificate)

Example 8 with SignerConfig

use of com.android.apksig.SigningCertificateLineage.SignerConfig in project apksig by venshine.

the class SigningCertificateLineageTest method testSublineageContainsExpectedSigners.

@Test
public void testSublineageContainsExpectedSigners() throws Exception {
    SigningCertificateLineage lineage = createLineageWithSignersFromResources(FIRST_RSA_2048_SIGNER_RESOURCE_NAME, SECOND_RSA_2048_SIGNER_RESOURCE_NAME);
    lineage = updateLineageWithSignerFromResources(lineage, THIRD_RSA_2048_SIGNER_RESOURCE_NAME);
    List<SignerConfig> subList = mSigners.subList(0, 2);
    X509Certificate cert = subList.get(1).getCertificate();
    SigningCertificateLineage subLineage = lineage.getSubLineage(cert);
    assertLineageContainsExpectedSigners(subLineage, subList);
}
Also used : SignerConfig(com.android.apksig.SigningCertificateLineage.SignerConfig) X509Certificate(java.security.cert.X509Certificate) Test(org.junit.Test)

Example 9 with SignerConfig

use of com.android.apksig.SigningCertificateLineage.SignerConfig in project apksig by venshine.

the class SigningCertificateLineageTest method testLineageFromFileDoesNotContainUnknownSigner.

@Test
public void testLineageFromFileDoesNotContainUnknownSigner() throws Exception {
    // This file contains the lineage with the first two rsa-2048 signers
    SigningCertificateLineage lineage = Resources.toSigningCertificateLineage(getClass(), "rsa-2048-lineage-2-signers");
    SignerConfig unknownSigner = Resources.toLineageSignerConfig(getClass(), THIRD_RSA_2048_SIGNER_RESOURCE_NAME);
    assertFalse("The signer " + unknownSigner.getCertificate().getSubjectDN() + " should not be in the lineage", lineage.isSignerInLineage(unknownSigner));
}
Also used : SignerConfig(com.android.apksig.SigningCertificateLineage.SignerConfig) Test(org.junit.Test)

Example 10 with SignerConfig

use of com.android.apksig.SigningCertificateLineage.SignerConfig in project apksig by venshine.

the class SigningCertificateLineageTest method testRotationWithExitingLineageAndNonDefaultCapabilitiesForNewSigner.

@Test
public void testRotationWithExitingLineageAndNonDefaultCapabilitiesForNewSigner() throws Exception {
    SigningCertificateLineage lineage = createLineageWithSignersFromResources(FIRST_RSA_2048_SIGNER_RESOURCE_NAME, SECOND_RSA_2048_SIGNER_RESOURCE_NAME);
    SignerConfig oldSigner = mSigners.get(mSigners.size() - 1);
    SignerConfig newSigner = Resources.toLineageSignerConfig(getClass(), THIRD_RSA_2048_SIGNER_RESOURCE_NAME);
    List<Boolean> newSignerCapabilityValues = Arrays.asList(false, false, false, false, false);
    lineage = lineage.spawnDescendant(oldSigner, newSigner, buildSignerCapabilities(newSignerCapabilityValues));
    SignerCapabilities newSignerCapabilities = lineage.getSignerCapabilities(newSigner);
    assertExpectedCapabilityValues(newSignerCapabilities, newSignerCapabilityValues);
}
Also used : SignerConfig(com.android.apksig.SigningCertificateLineage.SignerConfig) SignerCapabilities(com.android.apksig.SigningCertificateLineage.SignerCapabilities) Test(org.junit.Test)

Aggregations

SignerConfig (com.android.apksig.SigningCertificateLineage.SignerConfig)15 Test (org.junit.Test)12 SignerCapabilities (com.android.apksig.SigningCertificateLineage.SignerCapabilities)5 DataSource (com.android.apksig.util.DataSource)3 X509Certificate (java.security.cert.X509Certificate)2 ArrayList (java.util.ArrayList)2 File (java.io.File)1 PrivateKey (java.security.PrivateKey)1