Search in sources :

Example 1 with RSA_USING_SHA384

use of org.jose4j.jws.AlgorithmIdentifiers.RSA_USING_SHA384 in project bundletool by google.

the class CheckTransparencyCommandTest method bundleMode_unsupportedSignatureAlgorithm.

@Test
public void bundleMode_unsupportedSignatureAlgorithm() throws Exception {
    String serializedJws = createJwsToken(CodeTransparency.getDefaultInstance(), transparencyKeyCertificate, transparencyPrivateKey, RSA_USING_SHA384);
    AppBundleBuilder appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.test.app"))).addMetadataFile(BundleMetadata.BUNDLETOOL_NAMESPACE, BundleMetadata.TRANSPARENCY_SIGNED_FILE_NAME, CharSource.wrap(serializedJws).asByteSource(Charset.defaultCharset()));
    new AppBundleSerializer().writeToDisk(appBundle.build(), bundlePath);
    Throwable e = assertThrows(CommandExecutionException.class, () -> CheckTransparencyCommand.builder().setMode(Mode.BUNDLE).setBundlePath(bundlePath).build().checkTransparency(new PrintStream(new ByteArrayOutputStream())));
    assertThat(e).hasMessageThat().contains("Exception while verifying code transparency signature.");
}
Also used : X509Certificate(java.security.cert.X509Certificate) KeyPair(java.security.KeyPair) ApkTargeting(com.android.bundle.Targeting.ApkTargeting) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) ZipBuilder(com.android.tools.build.bundletool.io.ZipBuilder) Mode(com.android.tools.build.bundletool.commands.CheckTransparencyCommand.Mode) Path(java.nio.file.Path) FakeSystemEnvironmentProvider(com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider) KeyPairGenerator(java.security.KeyPairGenerator) JsonWebSignature(org.jose4j.jws.JsonWebSignature) ImmutableMap(com.google.common.collect.ImmutableMap) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) RequiredFlagNotSetException(com.android.tools.build.bundletool.flags.Flag.RequiredFlagNotSetException) ApkSerializer(com.android.tools.build.bundletool.io.ApkSerializer) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) ByteString(com.google.protobuf.ByteString) SystemEnvironmentProvider(com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) PrivateKey(java.security.PrivateKey) ModuleEntry(com.android.tools.build.bundletool.model.ModuleEntry) SignerConfig(com.android.tools.build.bundletool.model.SignerConfig) CodeTransparencyCryptoUtils(com.android.tools.build.bundletool.transparency.CodeTransparencyCryptoUtils) CodeTransparencyVersion(com.android.tools.build.bundletool.transparency.CodeTransparencyVersion) CodeTransparency(com.android.bundle.CodeTransparencyOuterClass.CodeTransparency) Mockito.mock(org.mockito.Mockito.mock) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) TestModule(com.android.tools.build.bundletool.testing.TestModule) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BundleModuleName(com.android.tools.build.bundletool.model.BundleModuleName) ZipPath(com.android.tools.build.bundletool.model.ZipPath) RunWith(org.junit.runner.RunWith) Hashing(com.google.common.hash.Hashing) Component(dagger.Component) RSA_USING_SHA384(org.jose4j.jws.AlgorithmIdentifiers.RSA_USING_SHA384) SigningConfiguration(com.android.tools.build.bundletool.model.SigningConfiguration) Inject(javax.inject.Inject) UnknownFlagsException(com.android.tools.build.bundletool.flags.ParsedFlags.UnknownFlagsException) ImmutableList(com.google.common.collect.ImmutableList) Charset(java.nio.charset.Charset) AppBundleSerializer(com.android.tools.build.bundletool.io.AppBundleSerializer) ANDROID_SERIAL(com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider.ANDROID_SERIAL) CharSource(com.google.common.io.CharSource) ByteSource(com.google.common.io.ByteSource) CodeTransparencyTestUtils.createJwsToken(com.android.tools.build.bundletool.testing.CodeTransparencyTestUtils.createJwsToken) ANDROID_HOME(com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider.ANDROID_HOME) VariantTargeting(com.android.bundle.Targeting.VariantTargeting) AdbServer(com.android.tools.build.bundletool.device.AdbServer) Before(org.junit.Before) PrintStream(java.io.PrintStream) CertificateFactory(com.android.tools.build.bundletool.testing.CertificateFactory) Files(java.nio.file.Files) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Test(org.junit.Test) BundleMetadata(com.android.tools.build.bundletool.model.BundleMetadata) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) Rule(org.junit.Rule) Paths(java.nio.file.Paths) InvalidCommandException(com.android.tools.build.bundletool.model.exceptions.InvalidCommandException) CodeRelatedFile(com.android.bundle.CodeTransparencyOuterClass.CodeRelatedFile) TemporaryFolder(org.junit.rules.TemporaryFolder) PrintStream(java.io.PrintStream) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) ByteString(com.google.protobuf.ByteString) AppBundleSerializer(com.android.tools.build.bundletool.io.AppBundleSerializer) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Aggregations

CodeRelatedFile (com.android.bundle.CodeTransparencyOuterClass.CodeRelatedFile)1 CodeTransparency (com.android.bundle.CodeTransparencyOuterClass.CodeTransparency)1 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)1 VariantTargeting (com.android.bundle.Targeting.VariantTargeting)1 Mode (com.android.tools.build.bundletool.commands.CheckTransparencyCommand.Mode)1 AdbServer (com.android.tools.build.bundletool.device.AdbServer)1 RequiredFlagNotSetException (com.android.tools.build.bundletool.flags.Flag.RequiredFlagNotSetException)1 FlagParser (com.android.tools.build.bundletool.flags.FlagParser)1 UnknownFlagsException (com.android.tools.build.bundletool.flags.ParsedFlags.UnknownFlagsException)1 ApkSerializer (com.android.tools.build.bundletool.io.ApkSerializer)1 AppBundleSerializer (com.android.tools.build.bundletool.io.AppBundleSerializer)1 ZipBuilder (com.android.tools.build.bundletool.io.ZipBuilder)1 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)1 BundleMetadata (com.android.tools.build.bundletool.model.BundleMetadata)1 BundleModuleName (com.android.tools.build.bundletool.model.BundleModuleName)1 ModuleEntry (com.android.tools.build.bundletool.model.ModuleEntry)1 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)1 SignerConfig (com.android.tools.build.bundletool.model.SignerConfig)1 SigningConfiguration (com.android.tools.build.bundletool.model.SigningConfiguration)1 ZipPath (com.android.tools.build.bundletool.model.ZipPath)1