common: Add support to generate secure boot image

Change-Id: Ie186b33ad6f78272e7d2d0a37c8b5be9071d4f02
This commit is contained in:
Channagoud Kadabi 2012-08-02 16:51:38 +05:30 committed by Linux Build Service Account
parent 91a573be66
commit 671d41497e
1 changed files with 26 additions and 0 deletions

View File

@ -1,6 +1,32 @@
# This makefile is used to generate extra images for QCOM targets
# persist & NAND images required for different QCOM targets.
ifeq ($(TARGET_BOOTIMG_SIGNED),true)
INSTALLED_SEC_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img.secure
INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
ifndef TARGET_SHA_TYPE
TARGET_SHA_TYPE := sha256
endif
define build-boot-image
$(hide) mv -f $(1) $(1).nonsecure
$(hide) openssl dgst -$(TARGET_SHA_TYPE) -binary $(1).nonsecure > $(1).$(TARGET_SHA_TYPE)
$(hide) openssl rsautl -sign -in $(1).$(TARGET_SHA_TYPE) -inkey $(PRODUCT_PRIVATE_KEY) -out $(1).sig
$(hide) dd if=/dev/zero of=$(1).sig.padded bs=$(BOARD_KERNEL_PAGESIZE) count=1
$(hide) dd if=$(1).sig of=$(1).sig.padded conv=notrunc
$(hide) cat $(1).nonsecure $(1).sig.padded > $(1).secure
$(hide) rm -rf $(1).$(TARGET_SHA_TYPE) $(1).sig $(1).sig.padded
$(hide) mv -f $(1).secure $(1)
endef
$(INSTALLED_SEC_BOOTIMAGE_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
$(hide) $(call build-boot-image,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_ARGS))
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SEC_BOOTIMAGE_TARGET)
ALL_MODULES.$(LOCAL_MODULE).INSTALLED += $(INSTALLED_SEC_BOOTIMAGE_TARGET)
endif
TARGET_OUT_PERSIST := $(PRODUCT_OUT)/persist
INTERNAL_PERSISTIMAGE_FILES := \