File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed
sw/device/silicon_creator Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -264,3 +264,20 @@ rom_error_t sc_otbn_load_app(const sc_otbn_app_t app) {
264
264
}
265
265
return kErrorOk ;
266
266
}
267
+
268
+ void sc_otbn_patch (void ) {
269
+ enum {
270
+ // Offset in the code of the bad instruction:
271
+ kBugOffset = 0x958 ,
272
+ // The bad instruction is:
273
+ // bn.rshi w16, w20, w31 >> 192
274
+ kBadInstr = 0xc1fa387b ,
275
+ // The good instruction is:
276
+ // bn.rshi w16, w31, w20 >> 192
277
+ kGoodInstr = 0xc14fb87b ,
278
+ };
279
+ uint32_t inst = abs_mmio_read32 (kBase + OTBN_IMEM_REG_OFFSET + kBugOffset );
280
+ if (inst == kBadInstr ) {
281
+ abs_mmio_write32 (kBase + OTBN_IMEM_REG_OFFSET + kBugOffset , kGoodInstr );
282
+ }
283
+ }
Original file line number Diff line number Diff line change @@ -322,6 +322,18 @@ rom_error_t sc_otbn_imem_sec_wipe(void);
322
322
OT_WARN_UNUSED_RESULT
323
323
rom_error_t sc_otbn_dmem_sec_wipe (void );
324
324
325
+ /**
326
+ * Patch a bad instruction in OTBN imem.
327
+ *
328
+ * There is a bug in the OTBN boot services program loaded by ROM. There is a
329
+ * single instruction with mistakenly transposed operands which can affect the
330
+ * random share values. This bug DOES NOT affect the correctness of the OTBN
331
+ * calculations.
332
+ *
333
+ * This function patches the bad instruction with the correctly instruction.
334
+ */
335
+ void sc_otbn_patch (void );
336
+
325
337
#ifdef __cplusplus
326
338
}
327
339
#endif
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ cc_library(
48
48
"//sw/device/silicon_creator/lib/base:static_dice" ,
49
49
"//sw/device/silicon_creator/lib/cert:dice_chain" ,
50
50
"//sw/device/silicon_creator/lib/drivers:flash_ctrl" ,
51
+ "//sw/device/silicon_creator/lib/drivers:otbn" ,
51
52
"//sw/device/silicon_creator/lib/drivers:rnd" ,
52
53
"//sw/device/silicon_creator/lib/ownership:ownership_key" ,
53
54
"//sw/device/silicon_creator/rom_ext:rom_ext_manifest" ,
Original file line number Diff line number Diff line change 11
11
#include "sw/device/silicon_creator/lib/base/sec_mmio.h"
12
12
#include "sw/device/silicon_creator/lib/cert/dice_chain.h"
13
13
#include "sw/device/silicon_creator/lib/drivers/flash_ctrl.h"
14
+ #include "sw/device/silicon_creator/lib/drivers/otbn.h"
14
15
#include "sw/device/silicon_creator/lib/drivers/rnd.h"
15
16
#include "sw/device/silicon_creator/lib/epmp_state.h"
16
17
#include "sw/device/silicon_creator/lib/error.h"
21
22
22
23
OT_WARN_UNUSED_RESULT
23
24
static rom_error_t imm_section_start (void ) {
25
+ // Patch a bug in the OTBN ECDSA-P256 program.
26
+ //
27
+ // There is a single instruction with mistakenly transposed operands which
28
+ // can affect the random share values. This bug DOES NOT affect the
29
+ // correctness of the OTBN calculations.
30
+ sc_otbn_patch ();
31
+
24
32
// Check the ePMP state.
25
33
HARDENED_RETURN_IF_ERROR (epmp_state_check ());
26
34
// Check sec_mmio expectations.
You can’t perform that action at this time.
0 commit comments