mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-04-27 10:29:22 -04:00
fpga/fw/testfw: Remove Blake2s register
Since the introduction of the syscall mechanism we don't allow execution in ROM anymore so it's impossible to call the firmware's blake2s() function. Co-authored-by: Mikael Ågren <mikael@tillitis.se>
This commit is contained in:
parent
24ef39b739
commit
5eb020275b
@ -141,9 +141,8 @@ TESTFW_OBJS = \
|
|||||||
$(P)/fw/testfw/main.o \
|
$(P)/fw/testfw/main.o \
|
||||||
$(P)/fw/testfw/start.o \
|
$(P)/fw/testfw/start.o \
|
||||||
$(P)/fw/tk1/proto.o \
|
$(P)/fw/tk1/proto.o \
|
||||||
$(P)/fw/tk1/lib.o \
|
|
||||||
$(P)/fw/tk1/assert.o \
|
$(P)/fw/tk1/assert.o \
|
||||||
$(P)/fw/tk1/blake2s/blake2s.o
|
$(P)/fw/tk1/lib.o
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
# All: Complete build of HW and FW.
|
# All: Complete build of HW and FW.
|
||||||
|
@ -81,8 +81,6 @@ module tk1 #(
|
|||||||
localparam ADDR_APP_START = 8'h0c;
|
localparam ADDR_APP_START = 8'h0c;
|
||||||
localparam ADDR_APP_SIZE = 8'h0d;
|
localparam ADDR_APP_SIZE = 8'h0d;
|
||||||
|
|
||||||
localparam ADDR_BLAKE2S = 8'h10;
|
|
||||||
|
|
||||||
localparam ADDR_CDI_FIRST = 8'h20;
|
localparam ADDR_CDI_FIRST = 8'h20;
|
||||||
localparam ADDR_CDI_LAST = 8'h27;
|
localparam ADDR_CDI_LAST = 8'h27;
|
||||||
|
|
||||||
@ -137,9 +135,6 @@ module tk1 #(
|
|||||||
reg [31 : 0] app_size_reg;
|
reg [31 : 0] app_size_reg;
|
||||||
reg app_size_we;
|
reg app_size_we;
|
||||||
|
|
||||||
reg [31 : 0] blake2s_addr_reg;
|
|
||||||
reg blake2s_addr_we;
|
|
||||||
|
|
||||||
reg [23 : 0] cpu_trap_ctr_reg;
|
reg [23 : 0] cpu_trap_ctr_reg;
|
||||||
reg [23 : 0] cpu_trap_ctr_new;
|
reg [23 : 0] cpu_trap_ctr_new;
|
||||||
reg [ 2 : 0] cpu_trap_led_reg;
|
reg [ 2 : 0] cpu_trap_led_reg;
|
||||||
@ -262,7 +257,6 @@ module tk1 #(
|
|||||||
gpio4_reg <= 1'h0;
|
gpio4_reg <= 1'h0;
|
||||||
app_start_reg <= 32'h0;
|
app_start_reg <= 32'h0;
|
||||||
app_size_reg <= APP_SIZE;
|
app_size_reg <= APP_SIZE;
|
||||||
blake2s_addr_reg <= 32'h0;
|
|
||||||
cdi_mem[0] <= 32'h0;
|
cdi_mem[0] <= 32'h0;
|
||||||
cdi_mem[1] <= 32'h0;
|
cdi_mem[1] <= 32'h0;
|
||||||
cdi_mem[2] <= 32'h0;
|
cdi_mem[2] <= 32'h0;
|
||||||
@ -317,10 +311,6 @@ module tk1 #(
|
|||||||
app_size_reg <= write_data;
|
app_size_reg <= write_data;
|
||||||
end
|
end
|
||||||
|
|
||||||
if (blake2s_addr_we) begin
|
|
||||||
blake2s_addr_reg <= write_data;
|
|
||||||
end
|
|
||||||
|
|
||||||
if (cdi_mem_we) begin
|
if (cdi_mem_we) begin
|
||||||
cdi_mem[address[2 : 0]] <= write_data;
|
cdi_mem[address[2 : 0]] <= write_data;
|
||||||
end
|
end
|
||||||
@ -512,7 +502,6 @@ module tk1 #(
|
|||||||
gpio4_we = 1'h0;
|
gpio4_we = 1'h0;
|
||||||
app_start_we = 1'h0;
|
app_start_we = 1'h0;
|
||||||
app_size_we = 1'h0;
|
app_size_we = 1'h0;
|
||||||
blake2s_addr_we = 1'h0;
|
|
||||||
cdi_mem_we = 1'h0;
|
cdi_mem_we = 1'h0;
|
||||||
ram_addr_rand_we = 1'h0;
|
ram_addr_rand_we = 1'h0;
|
||||||
ram_data_rand_we = 1'h0;
|
ram_data_rand_we = 1'h0;
|
||||||
@ -558,12 +547,6 @@ module tk1 #(
|
|||||||
system_reset_new = 1'h1;
|
system_reset_new = 1'h1;
|
||||||
end
|
end
|
||||||
|
|
||||||
if (address == ADDR_BLAKE2S) begin
|
|
||||||
if (!app_mode_reg) begin
|
|
||||||
blake2s_addr_we = 1'h1;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if ((address >= ADDR_CDI_FIRST) && (address <= ADDR_CDI_LAST)) begin
|
if ((address >= ADDR_CDI_FIRST) && (address <= ADDR_CDI_LAST)) begin
|
||||||
if (!app_mode_reg) begin
|
if (!app_mode_reg) begin
|
||||||
cdi_mem_we = 1'h1;
|
cdi_mem_we = 1'h1;
|
||||||
@ -644,10 +627,6 @@ module tk1 #(
|
|||||||
tmp_read_data = app_size_reg;
|
tmp_read_data = app_size_reg;
|
||||||
end
|
end
|
||||||
|
|
||||||
if (address == ADDR_BLAKE2S) begin
|
|
||||||
tmp_read_data = blake2s_addr_reg;
|
|
||||||
end
|
|
||||||
|
|
||||||
if ((address >= ADDR_CDI_FIRST) && (address <= ADDR_CDI_LAST)) begin
|
if ((address >= ADDR_CDI_FIRST) && (address <= ADDR_CDI_LAST)) begin
|
||||||
tmp_read_data = cdi_mem[address[2 : 0]];
|
tmp_read_data = cdi_mem[address[2 : 0]];
|
||||||
end
|
end
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
* SPDX-License-Identifier: GPL-2.0-only
|
* SPDX-License-Identifier: GPL-2.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../tk1/assert.h"
|
|
||||||
#include "../tk1/blake2s/blake2s.h"
|
|
||||||
#include "../tk1/lib.h"
|
#include "../tk1/lib.h"
|
||||||
#include "../tk1/proto.h"
|
#include "../tk1/proto.h"
|
||||||
#include "../tk1/types.h"
|
#include "../tk1/types.h"
|
||||||
@ -26,7 +24,6 @@ volatile uint32_t *timer_status = (volatile uint32_t *)TK1_MMIO_TIMER_STATUS
|
|||||||
volatile uint32_t *timer_ctrl = (volatile uint32_t *)TK1_MMIO_TIMER_CTRL;
|
volatile uint32_t *timer_ctrl = (volatile uint32_t *)TK1_MMIO_TIMER_CTRL;
|
||||||
volatile uint32_t *trng_status = (volatile uint32_t *)TK1_MMIO_TRNG_STATUS;
|
volatile uint32_t *trng_status = (volatile uint32_t *)TK1_MMIO_TRNG_STATUS;
|
||||||
volatile uint32_t *trng_entropy = (volatile uint32_t *)TK1_MMIO_TRNG_ENTROPY;
|
volatile uint32_t *trng_entropy = (volatile uint32_t *)TK1_MMIO_TRNG_ENTROPY;
|
||||||
volatile uint32_t *fw_blake2s_addr = (volatile uint32_t *)TK1_MMIO_TK1_BLAKE2S;
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#define UDS_WORDS 8
|
#define UDS_WORDS 8
|
||||||
@ -196,11 +193,6 @@ void failmsg(char *s)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// Function pointer to blake2s()
|
|
||||||
volatile int (*fw_blake2s)(void *, unsigned long, const void *,
|
|
||||||
unsigned long, const void *, unsigned long,
|
|
||||||
blake2s_ctx *);
|
|
||||||
|
|
||||||
uint8_t in = 0;
|
uint8_t in = 0;
|
||||||
uint8_t mode = 0;
|
uint8_t mode = 0;
|
||||||
uint8_t mode_bytes_left = 0;
|
uint8_t mode_bytes_left = 0;
|
||||||
@ -311,9 +303,6 @@ int main(void)
|
|||||||
anyfailed = 1;
|
anyfailed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store function pointer to blake2s() so it's reachable from app
|
|
||||||
*fw_blake2s_addr = (uint32_t)blake2s;
|
|
||||||
|
|
||||||
// Turn on application mode.
|
// Turn on application mode.
|
||||||
// -------------------------
|
// -------------------------
|
||||||
|
|
||||||
@ -394,32 +383,6 @@ int main(void)
|
|||||||
anyfailed = 1;
|
anyfailed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing the blake2s MMIO in app mode
|
|
||||||
|
|
||||||
fw_blake2s = (volatile int (*)(void *, unsigned long, const void *,
|
|
||||||
unsigned long, const void *,
|
|
||||||
unsigned long, blake2s_ctx *)) *
|
|
||||||
fw_blake2s_addr;
|
|
||||||
|
|
||||||
char msg[17] = "dldlkjsdkljdslsdj";
|
|
||||||
uint32_t digest0[8];
|
|
||||||
uint32_t digest1[8];
|
|
||||||
blake2s_ctx b2s_ctx;
|
|
||||||
|
|
||||||
blake2s(&digest0[0], 32, NULL, 0, &msg, 17, &b2s_ctx);
|
|
||||||
fw_blake2s(&digest1[0], 32, NULL, 0, &msg, 17, &b2s_ctx);
|
|
||||||
|
|
||||||
puts("\r\ndigest #0: \r\n");
|
|
||||||
hexdump((uint8_t *)digest0, 32);
|
|
||||||
|
|
||||||
puts("digest #1: \r\n");
|
|
||||||
hexdump((uint8_t *)digest1, 32);
|
|
||||||
|
|
||||||
if (!memeq(digest0, digest1, 32)) {
|
|
||||||
failmsg("Digests not the same");
|
|
||||||
anyfailed = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check and display test results.
|
// Check and display test results.
|
||||||
puts("\r\n--> ");
|
puts("\r\n--> ");
|
||||||
if (anyfailed) {
|
if (anyfailed) {
|
||||||
|
@ -21,7 +21,6 @@ static volatile uint32_t *udi = (volatile uint32_t *)TK1_MMIO_TK1_U
|
|||||||
static volatile uint32_t *cdi = (volatile uint32_t *)TK1_MMIO_TK1_CDI_FIRST;
|
static volatile uint32_t *cdi = (volatile uint32_t *)TK1_MMIO_TK1_CDI_FIRST;
|
||||||
static volatile uint32_t *app_addr = (volatile uint32_t *)TK1_MMIO_TK1_APP_ADDR;
|
static volatile uint32_t *app_addr = (volatile uint32_t *)TK1_MMIO_TK1_APP_ADDR;
|
||||||
static volatile uint32_t *app_size = (volatile uint32_t *)TK1_MMIO_TK1_APP_SIZE;
|
static volatile uint32_t *app_size = (volatile uint32_t *)TK1_MMIO_TK1_APP_SIZE;
|
||||||
static volatile uint32_t *fw_blake2s_addr = (volatile uint32_t *)TK1_MMIO_TK1_BLAKE2S;
|
|
||||||
static volatile uint32_t *trng_status = (volatile uint32_t *)TK1_MMIO_TRNG_STATUS;
|
static volatile uint32_t *trng_status = (volatile uint32_t *)TK1_MMIO_TRNG_STATUS;
|
||||||
static volatile uint32_t *trng_entropy = (volatile uint32_t *)TK1_MMIO_TRNG_ENTROPY;
|
static volatile uint32_t *trng_entropy = (volatile uint32_t *)TK1_MMIO_TRNG_ENTROPY;
|
||||||
static volatile uint32_t *timer = (volatile uint32_t *)TK1_MMIO_TIMER_TIMER;
|
static volatile uint32_t *timer = (volatile uint32_t *)TK1_MMIO_TIMER_TIMER;
|
||||||
@ -409,9 +408,6 @@ int main(void)
|
|||||||
|
|
||||||
print_hw_version();
|
print_hw_version();
|
||||||
|
|
||||||
// Let the app know the function adddress for blake2s()
|
|
||||||
*fw_blake2s_addr = (uint32_t)blake2s;
|
|
||||||
|
|
||||||
/*@-mustfreeonly@*/
|
/*@-mustfreeonly@*/
|
||||||
/* Yes, splint, this points directly to RAM and we don't care
|
/* Yes, splint, this points directly to RAM and we don't care
|
||||||
* about freeing anything was pointing to 0x0 before.
|
* about freeing anything was pointing to 0x0 before.
|
||||||
|
@ -126,8 +126,6 @@
|
|||||||
#define TK1_MMIO_TK1_APP_ADDR 0xff000030
|
#define TK1_MMIO_TK1_APP_ADDR 0xff000030
|
||||||
#define TK1_MMIO_TK1_APP_SIZE 0xff000034
|
#define TK1_MMIO_TK1_APP_SIZE 0xff000034
|
||||||
|
|
||||||
#define TK1_MMIO_TK1_BLAKE2S 0xff000040
|
|
||||||
|
|
||||||
#define TK1_MMIO_TK1_CDI_FIRST 0xff000080
|
#define TK1_MMIO_TK1_CDI_FIRST 0xff000080
|
||||||
#define TK1_MMIO_TK1_CDI_LAST 0xff00009c
|
#define TK1_MMIO_TK1_CDI_LAST 0xff00009c
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user