Skip to content

Commit

Permalink
Just randomize the data, not the address
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Strömbergson <[email protected]>
  • Loading branch information
secworks committed Apr 5, 2024
1 parent c8d1b54 commit 73adfe9
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions hw/application_fpga/fw/tk1/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,22 +380,17 @@ static void scramble_ram(void)
*ram_rand = rnd_word();
*ram_scramble = rnd_word();

// Use Marsaglia xorshift PRNG variant xorwow for address and
// data to fill the RAM random data (FW does not use RAM, has
// its stack in FW_RAM)
uint32_t addr_state = rnd_word();
uint32_t addr_acc = rnd_word();
// Get random state and accumulator seeds.
uint32_t data_state = rnd_word();
uint32_t data_acc = rnd_word();

for (uint32_t w = 0; w < TK1_RAM_SIZE / 4; w++) {
addr_state = xorwow(addr_state, addr_acc);
data_state = xorwow(data_state, data_acc);

ram[(addr_state & TK1_RAM_SIZE)] = data_state;
ram[w] = data_state;
}

// Set new scrambling values, for all use of RAM by app
// Set new address and RAM scrambling values,
// for all use of RAM by app.
*ram_rand = rnd_word();
*ram_scramble = rnd_word();
}
Expand Down

0 comments on commit 73adfe9

Please sign in to comment.