summaryrefslogtreecommitdiff
path: root/scripts/image_signing/insert_au_publickey.sh
blob: 9d1597de8223bef12197db5b955f5a3861cc1b62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash

# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Install an update payload verification public key to the image.

# Load common constants and variables.
. "$(dirname "$0")/common.sh"

main() {
  set -e

  local image="$1"
  local pub_key="$2"
  if [ $# -ne 2 ]; then
    cat <<EOF
Usage: $PROG <image.bin> <au_public_key.pem>
Installs the update verification public key <au_public_key.pem> to <image.bin>.
EOF
    exit 1
  fi
  local loopdev=$(loopback_partscan "${image}")
  local rootfs=$(make_temp_dir)
  local key_location="/usr/share/update_engine/"
  mount_loop_image_partition "${loopdev}" 3 "${rootfs}"
  sudo mkdir -p "$rootfs/$key_location"
  sudo cp "$pub_key" "$rootfs/$key_location/update-payload-key.pub.pem"
  sudo chown root:root "$rootfs/$key_location/update-payload-key.pub.pem"
  sudo chmod 644 "$rootfs/$key_location/update-payload-key.pub.pem"
  echo "AU verification key was installed. Do not forget to resign the image!"
}

main "$@"