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 27, 2024
1 parent 8dbcb51 commit 8760537
Show file tree
Hide file tree
Showing 8 changed files with 654 additions and 4 deletions.
9 changes: 8 additions & 1 deletion sw/device/tests/crypto/cryptotest/firmware/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,16 @@ cc_library(

cc_library(
name = "ibex_fi",
srcs = ["ibex_fi.c"],
srcs = [
"ibex_fi.S",
"ibex_fi.c",
],
hdrs = [
"ibex_fi.h",
"status.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 @@ -198,7 +202,10 @@ cc_library(
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
228 changes: 228 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,228 @@
// 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.
*
* @param a0 initial value which gets incremented.
*/
.globl target_function
.type target_function, @function
.balign 256
target_function:
// 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.
*
* @param a0 initial value which gets incremented.
*/
.globl expected_function
.type expected_function, @function
.balign 256
expected_function:
// 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 8760537

Please sign in to comment.