77 "fpga_params" ,
88 "opentitan_test" ,
99)
10+ load (
11+ "//sw/device/silicon_creator/rom_ext/e2e/ownership:defs.bzl" ,
12+ "ownership_transfer_test" ,
13+ )
1014
1115package (default_visibility = ["//visibility:public" ])
1216
13- opentitan_test (
14- name = "ownership_transfer_test" ,
15- srcs = ["//sw/device/silicon_creator/rom_ext/e2e/verified_boot:boot_test" ],
16- exec_env = {
17- "//hw/top_earlgrey:fpga_hyper310_rom_ext" : None ,
18- },
17+ # TODO(#24462): The tests in this file are marked `changes_otp = True`,
18+ # but they don't change OTP. They modify the ownership INFO pages,
19+ # so we need to clear the bitstream after the test, which is what the
20+ # `changes_otp` parameter actually does.
21+
22+ # rom_ext_e2e_testplan.hjson%rom_ext_e2e_transfer_any_test
23+ ownership_transfer_test (
24+ name = "transfer_any_test" ,
1925 fpga = fpga_params (
20- # This test doesn't change OTP, but it modifies the ownership INFO
21- # pages, so we need to clear the bitstream after the test, which is
22- # what the `changes_otp` parameter actually does.
2326 changes_otp = True ,
24- data = [
25- "//sw/device/silicon_creator/lib/ownership/keys/dummy:activate_key" ,
26- "//sw/device/silicon_creator/lib/ownership/keys/dummy:app_prod_pub" ,
27- "//sw/device/silicon_creator/lib/ownership/keys/dummy:owner_key" ,
28- "//sw/device/silicon_creator/lib/ownership/keys/dummy:unlock_key" ,
29- "//sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key" ,
30- ],
3127 test_cmd = """
3228 --clear-bitstream
3329 --bootstrap={firmware}
30+ --unlock-mode=Any
3431 --unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
3532 --next-owner-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:owner_key)
3633 --next-unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:unlock_key)
@@ -49,3 +46,205 @@ opentitan_test(
4946 "//sw/device/silicon_creator/lib/drivers:retention_sram" ,
5047 ],
5148)
49+
50+ # rom_ext_e2e_testplan.hjson%rom_ext_e2e_bad_unlock_test
51+ ownership_transfer_test (
52+ name = "bad_unlock_test" ,
53+ fpga = fpga_params (
54+ changes_otp = True ,
55+ test_cmd = """
56+ --clear-bitstream
57+ --bootstrap={firmware}
58+ --unlock-mode=Any
59+ # NOTE: We use the wrong unlock key to test that the unlock operation fails.
60+ --unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:activate_key)
61+ --next-owner-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:owner_key)
62+ --next-unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:unlock_key)
63+ --next-activate-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:activate_key)
64+ --next-application-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:app_prod_pub)
65+ --expected-error=OwnershipInvalidSignature
66+ """ ,
67+ test_harness = "//sw/host/tests/ownership:transfer_test" ,
68+ ),
69+ )
70+
71+ # rom_ext_e2e_testplan.hjson%rom_ext_e2e_bad_activate_test
72+ ownership_transfer_test (
73+ name = "bad_activate_test" ,
74+ fpga = fpga_params (
75+ changes_otp = True ,
76+ test_cmd = """
77+ --clear-bitstream
78+ --bootstrap={firmware}
79+ --unlock-mode=Any
80+ --unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
81+ # NOTE: We use the wrong activate key to test that the activate operation fails.
82+ --activate-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
83+ --next-owner-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:owner_key)
84+ --next-unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:unlock_key)
85+ --next-activate-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:activate_key)
86+ --next-application-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:app_prod_pub)
87+ --expected-error=OwnershipInvalidSignature
88+ """ ,
89+ test_harness = "//sw/host/tests/ownership:transfer_test" ,
90+ ),
91+ )
92+
93+ # rom_ext_e2e_testplan.hjson%rom_ext_e2e_bad_owner_block_test
94+ ownership_transfer_test (
95+ name = "bad_owner_block_test" ,
96+ fpga = fpga_params (
97+ changes_otp = True ,
98+ test_cmd = """
99+ --clear-bitstream
100+ --bootstrap={firmware}
101+ --unlock-mode=Any
102+ --unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
103+ --next-owner-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:owner_key)
104+ --next-unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:unlock_key)
105+ --next-activate-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:activate_key)
106+ --next-application-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:app_prod_pub)
107+ --corrupt-owner-block-signature=true
108+ --dual-owner-boot-check=false
109+ --expected-error=OwnershipInvalidInfoPage
110+ """ ,
111+ test_harness = "//sw/host/tests/ownership:transfer_test" ,
112+ ),
113+ )
114+
115+ # rom_ext_e2e_testplan.hjson%rom_ext_e2e_bad_app_key_test
116+ ownership_transfer_test (
117+ name = "bad_app_key_test" ,
118+ fpga = fpga_params (
119+ changes_otp = True ,
120+ test_cmd = """
121+ --clear-bitstream
122+ --bootstrap={firmware}
123+ --unlock-mode=Any
124+ --unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
125+ --next-owner-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:owner_key)
126+ --next-unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:unlock_key)
127+ --next-activate-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:activate_key)
128+ # NOTE: We use the wrong app key (fake instead of dummy) to test that we cannot boot
129+ # the test program after completing the transfer.
130+ --next-application-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:app_prod_pub)
131+ --expected-error=OwnershipKeyNotFound
132+ """ ,
133+ test_harness = "//sw/host/tests/ownership:transfer_test" ,
134+ ),
135+ )
136+
137+ # rom_ext_e2e_testplan.hjson%rom_ext_e2e_transfer_endorsed_test
138+ ownership_transfer_test (
139+ name = "transfer_endorsed_test" ,
140+ fpga = fpga_params (
141+ changes_otp = True ,
142+ test_cmd = """
143+ --clear-bitstream
144+ --bootstrap={firmware}
145+ --unlock-mode=Endorsed
146+ --unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
147+ --next-owner-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:owner_key)
148+ --next-owner-key-pub=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:owner_key_pub)
149+ --next-unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:unlock_key)
150+ --next-activate-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:activate_key)
151+ --next-application-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:app_prod_pub)
152+ """ ,
153+ test_harness = "//sw/host/tests/ownership:transfer_test" ,
154+ ),
155+ )
156+
157+ # rom_ext_e2e_testplan.hjson%rom_ext_e2e_bad_endorsee_test
158+ ownership_transfer_test (
159+ name = "bad_endorsee_test" ,
160+ fpga = fpga_params (
161+ changes_otp = True ,
162+ test_cmd = """
163+ --clear-bitstream
164+ --bootstrap={firmware}
165+ --unlock-mode=Endorsed
166+ --unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
167+ --next-owner-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:owner_key)
168+ # NOTE: We use the wrong next-owner-public-key to test that endorsee is rejected and the activate operation fails.
169+ --next-owner-key-pub=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:owner_key_pub)
170+ --next-unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:unlock_key)
171+ --next-activate-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:activate_key)
172+ --next-application-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:app_prod_pub)
173+ --dual-owner-boot-check=false
174+ --expected-error=OwnershipInvalidInfoPage
175+ """ ,
176+ test_harness = "//sw/host/tests/ownership:transfer_test" ,
177+ ),
178+ )
179+
180+ # rom_ext_e2e_testplan.hjson%rom_ext_e2e_locked_update_test
181+ ownership_transfer_test (
182+ name = "locked_update_test" ,
183+ fpga = fpga_params (
184+ changes_otp = True ,
185+ test_cmd = """
186+ --clear-bitstream
187+ --bootstrap={firmware}
188+ --unlock-mode=Update
189+ --unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
190+ --next-owner-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:owner_key)
191+ --next-unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
192+ --next-activate-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:activate_key)
193+ # NOTE: We rotate the `fake` test owner's application key to the dummy key to test that
194+ # we can execute code with the new key.
195+ --next-application-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:app_prod_pub)
196+ """ ,
197+ test_harness = "//sw/host/tests/ownership:transfer_test" ,
198+ ),
199+ )
200+
201+ # rom_ext_e2e_testplan.hjson%rom_ext_e2e_bad_locked_update_test
202+ # Part 1: Ensure a LockedUpdate with a new owner key is rejected.
203+ ownership_transfer_test (
204+ name = "bad_locked_update_test" ,
205+ fpga = fpga_params (
206+ changes_otp = True ,
207+ test_cmd = """
208+ --clear-bitstream
209+ --bootstrap={firmware}
210+ --unlock-mode=Update
211+ --unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
212+ # NOTE: We use the wrong owner key to test that the activate operation fails.
213+ --next-owner-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:owner_key)
214+ --next-unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
215+ --next-activate-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:activate_key)
216+ --next-application-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:app_prod_pub)
217+ --dual-owner-boot-check=false
218+ --expected-error=OwnershipInvalidInfoPage
219+ """ ,
220+ test_harness = "//sw/host/tests/ownership:transfer_test" ,
221+ ),
222+ rsa_key = {
223+ "//sw/device/silicon_creator/lib/ownership/keys/fake:app_prod" : "app_prod" ,
224+ },
225+ )
226+
227+ # rom_ext_e2e_testplan.hjson%rom_ext_e2e_bad_locked_update_test
228+ # Part 2: Ensure a LockedUpdate denies execution to anything signed with new app keys.
229+ ownership_transfer_test (
230+ name = "bad_locked_update_no_exec_test" ,
231+ fpga = fpga_params (
232+ changes_otp = True ,
233+ test_cmd = """
234+ --clear-bitstream
235+ --bootstrap={firmware}
236+ --unlock-mode=Update
237+ --unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
238+ --next-unlock-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:unlock_key)
239+ --next-activate-key=$(location //sw/device/silicon_creator/lib/ownership/keys/fake:activate_key)
240+
241+ # NOTE: We use the wrong owner key and the dummy app key (which the ownership_transfer_test rule
242+ # uses for signing) to check that owner code execution is denied in the intermediate
243+ # dual-owner state.
244+ --next-owner-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:owner_key)
245+ --next-application-key=$(location //sw/device/silicon_creator/lib/ownership/keys/dummy:app_prod_pub)
246+ --expected-error=OwnershipKeyNotFound
247+ """ ,
248+ test_harness = "//sw/host/tests/ownership:transfer_test" ,
249+ ),
250+ )
0 commit comments