blob: 0ea9ed0b0b88dfe55c10189705d468c94f719564 [file] [log] [blame]
Arthur Heymans94fe0862020-10-15 13:57:52 +02001ifeq ($(CONFIG_INTEL_CBNT_SUPPORT),y)
2
Arthur Heymans23907542021-03-16 19:28:50 +01003ramstage-y += cmos.c
4
Arthur Heymans21176dd2021-03-17 15:33:26 +01005# The private key also contains the public key, so use that if a private key is provided.
6ifeq ($(CONFIG_INTEL_CBNT_NEED_KM_PRIV_KEY),y)
7$(obj)/km_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_KM_PRIV_KEY_FILE))
8 openssl pkey -in $< -pubout > $@
9else ifeq ($(CONFIG_INTEL_CBNT_NEED_KM_PUB_KEY),y)
10$(obj)/km_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_KM_PUB_KEY_FILE))
11 cp $< $@
12endif
13
14# The private key also contains the public key, so use that if a private key is provided.
15ifeq ($(CONFIG_INTEL_CBNT_NEED_BPM_PRIV_KEY),y)
16$(obj)/bpm_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_BPM_PRIV_KEY_FILE))
17 openssl pkey -in $< -pubout > $@
18else ifeq ($(CONFIG_INTEL_CBNT_NEED_BPM_PUB_KEY),y)
19$(obj)/bpm_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_BPM_PUB_KEY_FILE))
20 cp $< $@
21endif
22
Arthur Heymans2ef2e472021-02-08 14:28:03 +010023BG_PROV:=$(obj)/bg-prov
24CBNT_CFG:=$(obj)/cbnt.json
25
26$(BG_PROV):
27 printf " BG_PROV building tool\n"
28 cd 3rdparty/intel-sec-tools; \
29 GO111MODULE=on go mod download; \
30 GO111MODULE=on go mod verify; \
31 GO111MODULE=on go build -o $(top)/$@ cmd/bg-prov/*.go
32
33$(CBNT_CFG): $(call strip_quotes, $(CONFIG_INTEL_CBNT_BG_PROV_CFG_FILE))
34 cp $(CONFIG_INTEL_CBNT_BG_PROV_CFG_FILE) $@
35
Arthur Heymans15412c02021-02-08 22:38:40 +010036ifeq ($(CONFIG_INTEL_CBNT_GENERATE_BPM),y)
37$(obj)/bpm_unsigned.bin: $(obj)/coreboot.rom $(BG_PROV) $(CBNT_CFG)
38 printf " BG_PROV creating unsigned BPM using config file\n"
39 $(BG_PROV) bpm-gen $@ $< --config=$(CBNT_CFG) --cut
40
Arthur Heymans6362df32021-03-17 12:23:20 +010041ifeq ($(CONFIG_INTEL_CBNT_BPM_ONLY_UNSIGNED),y)
42build_complete:: $(obj)/bpm_unsigned.bin
43 @printf "\n** WARNING **\n"
44 @printf "Build generated an unsigned BPM image: build/bpm_unsigned.bin.\n"
45 @printf "The resulting image will not work with CBnT.\n"
46 @printf "After you have externally signed the image you can add it to the coreboot image:\n"
47 @printf "$$ cbfstool build/coreboot.rom add -f bpm.bin -n boot_policy_manifest.bin -t raw -a 16\n"
48 @printf "$$ ifittool -r COREBOOT -a -n boot_policy_manifest.bin -t 12 -s 12 -f build/coreboot.rom\n"
49else
Arthur Heymans15412c02021-02-08 22:38:40 +010050$(obj)/bpm.bin: $(obj)/bpm_unsigned.bin $(BG_PROV) $(call strip_quotes, $(CONFIG_INTEL_CBNT_BPM_PRIV_KEY_FILE))
51 printf " BG_PROV signing real BPM\n"
52 $(BG_PROV) bpm-sign $< $@ $(CONFIG_INTEL_CBNT_BPM_PRIV_KEY_FILE) ""
53
54# Add BPM at the end of the build when all files have been added
55files_added:: $(obj)/bpm.bin
56 printf " CBNT Adding BPM\n"
57 $(CBFSTOOL) $(obj)/coreboot.rom add -f $< -n boot_policy_manifest.bin -a 0x10 -t raw
58 printf " IFITTOOL Adding BPM\n"
59 $(IFITTOOL) -r COREBOOT -a -n boot_policy_manifest.bin -t 12 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $(obj)/coreboot.rom
60
Arthur Heymans6362df32021-03-17 12:23:20 +010061endif # CONFIG_INTEL_CBNT_BPM_ONLY_UNSIGNED
62
Arthur Heymans15412c02021-02-08 22:38:40 +010063else # CONFIG_INTEL_CBNT_GENERATE_BPM
Arthur Heymans6362df32021-03-17 12:23:20 +010064
Arthur Heymans94fe0862020-10-15 13:57:52 +020065ifneq ($(CONFIG_INTEL_CBNT_BOOT_POLICY_MANIFEST_BINARY),"")
66cbfs-files-y += boot_policy_manifest.bin
67boot_policy_manifest.bin-file := $(CONFIG_INTEL_CBNT_BOOT_POLICY_MANIFEST_BINARY)
68boot_policy_manifest.bin-type := raw
69boot_policy_manifest.bin-align := 0x10
70
Arthur Heymanseeacd832021-02-19 17:14:23 +010071$(call add_intermediate, add_bpm_fit, $(IFITTOOL) set_fit_ptr)
Arthur Heymans94fe0862020-10-15 13:57:52 +020072 $(IFITTOOL) -r COREBOOT -a -n boot_policy_manifest.bin -t 12 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $<
73endif
Arthur Heymans15412c02021-02-08 22:38:40 +010074endif # CONFIG_INTEL_CBNT_GENERATE_BPM
Arthur Heymans94fe0862020-10-15 13:57:52 +020075
Arthur Heymans2ef2e472021-02-08 14:28:03 +010076ifeq ($(CONFIG_INTEL_CBNT_GENERATE_KM),y)
Arthur Heymans05143242021-02-08 19:41:23 +010077ifeq ($(CONFIG_INTEL_CBNT_BG_PROV_KM_USE_CFG_FILE),y)
Arthur Heymans2ef2e472021-02-08 14:28:03 +010078$(obj)/km_unsigned.bin: $(obj)/km_pub.pem $(BG_PROV) $(CBNT_CFG)
79 printf " BG_PROV creating unsigned KM using config file\n"
80 $(BG_PROV) km-gen $@ $< --config=$(CBNT_CFG)
Arthur Heymans05143242021-02-08 19:41:23 +010081else
82PK_HASH_ALG_SHA256:=11 # Hardcode as no other options are available for CBnT
83$(obj)/km_unsigned.bin: $(obj)/km_pub.pem $(obj)/bpm_pub.pem $(BG_PROV)
84 printf " BG_PROV creating unsigned KM\n"
85 $(BG_PROV) km-gen $@ $< --revision=$(CONFIG_INTEL_CBNT_KM_REVISION) \
86 --svn=$(CONFIG_INTEL_CBNT_KM_SVN) \
87 --id=$(CONFIG_INTEL_CBNT_KM_ID) \
88 --pkhashalg=$(PK_HASH_ALG_SHA256) \
89 --bpmpubkey=$(obj)/bpm_pub.pem \
90 --bpmhashalgo=$(PK_HASH_ALG_SHA256) \
91 --out=$(obj)/km_cfg.json
92endif
Arthur Heymans2ef2e472021-02-08 14:28:03 +010093
94$(obj)/km.bin: $(obj)/km_unsigned.bin $(BG_PROV) $(call strip_quotes, $(CONFIG_INTEL_CBNT_KM_PRIV_KEY_FILE))
95 printf " BG_PROV signing KM\n"
96 $(BG_PROV) km-sign $< $@ $(CONFIG_INTEL_CBNT_KM_PRIV_KEY_FILE) ""
97
98KM_FILE=$(obj)/km.bin
99else
100KM_FILE=$(CONFIG_INTEL_CBNT_KEY_MANIFEST_BINARY)
101endif
102
103ifneq ($(KM_FILE),"")
Arthur Heymans5e0119e2021-03-17 12:03:39 +0100104ifeq ($(CONFIG_INTEL_CBNT_KM_ONLY_UNSIGNED),y)
105$(call add_intermediate, gen_unsigned_km, $(obj)/km_unsigned.bin)
106 @printf "Generating unsgined KM\n"
107
108build_complete::
109 @printf "\n** WARNING **\n"
110 @printf "Build generated an unsigned KM image: build/km_unsiged.bin.\n"
111 @printf "The resulting image will not work with CBnT.\n"
112 @printf "After you have externally signed the image you can add it to the coreboot image:\n"
113 @printf "$$ cbfstool build/coreboot.rom add -f km.bin -n key_manifest.bin -t raw -a 16\n"
114 @printf "$$ ifittool -r COREBOOT -a -n key_manifest.bin -t 11 -s 12 -f build/coreboot.rom\n"
115
116else
Arthur Heymans94fe0862020-10-15 13:57:52 +0200117cbfs-files-y += key_manifest.bin
Arthur Heymans2ef2e472021-02-08 14:28:03 +0100118key_manifest.bin-file := $(KM_FILE)
Arthur Heymans94fe0862020-10-15 13:57:52 +0200119key_manifest.bin-type := raw
120key_manifest.bin-align := 0x10
121
Arthur Heymanseeacd832021-02-19 17:14:23 +0100122$(call add_intermediate, add_km_fit, $(IFITTOOL) set_fit_ptr)
Arthur Heymans94fe0862020-10-15 13:57:52 +0200123 $(IFITTOOL) -r COREBOOT -a -n key_manifest.bin -t 11 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $<
124endif
125
Arthur Heymans5e0119e2021-03-17 12:03:39 +0100126endif # CONFIG_INTEL_CBNT_KM_ONLY_UNSIGNED
Arthur Heymans94fe0862020-10-15 13:57:52 +0200127endif # CONFIG_INTEL_CBNT_SUPPORT