Skip to content

Commit

Permalink
[pentest] Manual Cherry Pick of "Add Ibex FI & SCA tests"
Browse files Browse the repository at this point in the history
This commit manually cherry picks #22269 as the
automatic cherry pick failed.

This commit adds the following SCA and FI penetration tests:
- ibex.fi.address_translation
- ibex.fi.address_translation_config
- ibex.fi.char.csr_write
- ibex.fi.char.csr_read
- ibex.sca.key_sideloading

The host code is located in lowRISC/ot-sca#350

Signed-off-by: Pascal Nasahl <[email protected]>
(cherry picked from commit ea26e1a)
  • Loading branch information
nasahlpa committed Apr 5, 2024
1 parent 9f23640 commit ea15a45
Show file tree
Hide file tree
Showing 11 changed files with 1,257 additions and 254 deletions.
29 changes: 25 additions & 4 deletions sw/device/tests/crypto/cryptotest/firmware/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,13 @@ cc_library(

cc_library(
name = "ibex_fi",
srcs = ["ibex_fi.c"],
hdrs = [
"ibex_fi.h",
"status.h",
srcs = [
"ibex_fi.S",
"ibex_fi.c",
],
hdrs = ["ibex_fi.h"],
deps = [
"//sw/device/lib/base:csr",
"//sw/device/lib/base:memory",
"//sw/device/lib/base:status",
"//sw/device/lib/dif:flash_ctrl",
Expand All @@ -184,6 +185,25 @@ cc_library(
],
)

cc_library(
name = "ibex_sca",
srcs = ["ibex_sca.c"],
hdrs = ["ibex_sca.h"],
deps = [
"//sw/device/lib/base:memory",
"//sw/device/lib/base:status",
"//sw/device/lib/dif:keymgr",
"//sw/device/lib/dif:kmac",
"//sw/device/lib/runtime:log",
"//sw/device/lib/testing:keymgr_testutils",
"//sw/device/lib/testing/test_framework:ujson_ottf",
"//sw/device/lib/ujson",
"//sw/device/sca/lib:sca",
"//sw/device/tests/crypto/cryptotest/firmware:sca_lib",
"//sw/device/tests/crypto/cryptotest/json:ibex_sca_commands",
],
)

cc_library(
name = "kmac_sca",
srcs = ["kmac_sca.c"],
Expand Down Expand Up @@ -300,6 +320,7 @@ FIRMWARE_DEPS = [
":hash",
":hmac",
":ibex_fi",
":ibex_sca",
":kmac_sca",
":kmac",
":otbn_fi",
Expand Down
234 changes: 234 additions & 0 deletions sw/device/tests/crypto/cryptotest/firmware/ibex_fi.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

/**
* Increments a value 100 times by 1.
*
* As this function is targeted by fault injection, the code is unrolled.
*
* @param a0 initial value which gets incremented.
* @return Initial value incremeted 100 times by 1.
*/
.globl increment_100x1
.type increment_100x1, @function
.balign 256
increment_100x1:
// a0: init value
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
addi a0, a0, 1
ret


/**
* Increments a value 100 times by 10.
*
* As this function is targeted by fault injection, the code is unrolled.
*
* @param a0 initial value which gets incremented.
* @return Initial value incremeted 100 times by 10.
*/
.globl increment_100x10
.type increment_100x10, @function
.balign 256
increment_100x10:
// a0: init value
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
addi a0, a0, 10
ret
Loading

0 comments on commit ea15a45

Please sign in to comment.