summaryrefslogtreecommitdiff
path: root/scripts/image_signing/sign_android_image.sh
Commit message (Collapse)AuthorAgeFilesLines
* signer: Verify many Android signer operations that content is unchanged.stabilize-13654.BYury Khmel2020-12-051-8/+29
| | | | | | | | | | | | | | This adds extra verifications to many Android signer operation in order to narrow down the problem when empty folders are removed from the disk. BUG=chromium:1154734 TEST=Locally image signing passed. Emulated problem and it was detected. BRANCH=none Signed-off-by: Yury Khmel <khmel@google.com> Change-Id: If8bb9fced290117766bfa9ff76a25fc86ed263dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2572240 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* sign_android: don't use xattrs from unsquashfsGeorge Engelbrecht2020-10-301-2/+2
| | | | | | | | | | | | | | | | | | | | | We've moved to applying a file based set of selinux policies instead of taking the ones that were snagged from the image. Remove the policy attributes and let unsquash do whatever it would do by default. See https://chat.google.com/room/AAAA45hbdCQ/jkXYe7jMEDk. BUG=chromium:1141907 TEST=unittests Change-Id: I0a976fb216e0a07c00c4bb2fb68df6fa1ea00d79 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2511121 Reviewed-by: Yury Khmel <khmel@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Yury Khmel <khmel@google.com> Commit-Queue: George Engelbrecht <engeg@google.com> Commit-Queue: Yury Khmel <khmel@google.com> Tested-by: George Engelbrecht <engeg@google.com> Auto-Submit: George Engelbrecht <engeg@google.com>
* signer: syncronize image packing to what we have in build image phase.Yury Khmel2020-10-141-26/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This follows steps we have in build image phase to have parity in image packing. * Discard reapply selinex context. This looks not needed once re-signing should not change selinux context. Instead we could do similar to build image, pass file context to mksquashfs * Apply mksquashfs params based on image type, container/vm. This fixes proper block size and image compression algorithm * Remove old image before packing to prevent mksquashfs merge attempt BUG=b:170400225 BUG=b:170220295 BUG=b:170219920 BRANCH=none TEST=locally signed vm (kohaku) and container (hana): arc.Optin*, arc.Preopt*. Also checked final image size. With this CL it is reduced to 150Mb(vm) and very close to original image size (delta is less than 0.1%) Signed-off-by: Yury Khmel <khmel@chromium.org> Change-Id: I7037bea68fc2969345a8fabc3c6a9b9b690f02d1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2462005 Reviewed-by: Yusuke Sato <yusukes@chromium.org> Reviewed-by: George Engelbrecht <engeg@google.com> Tested-by: Yury Khmel <khmel@google.com> Auto-Submit: Yury Khmel <khmel@google.com> Commit-Queue: Yury Khmel <khmel@google.com>
* signer: resign networkstack APKs with correct keystabilize-13525.Bfirmware-volteer-13521.BVictor Hsieh2020-10-091-1/+1
| | | | | | | | | | | | BUG=b:170156734 BRANCH=none TEST=sign rvc-arc image Signed-off-by: Victor HSieh <victorhsieh@chromium.org> Change-Id: I99fc4eb19be6cc785297e223a6603c1d777c5c77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2458789 Reviewed-by: Yury Khmel <khmel@chromium.org> Reviewed-by: George Engelbrecht <engeg@google.com>
* Deal with Android's new networkstack keyVictor Hsieh2020-10-081-1/+3
| | | | | | | | | | | BUG=b:170156734 TEST=run signing script locally BRANCH=None Signed-off-by: Victor HSieh <victorhsieh@chromium.org> Change-Id: I4f045729241b479b56fef5687b721b5b59c2eed8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2450551 Reviewed-by: George Engelbrecht <engeg@google.com>
* arc: Fix RVC signed image does not boot.factory-test-13517.BYury Khmel2020-10-061-9/+37
| | | | | | | | | | | | | | | | | | This supports new set of certificates plat_mac_permissions.xml and adds handling media and network_stack certificates. BRANCH=none BUG=b:169458218 TEST=Sign test image from goldeneye per instructions in bug, deploy it to device (kohaku) pass tast.arc.Optin.vm test Signed-off-by: Yury Khmel <khmel@chromium.org> Change-Id: I61c4e327eaa605ed60c0c80b3598c0f4fb6e5f5f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2447430 Tested-by: Yury Khmel <khmel@google.com> Auto-Submit: Yury Khmel <khmel@google.com> Reviewed-by: George Engelbrecht <engeg@google.com> Commit-Queue: Yury Khmel <khmel@google.com>
* inclusive: change usage of sanityDaisuke Nojiri2020-08-191-5/+5
| | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the term "sanity" with inclusive alternatives. BUG=b:163883397 BRANCH=None TEST=grep -ir sanity TEST=make runtests Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I708a044d89050c442f14fb11a8ae5e98490d56af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2353420 Reviewed-by: Julius Werner <jwerner@chromium.org>
* sign_android_image: use ARCVM file context if neededVictor Hsieh2020-07-291-3/+10
| | | | | | | | | | | | | | Apparently the file android_file_contexts has a different name for ARCVM with _vm suffix. Choose _vm if the container one is not found. BUG=b:161828692 TEST=sign_official_build.sh base recovery_image.bin mykey signed.bin BRANCH=none Signed-off-by: Victor Hsieh <victorhsieh@chromium.org> Change-Id: I8a93d8e1dd5b824f319d7de804f8f74825166a97 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2323647 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* sign_official_build: accept arcvm/bertha imageVictor Hsieh2020-07-231-1/+3
| | | | | | | | | | | | BUG=b:161828692 TEST=sign_official_build.sh base recovery_image.bin mykey signed.bin TEST=sign_android_unittests.sh BRANCH=none Signed-off-by: Victor Hsieh <victorhsieh@chromium.org> Change-Id: I158cd0c23198ffe8773b5882ba214b3ca4d26cae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2310758 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* image_signing: Activate file hash cache for watchlist service for signed builds.Yury Khmel2020-05-271-1/+4
| | | | | | | | | | | | | | | This follows the logic introduced in crrev.com/i/2523754 BUG=b:148229706 TEST= ./sign_official_build.sh usb source_image \ ~/trunk/src/platform/vboot_reference/tests/devkeys out_image BRANCH=None Cq-Depend: chrome-internal:3022044 Signed-off-by: Yury Khmel <khmel@google.com> Change-Id: I5398a9ea2984f0be11cb512f845507309d5f8f8e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2210771 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Support signing Android APKs with apksignerVictor Hsieh2019-06-051-19/+42
| | | | | | | | | | | | | | | | | | | | | * To enable, use --use_apksigner. * Drop signature schemes that we don't really need. * Supports key rotation. In this case, the signing lineage will be honored if the file exists next to the keys. * Update key generation script to auto generate the signing lineage. TEST=the script runs successfully with and without the flag TEST=`apksigner lineage --print-certs -v -in foo.apk` shows correct rotation info TEST=keygeneration/create_new_android_keys.sh --rotate-from old new BUG=None BRANCH=None Change-Id: Ic7b7b0ed4ea707a748dc42a1f39d6eb79d53cf1b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1643411 Tested-by: Victor Hsieh <victorhsieh@chromium.org> Reviewed-by: LaMont Jones <lamontjones@chromium.org> Commit-Queue: Victor Hsieh <victorhsieh@chromium.org>
* Update Android signing to support signature scheme v2Victor Hsieh2018-04-231-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | Signature Scheme V2 was introduced in N. TEST=(prepare) 1. Produce A.img by running the original sign_android_image.sh on a test image. 2. Produce B.img by running the new sign_android_image.sh on the same image. TEST=Check Settings.apk with apksigner. Saw only v1 signature exists with A.img, and only v2 exists with B.img, as expected. Certificates on both APKs have the same fingerprint. TEST=Login with A to create a new /data state, then login with B. Platform apps still run. No signature error in logcat. BRANCH=none BUG=b:67942659 Change-Id: Ibabc399563bfdc92836856a377997405cc660483 Reviewed-on: https://chromium-review.googlesource.com/993153 Commit-Ready: Victor Hsieh <victorhsieh@chromium.org> Tested-by: Victor Hsieh <victorhsieh@chromium.org> Reviewed-by: Bernie Thompson <bhthompson@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* arc: Enable packages cache generation during sign stage.factory-poppy-10509.BYury Khmel2018-03-201-1/+45
| | | | | | | | | | | | | | | This regenerates packages cache during signing the image once apks are changed due timestamp and key update. TEST=Build image, sign it useing devkeys and deploy to device. Perform user sign-in and enable ARC. Test logcat and everything is clear. BUG=b:74108152 Change-Id: I4809a1f87c8b8f52094054dbb4c8ba3e059aee89 Reviewed-on: https://chromium-review.googlesource.com/948064 Commit-Ready: Yury Khmel <khmel@google.com> Tested-by: Yury Khmel <khmel@google.com> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* image_signing: unit tests for Android imageNicolas Norvez2018-02-281-76/+8
| | | | | | | | | | | | | | | | | | | | | | - move helper functions that detect which keys should be used depending on the build flavor to a separate lib - add unit tests for that lib BUG=b:72947583 TEST=unit tests TEST=run against caroline image, scripts detects 'cheets' build flavor TEST=run against novato-arc64 image (SDK), script detects 'cheets' build flavor TEST=run against newbie image (AOSP), script detects 'aosp' build flavor TEST=run against invalid build property 'paosp_cheets_...', script aborts as expected BRANCH=None Change-Id: I5595c10a5a063e7658d0cf17c77dbeead429cd97 Reviewed-on: https://chromium-review.googlesource.com/923097 Commit-Ready: Nicolas Norvez <norvez@chromium.org> Tested-by: Nicolas Norvez <norvez@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* image_signing: Fix detection of build flavorNicolas Norvez2018-02-281-19/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | The original "ro.product.name" of the Android image is modified by the Chrome OS build process to change it to the CrOS device name instead, which breaks the detection of the build flavor. Instead, we now rely on the "ro.build.flavor" property which is not modified. If the build flavor is either cheets_* or sdk_google_cheets_*, we expect the keys to be the cheets keys. AOSP keys are used for aosp_cheets_* build flavors. BUG=b:72947583 TEST=run against caroline image, scripts detects 'cheets' build flavor TEST=run against novato-arc64 image (SDK), script detects 'cheets' build flavor TEST=run against newbie image (AOSP), script detects 'aosp' build flavor TEST=run against invalid build property 'paosp_cheets_...', script aborts as expected BRANCH=None Change-Id: I662436b256b59238b00c7374120f315b538fcd75 Reviewed-on: https://chromium-review.googlesource.com/911905 Commit-Ready: Nicolas Norvez <norvez@chromium.org> Tested-by: Nicolas Norvez <norvez@chromium.org> Reviewed-by: Victor Hsieh <victorhsieh@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* image_signing: Support AOSP dev signing keysNicolas Norvez2018-02-061-10/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | Following ag/3536780, aosp_cheets targets have their APKs signed with keys https://android.googlesource.com/platform/build/+/master/target/product/security/ The image signing script now: - detects if it's an aosp_cheets or cheets build - checks the correct signing keys have been used in either case - logs more information about the Android image BUG=b:72947583 TEST=manually test sign_framework_apks against AOSP and cheets builds TEST=aosp_cheets builds prior to ag/3536780 are now failing (expected) TEST=aosp_cheets builds posterior to ag/3536780 are passing TEST=cheets builds (before and after) are passing TEST=check that commenting out ro.product.name in build.prop triggers an error TEST=check that an invalid value in ro.product.name triggers an error BRANCH=None Change-Id: I72abea5182fbfe76820e3f48831be04f39cb334e Reviewed-on: https://chromium-review.googlesource.com/904726 Commit-Ready: Nicolas Norvez <norvez@chromium.org> Tested-by: Nicolas Norvez <norvez@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Use globbing to fetch mac_permissions.xml.Garfield Tan2017-09-271-1/+9
| | | | | | | | | | | | | | | | | Android master puts that file at a different location, so use similar logic to official signing script. TEST="sign_android_image.sh passed locally for both caroline (NYC) & caroline-bertha (master)." BUG=b:65610114 BRANCH=none Change-Id: If33bfbcaa7e6cff95f26ff26a91735c87880f3db Reviewed-on: https://chromium-review.googlesource.com/686046 Commit-Ready: Garfield Tan <xutan@chromium.org> Tested-by: Garfield Tan <xutan@chromium.org> Reviewed-by: Victor Hsieh <victorhsieh@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Preserve compress method when re-sign Android imageVictor Hsieh2017-03-281-1/+3
| | | | | | | | | | | | | TEST=sign_android_image.sh rootfs /path/to/tests/devkeys/android # unsquash -s still shows gzip (previous script always use lzo) BUG=chromium:705247 BRANCH=none Change-Id: If95686d293123a069ce36bc53cbea3a08aa3e7ab Reviewed-on: https://chromium-review.googlesource.com/461205 Commit-Ready: Victor Hsieh <victorhsieh@chromium.org> Tested-by: Victor Hsieh <victorhsieh@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Revert "Change debug key signatures"Victor Hsieh2016-09-261-11/+5
| | | | | | | | | | | | | | | The lab use test image (non-signed) to run CTS, so we still need to switch key to make a test pass (which blacklist Google's dev key). This reverts commit b94145a309131f23d49a08dd94fc26247621da65. TEST=None BUG=b:29915721,b:31373710 Change-Id: I0873d13b606f3e49b9d055e9dd081d3dacd97c65 Reviewed-on: https://chromium-review.googlesource.com/388636 Commit-Ready: Victor Hsieh <victorhsieh@chromium.org> Tested-by: Victor Hsieh <victorhsieh@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Preserve file capabilities while signing AndroidLuis Hector Chavez2016-09-231-4/+8
| | | | | | | | | | | | | | | | | | | | The version of unsquashfs that is shipped with Trusty does not correctly file capabilities, even though the target filesystem supports them. This change forces the Android signer script to prefer the pre-built binaries for mksquashfs/unsquashfs in order for the file capabilities to be preserved. BUG=b:31630024 BRANCH=none TEST=Called sign_android_image.sh locally, saw capabilities preserved across repeated invocations. CQ-DEPEND=CL:*289356 Change-Id: I13e8782edb699eb4ce8bcf82885bd474f4351430 Reviewed-on: https://chromium-review.googlesource.com/387867 Commit-Ready: Luis Hector Chavez <lhchavez@google.com> Tested-by: Luis Hector Chavez <lhchavez@google.com> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Change debug key signaturesVictor Hsieh2016-09-091-5/+11
| | | | | | | | | | | | | | We switched to different debug keys so the signature needs to be updated. TEST=sign_official_image with the new recovery image, failed before this change bug succeeded after. BUG=chromium:645628 Change-Id: I58236222c26f90268de80dc99f22d84650e67bb7 Reviewed-on: https://chromium-review.googlesource.com/383900 Reviewed-by: Mike Frysinger <vapier@chromium.org> Tested-by: Victor Hsieh <victorhsieh@chromium.org>
* Skip Android signing if executables are not foundstabilize-8737.BVictor Hsieh2016-08-231-0/+7
| | | | | | | | | | | TEST=./fm_and_key_version_test_prep ... in chroot BUG=chrome-os-partner:56279 Change-Id: I0c76aed757ae30245e07873180dbc9b609a8ec13 Reviewed-on: https://chromium-review.googlesource.com/374078 Tested-by: Victor Hsieh <victorhsieh@chromium.org> Reviewed-by: danny chan <dchan@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Refer keytool using relative pathVictor Hsieh2016-08-191-3/+1
| | | | | | | | | | | | | We will assume JDK bin/ is in the PATH, instead of using an absolute path. TEST=sign_official_image.sh BUG=b:29915721,chrome-os-partner:56279 Change-Id: I55379a8409b7d81f213d4d7418133691fa8152cf Reviewed-on: https://chromium-review.googlesource.com/373558 Reviewed-by: Mike Frysinger <vapier@chromium.org> Tested-by: Victor Hsieh <victorhsieh@chromium.org>
* Fix file ownership during Android apk signingVictor Hsieh2016-08-181-17/+30
| | | | | | | | | | | | | | Several files were changed to own by root instead of the original owner in the squashfs image. This has caused problem to boot Android. TEST=./sign_official_image with local keys, extract system.raw.img and override device copy. Able to launch ARC. BUG=b:29915721,b:30919855 Change-Id: Ic2595c99cbb7f7c2a2c543612a368681220cb3d9 Reviewed-on: https://chromium-review.googlesource.com/372312 Reviewed-by: Mike Frysinger <vapier@chromium.org> Tested-by: Victor Hsieh <victorhsieh@chromium.org>
* Add script to sign Android imageVictor Hsieh2016-08-151-0/+219
sign_android_image.sh is the main script that signs the image. It makes similar changes to an image like the Android official signing tool (sign_target_files_apks.py) does, but more Chrome OS specific. TEST=./sign_official_build.sh recovery recovery_image.bin \ ../../tests/devkeys/ out_img TEST=Same above but with a recovery image without Android image. Android signing was skipping. TEST=Same above but with a M53 image. Android signing was skipped. TEST=Unpack the image and diff the before and after. Looks correct. BUG=b:29915721 Change-Id: I0ae5f0ad8d2b05e485d60262558517ea563bf527 Reviewed-on: https://chromium-review.googlesource.com/366794 Commit-Ready: Victor Hsieh <victorhsieh@chromium.org> Tested-by: Victor Hsieh <victorhsieh@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>