Skip to content

Commit

Permalink
[pentest] Add Ibex FI & SCA tests
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
nasahlpa committed Mar 28, 2024
1 parent 8dbcb51 commit ea26e1a
Show file tree
Hide file tree
Showing 8 changed files with 1,006 additions and 328 deletions.
17 changes: 9 additions & 8 deletions sw/device/tests/crypto/cryptotest/firmware/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,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 @@ -191,14 +192,14 @@ cc_library(
cc_library(
name = "ibex_sca",
srcs = ["ibex_sca.c"],
hdrs = [
"ibex_sca.h",
"status.h",
],
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",
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.
// 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 ea26e1a

Please sign in to comment.