File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
sw/device/lib/crypto/drivers Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -650,12 +650,16 @@ static status_t kmac_process_msg_blocks(kmac_operation_t operation,
650650 uint32_t next_word = read_32 (& message [i ]);
651651 abs_mmio_write32 (kBase + KMAC_MSG_FIFO_REG_OFFSET , next_word );
652652 }
653+ // Check that the loops ran for the correct number of iterations.
654+ HARDENED_CHECK_LT (message_len , i + sizeof (uint32_t ));
653655
654656 // For the last few bytes, we need to write one byte at a time again.
655657 for (; i < message_len ; i ++ ) {
656658 HARDENED_TRY (wait_status_bit (KMAC_STATUS_FIFO_FULL_BIT , 0 ));
657659 abs_mmio_write8 (kmac_base () + KMAC_MSG_FIFO_REG_OFFSET , message [i ]);
658660 }
661+ // Check that the loops ran for the correct number of iterations.
662+ HARDENED_CHECK_EQ (i , message_len );
659663
660664 // If operation=KMAC, then we need to write `right_encode(digest->len)`
661665 if (operation == kKmacOperationKmac ) {
You can’t perform that action at this time.
0 commit comments