mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 14:28:07 +00:00
properly initialize rng
This commit is contained in:
parent
ee09a6a7b2
commit
0ed5bea0d0
7
speed-stm32/.gitignore
vendored
Normal file
7
speed-stm32/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
*.o
|
||||
*.d
|
||||
*.bin
|
||||
*.hex
|
||||
*.srec
|
||||
*.list
|
||||
*.elf
|
@ -2,6 +2,7 @@
|
||||
#include "rand.h"
|
||||
|
||||
void init_rand(void) {
|
||||
RNG_CR |= RNG_CR_IE | RNG_CR_RNGEN;
|
||||
}
|
||||
|
||||
uint32_t random32(void) {
|
||||
|
@ -213,8 +213,8 @@ void test_sign(void)
|
||||
priv_key[i] = random32() & 0xFF;
|
||||
}
|
||||
|
||||
// use our ECDSA signer to sign the message with the key
|
||||
for (i = 0; i < 100; i++) {
|
||||
// use our ECDSA signer 10 times to sign the message with the key
|
||||
for (i = 0; i < 10; i++) {
|
||||
ecdsa_sign(priv_key, msg, msg_len, sig, &sig_len);
|
||||
}
|
||||
}
|
||||
@ -258,6 +258,8 @@ int main(void)
|
||||
|
||||
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
|
||||
rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_OTGFSEN);
|
||||
rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_RNGEN);
|
||||
init_rand();
|
||||
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO11 | GPIO12);
|
||||
gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO11 | GPIO12);
|
||||
|
Loading…
Reference in New Issue
Block a user