このページでは、Google Pixel デバイスで Google Pixel イメージの正規バージョンを実行できるようにするための方法(信頼性が最も高い方法)について説明します。この方法では、ファクトリー イメージをパソコンにダウンロードし、 ダウンロードしたアーティファクトをデバイスに書き込む前に、 ログ インクルージョン証明 を実行します。
Google Pixel のファクトリー イメージを検証する方法
検証の前提条件
アーティファクト(ファームウェアまたは APK)が申告どおりであることを検証する前に、ネットワークに接続されたパソコンで次のツールが使用可能であることを確認してください。 検証対象によっては、すべてのツールが必要ない場合があります。
Golang
検証ツール は Go で記述されています。ビルドするには、Go サイトから Go 1.24 以降をインストールします。 Go サイトからインストールします。
Android Debug Bridge(ADB)
ADB は、Android デバイスと通信してイメージを検査したり、
APK を抽出したりするツールです。Android SDK Platform Tools のウェブサイトで入手できます。
インクルージョン証明検証ツール
インクルージョン証明検証ツールは、透明性ログにクエリを実行し、アーティファクトがログに含まれているかどうかを出力する Go モジュールです。
android-binary-transparency GitHub リポジトリ(
https://github.com/android/android-binary-transparency/tree/main)で公開されています。
AOSP avb リポジトリのクローンを作成するには:
computer:~$ git clone https://android.googlesource.com/platform/external/avb
android-binary-transparency GitHub リポジトリのクローンを作成するには:
computer:~$ git clone https://github.com/android/android-binary-transparency
AAPT2
AAPT2(Android Asset Packaging Tool)は、Android アプリのリソースのコンパイルとパッケージ化に使用されるビルドツールです。 Android SDK Build Tools バージョン 26.0.2 以降でスタンドアロン ツールとして使用できます。
bundletool
bundletool は、Android App Bundle(AAB)のビルドに使用されるツールです。APK コード署名の検証にも使用できます。
GitHub からダウンロードできます。
wget または curl
wget と curl は、インターネットからファイルを取得またはダウンロードするために使用できるツールです。 検証スクリプトでこれらのツールが使用される可能性があるため、いずれかのツールをインストールしておく必要があります。
Avbtool
avbtool
は、ファクトリー イメージの VBMeta ダイジェストの計算と
バイナリの検証に使用されます。
(インクルージョン証明検証ツール
のセクションで説明したように)avb リポジトリのクローンを作成すると、クローンされた avb ディレクトリ内に avbtool.py があります。
このディレクトリを $PATH 環境変数に追加する必要があります。
computer:~$ PATH=$PATH:DIRECTORY_CONTAINING_AVBTOOL
Fbpacktool
fbpacktool
は、Google Pixel
bootloader.img の個々のコンポーネントを解凍するために使用される Python スクリプトです。
APK を検証する場合は必要ありません。
このツールは、avbtool.py が検証に必要なイメージを検出できるようにするため、重要です。
fbpacktool には、Python 3.6 以降と
PyYAML パッケージ
(例: python3 -m pip install pyyaml)が必要です。
このツールを使用するには、次の 6 つの Python スクリプト
を avbtool.py が存在するディレクトリにダウンロードし、fbpacktool.py を実行可能にし、
便宜上 fbpacktool という名前のシンボリック リンクを fbpacktool.py に作成します。
wget がある場合:
computer:dir_to_avbtool$ wget https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/fbpacktool.py \
https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/fbpack.py \
https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/packedstruct.py \
https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/xmlparser.py \
https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/xmlserializer.py \
https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/yamlparser.py
computer:dir_to_avbtool$ chmod +x fbpacktool.py
computer:dir_to_avbtool$ ln -s fbpacktool.py fbpacktool
curl がある場合:
computer:dir_to_avbtool$ curl -LO https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/fbpacktool.py
computer:dir_to_avbtool$ curl -LO https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/fbpack.py
computer:dir_to_avbtool$ curl -LO https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/packedstruct.py
computer:dir_to_avbtool$ curl -LO https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/xmlparser.py
computer:dir_to_avbtool$ curl -LO https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/xmlserializer.py
computer:dir_to_avbtool$ curl -LO https://developers.google.com/android/binary_transparency/tools/pixel/fbpacktool/yamlparser.py
computer:dir_to_avbtool$ chmod +x fbpacktool.py
computer:dir_to_avbtool$ ln -s fbpacktool.py fbpacktool
OpenSSL
openssl は、検証ワークフローでターミナルを使用してさまざまな暗号化 オペレーションを実行するのに役立ちます。 システムにインストールされていることを確認してください。 ターミナルで次のコマンドを実行し、返された結果が空でないことを確認することで、確認できます。
computer:~$ which openssl
/usr/bin/openssl
検証用のペイロードを作成する
デバイス上のイメージまたは Google Pixel のファクトリー イメージのウェブサイトからのダウンロードを検証するには、まずビルドのフィンガープリントと VBMeta ダイジェストから、そのイメージに対応するペイロードを作成する必要があります。オプションは、手動と自動の 2 つがあります。以下で説明します。
- ビルドのフィンガープリント: ファクトリー イメージの文字列識別子
- 例:
google/oriole/oriole:12/SD1A.210817.015.A4/7697517:user/release-keys
- 例:
- VBMeta ダイジェスト: ファクトリー イメージのさまざまな部分をまとめる SHA-256 暗号ダイジェスト
- 例:
4d5e41b7c675a821de81f7d2c744623fe808c8c2d3e19a83e894dab5d0829dbe
- 例:
手動でペイロードを作成する
検証用のペイロードを手動で生成するには、ビルドのフィンガープリントを 1 行に、VBMeta ダイジェストを次の行に記述したテキスト
ファイル payload.txt を作成します。空の改行を追加してください(正確な形式については、
ログの内容のセクションをご覧ください)。
Google Pixel のファクトリー イメージのウェブサイトの手順に沿って操作すると、
ファイルpayload.txtの内容は次のようになります。
google/oriole/oriole:12/SD1A.210817.015.A4/7697517:user/release-keys
4d5e41b7c675a821de81f7d2c744623fe808c8c2d3e19a83e894dab5d0829dbe
Google Pixel のファクトリー イメージのウェブサイトから VBMeta ダイジェストとビルドのフィンガープリントを抽出する
Google Pixel のファクトリー イメージのウェブサイトからファクトリー イメージをダウンロードしたら、
ダウンロードしたファイルを解凍する必要があります。これにより、別のフォルダが
作成されます。新しく作成されたフォルダに移動し、関連する image-*.zip ファイルを解凍して、個々の *.img ファイルを取得します。これらのバイナリはパーティション イメージです。img ファイルの中に vbmeta.img ファイルがあることを確認してください。
次のように表示されます。
computer:oriole-sd1a.210817.015.a4$ unzip image-oriole-sd1a.210817.015.a4.zip
Archive: image-oriole-sd1a.210817.015.a4.zip
inflating: android-info.txt
inflating: boot.img
inflating: vendor_boot.img
inflating: system.img
inflating: vendor.img
inflating: product.img
inflating: system_ext.img
inflating: system_other.img
inflating: dtbo.img
inflating: vbmeta_system.img
inflating: vbmeta.img
inflating: super_empty.img
ダウンロードしたすべてのファイルからビルドのフィンガープリントを抽出し、VBMeta ダイジェストを計算できます。
avbtool.py が $PATH で使用可能になったら、ターミナルから次のコマンドを実行して、デバイス固有のビルドのフィンガープリントを抽出し、ダウンロードしたばかりのファクトリー イメージの VBMeta ダイジェストを計算できます。
computer:dir_containing_unzipped_factory_image~$ grep -a 'ro\.product\.build\.fingerprint=google/.*/release-keys' product.img | cut -f2 -d'='
google/oriole/oriole:12/SD1A.210817.015.A4/7697517:user/release-keys
computer:dir_containing_unzipped_factory_image$ avbtool.py calculate_vbmeta_digest --image vbmeta.img
4d5e41b7c675a821de81f7d2c744623fe808c8c2d3e19a83e894dab5d0829dbe
ダウンロードしたファクトリー イメージを手動で検証する
ダウンロードしたファクトリー イメージを正しく検証するには、
ダウンロード
fbpacktool.py
と、それに依存する他の Python ファイル(完全なリストとダウンロード
コマンドについては、前提条件の
Fbpacktoolをご覧ください)
をダウンロードして、bootloader.img 内のコンポーネントを解凍する必要があります。これらのコンポーネントは、VBMeta 構造体で個別に記述されています。解凍ツールを入手したら、fbpacktool.py を使用してブートローダー イメージを解凍できます。次に例を示します。
computer:dir_containing_unzipped_images$ python3 fbpacktool.py unpack bootloader-oriole-slider-1.0-7683913.img
そのディレクトリに .img ファイルが追加されていることを確認できます。
次に、avbtool.py を使用して、さまざまなパーティションの署名が一致していることを手動で検証します。
computer:dir_containing_unzipped_images$ avbtool.py verify_image --image vbmeta.img --follow_chain_partitions
Verifying image vbmeta.img using embedded public key
vbmeta: Successfully verified SHA256_RSA4096 vbmeta struct in vbmeta.img
vbmeta_system: Chained but ROLLBACK_SLOT (which is 1) and KEY (which has sha1 df529646b7225015196a714006346f0768b87fcf) not specified
--
Verifying image vbmeta_system.img using embedded public key
vbmeta: Successfully verified SHA256_RSA4096 vbmeta struct in vbmeta_system.img
product: Successfully verified sha256 hashtree of product.img for image of 2700468224 bytes
system: Successfully verified sha256 hashtree of system.img for image of 878493696 bytes
system_ext: Successfully verified sha256 hashtree of system_ext.img for image of 251334656 bytes
vbmeta_vendor: Chained but ROLLBACK_SLOT (which is 3) and KEY (which has sha1 85322346680a860c091fa14a64cef1fe4a3ffe31) not specified
--
Verifying image vbmeta_vendor.img using embedded public key
vbmeta: Successfully verified SHA256_RSA4096 vbmeta struct in vbmeta_vendor.img
vendor: Successfully verified sha256 hashtree of vendor.img for image of 472940544 bytes
boot: Chained but ROLLBACK_SLOT (which is 2) and KEY (which has sha1 85322346680a860c091fa14a64cef1fe4a3ffe31) not specified
--
Verifying image boot.img using embedded public key
vbmeta: Successfully verified footer and SHA256_RSA4096 vbmeta struct in boot.img
boot: Successfully verified sha256 hash of boot.img for image of 24481792 bytes
abl: Successfully verified sha256 hash of abl.img for image of 1744896 bytes
bl1: Successfully verified sha256 hash of bl1.img for image of 12288 bytes
bl2: Successfully verified sha256 hash of bl2.img for image of 544768 bytes
bl31: Successfully verified sha256 hash of bl31.img for image of 86016 bytes
dtbo: Successfully verified sha256 hash of dtbo.img for image of 2152234 bytes
gsa: Successfully verified sha256 hash of gsa.img for image of 262144 bytes
ldfw: Successfully verified sha256 hash of ldfw.img for image of 4096000 bytes
pbl: Successfully verified sha256 hash of pbl.img for image of 49152 bytes
tzsw: Successfully verified sha256 hash of tzsw.img for image of 4304896 bytes
vendor_boot: Successfully verified sha256 hash of vendor_boot.img for image of 25718784 bytes
vendor_dlkm: Successfully verified sha256 hashtree of vendor_dlkm.img for image of 54505472 bytes
エラー メッセージや失敗メッセージが表示されない場合は、ダウンロードしたイメージの VBMeta が正常に検証されたことを意味します。
自動でペイロードを作成する
便宜上、使用できる Python スクリプトも用意しています。このツールを使用すると、ファイルを手動で取得して解凍するのではなく、ファクトリー イメージの URL を指定するだけで済みます。
computer:dir_to_avb_repo/tools/transparency$ python3 ./pixel_factory_image_verify.py https://dl.google.com/dl/android/aosp/oriole-sd1a.210817.015.a4-factory-074b7f51.zip
Fetching file from: https://dl.google.com/dl/android/aosp/oriole-sd1a.210817.015.a4-factory-074b7f51.zip
Successfully downloaded file.
Successfully unpacked factory image.
Successfully unpacked factory image partitions.
Successfully unpacked bootloader image.
Successfully verified VBmeta.
Successfully extracted build fingerprint.
Successfully calculated VBMeta Digest.
The build fingerprint for factory image is: google/oriole/oriole:12/SD1A.210817.015.A4/7697517:user/release-keys
The VBMeta Digest for factory image is: 4d5e41b7c675a821de81f7d2c744623fe808c8c2d3e19a83e894dab5d0829dbe
A corresponding "payload.txt" file has been created.
上記のコマンドを実行すると、ファクトリー イメージ バンドルがダウンロードされ、バンドルが解凍され、署名付きパーティションの署名が検証されます。検証が成功すると、payload.txt という名前の新しいファイルが作成されます。その内容は次のようになります。
google/oriole/oriole:12/SD1A.210817.015.A4/7697517:user/release-keys
4d5e41b7c675a821de81f7d2c744623fe808c8c2d3e19a83e894dab5d0829dbe
payload.txt が正常に作成されたら、イメージ インクルージョンの 検証手順を開始できます。
イメージ インクルージョンを検証する(インクルージョン証明)
ペイロードを作成したら、ペイロードのパスを指定するようにシェル変数(例: $PAYLOAD_PATH)を設定します。
インクルージョン証明ツールは、Android オープンソース プロジェクト内の
avb リポジトリ
で公開されています。実行するには:
computer:external/avb/tools/transparency/verify$ PAYLOAD_PATH=../payload.txt
computer:external/avb/tools/transparency/verify$ go build cmd/verifier/verifier.go
computer:external/avb/tools/transparency/verify$ ./verifier --payload_path=${PAYLOAD_PATH} --log_type=pixel
検証ツールは、チェックポイントとログの内容( tile ディレクトリにあります)を使用して、イメージ ペイロードが 透明性ログに含まれていること、つまり Google によって公開されていることを確認します。
コマンドの出力は stdout に書き込まれます。
- イメージがログに含まれている場合は
OK. inclusion check success! - 含まれていない場合は
FAILURE