Home | History | Annotate | Download | only in image_signing
      1 #!/bin/bash
      2 
      3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
      4 # Use of this source code is governed by a BSD-style license that can be
      5 # found in the LICENSE file.
      6 
      7 # Install an update payload verification public key to the image.
      8 
      9 # Load common constants and variables.
     10 . "$(dirname "$0")/common.sh"
     11 
     12 main() {
     13   set -e
     14 
     15   local image="$1"
     16   local pub_key="$2"
     17   if [ $# -ne 2 ]; then
     18     cat <<EOF
     19 Usage: $PROG <image.bin> <au_public_key.pem>
     20 Installs the update verification public key <au_public_key.pem> to <image.bin>.
     21 EOF
     22     exit 1
     23   fi
     24   local rootfs=$(make_temp_dir)
     25   local key_location="/usr/share/update_engine/"
     26   mount_image_partition "$image" 3 "$rootfs"
     27   sudo mkdir -p "$rootfs/$key_location"
     28   sudo cp "$pub_key" "$rootfs/$key_location/update-payload-key.pub.pem"
     29   sudo chown root:root "$rootfs/$key_location/update-payload-key.pub.pem"
     30   sudo chmod 644 "$rootfs/$key_location/update-payload-key.pub.pem"
     31   echo "AU verification key was installed. Do not forget to resign the image!"
     32 }
     33 
     34 main "$@"
     35