Commit a117da05 authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

[modules] Verify module signature when faking on-demand install

To make this work this CL adds a specific build of the Play Core SDK
that exposes a verification method.

Bug: 901920
Change-Id: Icbf15a17f9345085d8ccd812d50d208f5279fe49
Reviewed-on: https://chromium-review.googlesource.com/c/1338563Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608991}
parent ec9eead7
...@@ -1201,6 +1201,17 @@ deps = { ...@@ -1201,6 +1201,17 @@ deps = {
'condition': 'checkout_src_internal', 'condition': 'checkout_src_internal',
}, },
'src/third_party/google_android_play_core': {
'packages': [
{
'package': 'chromium/third_party/android_deps/libs/com_google_android_play_core_verification',
'version': 'version:1.3.6-cr1',
},
],
'condition': 'checkout_android',
'dep_type': 'cipd',
},
# === ANDROID_DEPS Generated Code Start === # === ANDROID_DEPS Generated Code Start ===
# Generated by //tools/android/roll/android_deps/fetch_all.py # Generated by //tools/android/roll/android_deps/fetch_all.py
'src/third_party/android_deps/libs/android_arch_core_common': { 'src/third_party/android_deps/libs/android_arch_core_common': {
...@@ -1709,17 +1720,6 @@ deps = { ...@@ -1709,17 +1720,6 @@ deps = {
'dep_type': 'cipd', 'dep_type': 'cipd',
}, },
'src/third_party/android_deps/libs/com_google_android_play_core': {
'packages': [
{
'package': 'chromium/third_party/android_deps/libs/com_google_android_play_core',
'version': 'version:1.3.5-cr0',
},
],
'condition': 'checkout_android',
'dep_type': 'cipd',
},
'src/third_party/android_deps/libs/com_google_code_findbugs_jsr305': { 'src/third_party/android_deps/libs/com_google_code_findbugs_jsr305': {
'packages': [ 'packages': [
{ {
......
...@@ -13,6 +13,6 @@ android_library("module_installer_java") { ...@@ -13,6 +13,6 @@ android_library("module_installer_java") {
] ]
deps = [ deps = [
"//base:base_java", "//base:base_java",
"//third_party/android_deps:com_google_android_play_core_java", "//third_party/google_android_play_core:com_google_android_play_core_java",
] ]
} }
...@@ -7,6 +7,7 @@ package org.chromium.components.module_installer; ...@@ -7,6 +7,7 @@ package org.chromium.components.module_installer;
import android.content.Context; import android.content.Context;
import com.google.android.play.core.splitcompat.SplitCompat; import com.google.android.play.core.splitcompat.SplitCompat;
import com.google.android.play.core.splitcompat.ingestion.Verifier;
import org.chromium.base.BuildInfo; import org.chromium.base.BuildInfo;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
...@@ -69,10 +70,17 @@ class FakeModuleInstallerBackend extends ModuleInstallerBackend { ...@@ -69,10 +70,17 @@ class FakeModuleInstallerBackend extends ModuleInstallerBackend {
// Path where SplitCompat looks for downloaded modules. May change in future releases of // Path where SplitCompat looks for downloaded modules. May change in future releases of
// the Play Core SDK. // the Play Core SDK.
File dstModuleFile = joinPaths(context.getFilesDir().getPath(), "splitcompat", File dstModuleFile = joinPaths(context.getFilesDir().getPath(), "splitcompat",
Integer.toString(versionCode), "verified-splits", moduleName + ".apk"); Integer.toString(versionCode), "unverified-splits", moduleName + ".apk");
File srcModuleFile = joinPaths(MODULES_SRC_DIRECTORY_PATH, moduleName + ".apk"); File srcModuleFile = joinPaths(MODULES_SRC_DIRECTORY_PATH, moduleName + ".apk");
// NOTE: Need to give Chrome storage permission for this to work. // NOTE: Need to give Chrome storage permission for this to work.
try {
dstModuleFile.getParentFile().mkdirs();
} catch (SecurityException e) {
Log.e(TAG, "Failed to create module dir", e);
return false;
}
try (FileInputStream istream = new FileInputStream(srcModuleFile); try (FileInputStream istream = new FileInputStream(srcModuleFile);
FileOutputStream ostream = new FileOutputStream(dstModuleFile)) { FileOutputStream ostream = new FileOutputStream(dstModuleFile)) {
ostream.getChannel().transferFrom(istream.getChannel(), 0, istream.getChannel().size()); ostream.getChannel().transferFrom(istream.getChannel(), 0, istream.getChannel().size());
...@@ -81,10 +89,14 @@ class FakeModuleInstallerBackend extends ModuleInstallerBackend { ...@@ -81,10 +89,14 @@ class FakeModuleInstallerBackend extends ModuleInstallerBackend {
return false; return false;
} }
// Tell SplitCompat to do a full emulation of the module. The method name is obfuscated // Check that the module's signature matches Chrome's.
// since it is not part of the public API. We are using it here since this backend is for Verifier verifier = new Verifier(context);
// testing purposes only. if (!verifier.verifySplits()) {
return SplitCompat.a(context); return false;
}
// Tell SplitCompat to do a full emulation of the module.
return SplitCompat.fullInstall(context);
} }
private File joinPaths(String... paths) { private File joinPaths(String... paths) {
......
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
/glslang-angle/src /glslang-angle/src
/gn/ /gn/
/gnu_binutils/ /gnu_binutils/
/google_android_play_core/core-*.aar
/google_appengine_cloudstorage /google_appengine_cloudstorage
/google_toolbox_for_mac/src /google_toolbox_for_mac/src
/googlemac /googlemac
......
...@@ -535,12 +535,6 @@ android_aar_prebuilt( ...@@ -535,12 +535,6 @@ android_aar_prebuilt(
] ]
} }
android_aar_prebuilt("com_google_android_play_core_java") {
aar_path = "libs/com_google_android_play_core/core-1.3.5.aar"
info_path =
"libs/com_google_android_play_core/com_google_android_play_core.info"
}
java_prebuilt("com_google_dagger_dagger_java") { java_prebuilt("com_google_dagger_dagger_java") {
jar_path = "libs/com_google_dagger_dagger/dagger-2.17.jar" jar_path = "libs/com_google_dagger_dagger/dagger-2.17.jar"
output_name = "com_google_dagger_dagger" output_name = "com_google_dagger_dagger"
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
"libs/com_google_android_gms_play_services_tasks", "libs/com_google_android_gms_play_services_tasks",
"libs/com_google_android_gms_play_services_vision", "libs/com_google_android_gms_play_services_vision",
"libs/com_google_android_gms_play_services_vision_common", "libs/com_google_android_gms_play_services_vision_common",
"libs/com_google_android_play_core",
"libs/com_google_code_findbugs_jsr305", "libs/com_google_code_findbugs_jsr305",
"libs/com_google_dagger_dagger", "libs/com_google_dagger_dagger",
"libs/com_google_dagger_dagger_compiler", "libs/com_google_dagger_dagger_compiler",
......
file://third_party/android_deps/OWNERS
\ No newline at end of file
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/android/rules.gni")
android_aar_prebuilt("com_google_android_play_core_java") {
aar_path = "core-1.3.6.aar"
info_path = "com_google_android_play_core.info"
}
agrieve@chromium.org
tiborg@chromium.org
Name: Name: Goole Android Play Core
Short Name: core Short Name: Play Core
URL: https://developers.google.com/android/guides/setup URL: https://developers.google.com/android/guides/setup
Version: 1.3.5 Version: 1.3.6
License: Android Software Development Kit License License: Android Software Development Kit License
License File: LICENSE License File: LICENSE
Security Critical: yes Security Critical: yes
...@@ -10,4 +10,4 @@ Description: ...@@ -10,4 +10,4 @@ Description:
Local Modifications: Local Modifications:
No modifications. Unproguarded verification API.
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
# found in the LICENSE file. # found in the LICENSE file.
# To create CIPD package run the following command. # To create CIPD package run the following command.
# cipd create --pkg-def cipd.yaml -tag version:1.3.5-cr0 # cipd create --pkg-def cipd.yaml -tag version:1.3.6-cr1
package: chromium/third_party/android_deps/libs/com_google_android_play_core package: chromium/third_party/android_deps/libs/com_google_android_play_core_verification
description: "" description: ""
data: data:
- file: core-1.3.5.aar - file: core-1.3.6.aar
\ No newline at end of file
...@@ -39,8 +39,6 @@ dependencies { ...@@ -39,8 +39,6 @@ dependencies {
compile "com.google.android.gms:play-services-vision:${gmsVersion}" compile "com.google.android.gms:play-services-vision:${gmsVersion}"
compile "com.google.android.gms:play-services-fido:${gmsVersion}" compile "com.google.android.gms:play-services-fido:${gmsVersion}"
compile "com.google.android.play:core:1.3.5"
// Support v4 libraries // Support v4 libraries
def supportLibVersion = '27.0.0' def supportLibVersion = '27.0.0'
compile "com.android.support:support-v4:${supportLibVersion}" compile "com.android.support:support-v4:${supportLibVersion}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment