cros/faft: Update gen_test_images.sh

1. Changed "dump_fmap" to "futility dump_fmap" because the former
is now a symlink to the latter, and the symlink is not present
in the lxc containers used by lab servers.
2. Replace call to sign_official_build.sh with call to "futility sign"
because sign_official_build.sh and it's dependencies are not
available in the lxc container used in the lab.
Both replacements are no change in functionality.

BUG=chromium:961293, chromium:1003023
TEST=test_that --board=nocturne <IP> suite:fingerprint

Change-Id: I4ad4df0d7b62da1af08ec7d33e26469420af248d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2006016
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-by: Wai-Hong Tam <waihong@google.com>
Tested-by: Yicheng Li <yichengli@chromium.org>
Tested-by: Tom Hughes <tomhughes@chromium.org>
Commit-Queue: Tom Hughes <tomhughes@chromium.org>
diff --git a/server/cros/faft/gen_test_images.sh b/server/cros/faft/gen_test_images.sh
index 0f939cd..1565bb6 100755
--- a/server/cros/faft/gen_test_images.sh
+++ b/server/cros/faft/gen_test_images.sh
@@ -28,9 +28,9 @@
 
 # Pick up RO and RW version (only take up to 27 bytes, to leave an extra
 # 4 bytes for .dev/.rbX tag, and terminating \0.
-ro_version_offset=`dump_fmap $IMAGE RO_FRID | sed -n 's/area_offset: *//p'`
+ro_version_offset=`futility dump_fmap $IMAGE RO_FRID | sed -n 's/area_offset: *//p'`
 ro_version=`dd if=$IMAGE bs=1 skip=$((ro_version_offset)) count=27`
-rw_version_offset=`dump_fmap $IMAGE RW_FWID | sed -n 's/area_offset: *//p'`
+rw_version_offset=`futility dump_fmap $IMAGE RW_FWID | sed -n 's/area_offset: *//p'`
 rw_version=`dd if=$IMAGE bs=1 skip=$((rw_version_offset)) count=27`
 
 # Hack the version string
@@ -40,8 +40,8 @@
 
 # Resign the image with dev key
 echo "Generating image signed with dev keys:"
-~/trunk/src/platform/vboot_reference/scripts/image_signing/sign_official_build.sh accessory_rwsig ${BOARD}.dev .  ${BOARD}.dev.out
-mv ${BOARD}.dev.out ${BOARD}.dev
+KEY_NAME=key.vbprik2
+futility sign --type rwsig --prikey "${KEY_NAME}" --version 1 ${BOARD}.dev
 
 # Show signature
 futility show ${BOARD}.dev
@@ -49,7 +49,7 @@
 echo "Generating image with rollback = 0:"
 
 printf "Current rollback version: "
-rb_offset=`dump_fmap ${BOARD}.dev RW_RBVER | sed -n 's/area_offset: *//p'`
+rb_offset=`futility dump_fmap ${BOARD}.dev RW_RBVER | sed -n 's/area_offset: *//p'`
 dd if=${BOARD}.dev bs=1 skip=$((rb_offset)) count=4 2>/dev/null | xxd -l 4 -p
 
 cp ${BOARD}.dev ${BOARD}.dev.rb0
@@ -58,14 +58,13 @@
 # Hack the version string
 printf "${rw_version}.rb0" | dd of=${BOARD}.dev.rb0 bs=1 seek=$((rw_version_offset)) count=32 conv=notrunc
 # Resign the image with dev key
-~/trunk/src/platform/vboot_reference/scripts/image_signing/sign_official_build.sh accessory_rwsig ${BOARD}.dev.rb0 . ${BOARD}.dev.rb0.out
-mv ${BOARD}.dev.rb0.out ${BOARD}.dev.rb0
+futility sign --type rwsig --prikey "${KEY_NAME}" --version 1 ${BOARD}.dev.rb0
 
 
 echo "Generating image with rollback = 1:"
 
 printf "Current rollback version: "
-rb_offset=`dump_fmap ${BOARD}.dev RW_RBVER | sed -n 's/area_offset: *//p'`
+rb_offset=`futility dump_fmap ${BOARD}.dev RW_RBVER | sed -n 's/area_offset: *//p'`
 dd if=${BOARD}.dev bs=1 skip=$((rb_offset)) count=4 2>/dev/null | xxd -l 4 -p
 
 cp ${BOARD}.dev ${BOARD}.dev.rb1
@@ -74,13 +73,12 @@
 # Hack the version string
 printf "${rw_version}.rb1" | dd of=${BOARD}.dev.rb1 bs=1 seek=$((rw_version_offset)) count=32 conv=notrunc
 # Resign the image with dev key
-~/trunk/src/platform/vboot_reference/scripts/image_signing/sign_official_build.sh accessory_rwsig ${BOARD}.dev.rb1 . ${BOARD}.dev.rb1.out
-mv ${BOARD}.dev.rb1.out ${BOARD}.dev.rb1
+futility sign --type rwsig --prikey "${KEY_NAME}" --version 1 ${BOARD}.dev.rb1
 
 echo "Generating image with rollback = 9:"
 
 printf "Current rollback version: "
-rb_offset=`dump_fmap ${BOARD}.dev RW_RBVER | sed -n 's/area_offset: *//p'`
+rb_offset=`futility dump_fmap ${BOARD}.dev RW_RBVER | sed -n 's/area_offset: *//p'`
 dd if=${BOARD}.dev bs=1 skip=$((rb_offset)) count=4 2>/dev/null | xxd -l 4 -p
 
 cp ${BOARD}.dev ${BOARD}.dev.rb9
@@ -89,18 +87,17 @@
 # Hack the version string
 printf "${rw_version}.rb9" | dd of=${BOARD}.dev.rb9 bs=1 seek=$((rw_version_offset)) count=32 conv=notrunc
 # Resign the image with dev key
-~/trunk/src/platform/vboot_reference/scripts/image_signing/sign_official_build.sh accessory_rwsig ${BOARD}.dev.rb9 . ${BOARD}.dev.rb9.out
-mv ${BOARD}.dev.rb9.out ${BOARD}.dev.rb9
+futility sign --type rwsig --prikey "${KEY_NAME}" --version 1 ${BOARD}.dev.rb9
 
 
 echo "Generating image with bits corrupted at start of image:"
 cp $IMAGE ${BOARD}_corrupt_first_byte.bin
-offset=`dump_fmap ${BOARD}_corrupt_first_byte.bin EC_RW | sed -n 's/area_offset: *//p'`
+offset=`futility dump_fmap ${BOARD}_corrupt_first_byte.bin EC_RW | sed -n 's/area_offset: *//p'`
 dd if=/dev/random of=${BOARD}_corrupt_first_byte.bin bs=1 seek=$((offset+100)) count=1 conv=notrunc
 
 echo "Generating image with bits corrupted at end of image:"
 cp $IMAGE ${BOARD}_corrupt_last_byte.bin
-offset=`dump_fmap ${BOARD}_corrupt_last_byte.bin SIG_RW | sed -n 's/area_offset: *//p'`
+offset=`futility dump_fmap ${BOARD}_corrupt_last_byte.bin SIG_RW | sed -n 's/area_offset: *//p'`
 dd if=/dev/zero of=${BOARD}_corrupt_last_byte.bin bs=1 seek=$((offset-100)) count=1 conv=notrunc
 
 # hexdumps are always nice to have to do diffs